tests: replace ftruncate by xftruncate
authorFrédéric Bérat <fberat@redhat.com>
Fri, 28 Apr 2023 12:21:39 +0000 (14:21 +0200)
committerSiddhesh Poyarekar <siddhesh@sourceware.org>
Thu, 1 Jun 2023 16:45:13 +0000 (12:45 -0400)
With fortification enabled, ftruncate calls return result needs to be
checked, has it gets the __wur macro enabled.

Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
io/tst-copy_file_range.c
posix/tst-getopt-cancel.c
stdio-common/tst-perror.c

index d1f3aaa..bd64e9c 100644 (file)
@@ -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;
 
index 7167d1a..6f49391 100644 (file)
@@ -33,6 +33,7 @@
 #include <support/support.h>
 #include <support/temp_file.h>
 #include <support/xthread.h>
+#include <support/xunistd.h>
 
 static bool
 check_stderr (bool expect_errmsg, FILE *stderr_trapped)
@@ -48,7 +49,7 @@ check_stderr (bool expect_errmsg, FILE *stderr_trapped)
       fputs (lineptr, stdout);
     }
   rewind (stderr_trapped);
-  ftruncate (fileno (stderr_trapped), 0);
+  xftruncate (fileno (stderr_trapped), 0);
   return got_errmsg == expect_errmsg;
 }
 
index 57835e0..b4ab583 100644 (file)
@@ -9,6 +9,7 @@
 #include <unistd.h>
 #include <wchar.h>
 
+#include <support/xunistd.h>
 
 #define MB_EXP \
   "null mode test 1: Invalid or incomplete multibyte or wide character\n" \
@@ -94,7 +95,7 @@ do_test (void)
     puts ("multibyte test succeeded");
 
   lseek (fd, 0, SEEK_SET);
-  ftruncate (fd, 0);
+  xftruncate (fd, 0);
 
   if (dup2 (fd, 2) == -1)
     {