From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: 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 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1682685337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nCZxT1bIS1P4gooR/RKEUAg07lfWnljLj5F12kzCr6U=; b=f/XpLIUrLSTq02opBjRUZrUjJd7amkHntdyNe474JQjERSouDLfnhK73TDowXhPqhDwUKY XXNT5jOU1AtIGIo2TLvkc3f2oJfSwptK6bGqDGbwOZrtejseJPJWvG4ucKBkGJx/wQYTF9 fKwgEZxOgdo+XJIH0D5aP9p8NZuE1Ks= 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) From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20B=C3=A9rat?= 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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true 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 List-Id: 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; -- 2.39.2