From patchwork Tue Jun 18 07:41:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 33176 Received: (qmail 81412 invoked by alias); 18 Jun 2019 07:41:28 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 81402 invoked by uid 89); 18 Jun 2019 07:41:27 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-23.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx0a-001b2d01.pphosted.com Subject: Re: [PATCH] Fix gcc 9 build errors for make xcheck. To: DJ Delorie Cc: libc-alpha@sourceware.org References: From: Stefan Liebler Date: Tue, 18 Jun 2019 09:41:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: x-cbid: 19061807-0016-0000-0000-0000028A0571 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19061807-0017-0000-0000-000032E7543F Message-Id: <4b2afe98-41eb-0361-887b-99180d2cd1c7@linux.ibm.com> On 6/17/19 8:11 PM, DJ Delorie wrote: > > Stefan Liebler writes: >> tst-field.c:52:7: error: ‘%s’ directive argument is null [-Werror=format-overflow=] >> Please enter the commit message for your changes. Lines starting > > Heh, double check your commit message :-) :-) Removed. > >> - char buf[10]; >> + char buf[12]; > > -MAXINT would be "-2147483648\0" - 12 bytes. Ok. > >> - for (int t = 0; t <= 3; t++) >> + for (int t = 0; t < 3; t++) > > Corresponds to: > static malloc_args tests[3][NUM_ALLOCS]; > > So OK. > >> 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); > > Ok. Do we have a standard for printing NULL? I mean, other unix's > print "(null)" for example. If we're changing it anyway, a bit of > consistency would be nice. But OK anyway :-) Changed all to "(NULL)". > >> printf ("FAIL: rewrite \"%s\" -> \"%s\", expected \"%s\"\n", >> - input, result, expected); >> + (input == NULL) ? "NULL" : input, result, expected); > > We explicitly pass NULL for input at least once, so OK. We never pass > NULL for expected, but as for test-strcasestr.c, we should protect it > anyway. We test for result!=NULL so do not need to check that one. Yes, it does not hurt. Added this check. > >> 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); > > Ok. > >> 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); > > Ok. > Bye Stefan commit 04cd33dbc4b080837c40a7dbf5680e2ecb4fae66 Author: Stefan Liebler Date: Fri Jun 14 12:54:38 2019 +0200 Fix gcc 9 build errors for make xcheck. [BZ #24556] 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. diff --git a/argp/argp-test.c b/argp/argp-test.c index cb2976ddad..13e0c6df14 100644 --- a/argp/argp-test.c +++ b/argp/argp-test.c @@ -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 diff --git a/benchtests/bench-malloc-simple.c b/benchtests/bench-malloc-simple.c index b8bb2cc116..c4f06f6999 100644 --- a/benchtests/bench-malloc-simple.c +++ b/benchtests/bench-malloc-simple.c @@ -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]; diff --git a/benchtests/bench-strstr.c b/benchtests/bench-strstr.c index 2cbe13e9ac..aa97067e49 100644 --- a/benchtests/bench-strstr.c +++ b/benchtests/bench-strstr.c @@ -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; } } diff --git a/nss/tst-field.c b/nss/tst-field.c index 23d2f2abf6..b2943452bd 100644 --- a/nss/tst-field.c +++ b/nss/tst-field.c @@ -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); diff --git a/string/test-strcasestr.c b/string/test-strcasestr.c index 0a16f85dcd..452f8c5e0a 100644 --- a/string/test-strcasestr.c +++ b/string/test-strcasestr.c @@ -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; } diff --git a/string/test-strstr.c b/string/test-strstr.c index 031aff5534..0ffa9ba344 100644 --- a/string/test-strstr.c +++ b/string/test-strstr.c @@ -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; }