From 7ba426a1115318fc11f4355f3161f35817a06ba4 Mon Sep 17 00:00:00 2001 From: Frederic Berat Date: Mon, 12 Jun 2023 17:18:21 +0200 Subject: tests: replace fgets by xfgets With fortification enabled, fgets calls return result needs to be checked, has it gets the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar --- stdio-common/test_rdwr.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'stdio-common') diff --git a/stdio-common/test_rdwr.c b/stdio-common/test_rdwr.c index 7825ca9358..0544916eb1 100644 --- a/stdio-common/test_rdwr.c +++ b/stdio-common/test_rdwr.c @@ -20,6 +20,7 @@ #include #include +#include int main (int argc, char **argv) @@ -49,7 +50,7 @@ main (int argc, char **argv) (void) fputs (hello, f); rewind (f); - (void) fgets (buf, sizeof (buf), f); + xfgets (buf, sizeof (buf), f); rewind (f); (void) fputs (buf, f); rewind (f); @@ -104,12 +105,8 @@ main (int argc, char **argv) if (!lose) { rewind (f); - if (fgets (buf, sizeof (buf), f) == NULL) - { - printf ("fgets got %s.\n", strerror(errno)); - lose = 1; - } - else if (strcmp (buf, replace)) + xfgets (buf, sizeof (buf), f); + if (strcmp (buf, replace)) { printf ("Read \"%s\" instead of \"%s\".\n", buf, replace); lose = 1; -- cgit 1.4.1