diff options
author | Frederic Berat <fberat@redhat.com> | 2023-06-12 17:18:21 +0200 |
---|---|---|
committer | Siddhesh Poyarekar <siddhesh@sourceware.org> | 2023-06-13 19:59:08 -0400 |
commit | 7ba426a1115318fc11f4355f3161f35817a06ba4 (patch) | |
tree | af4aeb4348f06d4c8076475a892763612985ef59 /stdio-common | |
parent | a84dcb4bdfe5070f2327da693d8b025c89b4877a (diff) | |
download | glibc-7ba426a1115318fc11f4355f3161f35817a06ba4.tar.gz glibc-7ba426a1115318fc11f4355f3161f35817a06ba4.tar.xz glibc-7ba426a1115318fc11f4355f3161f35817a06ba4.zip |
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 <siddhesh@sourceware.org>
Diffstat (limited to 'stdio-common')
-rw-r--r-- | stdio-common/test_rdwr.c | 11 |
1 files changed, 4 insertions, 7 deletions
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 <stdlib.h> #include <string.h> +#include <support/xstdio.h> 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; |