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 --- posix/tst-execvp2.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'posix/tst-execvp2.c') diff --git a/posix/tst-execvp2.c b/posix/tst-execvp2.c index 440dfab438..f6c0cb4d98 100644 --- a/posix/tst-execvp2.c +++ b/posix/tst-execvp2.c @@ -25,12 +25,8 @@ prepare (int argc, char *argv[]) { char *buf; int off; - asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]); - if (buf == NULL) - { - puts ("asprintf failed"); - exit (1); - } + + buf = xasprintf ("cp %s %n%s-copy", argv[0], &off, argv[0]); if (system (buf) != 0) { puts ("system failed"); @@ -61,13 +57,8 @@ do_test (void) puts ("canonicalize_file_name failed"); return 1; } - char *path; - asprintf (&path, "%s:../libio:../elf", bindir); - if (path == NULL) - { - puts ("asprintf failed"); - return 1; - } + + char *path = xasprintf ("%s:../libio:../elf", bindir); setenv ("PATH", path, 1); -- cgit 1.4.1