[compiler-rt] a82747f - [dfsan] Fix internal build errors because of more strict warning checks

Jianzhou Zhao via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 7 09:57:08 PDT 2021


Author: Jianzhou Zhao
Date: 2021-06-07T16:55:56Z
New Revision: a82747fafe215862c24e690c1c7b384f4c27ad20

URL: https://github.com/llvm/llvm-project/commit/a82747fafe215862c24e690c1c7b384f4c27ad20
DIFF: https://github.com/llvm/llvm-project/commit/a82747fafe215862c24e690c1c7b384f4c27ad20.diff

LOG: [dfsan] Fix internal build errors because of more strict warning checks

Added: 
    

Modified: 
    compiler-rt/test/dfsan/custom.cpp
    compiler-rt/test/dfsan/interceptors.c

Removed: 
    


################################################################################
diff  --git a/compiler-rt/test/dfsan/custom.cpp b/compiler-rt/test/dfsan/custom.cpp
index d54b40aa7d955..705ee5c5c02fe 100644
--- a/compiler-rt/test/dfsan/custom.cpp
+++ b/compiler-rt/test/dfsan/custom.cpp
@@ -10,6 +10,8 @@
 //
 // REQUIRES: x86_64-target-arch
 
+#pragma clang diagnostic ignored "-Wformat-extra-args"
+
 #include <sanitizer/dfsan_interface.h>
 
 #include <arpa/inet.h>
@@ -325,13 +327,16 @@ void test_strcmp() {
 void test_strcat() {
   char src[] = "world";
   int volatile x = 0; // buffer to ensure src and dst do not share origins
+  (void)x;
   char dst[] = "hello \0    ";
   int volatile y = 0; // buffer to ensure dst and p do not share origins
+  (void)y;
   char *p = dst;
   dfsan_set_label(k_label, &p, sizeof(p));
   dfsan_set_label(i_label, src, sizeof(src));
   dfsan_set_label(j_label, dst, sizeof(dst));
   dfsan_origin dst_o = dfsan_get_origin((long)dst[0]);
+  (void)dst_o;
   char *ret = strcat(p, src);
   ASSERT_LABEL(ret, k_label);
   ASSERT_EQ_ORIGIN(ret, p);
@@ -642,6 +647,10 @@ void test_recvmmsg() {
 
   dfsan_origin msg_len0_o = dfsan_get_origin((long)(rmmsg[0].msg_len));
   dfsan_origin msg_len1_o = dfsan_get_origin((long)(rmmsg[1].msg_len));
+#ifndef ORIGIN_TRACKING
+  (void)msg_len0_o;
+  (void)msg_len1_o;
+#endif
 
   // Receive messages and check labels.
   int received_msgs = recvmmsg(sockfds[1], rmmsg, 2, 0, &timeout);
@@ -758,6 +767,9 @@ void test_clock_gettime() {
   struct timespec tp;
   dfsan_set_label(j_label, ((char *)&tp) + 3, 1);
   dfsan_origin origin = dfsan_get_origin((long)(((char *)&tp)[3]));
+#ifndef ORIGIN_TRACKING
+  (void)origin;
+#endif
   int t = clock_gettime(CLOCK_REALTIME, &tp);
   assert(t == 0);
   ASSERT_ZERO_LABEL(t);
@@ -789,6 +801,9 @@ void test_ctime_r() {
   t = 0;
   dfsan_set_label(j_label, &buf, sizeof(&buf));
   dfsan_origin buf_ptr_o = dfsan_get_origin((long)buf);
+#ifndef ORIGIN_TRACKING
+  (void)buf_ptr_o;
+#endif
   ret = ctime_r(&t, buf);
   ASSERT_LABEL(ret, j_label);
   ASSERT_ORIGIN(ret, buf_ptr_o);
@@ -844,6 +859,11 @@ void test_dfsan_set_write_callback() {
   dfsan_origin fd_o = dfsan_get_origin((long)fd);
   dfsan_origin buf3_o = dfsan_get_origin((long)(buf[3]));
   dfsan_origin buf_len_o = dfsan_get_origin((long)buf_len);
+#ifndef ORIGIN_TRACKING
+  (void)fd_o;
+  (void)buf3_o;
+  (void)buf_len_o;
+#endif
 
   res = write(fd, buf, buf_len);
   assert(write_callback_count == 2);
@@ -1148,6 +1168,12 @@ void test_localtime_r() {
   struct tm *pt1 = &t1;
   dfsan_set_label(j_label, &pt1, sizeof(pt1));
   dfsan_origin pt1_o = dfsan_get_origin((long)pt1);
+
+#ifndef ORIGIN_TRACKING
+  (void)t0_o;
+  (void)pt1_o;
+#endif
+
   struct tm *ret = localtime_r(&t0, pt1);
   assert(ret == &t1);
   assert(t1.tm_min == 56);
@@ -1409,6 +1435,10 @@ void test__dl_get_tls_static_info() {
   dfsan_set_label(i_label, &alignp, sizeof(alignp));
   dfsan_origin sizep_o = dfsan_get_origin(sizep);
   dfsan_origin alignp_o = dfsan_get_origin(alignp);
+#ifndef ORIGIN_TRACKING
+  (void)sizep_o;
+  (void)alignp_o;
+#endif
   _dl_get_tls_static_info(&sizep, &alignp);
   ASSERT_ZERO_LABEL(sizep);
   ASSERT_ZERO_LABEL(alignp);
@@ -1779,6 +1809,9 @@ void test_sprintf_chunk(const char* expected, const char* format, T arg) {
   // Labelled arg.
   dfsan_set_label(i_label, &arg, sizeof(arg));
   dfsan_origin a_o = dfsan_get_origin((long)(arg));
+#ifndef ORIGIN_TRACKING
+  (void)a_o;
+#endif
   assert(sprintf(buf, padded_format,  arg) == strlen(padded_expected));
   assert(strcmp(buf, padded_expected) == 0);
   ASSERT_READ_LABEL(buf, 4, 0);
@@ -1812,6 +1845,11 @@ void test_sprintf() {
   dfsan_origin m_o = dfsan_get_origin((long)m);
   dfsan_set_label(j_label, &d, sizeof(d));
   dfsan_origin d_o = dfsan_get_origin((long)d);
+#ifndef ORIGIN_TRACKING
+  (void)s_o;
+  (void)m_o;
+  (void)d_o;
+#endif
   int n;
   int r = sprintf(buf, "hello %s, %-d/%d/%d %f %% %n%d", s, 2014, m, d,
                   12345.6781234, &n, 1000);
@@ -1880,6 +1918,11 @@ void test_snprintf() {
   dfsan_origin y_o = dfsan_get_origin((long)y);
   dfsan_set_label(j_label, &m, sizeof(m));
   dfsan_origin m_o = dfsan_get_origin((long)m);
+#ifndef ORIGIN_TRACKING
+  (void)s_o;
+  (void)y_o;
+  (void)m_o;
+#endif
   int r = snprintf(buf, 19, "hello %s, %-d/   %d/%d %f", s, y, m, d,
                    12345.6781234);
   // The return value is the number of bytes that would have been written to

diff  --git a/compiler-rt/test/dfsan/interceptors.c b/compiler-rt/test/dfsan/interceptors.c
index 62a3ad007b4ad..b949d2f338887 100644
--- a/compiler-rt/test/dfsan/interceptors.c
+++ b/compiler-rt/test/dfsan/interceptors.c
@@ -10,6 +10,7 @@
 #include <assert.h>
 #include <malloc.h>
 #include <stdlib.h>
+#include <string.h>
 #include <sys/mman.h>
 
 #define ASSERT_ZERO_LABEL(data) \


        


More information about the llvm-commits mailing list