From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dog.elm.relay.mailchannels.net (dog.elm.relay.mailchannels.net [23.83.212.48]) by sourceware.org (Postfix) with ESMTPS id 1A8053858D20 for ; Thu, 25 May 2023 01:35:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1A8053858D20 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=gotplt.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id A50B87E0D30; Thu, 25 May 2023 01:35:27 +0000 (UTC) Received: from pdx1-sub0-mail-a305.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 38C3E7E0170; Thu, 25 May 2023 01:35:27 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1684978527; a=rsa-sha256; cv=none; b=UwsYROHnEuSAoF3tWmjPZB6cCtfgm18tNYNUzNyHQgCdDOEkmBDTvgBY/0vr5uMjnDH9UJ tQgWT3HsDQlNkb3qiTVS5dbmULwgt9w7Mrg8j9AcutTNn09uUYCYMciRh3h5Vokwi/HIdZ f6iH+PoLA9WVxmW+OeNVOQJ2oF3OuOdyGsf4Qvj/az1Phm5pjdfocYzmCI3M/hrHSMgTYz ptMYTSn2C+shJTDeWSns2mPrtTdmgU65qWVVgjc3GhIf5K3hcfz4g1cOrszrKTEEg1O68s iemAG3Qs3wMnoTcooOleDGuhJjIirzSbwhY+eax+hxFw4mwl5/GAZ4m7GRvcEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1684978527; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=dr3nsheKo3BGCEYLuvjgrAAem4f7XuV8mkkzZG2wnhw=; b=rFLjUqwNRx7i1ErY3GtmO0TSYEwosDAWc2+o/KZ/YoWuUuNcxTRNMaGbe5am0y4SmQosO9 VPNHwvRKmkRi2l4RwhXQiuhk4vG+Uq9uHDUVQTaR4FWhdvzM/0T3krBL0LMUqlUmhZQE+d a5tVbFAP1Tby8QJOCISHPTJoq6SVnIrgwRX1Y3x4TUN8qaSHF8OungaZq6nQQ6xMV+NZN8 +TCYW+k75CI88IA/9xsVMqBp164P01bri3LVeeS6HEFTEimt6ZwPQA5Gs+V8gyz6bCh1N+ 7T8wRsnOaxR+1uI3UbSFNOKm+J8s6plolCQ2drGzEV+eZyXUPkU91MJI5aUgtQ== ARC-Authentication-Results: i=1; rspamd-79bb5575d7-hbqrk; auth=pass smtp.auth=dreamhost smtp.mailfrom=siddhesh@gotplt.org X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Ruddy-Plucky: 5dd545d15d20ee01_1684978527490_2823921874 X-MC-Loop-Signature: 1684978527490:2170383782 X-MC-Ingress-Time: 1684978527490 Received: from pdx1-sub0-mail-a305.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.106.146.233 (trex/6.8.1); Thu, 25 May 2023 01:35:27 +0000 Received: from [192.168.0.182] (bras-vprn-toroon4834w-lp130-02-142-113-138-85.dsl.bell.ca [142.113.138.85]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a305.dreamhost.com (Postfix) with ESMTPSA id 4QRVxB5Z5bzBD; Wed, 24 May 2023 18:35:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1684978527; bh=dr3nsheKo3BGCEYLuvjgrAAem4f7XuV8mkkzZG2wnhw=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=JNTdGtAd/DJPZ1AyGWvgKJ5xHxDuyfgptpgZAu9+NH3LaYFbR1rqzLQFvi+k94PPa 7AlaMbjdZqTc7C6DvbLlWUbhJMRLd18qSQJiBGI/lFAnzN/nrttMH6fbSs3VVp/COy ihLFebr93joP8h7olLo9vtKtRNWNvZP2Sj0e1eakp9wCgPPQKmjSNnzozy5ZwqZvHP ok7Cuk1D1SGY1GgP0uyLKC39jcdo2NL70Bb9UWhHMWIWdxNRJJsNL+GdAnJ2DViu2E PtYLBf7+sTyZXgBxbjxx/vn9Kg05TBsQkymoaC2iOg1JtiCVW5TEZgQrgqRXiiDIuM IV4fqnEw8li9g== Message-ID: <8b517d8b-4e4b-e2a8-5cf3-ff8521eaac7e@gotplt.org> Date: Wed, 24 May 2023 21:35:25 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH v4 15/15] tests: fix warn unused results Content-Language: en-US To: =?UTF-8?B?RnLDqWTDqXJpYyBCw6lyYXQ=?= , libc-alpha@sourceware.org References: <20230428122142.928135-1-fberat@redhat.com> <20230428122142.928135-16-fberat@redhat.com> From: Siddhesh Poyarekar In-Reply-To: <20230428122142.928135-16-fberat@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3037.5 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: A very tiny nit in this one (unnecessary paren), but OK otherwise. On 2023-04-28 08:21, Frédéric Bérat wrote: > With fortification enabled, few function calls return result need to be > checked, has they get the __wur macro enabled. > --- > crypt/cert.c | 6 +++++- > misc/tst-efgcvt-template.c | 4 ++-- > posix/tst-nice.c | 3 +-- > posix/wordexp-test.c | 6 +++++- > stdio-common/bug19.c | 9 +++++++-- > stdio-common/bug6.c | 8 ++++---- > stdio-common/tstscanf.c | 14 ++++++++++++-- > stdlib/test-canon.c | 18 +++++++++++++++--- > support/test-container.c | 4 ++-- > sysdeps/pthread/tst-cancel16.c | 6 +++++- > sysdeps/pthread/tst-cancel4.c | 6 ++++-- > 11 files changed, 62 insertions(+), 22 deletions(-) > > diff --git a/crypt/cert.c b/crypt/cert.c > index 32c4386caf..5b4277f76d 100644 > --- a/crypt/cert.c > +++ b/crypt/cert.c > @@ -99,7 +99,11 @@ get8 (char *cp) > int i,j,t; > > for(i=0;i<8;i++){ > - scanf("%2x",&t); > + if (scanf("%2x",&t) < 1) > + { > + if(ferror(stdin)) > + totfails++; > + } > if(feof(stdin)) > good_bye(); > for(j=0; j<8 ; j++) { > diff --git a/misc/tst-efgcvt-template.c b/misc/tst-efgcvt-template.c > index b924659a3d..87e3ebe4fa 100644 > --- a/misc/tst-efgcvt-template.c > +++ b/misc/tst-efgcvt-template.c > @@ -200,8 +200,8 @@ special (void) > output_error (NAME (ECVT), INFINITY, 10, "inf", 0, 0, p, decpt, sign); > > /* Simply make sure these calls with large NDIGITs don't crash. */ > - (void) ECVT (123.456, 10000, &decpt, &sign); > - (void) FCVT (123.456, 10000, &decpt, &sign); > + p = ECVT (123.456, 10000, &decpt, &sign); > + p = FCVT (123.456, 10000, &decpt, &sign); > > /* Some tests for the reentrant functions. */ > /* Use a too small buffer. */ > diff --git a/posix/tst-nice.c b/posix/tst-nice.c > index fe9888b3f6..59cf953e27 100644 > --- a/posix/tst-nice.c > +++ b/posix/tst-nice.c > @@ -58,8 +58,7 @@ do_test (void) > > /* BZ #18086. Make sure we don't reset errno. */ > errno = EBADF; > - nice (0); > - if (errno != EBADF) > + if (nice (0) == -1 || errno != EBADF) > { > printf ("FAIL: errno = %i, but wanted EBADF (%i)\n", errno, EBADF); > return 1; > diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c > index 87d537c931..057c89dd3c 100644 > --- a/posix/wordexp-test.c > +++ b/posix/wordexp-test.c > @@ -253,7 +253,11 @@ do_test (int argc, char *argv[]) > cwd = getcwd (NULL, 0); > > /* Set up arena for pathname expansion */ > - tmpnam (tmpdir); > + if (!tmpnam (tmpdir)) > + { > + printf ("Failed to create a temporary directory with a unique name: %m"); > + return 1; > + } > xmkdir (tmpdir, S_IRWXU); > TEST_VERIFY_EXIT (chdir (tmpdir) == 0); > > diff --git a/stdio-common/bug19.c b/stdio-common/bug19.c > index e083304bda..9a3deac3fc 100644 > --- a/stdio-common/bug19.c > +++ b/stdio-common/bug19.c > @@ -29,12 +29,17 @@ do_test (void) > printf("checking sscanf\n"); > > int i, j, n; > + int result = 0; > > i = j = n = 0; > - FSCANF (fp, L(" %i - %i %n"), &i, &j, &n); > + if (FSCANF (fp, L(" %i - %i %n"), &i, &j, &n) < 2) > + { > + printf ("FSCANF couldn't read all parameters %d\n", errno); > + result = 1; > + } > + > printf ("found %i-%i (length=%i)\n", i, j, n); > > - int result = 0; > if (i != 7) > { > printf ("i is %d, expected 7\n", i); > diff --git a/stdio-common/bug6.c b/stdio-common/bug6.c > index 0db63a3b44..50098bf3f2 100644 > --- a/stdio-common/bug6.c > +++ b/stdio-common/bug6.c > @@ -7,16 +7,16 @@ main (void) > int i; > int lost = 0; > > - scanf ("%2s", buf); > + lost = (scanf ("%2s", buf) < 0); > lost |= (buf[0] != 'X' || buf[1] != 'Y' || buf[2] != '\0'); > if (lost) > puts ("test of %2s failed."); > - scanf (" "); > - scanf ("%d", &i); > + lost |= (scanf (" ") < 0); > + lost |= (scanf ("%d", &i) < 0); > lost |= (i != 1234); > if (lost) > puts ("test of %d failed."); > - scanf ("%c", buf); > + lost |= (scanf ("%c", buf) < 0); > lost |= (buf[0] != 'L'); > if (lost) > puts ("test of %c failed.\n"); > diff --git a/stdio-common/tstscanf.c b/stdio-common/tstscanf.c > index 3a4ebf7524..7e92df4720 100644 > --- a/stdio-common/tstscanf.c > +++ b/stdio-common/tstscanf.c > @@ -120,7 +120,12 @@ main (int argc, char **argv) > int i; > float x; > char name[50]; > - (void) fscanf (in, "%2d%f%*d %[0123456789]", &i, &x, name); > + if (fscanf (in, "%2d%f%*d %[0123456789]", &i, &x, name) < 3) > + { > + fputs ("test failed!\n", stdout); > + result = 1; > + } > + > fprintf (out, "i = %d, x = %f, name = \"%.50s\"\n", i, x, name); > if (i != 56 || x != 789.0F || strcmp (name, "56")) > { > @@ -164,7 +169,12 @@ main (int argc, char **argv) > quant = 0.0; > units[0] = item[0] = '\0'; > count = fscanf (in, "%f%20s of %20s", &quant, units, item); > - (void) fscanf (in, "%*[^\n]"); > + if (fscanf (in, "%*[^\n]") < 0 && ferror (in)) > + { > + fputs ("test failed!\n", stdout); > + result = 1; > + } > + > fprintf (out, "count = %d, quant = %f, item = %.21s, units = %.21s\n", > count, quant, item, units); > if (count != ok[rounds-1].count || quant != ok[rounds-1].quant > diff --git a/stdlib/test-canon.c b/stdlib/test-canon.c > index 5a2e7e1e6e..61fe893609 100644 > --- a/stdlib/test-canon.c > +++ b/stdlib/test-canon.c > @@ -123,8 +123,15 @@ do_test (int argc, char ** argv) > int i, errors = 0; > char buf[PATH_MAX]; > > - getcwd (cwd, sizeof (buf)); > - cwd_len = strlen (cwd); > + if (getcwd (cwd, sizeof (buf))) > + { Unnecessary paren. > + cwd_len = strlen (cwd); > + } > + else > + { > + printf ("%s: current working directory couldn't be retrieved\n", argv[0]); > + ++errors; > + } > > errno = 0; > if (realpath (NULL, buf) != NULL || errno != EINVAL) > @@ -210,7 +217,12 @@ do_test (int argc, char ** argv) > free (result2); > } > > - getcwd (buf, sizeof (buf)); > + if (!getcwd (buf, sizeof (buf))) > + { > + printf ("%s: current working directory couldn't be retrieved\n", argv[0]); > + ++errors; > + } > + > if (strcmp (buf, cwd)) > { > printf ("%s: current working directory changed from %s to %s\n", > diff --git a/support/test-container.c b/support/test-container.c > index 37beb778d6..f51afefedb 100644 > --- a/support/test-container.c > +++ b/support/test-container.c > @@ -714,8 +714,8 @@ check_for_unshare_hints (int require_pidns) > continue; > > val = -1; /* Sentinel. */ > - fscanf (f, "%d", &val); > - if (val != files[i].bad_value) > + int cnt = fscanf (f, "%d", &val); > + if (cnt == 1 && val != files[i].bad_value) > continue; > > printf ("To enable test-container, please run this as root:\n"); > diff --git a/sysdeps/pthread/tst-cancel16.c b/sysdeps/pthread/tst-cancel16.c > index 511b9e1e91..d47c7c68cb 100644 > --- a/sysdeps/pthread/tst-cancel16.c > +++ b/sysdeps/pthread/tst-cancel16.c > @@ -50,7 +50,11 @@ tf (void *arg) > pthread_cleanup_push (cl, NULL); > > /* This call should never return. */ > - (void) lockf (fd, F_LOCK, 0); > + if (lockf (fd, F_LOCK, 0)) > + { > + puts ("child thread: lockf failed"); > + exit (1); > + } > > pthread_cleanup_pop (0); > > diff --git a/sysdeps/pthread/tst-cancel4.c b/sysdeps/pthread/tst-cancel4.c > index 4f5c89314c..4c9e8670ca 100644 > --- a/sysdeps/pthread/tst-cancel4.c > +++ b/sysdeps/pthread/tst-cancel4.c > @@ -1009,7 +1009,8 @@ tf_pread (void *arg) > pthread_cleanup_push (cl, NULL); > > char mem[10]; > - pread (tempfd, mem, sizeof (mem), 0); > + if (pread (tempfd, mem, sizeof (mem), 0) < 0) > + FAIL_EXIT1 ("pread failed: %m"); > > pthread_cleanup_pop (0); > > @@ -1038,7 +1039,8 @@ tf_pwrite (void *arg) > pthread_cleanup_push (cl, NULL); > > char mem[10]; > - pwrite (tempfd, mem, sizeof (mem), 0); > + if (pwrite (tempfd, mem, sizeof (mem), 0) <0) > + FAIL_EXIT1 ("pwrite failed: %m"); > > pthread_cleanup_pop (0); >