From patchwork Fri Jun 2 15:28:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frederic Berat X-Patchwork-Id: 70535 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 AD5DE3854E6A for ; Fri, 2 Jun 2023 15:30:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org AD5DE3854E6A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1685719858; bh=zX+ZyLtUhHhgCkhv6Tn/Fk5LtlqKK/Y5q/HlGk0I30c=; 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=gGX3rwB6HHwojwtv+xLhDQDe+fzrstQ6EICoQSv4DQEd87QVjW0P+i1sklx72+Gw1 B0ebbMySSvEb8h+LxKEyxCfO9yV0IqBnxRfv4o7DCIYX/nktmd+LFNQfr7PIuBdc+O U3VV6DvHs0tVfcVRtU6K2KleTnD3VaQD2G/24JPQ= 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 50FDE3856616 for ; Fri, 2 Jun 2023 15:28:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 50FDE3856616 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-204-Veei5tiBNBqzcC6L1svc2Q-1; Fri, 02 Jun 2023 11:28:22 -0400 X-MC-Unique: Veei5tiBNBqzcC6L1svc2Q-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 63AAF8002BF; Fri, 2 Jun 2023 15:28:21 +0000 (UTC) Received: from Nymeria-redhat.redhat.com (unknown [10.39.193.180]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BECB140CFD45; Fri, 2 Jun 2023 15:28:20 +0000 (UTC) To: libc-alpha@sourceware.org Cc: siddhesh@gotplt.org, fberat@redhat.com Subject: [PATCH v6 6/7] tests: Replace various function calls with their x variant Date: Fri, 2 Jun 2023 17:28:11 +0200 Message-Id: <20230602152812.108497-7-fberat@redhat.com> In-Reply-To: <20230602152812.108497-1-fberat@redhat.com> References: <20230602152812.108497-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.5 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, 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. Reviewed-by: Siddhesh Poyarekar --- Changes since v5: - Actually replace functions with their x variant as described misc/tst-error1.c | 4 +++- nss/tst-reload2.c | 2 +- posix/tst-chmod.c | 7 +++++-- posix/wordexp-test.c | 2 +- stdlib/test-canon.c | 4 +++- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/misc/tst-error1.c b/misc/tst-error1.c index 9c4a62fbd0..75d4edf476 100644 --- a/misc/tst-error1.c +++ b/misc/tst-error1.c @@ -5,11 +5,13 @@ #include #include +#include + static int do_test (int argc, char *argv[]) { mtrace (); - (void) freopen (argc == 1 ? "/dev/stdout" : argv[1], "a", stderr); + xfreopen (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..89cc9ea242 100644 --- a/nss/tst-reload2.c +++ b/nss/tst-reload2.c @@ -121,7 +121,7 @@ do_test (void) /* Change the root dir. */ TEST_VERIFY (chroot ("/subdir") == 0); - chdir ("/"); + xchdir ("/"); /* Check we're NOT using the "inner" nsswitch.conf. */ diff --git a/posix/tst-chmod.c b/posix/tst-chmod.c index b98a05a265..470a696fe5 100644 --- a/posix/tst-chmod.c +++ b/posix/tst-chmod.c @@ -27,6 +27,8 @@ #include #include +#include + #define OUT_OF_MEMORY \ do { \ @@ -229,7 +231,8 @@ do_test (int argc, char *argv[]) close (fd); snprintf (buf, buflen, "%s/..", testdir); - chdir (buf); + xchdir (buf); + /* We are now in the directory above the one we create the test directory in. */ @@ -349,7 +352,7 @@ do_test (int argc, char *argv[]) } fail: - chdir (startdir); + xchdir (startdir); /* Remove all the files. */ chmod (testdir, 0700); diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c index 524597d96b..28d1d1509b 100644 --- a/posix/wordexp-test.c +++ b/posix/wordexp-test.c @@ -336,7 +336,7 @@ do_test (int argc, char *argv[]) if (cwd == NULL) cwd = ".."; - chdir (cwd); + xchdir (cwd); rmdir (tmpdir); return 0; diff --git a/stdlib/test-canon.c b/stdlib/test-canon.c index bf19b1f1b1..2874258722 100644 --- a/stdlib/test-canon.c +++ b/stdlib/test-canon.c @@ -27,6 +27,8 @@ #include #include +#include + /* Prototype for our test function. */ extern int do_test (int argc, char *argv[]); #include @@ -159,7 +161,7 @@ do_test (int argc, char ** argv) } for (i = 0; i < (int) (sizeof (symlinks) / sizeof (symlinks[0])); ++i) - symlink (symlinks[i].value, symlinks[i].name); + xsymlink (symlinks[i].value, symlinks[i].name); int has_dir = mkdir ("doesExist", 0777) == 0;