From 8c4f69d711481a18c70cb9a6c0a5367604894320 Mon Sep 17 00:00:00 2001 From: Frédéric Bérat Date: Fri, 2 Jun 2023 17:28:06 +0200 Subject: tests: fix warn unused result on asprintf calls When enabling _FORTIFY_SOURCE, some functions now lead to warnings when their result is not checked. Reviewed-by: Siddhesh Poyarekar --- stdio-common/bug5.c | 4 +++- stdio-common/test-fwrite.c | 4 +++- stdio-common/tst-fseek.c | 5 ++--- 3 files changed, 8 insertions(+), 5 deletions(-) (limited to 'stdio-common') diff --git a/stdio-common/bug5.c b/stdio-common/bug5.c index 7bfe9b2b8d..dfa19aed55 100644 --- a/stdio-common/bug5.c +++ b/stdio-common/bug5.c @@ -7,6 +7,8 @@ #include #include +#include + static char buf[8192]; int @@ -60,7 +62,7 @@ main (void) the perhaps incompatible new shared libraries. */ unsetenv ("LD_LIBRARY_PATH"); - asprintf (&printbuf, "cmp %s %s", inname, outname); + printbuf = xasprintf ("cmp %s %s", inname, outname); result = system (printbuf); remove (inname); remove (outname); diff --git a/stdio-common/test-fwrite.c b/stdio-common/test-fwrite.c index 5677c6da80..7f383921ca 100644 --- a/stdio-common/test-fwrite.c +++ b/stdio-common/test-fwrite.c @@ -1,6 +1,8 @@ #include #include +#include + static int do_test (void) { @@ -57,7 +59,7 @@ do_test (void) return 1; } - asprintf (&line, "\ + line = xasprintf ("\ GDB is free software and you are welcome to distribute copies of it\n\ under certain conditions; type \"show copying\" to see the conditions.\n\ There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\ diff --git a/stdio-common/tst-fseek.c b/stdio-common/tst-fseek.c index c4ac17cdf4..386dd1dd51 100644 --- a/stdio-common/tst-fseek.c +++ b/stdio-common/tst-fseek.c @@ -25,6 +25,7 @@ #include #include +#include static int do_test (void) @@ -44,9 +45,7 @@ do_test (void) if (tmpdir == NULL || tmpdir[0] == '\0') tmpdir = "/tmp"; - asprintf (&fname, "%s/tst-fseek.XXXXXX", tmpdir); - if (fname == NULL) - error (EXIT_FAILURE, errno, "cannot generate name for temporary file"); + fname = xasprintf ("%s/tst-fseek.XXXXXX", tmpdir); /* Create a temporary file. */ fd = mkstemp (fname); -- cgit 1.4.1