From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gerbil.ash.relay.mailchannels.net (gerbil.ash.relay.mailchannels.net [23.83.222.67]) by sourceware.org (Postfix) with ESMTPS id 813B43858C50 for ; Tue, 18 Apr 2023 12:23:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 813B43858C50 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 8C903413DB; Tue, 18 Apr 2023 12:23:29 +0000 (UTC) Received: from pdx1-sub0-mail-a307.dreamhost.com (unknown [127.0.0.6]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id 1F3ED411F6; Tue, 18 Apr 2023 12:23:29 +0000 (UTC) ARC-Seal: i=1; s=arc-2022; d=mailchannels.net; t=1681820609; a=rsa-sha256; cv=none; b=fym7y5sjlVrZNuQMJTkNT6a/qZN5nPby+KMqrYzCR6cuVj6wM+LbSYaBKH1arQjyzfMiXO zVADZvvkzMyUgTXTN1ozGDgQc71GsU4d0PfGw+wAEZdqaeOlNh1K9LGbvplr7w7UpsXGe8 OQKfAfzwNRWQLZuA+VOtbpUyRiM7AA0q2Yo6R+yvvrv1pvHPouc+zTw9h9Cu76NULBLcu2 2KUiOq62t01FdANubHvpvMiRPbDZyyrtUW3MlEAFLkp4Jmx7f/Oac8esoDYhbuKr2uUvpE vpnpsK7WCs0aICc9XRkcoA3jniVgKuYU/0SdtH3e2YDADKB1KQOhmGJaawbK6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=mailchannels.net; s=arc-2022; t=1681820609; 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=MFAKNMHuG6HUn/S5PZUr89z7oIwgQbmutGacyyWXhKU=; b=88qxHRQ18Kn8I1vne7nfa0hR9WWUliKGT9lcwmVjakkr6u/7C1zqjL1kbTsWIYJukMOGQq 6lDFXwbujqD3bgH5uwrqwUn3KjNf0kIVxsQKJn0Erly9XunV/FaH5IS5ANDTbFEB6b2zpR 0CNgNqYk090xxAVJekXBR7KDIpMDoGGwFKFBLmeEojlExfg4tsHkjHHlBQsVoHWQ+iLKeK mmE4KxTCegUvcGFhasISbqwzck0Cnyt61FfWgfWviyQhg1+JSs6rjEeIAw4Cs5Gsw5i3V7 lOFFegqsr/2wB9szsmnxgFHG1b5DUEBVRvz0L3DT2FBqU+aZKN3d/okzr5/+VQ== ARC-Authentication-Results: i=1; rspamd-548d6c8f77-gw8lt; 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-Madly-Wide-Eyed: 642c043d3307359c_1681820609387_1674911011 X-MC-Loop-Signature: 1681820609387:1256822909 X-MC-Ingress-Time: 1681820609387 Received: from pdx1-sub0-mail-a307.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384) by 100.125.42.185 (trex/6.7.2); Tue, 18 Apr 2023 12:23:29 +0000 Received: from [192.168.2.12] (bras-vprn-toroon4834w-lp130-09-174-91-45-80.dsl.bell.ca [174.91.45.80]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a307.dreamhost.com (Postfix) with ESMTPSA id 4Q134055vwzNm; Tue, 18 Apr 2023 05:23:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gotplt.org; s=dreamhost; t=1681820608; bh=Lo097/6DH4/WlWCqj53LZhi4j2feLOO48ENVSIIunJg=; h=Date:Subject:To:From:Content-Type:Content-Transfer-Encoding; b=jhdh8vo+XLyTe+brjj44IOf1n0wL118FeQ26TgQAC1IZAjb/hABl2Xbob5vgUvF6L ZMjhGMtWJGoAGa+Wp2TNymxZJAkdiDHGQwCun4EPyz0S3Y4L/uUWjAGGPJA+95y2p6 euyTg05T1erG5kt25vfyWkXP8m5z3QMS8XdEvDWKI5iHpeW/3bm+onXMHP2jCiTUgV 5R25+uXebrJFVoR473pyN1D/wGljgTU8MfEVPo/pmwOlvJsH7rcW1L5GM5PVN0I9sp qGHkLPi+v/TFM62M4Oiwl3v6Mb0u5WTcU4x5ex64SbOJAu/otQiQiuLKbfPYG8xor0 kAdZ8nEApWyJg== Message-ID: Date: Tue, 18 Apr 2023 08:23:27 -0400 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.1 Subject: Re: [PATCH 1/8] tests: fix warn unused result Content-Language: en-US To: =?UTF-8?B?RnLDqWTDqXJpYyBCw6lyYXQ=?= , libc-alpha@sourceware.org References: <20230418121130.844302-1-fberat@redhat.com> <20230418121130.844302-2-fberat@redhat.com> From: Siddhesh Poyarekar In-Reply-To: <20230418121130.844302-2-fberat@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3038.2 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: On 2023-04-18 08:11, Frédéric Bérat via Libc-alpha wrote: > When enabling _FORTIFY_SOURCE, some functions now lead to warnings when > their result is not checked. I haven't done a full review of this patch yet, but the first straight issue I can see is that you could use the x* functions in support/ in the tests to avoid repeating the error checking blocks in tests. For example: > --- > argp/argp-test.c | 14 +++++++++++--- > assert/test-assert-perr.c | 13 +++++++------ > assert/test-assert.c | 13 +++++++------ > crypt/cert.c | 6 +++++- > dirent/tst-fdopendir.c | 13 +++++++++++-- > elf/tst-stackguard1.c | 2 +- > io/tst-copy_file_range.c | 2 +- > io/tst-faccessat.c | 6 +++++- > io/tst-fchmodat.c | 6 +++++- > io/tst-fchownat.c | 6 +++++- > io/tst-fstatat.c | 6 +++++- > io/tst-futimesat.c | 6 +++++- > io/tst-linkat.c | 6 +++++- > io/tst-openat.c | 6 +++++- > io/tst-renameat.c | 6 +++++- > io/tst-symlinkat.c | 6 +++++- > io/tst-unlinkat.c | 6 +++++- > libio/bug-fseek.c | 15 ++++++++++++--- > libio/bug-mmap-fflush.c | 12 ++++++++++-- > libio/bug-ungetc.c | 7 ++++++- > libio/bug-ungetc3.c | 7 ++++++- > libio/bug-ungetc4.c | 7 ++++++- > libio/bug-wfflush.c | 6 +++++- > libio/bug-wsetpos.c | 7 ++++++- > misc/tst-efgcvt-template.c | 4 ++-- > misc/tst-error1.c | 2 +- > nptl/tst-cancel7.c | 2 +- > nptl/tst-cleanup4.c | 6 +++++- > nptl/tst-stackguard1.c | 8 ++++++-- > nptl/tst-tls3mod.c | 4 ++-- > nss/tst-nss-db-endpwent.c | 6 +++++- > nss/tst-reload2.c | 6 +++++- > posix/tst-chmod.c | 9 +++++++-- > posix/tst-execl2.c | 4 ++-- > posix/tst-execle2.c | 4 ++-- > posix/tst-execlp2.c | 7 +++---- > posix/tst-execv2.c | 3 +-- > posix/tst-execve2.c | 3 +-- > posix/tst-execvp2.c | 6 ++---- > posix/tst-getopt-cancel.c | 2 +- > posix/tst-nice.c | 3 +-- > posix/wordexp-test.c | 12 ++++++++++-- > rt/tst-cpuclock2.c | 2 +- > rt/tst-cputimer1.c | 2 +- > rt/tst-cputimer2.c | 2 +- > rt/tst-cputimer3.c | 2 +- > stdio-common/bug12.c | 15 ++++++++++----- > stdio-common/bug19.c | 9 +++++++-- > stdio-common/bug3.c | 6 +++++- > stdio-common/bug4.c | 6 +++++- > stdio-common/bug5.c | 6 +++++- > stdio-common/bug6.c | 8 ++++---- > stdio-common/test-fwrite.c | 8 ++++++-- > stdio-common/test_rdwr.c | 3 ++- > stdio-common/tst-cookie.c | 4 +++- > stdio-common/tst-fmemopen3.c | 6 +++++- > stdio-common/tst-fseek.c | 3 +-- > stdio-common/tst-perror.c | 6 +++++- > stdio-common/tstscanf.c | 14 ++++++++++++-- > stdlib/test-canon.c | 25 +++++++++++++++++++++---- > support/test-container.c | 18 +++++++++++------- > sysdeps/pthread/tst-cancel11.c | 6 +++++- > sysdeps/pthread/tst-cancel16.c | 6 +++++- > sysdeps/pthread/tst-cancel20.c | 2 -- > sysdeps/pthread/tst-cancel21.c | 2 -- > sysdeps/pthread/tst-cancel4.c | 6 ++++-- > sysdeps/pthread/tst-cancel6.c | 3 ++- > sysdeps/pthread/tst-cond18.c | 2 +- > sysdeps/pthread/tst-fini1mod.c | 6 +++++- > sysdeps/pthread/tst-flock1.c | 6 +++++- > sysdeps/pthread/tst-flock2.c | 6 +++++- > sysdeps/pthread/tst-key1.c | 10 +++++----- > sysdeps/pthread/tst-signal1.c | 6 +++++- > sysdeps/pthread/tst-signal2.c | 6 +++++- > sysdeps/pthread/tst-timer.c | 2 +- > time/tst-cpuclock1.c | 2 +- > 76 files changed, 356 insertions(+), 135 deletions(-) > > diff --git a/argp/argp-test.c b/argp/argp-test.c > index c7e20f6235..fa7f9694d1 100644 > --- a/argp/argp-test.c > +++ b/argp/argp-test.c > @@ -178,12 +178,20 @@ help_filter (int key, const char *text, void *input) > if (key == ARGP_KEY_HELP_POST_DOC && text) > { > time_t now = time (0); > - asprintf (&new_text, text, ctime (&now)); > + if (asprintf (&new_text, text, ctime (&now)) < 0) ... this could be xasprintf, > + { > + printf("Failed to execute asprintf: %m\n"); > + exit(1); > + } > } > else if (key == 'f') > /* Show the default for the --foonly option. */ > - asprintf (&new_text, "%s (ZOT defaults to %x)", > - text, params->foonly_default); > + if (asprintf (&new_text, "%s (ZOT defaults to %x)", > + text, params->foonly_default) < 0) > + { > + printf("Failed to execute asprintf: %m\n"); > + exit(1); > + } > else > new_text = (char *)text; > > diff --git a/assert/test-assert-perr.c b/assert/test-assert-perr.c > index 8496db6ffd..ecfd4d14e5 100644 > --- a/assert/test-assert-perr.c > +++ b/assert/test-assert-perr.c > @@ -46,6 +46,7 @@ int > main(void) > { > volatile int failed = 1; /* safety in presence of longjmp() */ > + char *ret; > > fclose (stderr); > stderr = tmpfile (); > @@ -70,16 +71,16 @@ main(void) > failed = 1; /* should not happen */ > > rewind (stderr); > - fgets (buf, 160, stderr); > - if (!strstr(buf, strerror (1))) > + ret = fgets (buf, 160, stderr); > + if ((!ret && ferror(stderr)) || !strstr(buf, strerror (1))) This could be a new xfgets, and so on. I'd suggest making these test fixes into their own series, grouped by the x* functions, i.e. one patch for xasprintf, one for xfgets, etc. Thanks, Sid