From patchwork Fri Apr 28 12:21:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 68480 X-Patchwork-Delegate: siddhesh@gotplt.org Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5DE29387090C for ; Fri, 28 Apr 2023 12:38:17 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5DE29387090C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1682685497; bh=nCZxT1bIS1P4gooR/RKEUAg07lfWnljLj5F12kzCr6U=; 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=FLVF4VmlNH/FvocdmEWb3xLN33WSB/oKzQ3Aoaxv6OAfmq3zyKBqm2AC4BUVQ1A/y LEJd3R0pdqSptdwtBtuH3Huu/FQLKNB6JoHZ+QAYXR+cyU73V8jxJJ7zXk4JzQz58J UFF0lo1xdw3RvCCAgGJg0IayDDE5clWHoFJ5Op+s= 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 598DC3857708 for ; Fri, 28 Apr 2023 12:35:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 598DC3857708 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-160-oyG67FEkMA6POwB9-M8QOQ-1; Fri, 28 Apr 2023 08:35:34 -0400 X-MC-Unique: oyG67FEkMA6POwB9-M8QOQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id DE9B8A0F380; Fri, 28 Apr 2023 12:35:33 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.84]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3FE3FC15BA0; Fri, 28 Apr 2023 12:35:33 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com Subject: [PATCH v4 14/15] tests: Replace various function calls with their x variant Date: Fri, 28 Apr 2023 14:21:41 +0200 Message-Id: <20230428122142.928135-15-fberat@redhat.com> In-Reply-To: <20230418121130.844302-2-fberat@redhat.com> References: <20230428122142.928135-1-fberat@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" With fortification enabled, few function calls return result need to be checked, has they get the __wur macro enabled. --- misc/tst-error1.c | 2 +- nss/tst-reload2.c | 6 +++++- posix/tst-chmod.c | 9 +++++++-- posix/wordexp-test.c | 6 +++++- stdlib/test-canon.c | 7 ++++++- 5 files changed, 24 insertions(+), 6 deletions(-) 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/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/wordexp-test.c b/posix/wordexp-test.c index bae27d6cee..87d537c931 100644 --- a/posix/wordexp-test.c +++ b/posix/wordexp-test.c @@ -332,7 +332,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/stdlib/test-canon.c b/stdlib/test-canon.c index 4edee73dd8..5a2e7e1e6e 100644 --- a/stdlib/test-canon.c +++ b/stdlib/test-canon.c @@ -154,7 +154,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;