]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix gcc 9 build errors for make xcheck. [BZ #24556]
authorStefan Liebler <stli@linux.ibm.com>
Wed, 19 Jun 2019 10:32:04 +0000 (12:32 +0200)
committerStefan Liebler <stli@linux.ibm.com>
Wed, 19 Jun 2019 10:32:04 +0000 (12:32 +0200)
This patch fixes the following gcc 9 warnings for "make xcheck" / "make bench":
-string/tst-strcasestr.c:
../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=]

-argp/argp-test.c:
argp-test.c:130:20: error: ‘%d’ directive writing between 1 and 11 bytes into a region of size 10 [-Werror=format-overflow=]
argp-test.c:130:19: note: directive argument in the range [-2147483648, 122]
argp-test.c:130:5: note: ‘sprintf’ output between 2 and 12 bytes into a destination of size 10

-nss/tst-field.c:
tst-field.c:52:7: error: ‘%s’ directive argument is null [-Werror=format-overflow=]

-benchtests/bench-strstr.c:
../include/bits/../../misc/bits/error.h:42:5: error: ‘%s’ directive argument is null [-Werror=format-overflow=]

-benchtests/bench-malloc-simple.c:
bench-malloc-simple.c:93:16: error: iteration 3 invokes undefined behavior [-Werror=aggressive-loop-optimizations]

ChangeLog:

[BZ #24556]
* string/test-strcasestr.c (check_result): Add NULL check.
* nss/tst-field.c (check_rewrite): Likewise.
* benchtests/bench-strstr.c (do_one_test): Likewise.
* string/test-strstr.c (check_result): Likewise.
* argp/argp-test.c (popt): Increase size of buf to 12.
* benchtests/bench-malloc-simple.c (bench):
Do not initialize tests array out of bounds.

ChangeLog
argp/argp-test.c
benchtests/bench-malloc-simple.c
benchtests/bench-strstr.c
nss/tst-field.c
string/test-strcasestr.c
string/test-strstr.c

index f32b734166db88304ef7163be27e3a0b7946cf9e..48d59d37ce10457b66ad58209b4b0be1582e2232 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2019-06-19  Stefan Liebler  <stli@linux.ibm.com>
+
+       [BZ #24556]
+       * string/test-strcasestr.c (check_result): Add NULL check.
+       * nss/tst-field.c (check_rewrite): Likewise.
+       * benchtests/bench-strstr.c (do_one_test): Likewise.
+       * string/test-strstr.c (check_result): Likewise.
+       * argp/argp-test.c (popt): Increase size of buf to 12.
+       * benchtests/bench-malloc-simple.c (bench):
+       Do not initialize tests array out of bounds.
+
 2019-06-19  Florian Weimer  <fweimer@redhat.com>
 
        [BZ #24166]
index cb2976ddad47a0cfb57efc7c7269d0af5f0b7a6e..13e0c6df14bdf936fe16581c95e28f179c9b39ba 100644 (file)
@@ -123,7 +123,7 @@ static const char doc[] = "Test program for argp."
 static void
 popt (int key, char *arg)
 {
-  char buf[10];
+  char buf[12];
   if (isprint (key))
     sprintf (buf, "%c", key);
   else
index b8bb2cc116953c6691c17633d18c5661c7d9243e..c4f06f69993d1b667fc10722c3bfe767eb54d39e 100644 (file)
@@ -87,7 +87,7 @@ bench (unsigned long size)
   size_t iters = NUM_ITERS;
   int **arr = (int**) malloc (MAX_ALLOCS * sizeof (void*));
 
-  for (int t = 0; t <= 3; t++)
+  for (int t = 0; t < 3; t++)
     for (int i = 0; i < NUM_ALLOCS; i++)
       {
        tests[t][i].n = allocs[i];
index 2cbe13e9ac06eed303cdb9d61da31f111d55a736..89d1755813f827f7857edfffa030a7b2af36995f 100644 (file)
@@ -147,7 +147,8 @@ do_one_test (impl_t *impl, const char *s1, const char *s2, char *exp_result)
   if (res != exp_result)
     {
       error (0, 0, "Wrong result in function %s %s %s", impl->name,
-            res, exp_result);
+            (res == NULL) ? "(null)" : res,
+            (exp_result == NULL) ? "(null)" : exp_result);
       ret = 1;
     }
 }
index 23d2f2abf65d5f2a0a8c8256f05a27f5c239102c..d98d3eead01492e438670c2b2c34b785be0c9a2b 100644 (file)
@@ -50,7 +50,8 @@ check_rewrite (const char *input, const char *expected)
   if (result != NULL && strcmp (result, expected) != 0)
     {
       printf ("FAIL: rewrite \"%s\" -> \"%s\", expected \"%s\"\n",
-             input, result, expected);
+             (input == NULL) ? "(null)" : input, result,
+             (expected == NULL) ? "(null)" : expected);
       errors = true;
     }
   free (to_free);
index 0a16f85dcd2df8499d85ba014da2ad2dd72e0472..7649cc6e1d6d575f6567397c30f470104f590cc9 100644 (file)
@@ -67,7 +67,8 @@ check_result (impl_t *impl, const char *s1, const char *s2,
   if (result != exp_result)
     {
       error (0, 0, "Wrong result in function %s %s %s", impl->name,
-            result, exp_result);
+            (result == NULL) ? "(null)" : result,
+            (exp_result == NULL) ? "(null)" : exp_result);
       ret = 1;
       return -1;
     }
index 031aff553465165680dc61f1db9cb58877985679..df6dbc251ecf984196b8c0e75ca9f78784e1e016 100644 (file)
@@ -66,7 +66,8 @@ check_result (impl_t *impl, const char *s1, const char *s2,
   if (result != exp_result)
     {
       error (0, 0, "Wrong result in function %s %s %s", impl->name,
-            result, exp_result);
+            (result == NULL) ? "(null)" : result,
+            (exp_result == NULL) ? "(null)" : exp_result);
       ret = 1;
       return -1;
     }