Workaround 'uninitialized memory use' code analyzer false warning (tests)
authorIvan Maidanski <ivmai@mail.ru>
Wed, 19 Apr 2017 21:44:43 +0000 (00:44 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Wed, 19 Apr 2017 21:44:43 +0000 (00:44 +0300)
* tests/test_atomic_include.template [AO_HAVE_storeXX && LINT2
&& AO_PREFER_GENERALIZED] (test_atomicXX): Initialize x local variable
(before AO_storeXX which can be defined using CAS); update comment.
* tests/test_atomic_include.template [AO_HAVE_short_storeXX && LINT2
&& AO_PREFER_GENERALIZED] (test_atomicXX): Initialize s local variable.
* tests/test_atomic_include.template [AO_HAVE_char_storeXX && LINT2
&& AO_PREFER_GENERALIZED] (test_atomicXX): Initialize b local variable.
* tests/test_atomic_include.template [AO_HAVE_int_storeXX && LINT2
&& AO_PREFER_GENERALIZED] (test_atomicXX): Initialize zz local variable.

tests/test_atomic_include.template

index b6bcc18..e246b66 100644 (file)
@@ -61,8 +61,9 @@ void test_atomicXX(void)
     MISSING(AO_nop);
 # endif
 # if defined(AO_HAVE_storeXX)
-#   if defined(AO_MEMORY_SANITIZER) && defined(AO_PREFER_GENERALIZED)
-      *(volatile AO_t *)&x = 0; /* initialize to avoid MSan false warning */
+#   if (defined(AO_MEMORY_SANITIZER) || defined(LINT2)) \
+       && defined(AO_PREFER_GENERALIZED)
+      *(volatile AO_t *)&x = 0; /* initialize to avoid false warning */
 #   endif
     AO_storeXX(&x, 13);
     TA_assert(x == 13);
@@ -110,7 +111,8 @@ void test_atomicXX(void)
     --x;
 # endif
 # if defined(AO_HAVE_short_storeXX)
-#   if defined(AO_MEMORY_SANITIZER) && defined(AO_PREFER_GENERALIZED)
+#   if (defined(AO_MEMORY_SANITIZER) || defined(LINT2)) \
+       && defined(AO_PREFER_GENERALIZED)
       *(volatile short *)&s = 0;
 #   endif
     AO_short_storeXX(&s, 13);
@@ -152,7 +154,8 @@ void test_atomicXX(void)
 # endif
   TA_assert(*(volatile short *)&s == 13);
 # if defined(AO_HAVE_char_storeXX)
-#   if defined(AO_MEMORY_SANITIZER) && defined(AO_PREFER_GENERALIZED)
+#   if (defined(AO_MEMORY_SANITIZER) || defined(LINT2)) \
+       && defined(AO_PREFER_GENERALIZED)
       *(volatile char *)&b = 0;
 #   endif
     AO_char_storeXX(&b, 13);
@@ -193,7 +196,8 @@ void test_atomicXX(void)
 # endif
   TA_assert(*(volatile char *)&b == 13);
 # if defined(AO_HAVE_int_storeXX)
-#   if defined(AO_MEMORY_SANITIZER) && defined(AO_PREFER_GENERALIZED)
+#   if (defined(AO_MEMORY_SANITIZER) || defined(LINT2)) \
+       && defined(AO_PREFER_GENERALIZED)
       *(volatile int *)&zz = 0;
 #   endif
     AO_int_storeXX(&zz, 13);