From patchwork Tue Apr 18 12:11:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1770121 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=HWVw6qpG; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12qq3g9tz1ybC for ; Tue, 18 Apr 2023 22:12:55 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7105738560B8 for ; Tue, 18 Apr 2023 12:12:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7105738560B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681819973; bh=zhtYz8Jv66HMNUZCjm8NKifT1FEhWiT52Ei1arjOCQQ=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=HWVw6qpGiOzlxx9quBO3Wmhfz5tqCBjnsRa32UFipHBMpmKPyMScI9PxzBrVH3VbT xAzbqHNtRn75TbO70+5sGljmE49jzwJwgkuSao9bWGPfNIY5zPf6KaLTYMvdgVkv32 CiLChDoFxd0jZGVCDMpWxOBRfrCcWk2mP7t3+WPA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 174BA3857BB2 for ; Tue, 18 Apr 2023 12:11:39 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 174BA3857BB2 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-34-ez7mcl3kN3-_-EzJHEnP4A-1; Tue, 18 Apr 2023 08:11:37 -0400 X-MC-Unique: ez7mcl3kN3-_-EzJHEnP4A-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 686953C10681 for ; Tue, 18 Apr 2023 12:11:37 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8627E40C20FA; Tue, 18 Apr 2023 12:11:36 +0000 (UTC) To: libc-alpha@sourceware.org Cc: sipoyare@redhat.com Subject: [PATCH 1/8] tests: fix warn unused result Date: Tue, 18 Apr 2023 14:11:23 +0200 Message-Id: <20230418121130.844302-2-fberat@redhat.com> In-Reply-To: <20230418121130.844302-1-fberat@redhat.com> References: <20230418121130.844302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" When enabling _FORTIFY_SOURCE, some functions now lead to warnings when their result is not checked. --- 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) + { + 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))) failed = 1; - fgets (buf, 160, stderr); - if (strstr (buf, strerror (0))) + ret = fgets (buf, 160, stderr); + if ((!ret && ferror(stderr)) || strstr (buf, strerror (0))) failed = 1; - fgets (buf, 160, stderr); - if (strstr (buf, strerror (2))) + ret = fgets (buf, 160, stderr); + if ((!ret && ferror(stderr)) || strstr (buf, strerror (2))) failed = 1; return failed; diff --git a/assert/test-assert.c b/assert/test-assert.c index 26b58d4dd3..22d250317c 100644 --- a/assert/test-assert.c +++ b/assert/test-assert.c @@ -48,6 +48,7 @@ main (void) { volatile int failed = 1; + char *ret; fclose (stderr); stderr = tmpfile (); @@ -72,16 +73,16 @@ main (void) failed = 1; /* should not happen */ rewind (stderr); - fgets (buf, 160, stderr); - if (!strstr (buf, "1 == 2")) + ret = fgets (buf, 160, stderr); + if ((!ret && ferror(stderr)) || !strstr (buf, "1 == 2")) failed = 1; - fgets (buf, 160, stderr); - if (strstr (buf, "1 == 1")) + ret = fgets (buf, 160, stderr); + if ((!ret && ferror(stderr)) || strstr (buf, "1 == 1")) failed = 1; - fgets (buf, 160, stderr); - if (strstr (buf, "2 == 3")) + ret = fgets (buf, 160, stderr); + if ((!ret && ferror(stderr)) || strstr (buf, "2 == 3")) failed = 1; return failed; 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/dirent/tst-fdopendir.c b/dirent/tst-fdopendir.c index 6321af1daa..ee645cf9af 100644 --- a/dirent/tst-fdopendir.c +++ b/dirent/tst-fdopendir.c @@ -22,7 +22,11 @@ do_test (void) return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + printf ("Failed to write to file: %m\n"); + return 1; + } close (fd); struct stat64 st; @@ -43,7 +47,12 @@ do_test (void) } char buf[5]; - read(fd, buf, sizeof (buf)); + if (read(fd, buf, sizeof (buf)) < 0) + { + puts ("read failed"); + return 1; + } + close(fd); struct stat64 st2; diff --git a/elf/tst-stackguard1.c b/elf/tst-stackguard1.c index 2e65e36078..1a98a9da52 100644 --- a/elf/tst-stackguard1.c +++ b/elf/tst-stackguard1.c @@ -108,7 +108,7 @@ do_test (void) dup2 (fds[1], 2); close (fds[1]); - system (command); + if (system (command)) {} exit (0); } diff --git a/io/tst-copy_file_range.c b/io/tst-copy_file_range.c index d1f3aaa5a9..bd64e9c42b 100644 --- a/io/tst-copy_file_range.c +++ b/io/tst-copy_file_range.c @@ -166,7 +166,7 @@ short_copy (void) inoff = 3; xlseek (infd, shift, SEEK_SET); } - ftruncate (outfd, 0); + xftruncate (outfd, 0); xlseek (outfd, 0, SEEK_SET); outoff = 0; diff --git a/io/tst-faccessat.c b/io/tst-faccessat.c index 7bdeed008c..5ef81b1451 100644 --- a/io/tst-faccessat.c +++ b/io/tst-faccessat.c @@ -96,7 +96,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + printf ("Failed to write to file: %m\n"); + return 1; + } puts ("file created"); /* Before closing the file, try using this file descriptor to open diff --git a/io/tst-fchmodat.c b/io/tst-fchmodat.c index 7d4a8717ff..aeed98e0a8 100644 --- a/io/tst-fchmodat.c +++ b/io/tst-fchmodat.c @@ -98,7 +98,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + puts ("failed to write to file"); + return 1; + } puts ("file created"); struct stat64 st1; diff --git a/io/tst-fchownat.c b/io/tst-fchownat.c index e8adf6229f..b206c04200 100644 --- a/io/tst-fchownat.c +++ b/io/tst-fchownat.c @@ -106,7 +106,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + printf ("Failed to write to file: %m\n"); + return 1; + } puts ("file created"); struct stat64 st1; diff --git a/io/tst-fstatat.c b/io/tst-fstatat.c index 4766bb2e71..712cd5226d 100644 --- a/io/tst-fstatat.c +++ b/io/tst-fstatat.c @@ -94,7 +94,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + puts ("failed to write to file"); + return 1; + } puts ("file created"); struct stat64 st1; diff --git a/io/tst-futimesat.c b/io/tst-futimesat.c index 3d41721f42..0e1d104623 100644 --- a/io/tst-futimesat.c +++ b/io/tst-futimesat.c @@ -114,7 +114,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + puts ("failed to write to file"); + return 1; + } puts ("file created"); struct_stat st1; diff --git a/io/tst-linkat.c b/io/tst-linkat.c index 97445b7954..92b1cc65f7 100644 --- a/io/tst-linkat.c +++ b/io/tst-linkat.c @@ -94,7 +94,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + puts ("failed to write to file"); + return 1; + } puts ("file created"); struct stat64 st1; diff --git a/io/tst-openat.c b/io/tst-openat.c index 741b8d0ad2..999fdb79ba 100644 --- a/io/tst-openat.c +++ b/io/tst-openat.c @@ -94,7 +94,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + puts ("failed to write to file"); + return 1; + } /* Before closing the file, try using this file descriptor to open another file. This must fail. */ diff --git a/io/tst-renameat.c b/io/tst-renameat.c index 435302b52b..33885a4280 100644 --- a/io/tst-renameat.c +++ b/io/tst-renameat.c @@ -94,7 +94,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + puts ("failed to write to file"); + return 1; + } puts ("file created"); struct stat64 st1; diff --git a/io/tst-symlinkat.c b/io/tst-symlinkat.c index 214a8e348e..e9aba970c7 100644 --- a/io/tst-symlinkat.c +++ b/io/tst-symlinkat.c @@ -94,7 +94,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + puts ("failed to write to file"); + return 1; + } puts ("file created"); struct stat64 st1; diff --git a/io/tst-unlinkat.c b/io/tst-unlinkat.c index e21d56f9f7..027d91ba98 100644 --- a/io/tst-unlinkat.c +++ b/io/tst-unlinkat.c @@ -94,7 +94,11 @@ do_test (void) puts ("file creation failed"); return 1; } - write (fd, "hello", 5); + if (write (fd, "hello", 5) < 5) + { + puts ("failed to write to file"); + return 1; + } close (fd); puts ("file created"); diff --git a/libio/bug-fseek.c b/libio/bug-fseek.c index 1b60580b53..509db8689e 100644 --- a/libio/bug-fseek.c +++ b/libio/bug-fseek.c @@ -48,7 +48,10 @@ do_test (void) perror ("fopen(\"r\")"); } - fread (buf, 3, 1, f); + if (fread (buf, 3, 1, f) < 1) + { + perror ("fread"); + } errno = 0; if (fseek (f, -10, SEEK_CUR) == 0) { @@ -72,7 +75,10 @@ Got %d instead\n", perror ("fopen(\"r+\")"); } - fread (buf, 3, 1, f); + if (fread (buf, 3, 1, f) < 1) + { + perror ("fread"); + } errno = 0; if (fseek (f, -10, SEEK_CUR) == 0) { @@ -96,7 +102,10 @@ Got %d instead\n", perror ("fopen(\"r+\")"); } - fread (buf, 3, 1, f); + if (fread (buf, 3, 1, f) < 1) + { + perror ("fread"); + } if (ftell (f) != 3) { puts ("ftell failed"); diff --git a/libio/bug-mmap-fflush.c b/libio/bug-mmap-fflush.c index d8aa58985a..697d39816e 100644 --- a/libio/bug-mmap-fflush.c +++ b/libio/bug-mmap-fflush.c @@ -35,14 +35,22 @@ do_test (void) char buffer[1024]; snprintf (buffer, sizeof (buffer), "echo 'From foo@bar.com' > %s", fname); - system (buffer); + if (system (buffer)) + { + perror ("Failed to execute echo command %m\n"); + exit (1); + } f = fopen (fname, "r"); fseek (f, 0, SEEK_END); o = ftello (f); fseek (f, 0, SEEK_SET); fflush (f); snprintf (buffer, sizeof (buffer), "echo 'From bar@baz.edu' >> %s", fname); - system (buffer); + if (system (buffer)) + { + perror ("Failed to execute echo command %m\n"); + exit (1); + } fseek (f, o, SEEK_SET); if (fgets (buffer, 1024, f) == NULL) exit (1); diff --git a/libio/bug-ungetc.c b/libio/bug-ungetc.c index 51940b68f5..5db5417170 100644 --- a/libio/bug-ungetc.c +++ b/libio/bug-ungetc.c @@ -20,7 +20,12 @@ do_prepare (void) printf ("cannot create temporary file: %m\n"); exit (1); } - write (fd, pattern, sizeof (pattern)); + + if (write (fd, pattern, sizeof (pattern)) < sizeof (pattern)) + { + printf ("cannot write to temporary file: %m\n"); + exit (1); + } close (fd); } diff --git a/libio/bug-ungetc3.c b/libio/bug-ungetc3.c index 0c83c1161e..2afe000d2a 100644 --- a/libio/bug-ungetc3.c +++ b/libio/bug-ungetc3.c @@ -20,7 +20,12 @@ do_prepare (void) printf ("cannot create temporary file: %m\n"); exit (1); } - write (fd, pattern, sizeof (pattern)); + if (write (fd, pattern, sizeof (pattern)) < sizeof (pattern)) + { + printf ("cannot write to temporary file: %m\n"); + exit (1); + } + close (fd); } diff --git a/libio/bug-ungetc4.c b/libio/bug-ungetc4.c index 0bd02a570d..df47bcd263 100644 --- a/libio/bug-ungetc4.c +++ b/libio/bug-ungetc4.c @@ -36,7 +36,12 @@ do_prepare (void) printf ("cannot create temporary file: %m\n"); exit (1); } - write (fd, pattern, sizeof (pattern) - 1); + + if (write (fd, pattern, sizeof (pattern) - 1) < sizeof (pattern) - 1) + { + printf ("cannot write to temporary file: %m\n"); + exit (1); + } close (fd); } diff --git a/libio/bug-wfflush.c b/libio/bug-wfflush.c index a8fd61e997..771c32e17b 100644 --- a/libio/bug-wfflush.c +++ b/libio/bug-wfflush.c @@ -20,7 +20,11 @@ do_prepare (void) printf ("cannot create temporary file: %m\n"); exit (1); } - write (fd, "1!", 2); + if (write (fd, "1!", 2) < 2) + { + printf ("cannot write to temporary file: %m\n"); + exit (1); + } close (fd); } diff --git a/libio/bug-wsetpos.c b/libio/bug-wsetpos.c index ccb22a4b62..39180ccee1 100644 --- a/libio/bug-wsetpos.c +++ b/libio/bug-wsetpos.c @@ -22,7 +22,12 @@ do_prepare (void) printf ("cannot create temporary file: %m\n"); exit (1); } - write (fd, pattern, sizeof (pattern)); + if (write (fd, pattern, sizeof (pattern)) < sizeof (pattern)) + { + printf ("cannot write to temporary file: %m\n"); + exit (1); + } + close (fd); } 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/misc/tst-error1.c b/misc/tst-error1.c index 9c4a62fbd0..65e3fd0c0e 100644 --- a/misc/tst-error1.c +++ b/misc/tst-error1.c @@ -9,7 +9,7 @@ static int do_test (int argc, char *argv[]) { mtrace (); - (void) freopen (argc == 1 ? "/dev/stdout" : argv[1], "a", stderr); + if (freopen (argc == 1 ? "/dev/stdout" : argv[1], "a", stderr)) {} /* Orient the stream. */ fwprintf (stderr, L"hello world\n"); char buf[20000]; diff --git a/nptl/tst-cancel7.c b/nptl/tst-cancel7.c index 2835613a9b..e4196d9d11 100644 --- a/nptl/tst-cancel7.c +++ b/nptl/tst-cancel7.c @@ -43,7 +43,7 @@ tf (void *arg) { char *cmd = xasprintf ("%s --direct --sem %s --pidfile %s", command, semfilename, pidfilename); - system (cmd); + if (system (cmd)) {}; /* This call should never return. */ return NULL; } diff --git a/nptl/tst-cleanup4.c b/nptl/tst-cleanup4.c index 1d3d53fb5f..64206c4ab6 100644 --- a/nptl/tst-cleanup4.c +++ b/nptl/tst-cleanup4.c @@ -64,7 +64,11 @@ fn_read (void) } char c; - read (fds[0], &c, 1); + if (read (fds[0], &c, 1) < 1) + { + printf ("%s: read failed\n", __FUNCTION__); + exit (1); + } } diff --git a/nptl/tst-stackguard1.c b/nptl/tst-stackguard1.c index b9cf6844de..96cfcb02f7 100644 --- a/nptl/tst-stackguard1.c +++ b/nptl/tst-stackguard1.c @@ -96,7 +96,11 @@ do_test (void) else if (ret != NULL) return 1; - write (2, &stack_chk_guard_copy, sizeof (stack_chk_guard_copy)); + if (write (2, &stack_chk_guard_copy, sizeof (stack_chk_guard_copy)) < 0) + { + puts("failed to write stack_chk_guard_copy"); + return 1; + } return 0; } @@ -138,7 +142,7 @@ do_test (void) dup2 (fds[1], 2); close (fds[1]); - system (command); + if (system (command)) {} exit (0); } diff --git a/nptl/tst-tls3mod.c b/nptl/tst-tls3mod.c index c6e8910b1e..ba9e012204 100644 --- a/nptl/tst-tls3mod.c +++ b/nptl/tst-tls3mod.c @@ -43,7 +43,7 @@ handler (int sig) { if (sig != THE_SIG) { - write (STDOUT_FILENO, "wrong signal\n", 13); + if (write (STDOUT_FILENO, "wrong signal\n", 13) < 13) {} _exit (1); } @@ -51,7 +51,7 @@ handler (int sig) if (sem_post (&s) != 0) { - write (STDOUT_FILENO, "sem_post failed\n", 16); + if (write (STDOUT_FILENO, "sem_post failed\n", 16) < 16) {} _exit (1); } } diff --git a/nss/tst-nss-db-endpwent.c b/nss/tst-nss-db-endpwent.c index 2b0fc1b064..519b73c41e 100644 --- a/nss/tst-nss-db-endpwent.c +++ b/nss/tst-nss-db-endpwent.c @@ -55,7 +55,11 @@ do_test (void) cmd = xasprintf ("%s/makedb -o /var/db/passwd.db /var/db/passwd.in", support_bindir_prefix); - system (cmd); + if (system (cmd) < 0) + { + printf("failed to prepare the test"); + return 1; + } free (cmd); try_it (); diff --git a/nss/tst-reload2.c b/nss/tst-reload2.c index ba9b5b7687..b25e5e3528 100644 --- a/nss/tst-reload2.c +++ b/nss/tst-reload2.c @@ -121,7 +121,11 @@ do_test (void) /* Change the root dir. */ TEST_VERIFY (chroot ("/subdir") == 0); - chdir ("/"); + if (chdir ("/") < 0) + { + printf("Failed to change directory: %m"); + return 1; + } /* Check we're NOT using the "inner" nsswitch.conf. */ diff --git a/posix/tst-chmod.c b/posix/tst-chmod.c index b98a05a265..bec2d2b8eb 100644 --- a/posix/tst-chmod.c +++ b/posix/tst-chmod.c @@ -229,7 +229,12 @@ do_test (int argc, char *argv[]) close (fd); snprintf (buf, buflen, "%s/..", testdir); - chdir (buf); + if (chdir (buf)) + { + printf ("cannot change directory: %m\n"); + result = 1; + goto fail; + } /* We are now in the directory above the one we create the test directory in. */ @@ -349,7 +354,7 @@ do_test (int argc, char *argv[]) } fail: - chdir (startdir); + if (chdir (startdir)) {} /* Remove all the files. */ chmod (testdir, 0700); diff --git a/posix/tst-execl2.c b/posix/tst-execl2.c index 5b74959ef8..3c22ecce5c 100644 --- a/posix/tst-execl2.c +++ b/posix/tst-execl2.c @@ -18,8 +18,8 @@ prepare (int argc, char *argv[]) { char *buf; int off; - asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]); - if (buf == NULL) + + if (asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]) < 0 || buf == NULL) { puts ("asprintf failed"); exit (1); diff --git a/posix/tst-execle2.c b/posix/tst-execle2.c index 0430b7b573..28d3071dd9 100644 --- a/posix/tst-execle2.c +++ b/posix/tst-execle2.c @@ -18,8 +18,8 @@ prepare (int argc, char *argv[]) { char *buf; int off; - asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]); - if (buf == NULL) + + if (asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]) < 0 || buf == NULL) { puts ("asprintf failed"); exit (1); diff --git a/posix/tst-execlp2.c b/posix/tst-execlp2.c index 81a723dda4..797a320bb5 100644 --- a/posix/tst-execlp2.c +++ b/posix/tst-execlp2.c @@ -22,8 +22,8 @@ prepare (int argc, char *argv[]) { char *buf; int off; - asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]); - if (buf == NULL) + + if (asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]) < 0 || buf == NULL) { puts ("asprintf failed"); exit (1); @@ -59,8 +59,7 @@ do_test (void) return 1; } char *path; - asprintf (&path, "%s:../libio:../elf", bindir); - if (path == NULL) + if (asprintf (&path, "%s:../libio:../elf", bindir) < 0 || path == NULL) { puts ("asprintf failed"); return 1; diff --git a/posix/tst-execv2.c b/posix/tst-execv2.c index a5168a269c..2de3286a6d 100644 --- a/posix/tst-execv2.c +++ b/posix/tst-execv2.c @@ -18,8 +18,7 @@ prepare (int argc, char *argv[]) { char *buf; int off; - asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]); - if (buf == NULL) + if (asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]) < 0 || buf == NULL) { puts ("asprintf failed"); exit (1); diff --git a/posix/tst-execve2.c b/posix/tst-execve2.c index 1a804e94fd..57da680536 100644 --- a/posix/tst-execve2.c +++ b/posix/tst-execve2.c @@ -18,8 +18,7 @@ prepare (int argc, char *argv[]) { char *buf; int off; - asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]); - if (buf == NULL) + if (asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]) < 0 || buf == NULL) { puts ("asprintf failed"); exit (1); diff --git a/posix/tst-execvp2.c b/posix/tst-execvp2.c index 440dfab438..ab6c3ee175 100644 --- a/posix/tst-execvp2.c +++ b/posix/tst-execvp2.c @@ -25,8 +25,7 @@ prepare (int argc, char *argv[]) { char *buf; int off; - asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]); - if (buf == NULL) + if (asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]) < 0 || buf == NULL) { puts ("asprintf failed"); exit (1); @@ -62,8 +61,7 @@ do_test (void) return 1; } char *path; - asprintf (&path, "%s:../libio:../elf", bindir); - if (path == NULL) + if (asprintf (&path, "%s:../libio:../elf", bindir) < 0 || path == NULL) { puts ("asprintf failed"); return 1; diff --git a/posix/tst-getopt-cancel.c b/posix/tst-getopt-cancel.c index 7167d1a914..24771ee82e 100644 --- a/posix/tst-getopt-cancel.c +++ b/posix/tst-getopt-cancel.c @@ -48,7 +48,7 @@ check_stderr (bool expect_errmsg, FILE *stderr_trapped) fputs (lineptr, stdout); } rewind (stderr_trapped); - ftruncate (fileno (stderr_trapped), 0); + if (ftruncate (fileno (stderr_trapped), 0) < 0) {} return got_errmsg == expect_errmsg; } 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 bae27d6cee..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); @@ -332,7 +336,11 @@ do_test (int argc, char *argv[]) if (cwd == NULL) cwd = ".."; - chdir (cwd); + if (chdir (cwd) < 0) + { + printf ("failed to change dir: %m"); + return 1; + } rmdir (tmpdir); return 0; diff --git a/rt/tst-cpuclock2.c b/rt/tst-cpuclock2.c index e4584d8791..22f20870f8 100644 --- a/rt/tst-cpuclock2.c +++ b/rt/tst-cpuclock2.c @@ -55,7 +55,7 @@ chew_cpu (void *arg) for (int i = 0; i < 100; ++i) for (size_t j = 0; j < sizeof buf; ++j) buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); + if (write (nullfd, (char *) buf, sizeof buf)) {}; close (nullfd); } diff --git a/rt/tst-cputimer1.c b/rt/tst-cputimer1.c index 8f5dd76cf2..ec75424a83 100644 --- a/rt/tst-cputimer1.c +++ b/rt/tst-cputimer1.c @@ -29,7 +29,7 @@ chew_cpu (void *arg) for (int i = 0; i < 100; ++i) for (size_t j = 0; j < sizeof buf; ++j) buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); + if (write (nullfd, (char *) buf, sizeof buf)) {} close (nullfd); } diff --git a/rt/tst-cputimer2.c b/rt/tst-cputimer2.c index 397d7998c0..7fb78fe485 100644 --- a/rt/tst-cputimer2.c +++ b/rt/tst-cputimer2.c @@ -32,7 +32,7 @@ chew_cpu (void *arg) for (int i = 0; i < 100; ++i) for (size_t j = 0; j < sizeof buf; ++j) buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); + if (write (nullfd, (char *) buf, sizeof buf)) {} close (nullfd); } diff --git a/rt/tst-cputimer3.c b/rt/tst-cputimer3.c index 056766a377..e8661b9cfc 100644 --- a/rt/tst-cputimer3.c +++ b/rt/tst-cputimer3.c @@ -33,7 +33,7 @@ chew_cpu (void) for (int i = 0; i < 100; ++i) for (size_t j = 0; j < sizeof buf; ++j) buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); + if (write (nullfd, (char *) buf, sizeof buf)) {} close (nullfd); if (getppid () == 1) _exit (2); diff --git a/stdio-common/bug12.c b/stdio-common/bug12.c index 48610c0e78..820e91f618 100644 --- a/stdio-common/bug12.c +++ b/stdio-common/bug12.c @@ -20,24 +20,29 @@ main (void) } rewind (f); - fread (m, 4096 * 4 - 10, 1, f); - fread (b, 20, 1, f); + if (fread (m, 4096 * 4 - 10, 1, f) < 1) + failed = 1; + if (fread (b, 20, 1, f) < 1) + failed = 1; printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx"); if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx")) failed = 1; fseek (f, -40, SEEK_CUR); - fread (b, 20, 1, f); + if (fread (b, 20, 1, f) < 1) + failed = 1; printf ("got %s (should be %s)\n", b, "zzzzzzzzzzzzzzzzzzzz"); if (strcmp (b, "zzzzzzzzzzzzzzzzzzzz")) failed = 1; - fread (b, 20, 1, f); + if (fread (b, 20, 1, f) < 1) + failed = 1; printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx"); if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx")) failed = 1; - fread (b, 20, 1, f); + if (fread (b, 20, 1, f) < 1) + failed = 1; printf ("got %s (should be %s)\n", b, "xxxxxxxxxxxxxxxxxxxx"); if (strcmp (b, "xxxxxxxxxxxxxxxxxxxx")) failed = 1; 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/bug3.c b/stdio-common/bug3.c index 62a6cab330..c764a5a442 100644 --- a/stdio-common/bug3.c +++ b/stdio-common/bug3.c @@ -32,7 +32,11 @@ main (void) char buf[25]; buf[0] = j; - fread (buf + 1, 1, 23, f); + if (fread (buf + 1, 1, 23, f) < 23) + { + printf ("%s\nTest FAILED!\n", buf); + return 1; + } buf[24] = '\0'; if (strcmp (buf, "Where does this text go?") != 0) { diff --git a/stdio-common/bug4.c b/stdio-common/bug4.c index cf7fe116eb..d587dfcfd4 100644 --- a/stdio-common/bug4.c +++ b/stdio-common/bug4.c @@ -30,7 +30,11 @@ main (int argc, char *argv[]) fseek (f, 8180L, 0); fwrite ("Where does this text come from?", 1, 31, f); fseek (f, 8180L, 0); - fread (buffer, 1, 31, f); + if (fread (buffer, 1, 31, f) < 31) + { + puts ("\nTest FAILED!"); + return 1; + } fwrite (buffer, 1, 31, stdout); fclose (f); remove (filename); diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c index 7bfe9b2b8d..e6ee6ceb41 100644 --- a/stdio-common/bug5.c +++ b/stdio-common/bug5.c @@ -60,7 +60,11 @@ main (void) the perhaps incompatible new shared libraries. */ unsetenv ("LD_LIBRARY_PATH"); - asprintf (&printbuf, "cmp %s %s", inname, outname); + if (asprintf (&printbuf, "cmp %s %s", inname, outname) < 0) + { + perror ("asprintf"); + return 1; + } result = system (printbuf); remove (inname); remove (outname); 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/test-fwrite.c b/stdio-common/test-fwrite.c index 5677c6da80..3f39f3fd8b 100644 --- a/stdio-common/test-fwrite.c +++ b/stdio-common/test-fwrite.c @@ -57,11 +57,15 @@ do_test (void) return 1; } - asprintf (&line, "\ + if (asprintf (&line, "\ GDB is free software and you are welcome to distribute copies of it\n\ under certain conditions; type \"show copying\" to see the conditions.\n\ There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\ -"); +") < 0) + { + perror ("asprintf"); + return 1; + } puts ("Test succeeded."); return 0; diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c index 7825ca9358..9d7834c852 100644 --- a/stdio-common/test_rdwr.c +++ b/stdio-common/test_rdwr.c @@ -49,7 +49,8 @@ main (int argc, char **argv) (void) fputs (hello, f); rewind (f); - (void) fgets (buf, sizeof (buf), f); + if (!fgets (buf, sizeof (buf), f) && ferror (f)) + lose = 1; rewind (f); (void) fputs (buf, f); rewind (f); diff --git a/stdio-common/tst-cookie.c b/stdio-common/tst-cookie.c index 030e684562..76df5b4d13 100644 --- a/stdio-common/tst-cookie.c +++ b/stdio-common/tst-cookie.c @@ -77,7 +77,9 @@ do_test (void) f = fopencookie (THE_COOKIE, "r+", fcts); - fread (buf, 1, 1, f); + if (fread (buf, 1, 1, f) < 1) + ++errors; + fwrite (buf, 1, 1, f); fseek (f, 0, SEEK_CUR); fclose (f); diff --git a/stdio-common/tst-fmemopen3.c b/stdio-common/tst-fmemopen3.c index 3cc2832edc..971d0bcf5e 100644 --- a/stdio-common/tst-fmemopen3.c +++ b/stdio-common/tst-fmemopen3.c @@ -153,7 +153,11 @@ do_test_read_seek_neg (const char *mode, const char *expected) FILE *fp = fmemopen (buf, sizeof (buf), mode); fseek (fp, offset, SEEK_END); - fread (tmp, tmps, 1, fp); + if (fread (tmp, tmps, 1, fp) < 1) + { + printf ("fread failed"); + return 1; + } if (memcmp (tmp, expected, tmps) != 0) { diff --git a/stdio-common/tst-fseek.c b/stdio-common/tst-fseek.c index c4ac17cdf4..bacc390c27 100644 --- a/stdio-common/tst-fseek.c +++ b/stdio-common/tst-fseek.c @@ -44,8 +44,7 @@ do_test (void) if (tmpdir == NULL || tmpdir[0] == '\0') tmpdir = "/tmp"; - asprintf (&fname, "%s/tst-fseek.XXXXXX", tmpdir); - if (fname == NULL) + if (asprintf (&fname, "%s/tst-fseek.XXXXXX", tmpdir) < 0 || fname == NULL) error (EXIT_FAILURE, errno, "cannot generate name for temporary file"); /* Create a temporary file. */ diff --git a/stdio-common/tst-perror.c b/stdio-common/tst-perror.c index 57835e0c59..af0bbc261a 100644 --- a/stdio-common/tst-perror.c +++ b/stdio-common/tst-perror.c @@ -94,7 +94,11 @@ do_test (void) puts ("multibyte test succeeded"); lseek (fd, 0, SEEK_SET); - ftruncate (fd, 0); + if (ftruncate (fd, 0) < 0) + { + printf ("cannot truncate file descriptor: %m\n"); + exit (EXIT_FAILURE); + } if (dup2 (fd, 2) == -1) { 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 4edee73dd8..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))) + { + 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) @@ -154,7 +161,12 @@ do_test (int argc, char ** argv) } for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i) - symlink (symlinks[i].value, symlinks[i].name); + if (symlink (symlinks[i].value, symlinks[i].name)) + { + printf ("%s: Unable to create symlink for %s -> %s\n", + argv[0], symlinks[i].name, symlinks[i].value); + ++errors; + } int has_dir = mkdir ("doesExist", 0777) == 0; @@ -205,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 e68f16eecf..f8d808f331 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"); @@ -1186,7 +1186,7 @@ main (int argc, char **argv) int status; /* Send the child's "outside" pid to it. */ - write (pipes[1], &child, sizeof(child)); + xwrite (pipes[1], &child, sizeof(child)); close (pipes[0]); close (pipes[1]); @@ -1217,7 +1217,9 @@ main (int argc, char **argv) /* Get our "outside" pid from our parent. We use this to help with debugging from outside the container. */ - read (pipes[0], &child, sizeof(child)); + if (read (pipes[0], &child, sizeof(child)) < sizeof(child)) + FAIL_EXIT1 ("Unable to read PID"); + close (pipes[0]); close (pipes[1]); sprintf (pid_buf, "%lu", (long unsigned)child); @@ -1255,7 +1257,8 @@ main (int argc, char **argv) sprintf (tmp, "%lld %lld 1\n", (long long) (be_su ? 0 : original_uid), (long long) original_uid); - write (UMAP, tmp, strlen (tmp)); + xwrite (UMAP, tmp, strlen (tmp)); + xclose (UMAP); /* We must disable setgroups () before we can map our groups, else we @@ -1264,7 +1267,7 @@ main (int argc, char **argv) if (GMAP >= 0) { /* We support kernels old enough to not have this. */ - write (GMAP, "deny\n", 5); + xwrite (GMAP, "deny\n", 5); xclose (GMAP); } @@ -1276,7 +1279,8 @@ main (int argc, char **argv) sprintf (tmp, "%lld %lld 1\n", (long long) (be_su ? 0 : original_gid), (long long) original_gid); - write (GMAP, tmp, strlen (tmp)); + xwrite (GMAP, tmp, strlen (tmp)); + xclose (GMAP); } diff --git a/sysdeps/pthread/tst-cancel11.c b/sysdeps/pthread/tst-cancel11.c index 4dd84d6673..4e577f97ad 100644 --- a/sysdeps/pthread/tst-cancel11.c +++ b/sysdeps/pthread/tst-cancel11.c @@ -56,7 +56,11 @@ tf (void *arg) /* This call should block and be cancelable. */ char buf[20]; - read (fd[0], buf, sizeof (buf)); + if (read (fd[0], buf, sizeof (buf)) < sizeof (buf)) + { + puts ("tf: read failed"); + exit (1); + } pthread_cleanup_pop (0); 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-cancel20.c b/sysdeps/pthread/tst-cancel20.c index 1d5c53049b..93f287aa4f 100644 --- a/sysdeps/pthread/tst-cancel20.c +++ b/sysdeps/pthread/tst-cancel20.c @@ -84,8 +84,6 @@ tf_body (void) exit (1); } - read (fd[0], &c, 1); - pthread_cleanup_pop (0); } diff --git a/sysdeps/pthread/tst-cancel21.c b/sysdeps/pthread/tst-cancel21.c index bc4ff308f9..ec8bf0dba3 100644 --- a/sysdeps/pthread/tst-cancel21.c +++ b/sysdeps/pthread/tst-cancel21.c @@ -85,8 +85,6 @@ tf_body (void) exit (1); } - read (fd[0], &c, 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); diff --git a/sysdeps/pthread/tst-cancel6.c b/sysdeps/pthread/tst-cancel6.c index 63e6d49707..11a16cd564 100644 --- a/sysdeps/pthread/tst-cancel6.c +++ b/sysdeps/pthread/tst-cancel6.c @@ -25,7 +25,8 @@ static void * tf (void *arg) { char buf[100]; - fgets (buf, sizeof (buf), arg); + if (!fgets (buf, sizeof (buf), arg)) + puts ("fgets failed"); /* This call should never return. */ return NULL; } diff --git a/sysdeps/pthread/tst-cond18.c b/sysdeps/pthread/tst-cond18.c index edac4fa4ff..ceeecbd70c 100644 --- a/sysdeps/pthread/tst-cond18.c +++ b/sysdeps/pthread/tst-cond18.c @@ -40,7 +40,7 @@ tf (void *id) while (!exiting) { if ((spins++ % 1000) == 0) - write (fd, ".", 1); + if(write (fd, ".", 1)) {} pthread_mutex_unlock (&lock); pthread_mutex_lock (&lock); diff --git a/sysdeps/pthread/tst-fini1mod.c b/sysdeps/pthread/tst-fini1mod.c index cdadf034cd..cee1e3838b 100644 --- a/sysdeps/pthread/tst-fini1mod.c +++ b/sysdeps/pthread/tst-fini1mod.c @@ -32,7 +32,11 @@ tf (void *arg) } char buf[10]; - read (fds[0], buf, sizeof (buf)); + if (read (fds[0], buf, sizeof (buf)) < sizeof (buf)) + { + puts ("can't read enough"); + exit (1); + } puts ("read returned"); exit (1); diff --git a/sysdeps/pthread/tst-flock1.c b/sysdeps/pthread/tst-flock1.c index 7eef9070ab..660f3f1e3e 100644 --- a/sysdeps/pthread/tst-flock1.c +++ b/sysdeps/pthread/tst-flock1.c @@ -56,7 +56,11 @@ do_test (void) unlink (tmp); - write (fd, "foobar xyzzy", 12); + if (write (fd, "foobar xyzzy", 12) < 12) + { + puts ("write failed"); + exit (1); + } if (flock (fd, LOCK_EX | LOCK_NB) != 0) { diff --git a/sysdeps/pthread/tst-flock2.c b/sysdeps/pthread/tst-flock2.c index 8762e93b52..122ffe296f 100644 --- a/sysdeps/pthread/tst-flock2.c +++ b/sysdeps/pthread/tst-flock2.c @@ -70,7 +70,11 @@ do_test (void) int i; for (i = 0; i < 20; ++i) - write (fd, "foobar xyzzy", 12); + if (write (fd, "foobar xyzzy", 12) < 12) + { + puts ("write failed"); + return 1; + } pthread_barrier_t *b; b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE, diff --git a/sysdeps/pthread/tst-key1.c b/sysdeps/pthread/tst-key1.c index 933edafef8..f9560a9bf5 100644 --- a/sysdeps/pthread/tst-key1.c +++ b/sysdeps/pthread/tst-key1.c @@ -51,7 +51,7 @@ do_test (void) if (pthread_setspecific (keys[i], (const void *) (i + 100l)) != 0) { - write (2, "setspecific failed\n", 19); + if (write (2, "setspecific failed\n", 19)) {}; _exit (1); } } @@ -60,13 +60,13 @@ do_test (void) { if (pthread_getspecific (keys[i]) != (void *) (i + 100l)) { - write (2, "getspecific failed\n", 19); + if (write (2, "getspecific failed\n", 19)) {}; _exit (1); } if (pthread_key_delete (keys[i]) != 0) { - write (2, "key_delete failed\n", 18); + if (write (2, "key_delete failed\n", 18)) {}; _exit (1); } } @@ -74,13 +74,13 @@ do_test (void) /* Now it must be once again possible to allocate keys. */ if (pthread_key_create (&keys[0], NULL) != 0) { - write (2, "2nd key_create failed\n", 22); + if (write (2, "2nd key_create failed\n", 22)) {}; _exit (1); } if (pthread_key_delete (keys[0]) != 0) { - write (2, "2nd key_delete failed\n", 22); + if (write (2, "2nd key_delete failed\n", 22)) {}; _exit (1); } diff --git a/sysdeps/pthread/tst-signal1.c b/sysdeps/pthread/tst-signal1.c index d1073e8459..7459e30031 100644 --- a/sysdeps/pthread/tst-signal1.c +++ b/sysdeps/pthread/tst-signal1.c @@ -105,7 +105,11 @@ do_test (void) int i; for (i = 0; i < 20; ++i) - write (fd, "foobar xyzzy", 12); + if (write (fd, "foobar xyzzy", 12) < 0) + { + puts ("write failed"); + exit (1); + } b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); diff --git a/sysdeps/pthread/tst-signal2.c b/sysdeps/pthread/tst-signal2.c index dfe7d9f64a..34c5fda7e5 100644 --- a/sysdeps/pthread/tst-signal2.c +++ b/sysdeps/pthread/tst-signal2.c @@ -111,7 +111,11 @@ do_test (void) int i; for (i = 0; i < 20; ++i) - write (fd, "foobar xyzzy", 12); + if (write (fd, "foobar xyzzy", 12) < 0) + { + puts ("write failed"); + exit (1); + } b = mmap (NULL, sizeof (pthread_barrier_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); diff --git a/sysdeps/pthread/tst-timer.c b/sysdeps/pthread/tst-timer.c index 47472ab8e1..0363a13ab2 100644 --- a/sysdeps/pthread/tst-timer.c +++ b/sysdeps/pthread/tst-timer.c @@ -44,7 +44,7 @@ signal_func (int sig) { static const char text[] = "signal_func\n"; signal (sig, signal_func); - write (STDOUT_FILENO, text, sizeof text - 1); + if (write (STDOUT_FILENO, text, sizeof text - 1)) {}; } static void diff --git a/time/tst-cpuclock1.c b/time/tst-cpuclock1.c index 6f2e70a58a..1fb22329e4 100644 --- a/time/tst-cpuclock1.c +++ b/time/tst-cpuclock1.c @@ -41,7 +41,7 @@ chew_cpu (void) for (int i = 0; i < 100; ++i) for (size_t j = 0; j < sizeof buf; ++j) buf[j] = 0xbb; - write (nullfd, (char *) buf, sizeof buf); + if (write (nullfd, (char *) buf, sizeof buf)) {} close (nullfd); if (getppid () == 1) _exit (2); From patchwork Tue Apr 18 12:11:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1770123 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=d4QAPjcp; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12rY0yxcz1ybC for ; Tue, 18 Apr 2023 22:13:33 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 1A62D3853544 for ; Tue, 18 Apr 2023 12:13:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1A62D3853544 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681820011; bh=+9pUyKP9jLTJeTKlvEP1ndW/S/fJ/gcBB+b0nKOxiXI=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=d4QAPjcpTi6810sB19t1IKE91NpMefqIKVwH9Dau/qFjkcqw05YvmS7IBU4CNV9D/ 3FOphdAHtBs9aDhkeJ//4twu/RpZu1B7GKABNiGqqV06paeWrHA07OhDGsIn4brps+ xC8PXtyNz1FKtrI9ZFKwwYda7nHKTL+SOPgTEhvg= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 0C9DA385783F for ; Tue, 18 Apr 2023 12:11:40 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 0C9DA385783F Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-319-3XPBSqe7N5C7KAiEq2l-Bw-1; Tue, 18 Apr 2023 08:11:38 -0400 X-MC-Unique: 3XPBSqe7N5C7KAiEq2l-Bw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2D36C185A78F for ; Tue, 18 Apr 2023 12:11:38 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A42D240C83A9; Tue, 18 Apr 2023 12:11:37 +0000 (UTC) To: libc-alpha@sourceware.org Cc: sipoyare@redhat.com Subject: [PATCH 2/8] catgets/gencat.c: fix warn unused result Date: Tue, 18 Apr 2023 14:11:24 +0200 Message-Id: <20230418121130.844302-3-fberat@redhat.com> In-Reply-To: <20230418121130.844302-1-fberat@redhat.com> References: <20230418121130.844302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. --- catgets/gencat.c | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/catgets/gencat.c b/catgets/gencat.c index 61ac797349..ecfdaa6e6d 100644 --- a/catgets/gencat.c +++ b/catgets/gencat.c @@ -852,6 +852,7 @@ write_out (struct catalog *catalog, const char *output_name, const char *strings; size_t strings_size; uint32_t *array1, *array2; + uint32_t array_size; size_t cnt; int fd; @@ -927,12 +928,11 @@ write_out (struct catalog *catalog, const char *output_name, obj.plane_size = best_size; obj.plane_depth = best_depth; + array_size = best_size * best_depth * sizeof (uint32_t) * 3; /* Allocate room for all needed arrays. */ - array1 = - (uint32_t *) alloca (best_size * best_depth * sizeof (uint32_t) * 3); - memset (array1, '\0', best_size * best_depth * sizeof (uint32_t) * 3); - array2 - = (uint32_t *) alloca (best_size * best_depth * sizeof (uint32_t) * 3); + array1 = (uint32_t *) alloca (array_size); + memset (array1, '\0', array_size); + array2 = (uint32_t *) alloca (array_size); obstack_init (&string_pool); set_run = catalog->all_sets; @@ -985,22 +985,34 @@ write_out (struct catalog *catalog, const char *output_name, } /* Write out header. */ - write (fd, &obj, sizeof (obj)); + if (write (fd, &obj, sizeof (obj)) < sizeof (obj)) + error (EXIT_FAILURE, errno, + gettext ("cannot write enough bytes to `%s'"), output_name); /* We always write out the little endian version of the index arrays. */ #if __BYTE_ORDER == __LITTLE_ENDIAN - write (fd, array1, best_size * best_depth * sizeof (uint32_t) * 3); - write (fd, array2, best_size * best_depth * sizeof (uint32_t) * 3); + if (write (fd, array1, array_size) < array_size) + error (EXIT_FAILURE, errno, + gettext ("cannot write enough bytes to `%s'"), output_name); + if (write (fd, array2, array_size) < array_size) + error (EXIT_FAILURE, errno, + gettext ("cannot write enough bytes to `%s'"), output_name); #elif __BYTE_ORDER == __BIG_ENDIAN - write (fd, array2, best_size * best_depth * sizeof (uint32_t) * 3); - write (fd, array1, best_size * best_depth * sizeof (uint32_t) * 3); + if (write (fd, array2, array_size) < array_size) + error (EXIT_FAILURE, errno, + gettext ("cannot write enough bytes to `%s'"), output_name); + if (write (fd, array1, array_size) < array_size) + error (EXIT_FAILURE, errno, + gettext ("cannot write enough bytes to `%s'"), output_name); #else # error Cannot handle __BYTE_ORDER byte order #endif /* Finally write the strings. */ - write (fd, strings, strings_size); + if (write (fd, strings, strings_size) < strings_size) + error (EXIT_FAILURE, errno, + gettext ("cannot write enough bytes to `%s'"), output_name); if (fd != STDOUT_FILENO) close (fd); From patchwork Tue Apr 18 12:11:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1770115 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Vf7HHKLD; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12px1SbBz1ybC for ; Tue, 18 Apr 2023 22:12:09 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 257153856951 for ; Tue, 18 Apr 2023 12:12:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 257153856951 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681819927; bh=ZDldsk2nxwLvn8lWOJgpooQJTD/vA1+mhXmF/oZPFgI=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Vf7HHKLDbCwodCY+QVvSBoHJr0l2EjEKobXJ0alk5fpVYxAdJZS9ceDdxITNpUnYq BqmaGOmw3FgbBISTu8EeRB22QElEPqud62Km3XPhbPmY9GFu1kNeuaXp6jtR+ATkmE 8SmZ3wIrkn/uBLFtIKaG3UQQYcSd8pCIaQ5+1SDU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A851438582BD for ; Tue, 18 Apr 2023 12:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A851438582BD Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-220-Aoq8bYGTMfSBGEDNzFgnlA-1; Tue, 18 Apr 2023 08:11:39 -0400 X-MC-Unique: Aoq8bYGTMfSBGEDNzFgnlA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E4AFE88F9E0 for ; Tue, 18 Apr 2023 12:11:38 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 676DB40C83A9; Tue, 18 Apr 2023 12:11:38 +0000 (UTC) To: libc-alpha@sourceware.org Cc: sipoyare@redhat.com Subject: [PATCH 3/8] inet/rcmd.c: fix warn unused result Date: Tue, 18 Apr 2023 14:11:25 +0200 Message-Id: <20230418121130.844302-4-fberat@redhat.com> In-Reply-To: <20230418121130.844302-1-fberat@redhat.com> References: <20230418121130.844302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. Reviewed-by: Siddhesh Poyarekar --- inet/rcmd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/inet/rcmd.c b/inet/rcmd.c index ad8a894907..c1cd9daeb5 100644 --- a/inet/rcmd.c +++ b/inet/rcmd.c @@ -561,7 +561,9 @@ ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser, reading an NFS mounted file system, can't read files that are protected read/write owner only. */ uid = __geteuid (); - seteuid (pwd->pw_uid); + if (seteuid (pwd->pw_uid) < 0) + return -1; + hostf = iruserfopen (pbuf, pwd->pw_uid); if (hostf != NULL) @@ -570,7 +572,8 @@ ruserok2_sa (struct sockaddr *ra, size_t ralen, int superuser, fclose (hostf); } - seteuid (uid); + if (seteuid (uid) < 0) + return -1; return isbad; } return -1; From patchwork Tue Apr 18 12:11:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1770117 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=Ls+EZ/yL; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12q73cDgz23tV for ; Tue, 18 Apr 2023 22:12:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6F77A3856DD2 for ; Tue, 18 Apr 2023 12:12:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6F77A3856DD2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681819937; bh=KbZVxBsqXl3SRQ77Z2a3Uw9w91zJRaAqg8w7wEt37BU=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=Ls+EZ/yLgKMdSV62QQp61Quu2yctQFZpM+a4nZ+vUEgVc5DcVAYsbP4SY5bOu2rhs 6pEyyQe4MAKR/ZKTurA+XWFo+tkKila0b9lC9imNHPopPLR4a09StPgmXgsT6d5YyA iqXO+PKPxg/6OOVG6icOc4PD/guapN6e09Tt32Lk= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 508D23857706 for ; Tue, 18 Apr 2023 12:11:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 508D23857706 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-250-KEJuMRUoOVe_OrSMi-5Vew-1; Tue, 18 Apr 2023 08:11:39 -0400 X-MC-Unique: KEJuMRUoOVe_OrSMi-5Vew-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A7506101A550 for ; Tue, 18 Apr 2023 12:11:39 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2C97340C845F; Tue, 18 Apr 2023 12:11:39 +0000 (UTC) To: libc-alpha@sourceware.org Cc: sipoyare@redhat.com Subject: [PATCH 4/8] locale/programs/locarchive.c: fix warn unused result Date: Tue, 18 Apr 2023 14:11:26 +0200 Message-Id: <20230418121130.844302-5-fberat@redhat.com> In-Reply-To: <20230418121130.844302-1-fberat@redhat.com> References: <20230418121130.844302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. --- locale/programs/locarchive.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/locale/programs/locarchive.c b/locale/programs/locarchive.c index 87d2d9b1b2..4e13bb9ce9 100644 --- a/locale/programs/locarchive.c +++ b/locale/programs/locarchive.c @@ -1154,10 +1154,11 @@ add_locale_to_archive (struct locarhandle *ah, const char *name, if (mask & XPG_NORM_CODESET) /* This name contains a codeset in unnormalized form. We will store it in the archive with a normalized name. */ - asprintf (&normalized_name, "%s%s%s.%s%s%s", - language, territory == NULL ? "" : "_", territory ?: "", - (mask & XPG_NORM_CODESET) ? normalized_codeset : codeset, - modifier == NULL ? "" : "@", modifier ?: ""); + if (asprintf (&normalized_name, "%s%s%s.%s%s%s", + language, territory == NULL ? "" : "_", territory ?: "", + (mask & XPG_NORM_CODESET) ? normalized_codeset : codeset, + modifier == NULL ? "" : "@", modifier ?: "") < 0) + return -1; /* This call does the main work. */ locrec_offset = add_locale (ah, normalized_name ?: name, data, replace); @@ -1188,10 +1189,11 @@ add_locale_to_archive (struct locarhandle *ah, const char *name, normalized_codeset = _nl_normalize_codeset (codeset, strlen (codeset)); mask |= XPG_NORM_CODESET; - asprintf (&normalized_codeset_name, "%s%s%s.%s%s%s", - language, territory == NULL ? "" : "_", territory ?: "", - normalized_codeset, - modifier == NULL ? "" : "@", modifier ?: ""); + if (asprintf (&normalized_codeset_name, "%s%s%s.%s%s%s", + language, territory == NULL ? "" : "_", territory ?: "", + normalized_codeset, + modifier == NULL ? "" : "@", modifier ?: "") < 0) + return -1; add_alias (ah, normalized_codeset_name, replace, normalized_name ?: name, &locrec_offset); From patchwork Tue Apr 18 12:11:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1770119 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=GU9Ogf8h; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12qS61jbz1ybC for ; Tue, 18 Apr 2023 22:12:36 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 066BF38560A4 for ; Tue, 18 Apr 2023 12:12:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 066BF38560A4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681819954; bh=JxM/zCv3gyTQ9UppeXT7zaUQgDX2Tuvio7fe7wUydzc=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=GU9Ogf8hwqtY8uR5WfKbfaVA4RlUCq0JKRni+kfD9mQ1yuhZfQqfTSm2TdECw/eRn UqOACi+aaJ21jMok2n2r0QED4TJCqi/tRoduURVvA3VJWz8UIxl1V7nzQLI+zztAyB 2zxDNK6wzeJTGkcaYcGD63Ry4aUD96N5DBxx2SzI= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id A63393858C2D for ; Tue, 18 Apr 2023 12:11:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A63393858C2D Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-656-gJNoVACkMNesB6YK7ZEwhw-1; Tue, 18 Apr 2023 08:11:40 -0400 X-MC-Unique: gJNoVACkMNesB6YK7ZEwhw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6B87329DD991 for ; Tue, 18 Apr 2023 12:11:40 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E2D1340C83A9; Tue, 18 Apr 2023 12:11:39 +0000 (UTC) To: libc-alpha@sourceware.org Cc: sipoyare@redhat.com Subject: [PATCH 5/8] malloc/{memusage.c, memusagestat.c}: fix warn unused result Date: Tue, 18 Apr 2023 14:11:27 +0200 Message-Id: <20230418121130.844302-6-fberat@redhat.com> In-Reply-To: <20230418121130.844302-1-fberat@redhat.com> References: <20230418121130.844302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. --- malloc/memusage.c | 38 ++++++++++++++++++++++++++------------ malloc/memusagestat.c | 13 +++++++++---- 2 files changed, 35 insertions(+), 16 deletions(-) diff --git a/malloc/memusage.c b/malloc/memusage.c index 2a3a508557..6251e039b0 100644 --- a/malloc/memusage.c +++ b/malloc/memusage.c @@ -18,6 +18,8 @@ #include #include +#include +#include #include #include #include @@ -210,10 +212,12 @@ update_data (struct header *result, size_t len, size_t old_len) gettime (&buffer[idx]); /* Write out buffer if it is full. */ - if (idx + 1 == buffer_size) - write (fd, buffer, buffer_size * sizeof (struct entry)); - else if (idx + 1 == 2 * buffer_size) - write (fd, &buffer[buffer_size], buffer_size * sizeof (struct entry)); + if (idx + 1 == buffer_size || idx + 1 == 2 * buffer_size) + { + uint32_t write_size = buffer_size * sizeof (buffer[0]); + if (write (fd, &buffer[idx + 1 - buffer_size], write_size) < write_size) + error(EXIT_FAILURE, errno, "cannot write buffer"); + } } } @@ -299,8 +303,10 @@ me (void) first.stack = 0; gettime (&first); /* Write it two times since we need the starting and end time. */ - write (fd, &first, sizeof (first)); - write (fd, &first, sizeof (first)); + if (write (fd, &first, sizeof (first)) < sizeof (first)) + error(EXIT_FAILURE, errno, "cannot write entry"); + if (write (fd, &first, sizeof (first)) < sizeof (first)) + error(EXIT_FAILURE, errno, "cannot write entry"); /* Determine the buffer size. We use the default if the environment variable is not present. */ @@ -850,24 +856,32 @@ dest (void) if (fd != -1) { /* Write the partially filled buffer. */ + struct entry *start = buffer; + uint32_t write_cnt = buffer_cnt; + if (buffer_cnt > buffer_size) - write (fd, buffer + buffer_size, - (buffer_cnt - buffer_size) * sizeof (struct entry)); - else - write (fd, buffer, buffer_cnt * sizeof (struct entry)); + { + start = buffer + buffer_size; + write_cnt = buffer_cnt - buffer_size; + } + + if (write(fd, start, write_cnt * sizeof (buffer[0])) < sizeof (buffer[0])) + error(EXIT_FAILURE, errno, "cannot write buffer"); /* Go back to the beginning of the file. We allocated two records here when we opened the file. */ lseek (fd, 0, SEEK_SET); /* Write out a record containing the total size. */ first.stack = peak_total; - write (fd, &first, sizeof (struct entry)); + if (write (fd, &first, sizeof (first)) < sizeof (first)) + error(EXIT_FAILURE, errno, "cannot write first"); /* Write out another record containing the maximum for heap and stack. */ first.heap = peak_heap; first.stack = peak_stack; gettime (&first); - write (fd, &first, sizeof (struct entry)); + if (write (fd, &first, sizeof (first)) < sizeof (first)) + error(EXIT_FAILURE, errno, "cannot write first"); /* Close the file. */ close (fd); diff --git a/malloc/memusagestat.c b/malloc/memusagestat.c index 67c5131f79..3853f00b9b 100644 --- a/malloc/memusagestat.c +++ b/malloc/memusagestat.c @@ -188,7 +188,8 @@ main (int argc, char *argv[]) total = st.st_size / sizeof (struct entry) - 2; /* Read the administrative information. */ - read (fd, headent, sizeof (headent)); + if (read (fd, headent, sizeof (headent)) < sizeof (headent)) + error(EXIT_FAILURE, errno, "cannot read entry header"); maxsize_heap = headent[1].heap; maxsize_stack = headent[1].stack; maxsize_total = headent[0].stack; @@ -220,7 +221,9 @@ main (int argc, char *argv[]) /* Write the computed values in the file. */ lseek (fd, 0, SEEK_SET); - write (fd, headent, 2 * sizeof (struct entry)); + if (write (fd, headent, sizeof (headent)) < sizeof (headent)) + error(EXIT_FAILURE, errno, "cannot write entries"); + } if (also_total) @@ -372,7 +375,8 @@ main (int argc, char *argv[]) size_t new[2]; uint64_t now; - read (fd, &entry, sizeof (entry)); + if (read (fd, &entry, sizeof (entry)) < sizeof (entry)) + error(EXIT_FAILURE, errno, "cannot read entry"); now = ((uint64_t) entry.time_high) << 32 | entry.time_low; @@ -455,7 +459,8 @@ main (int argc, char *argv[]) size_t xpos; uint64_t now; - read (fd, &entry, sizeof (entry)); + if (read (fd, &entry, sizeof (entry)) < sizeof (entry)) + error(EXIT_FAILURE, errno, "cannot read entry"); now = ((uint64_t) entry.time_high) << 32 | entry.time_low; xpos = 40 + ((xsize - 80) * (now - start_time)) / total_time; From patchwork Tue Apr 18 12:11:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1770125 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=pYtBIy5y; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12sP2RGMz1ybC for ; Tue, 18 Apr 2023 22:14:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 38A153851C1B for ; Tue, 18 Apr 2023 12:14:15 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 38A153851C1B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681820055; bh=QE9BoKlNnPC3sE1N3j2SI7VCQUXts5JCnefYYdk9pjw=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=pYtBIy5yFQsE38tUgAv5csxIJw4XS5x9fde1B8ZFH7JAIKJBYt0KCtFBlROy34AZM ZAoDlOo/IjXCTLUpSxANUCgrBDCLyG81EEpOJE0anofAYK38L9z7GfxI5Fype5V8IY 5GWVTA9OV3JVGQev2f3KCdNrNFYOtRev8yco4BFU= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id EF7D63857728 for ; Tue, 18 Apr 2023 12:11:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EF7D63857728 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-643-ivwFr8dkN7SkoVZmhsZHRg-1; Tue, 18 Apr 2023 08:11:41 -0400 X-MC-Unique: ivwFr8dkN7SkoVZmhsZHRg-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2F65138173CA for ; Tue, 18 Apr 2023 12:11:41 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A75A540C84A1; Tue, 18 Apr 2023 12:11:40 +0000 (UTC) To: libc-alpha@sourceware.org Cc: sipoyare@redhat.com Subject: [PATCH 6/8] nptl_db/thread_dbP.h: fix warn unused result Date: Tue, 18 Apr 2023 14:11:28 +0200 Message-Id: <20230418121130.844302-7-fberat@redhat.com> In-Reply-To: <20230418121130.844302-1-fberat@redhat.com> References: <20230418121130.844302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. Reviewed-by: Siddhesh Poyarekar --- nptl_db/thread_dbP.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nptl_db/thread_dbP.h b/nptl_db/thread_dbP.h index 8845722109..ad0c197f6f 100644 --- a/nptl_db/thread_dbP.h +++ b/nptl_db/thread_dbP.h @@ -61,7 +61,7 @@ enum /* Comment out the following for less verbose output. */ #ifndef NDEBUG -# define LOG(c) if (__td_debug) write (2, c "\n", strlen (c "\n")) +# define LOG(c) if (__td_debug) assert(write (2, c "\n", strlen (c "\n")) == strlen (c "\n")) extern int __td_debug attribute_hidden; #else # define LOG(c) From patchwork Tue Apr 18 12:11:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1770124 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=HDXVD/9a; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12rj1rSXz23tD for ; Tue, 18 Apr 2023 22:13:41 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3778B385B526 for ; Tue, 18 Apr 2023 12:13:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3778B385B526 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681820019; bh=Cmn/ZAj78D1fA3H5Z0aILuqgNpJzLtOiGeGgZq3nHL8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=HDXVD/9ayupAhTQ3dsfmSieKmcpXHHr8Y7jGFW+YO1xYyeRFvxtkcl9x5zbtgjYZx 6YULAG6+H/B8QDdKU6wsfL1d8N7zmcV5tPKGIPV+zFhLgstX4NK7KYeZ8pB70BQezD g2Uxd/2ATuOXm6YM3aLy9TqzwGErFQdF9F39arjo= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id EAC7D3857712 for ; Tue, 18 Apr 2023 12:11:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EAC7D3857712 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-622-YpYRVjHJNoOsQEG8WCX8Ww-1; Tue, 18 Apr 2023 08:11:42 -0400 X-MC-Unique: YpYRVjHJNoOsQEG8WCX8Ww-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E615B29DD99C for ; Tue, 18 Apr 2023 12:11:41 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6ACD940C83A9; Tue, 18 Apr 2023 12:11:41 +0000 (UTC) To: libc-alpha@sourceware.org Cc: sipoyare@redhat.com Subject: [PATCH 7/8] sunrpc/netname.c: fix warn unused result Date: Tue, 18 Apr 2023 14:11:29 +0200 Message-Id: <20230418121130.844302-8-fberat@redhat.com> In-Reply-To: <20230418121130.844302-1-fberat@redhat.com> References: <20230418121130.844302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. --- sunrpc/netname.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sunrpc/netname.c b/sunrpc/netname.c index dd2cb1b441..949954959a 100644 --- a/sunrpc/netname.c +++ b/sunrpc/netname.c @@ -96,7 +96,8 @@ host2netname (char netname[MAXNETNAMELEN + 1], const char *host, else { domainname[0] = 0; - getdomainname (domainname, MAXHOSTNAMELEN); + if(getdomainname (domainname, MAXHOSTNAMELEN)) + return 0; } } else From patchwork Tue Apr 18 12:11:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 1770122 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=sourceware.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=ewFYH7EE; dkim-atps=neutral Received: from sourceware.org (ip-8-43-85-97.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Q12r4306Zz1ybC for ; Tue, 18 Apr 2023 22:13:08 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 608D83850874 for ; Tue, 18 Apr 2023 12:13:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 608D83850874 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681819986; bh=4d/aZ2f+P/Rd8Qc39YCCjZ89aK5ysacUEmS0NV+tb4I=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=ewFYH7EEovlmvmnYKcV9CKQmwPdge5sAKWW1j3E0g6J3NGreWyTeuxHYoMRtbVzcc jicG/c0e6lZG2VBWvw9qXI4q+3f17fI/IWKdGlx95l761OEc+hPIbedIKCHijMN92u OAILbBRJaouE7aZeW5r/aQPxpSVxivKY5TJFjrkE= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 995583857716 for ; Tue, 18 Apr 2023 12:11:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 995583857716 Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-553-8rkC9W7IN-K6bkzaHtm7-Q-1; Tue, 18 Apr 2023 08:11:44 -0400 X-MC-Unique: 8rkC9W7IN-K6bkzaHtm7-Q-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 120A28996E0 for ; Tue, 18 Apr 2023 12:11:43 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.127]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DAE840C20FA; Tue, 18 Apr 2023 12:11:42 +0000 (UTC) To: libc-alpha@sourceware.org Cc: sipoyare@redhat.com Subject: [PATCH 8/8] sysdeps/pthread/eintr.c: fix warn unused result Date: Tue, 18 Apr 2023 14:11:30 +0200 Message-Id: <20230418121130.844302-9-fberat@redhat.com> In-Reply-To: <20230418121130.844302-1-fberat@redhat.com> References: <20230418121130.844302-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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 X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: =?utf-8?q?Fr=C3=A9d=C3=A9ric_B=C3=A9rat_via_Libc-alpha?= From: Frederic Berat Reply-To: =?utf-8?b?RnLDqWTDqXJpYyBCw6lyYXQ=?= Errors-To: libc-alpha-bounces+incoming=patchwork.ozlabs.org@sourceware.org Sender: "Libc-alpha" Fix unused result warnings, detected when _FORTIFY_SOURCE is enabled in glibc. --- sysdeps/pthread/eintr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sysdeps/pthread/eintr.c b/sysdeps/pthread/eintr.c index 000649d24e..8441df0c77 100644 --- a/sysdeps/pthread/eintr.c +++ b/sysdeps/pthread/eintr.c @@ -31,10 +31,10 @@ eintr_handler (int sig) { if (sig != the_sig) { - write (STDOUT_FILENO, "eintr_handler: signal number wrong\n", 35); + if (write (STDOUT_FILENO, "eintr_handler: signal number wrong\n", 35)) {}; _exit (1); } - write (STDOUT_FILENO, ".", 1); + if (write (STDOUT_FILENO, ".", 1)) {}; }