mirror of
git://sourceware.org/git/glibc.git
synced 2025-03-06 20:58:33 +01:00
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 <siddhesh@sourceware.org>
This commit is contained in:
parent
7d42120928
commit
8c4f69d711
10 changed files with 29 additions and 58 deletions
|
@ -25,6 +25,8 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <argp.h>
|
#include <argp.h>
|
||||||
|
|
||||||
|
#include <support/support.h>
|
||||||
|
|
||||||
const char *argp_program_version = "argp-test 1.0";
|
const char *argp_program_version = "argp-test 1.0";
|
||||||
|
|
||||||
struct argp_option sub_options[] =
|
struct argp_option sub_options[] =
|
||||||
|
@ -178,12 +180,12 @@ help_filter (int key, const char *text, void *input)
|
||||||
if (key == ARGP_KEY_HELP_POST_DOC && text)
|
if (key == ARGP_KEY_HELP_POST_DOC && text)
|
||||||
{
|
{
|
||||||
time_t now = time (0);
|
time_t now = time (0);
|
||||||
asprintf (&new_text, text, ctime (&now));
|
new_text = xasprintf (text, ctime (&now));
|
||||||
}
|
}
|
||||||
else if (key == 'f')
|
else if (key == 'f')
|
||||||
/* Show the default for the --foonly option. */
|
/* Show the default for the --foonly option. */
|
||||||
asprintf (&new_text, "%s (ZOT defaults to %x)",
|
new_text = xasprintf ("%s (ZOT defaults to %x)",
|
||||||
text, params->foonly_default);
|
text, params->foonly_default);
|
||||||
else
|
else
|
||||||
new_text = (char *)text;
|
new_text = (char *)text;
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,8 @@ prepare (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int off;
|
int off;
|
||||||
asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
|
|
||||||
if (buf == NULL)
|
buf = xasprintf ("cp %s %n%s-copy", argv[0], &off, argv[0]);
|
||||||
{
|
|
||||||
puts ("asprintf failed");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
if (system (buf) != 0)
|
if (system (buf) != 0)
|
||||||
{
|
{
|
||||||
puts ("system failed");
|
puts ("system failed");
|
||||||
|
|
|
@ -18,12 +18,8 @@ prepare (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int off;
|
int off;
|
||||||
asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
|
|
||||||
if (buf == NULL)
|
buf = xasprintf ("cp %s %n%s-copy", argv[0], &off, argv[0]);
|
||||||
{
|
|
||||||
puts ("asprintf failed");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
if (system (buf) != 0)
|
if (system (buf) != 0)
|
||||||
{
|
{
|
||||||
puts ("system failed");
|
puts ("system failed");
|
||||||
|
|
|
@ -22,12 +22,8 @@ prepare (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int off;
|
int off;
|
||||||
asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
|
|
||||||
if (buf == NULL)
|
buf = xasprintf ("cp %s %n%s-copy", argv[0], &off, argv[0]);
|
||||||
{
|
|
||||||
puts ("asprintf failed");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
if (system (buf) != 0)
|
if (system (buf) != 0)
|
||||||
{
|
{
|
||||||
puts ("system failed");
|
puts ("system failed");
|
||||||
|
@ -58,13 +54,8 @@ do_test (void)
|
||||||
puts ("canonicalize_file_name failed");
|
puts ("canonicalize_file_name failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
char *path;
|
|
||||||
asprintf (&path, "%s:../libio:../elf", bindir);
|
char *path = xasprintf ("%s:../libio:../elf", bindir);
|
||||||
if (path == NULL)
|
|
||||||
{
|
|
||||||
puts ("asprintf failed");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
setenv ("PATH", path, 1);
|
setenv ("PATH", path, 1);
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,8 @@ prepare (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int off;
|
int off;
|
||||||
asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
|
|
||||||
if (buf == NULL)
|
buf = xasprintf ("cp %s %n%s-copy", argv[0], &off, argv[0]);
|
||||||
{
|
|
||||||
puts ("asprintf failed");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
if (system (buf) != 0)
|
if (system (buf) != 0)
|
||||||
{
|
{
|
||||||
puts ("system failed");
|
puts ("system failed");
|
||||||
|
|
|
@ -18,12 +18,8 @@ prepare (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int off;
|
int off;
|
||||||
asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
|
|
||||||
if (buf == NULL)
|
buf = xasprintf ("cp %s %n%s-copy", argv[0], &off, argv[0]);
|
||||||
{
|
|
||||||
puts ("asprintf failed");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
if (system (buf) != 0)
|
if (system (buf) != 0)
|
||||||
{
|
{
|
||||||
puts ("system failed");
|
puts ("system failed");
|
||||||
|
|
|
@ -25,12 +25,8 @@ prepare (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *buf;
|
char *buf;
|
||||||
int off;
|
int off;
|
||||||
asprintf (&buf, "cp %s %n%s-copy", argv[0], &off, argv[0]);
|
|
||||||
if (buf == NULL)
|
buf = xasprintf ("cp %s %n%s-copy", argv[0], &off, argv[0]);
|
||||||
{
|
|
||||||
puts ("asprintf failed");
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
if (system (buf) != 0)
|
if (system (buf) != 0)
|
||||||
{
|
{
|
||||||
puts ("system failed");
|
puts ("system failed");
|
||||||
|
@ -61,13 +57,8 @@ do_test (void)
|
||||||
puts ("canonicalize_file_name failed");
|
puts ("canonicalize_file_name failed");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
char *path;
|
|
||||||
asprintf (&path, "%s:../libio:../elf", bindir);
|
char *path = xasprintf ("%s:../libio:../elf", bindir);
|
||||||
if (path == NULL)
|
|
||||||
{
|
|
||||||
puts ("asprintf failed");
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
setenv ("PATH", path, 1);
|
setenv ("PATH", path, 1);
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include <support/support.h>
|
||||||
|
|
||||||
static char buf[8192];
|
static char buf[8192];
|
||||||
|
|
||||||
int
|
int
|
||||||
|
@ -60,7 +62,7 @@ main (void)
|
||||||
the perhaps incompatible new shared libraries. */
|
the perhaps incompatible new shared libraries. */
|
||||||
unsetenv ("LD_LIBRARY_PATH");
|
unsetenv ("LD_LIBRARY_PATH");
|
||||||
|
|
||||||
asprintf (&printbuf, "cmp %s %s", inname, outname);
|
printbuf = xasprintf ("cmp %s %s", inname, outname);
|
||||||
result = system (printbuf);
|
result = system (printbuf);
|
||||||
remove (inname);
|
remove (inname);
|
||||||
remove (outname);
|
remove (outname);
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <support/support.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
{
|
{
|
||||||
|
@ -57,7 +59,7 @@ do_test (void)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
asprintf (&line, "\
|
line = xasprintf ("\
|
||||||
GDB is free software and you are welcome to distribute copies of it\n\
|
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\
|
under certain conditions; type \"show copying\" to see the conditions.\n\
|
||||||
There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
|
There is absolutely no warranty for GDB; type \"show warranty\" for details.\n\
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
#include <support/support.h>
|
||||||
|
|
||||||
static int
|
static int
|
||||||
do_test (void)
|
do_test (void)
|
||||||
|
@ -44,9 +45,7 @@ do_test (void)
|
||||||
if (tmpdir == NULL || tmpdir[0] == '\0')
|
if (tmpdir == NULL || tmpdir[0] == '\0')
|
||||||
tmpdir = "/tmp";
|
tmpdir = "/tmp";
|
||||||
|
|
||||||
asprintf (&fname, "%s/tst-fseek.XXXXXX", tmpdir);
|
fname = xasprintf ("%s/tst-fseek.XXXXXX", tmpdir);
|
||||||
if (fname == NULL)
|
|
||||||
error (EXIT_FAILURE, errno, "cannot generate name for temporary file");
|
|
||||||
|
|
||||||
/* Create a temporary file. */
|
/* Create a temporary file. */
|
||||||
fd = mkstemp (fname);
|
fd = mkstemp (fname);
|
||||||
|
|
Loading…
Add table
Reference in a new issue