]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
tests: Replace various function calls with their x variant
authorFrédéric Bérat <fberat@redhat.com>
Fri, 2 Jun 2023 15:28:11 +0000 (17:28 +0200)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Tue, 6 Jun 2023 12:23:53 +0000 (08:23 -0400)
With fortification enabled, few function calls return result need to be
checked, has they get the __wur macro enabled.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
misc/tst-error1.c
nss/tst-reload2.c
posix/tst-chmod.c
posix/wordexp-test.c
stdlib/test-canon.c

index 9c4a62fbd0bfd3f8ef024392aed1019596d3348f..75d4edf476d312172dfbc80b1782b9e70cb86d8d 100644 (file)
@@ -5,11 +5,13 @@
 #include <wchar.h>
 #include <libc-diag.h>
 
+#include <support/xstdio.h>
+
 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];
index ba9b5b7687ddcbafc3978b696252bb799e8ae581..89cc9ea24254d57d17a483e0170d0e6f8ad59649 100644 (file)
@@ -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.  */
 
index b98a05a26556d967a878b90c0cf334bf6fd16fe5..470a696fe55c72041c3010ed0e1e9f7d1b603837 100644 (file)
@@ -27,6 +27,8 @@
 #include <unistd.h>
 #include <sys/stat.h>
 
+#include <support/xunistd.h>
+
 
 #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);
index 524597d96b375657185179aa8019f37a849e1c1a..28d1d1509b805c2445d6384a0db6eaea86b36904 100644 (file)
@@ -336,7 +336,7 @@ do_test (int argc, char *argv[])
   if (cwd == NULL)
     cwd = "..";
 
-  chdir (cwd);
+  xchdir (cwd);
   rmdir (tmpdir);
 
   return 0;
index bf19b1f1b1a5bca66dad7a78775cc9c2007fcc98..28742587220949476b2957a54af6d892ff5af2c6 100644 (file)
@@ -27,6 +27,8 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 
+#include <support/xunistd.h>
+
 /* Prototype for our test function.  */
 extern int do_test (int argc, char *argv[]);
 #include <test-skeleton.c>
@@ -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;