From 32043daaafcd59793b9addf7af1bcedb3b666f09 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20B=C3=A9rat?= Date: Fri, 28 Apr 2023 14:21:39 +0200 Subject: [PATCH] tests: replace ftruncate by xftruncate With fortification enabled, ftruncate calls return result needs to be checked, has it gets the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar --- io/tst-copy_file_range.c | 2 +- posix/tst-getopt-cancel.c | 3 ++- stdio-common/tst-perror.c | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/io/tst-copy_file_range.c b/io/tst-copy_file_range.c index d1f3aaa..bd64e9c 100644 --- a/io/tst-copy_file_range.c +++ b/io/tst-copy_file_range.c @@ -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; diff --git a/posix/tst-getopt-cancel.c b/posix/tst-getopt-cancel.c index 7167d1a..6f49391 100644 --- a/posix/tst-getopt-cancel.c +++ b/posix/tst-getopt-cancel.c @@ -33,6 +33,7 @@ #include #include #include +#include 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; } diff --git a/stdio-common/tst-perror.c b/stdio-common/tst-perror.c index 57835e0..b4ab583 100644 --- a/stdio-common/tst-perror.c +++ b/stdio-common/tst-perror.c @@ -9,6 +9,7 @@ #include #include +#include #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) { -- 2.7.4