mirror of
https://sourceware.org/git/glibc.git
synced 2024-11-21 12:30:06 +00:00
tests: fix warn unused results
With fortification enabled, few function calls return result need to be checked, has they get the __wur macro enabled. Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
This commit is contained in:
parent
a952fcda58
commit
29e25f6f13
@ -99,7 +99,11 @@ get8 (char *cp)
|
||||
int i,j,t;
|
||||
|
||||
for(i=0;i<8;i++){
|
||||
scanf("%2x",&t);
|
||||
if (scanf("%2x",&t) < 1)
|
||||
{
|
||||
if(ferror(stdin))
|
||||
totfails++;
|
||||
}
|
||||
if(feof(stdin))
|
||||
good_bye();
|
||||
for(j=0; j<8 ; j++) {
|
||||
|
@ -200,8 +200,8 @@ special (void)
|
||||
output_error (NAME (ECVT), INFINITY, 10, "inf", 0, 0, p, decpt, sign);
|
||||
|
||||
/* Simply make sure these calls with large NDIGITs don't crash. */
|
||||
(void) ECVT (123.456, 10000, &decpt, &sign);
|
||||
(void) FCVT (123.456, 10000, &decpt, &sign);
|
||||
p = ECVT (123.456, 10000, &decpt, &sign);
|
||||
p = FCVT (123.456, 10000, &decpt, &sign);
|
||||
|
||||
/* Some tests for the reentrant functions. */
|
||||
/* Use a too small buffer. */
|
||||
|
@ -58,8 +58,7 @@ do_test (void)
|
||||
|
||||
/* BZ #18086. Make sure we don't reset errno. */
|
||||
errno = EBADF;
|
||||
nice (0);
|
||||
if (errno != EBADF)
|
||||
if (nice (0) == -1 || errno != EBADF)
|
||||
{
|
||||
printf ("FAIL: errno = %i, but wanted EBADF (%i)\n", errno, EBADF);
|
||||
return 1;
|
||||
|
@ -253,7 +253,11 @@ do_test (int argc, char *argv[])
|
||||
cwd = getcwd (NULL, 0);
|
||||
|
||||
/* Set up arena for pathname expansion */
|
||||
tmpnam (tmpdir);
|
||||
if (!tmpnam (tmpdir))
|
||||
{
|
||||
printf ("Failed to create a temporary directory with a unique name: %m");
|
||||
return 1;
|
||||
}
|
||||
xmkdir (tmpdir, S_IRWXU);
|
||||
TEST_VERIFY_EXIT (chdir (tmpdir) == 0);
|
||||
|
||||
|
@ -29,12 +29,17 @@ do_test (void)
|
||||
printf("checking sscanf\n");
|
||||
|
||||
int i, j, n;
|
||||
int result = 0;
|
||||
|
||||
i = j = n = 0;
|
||||
FSCANF (fp, L(" %i - %i %n"), &i, &j, &n);
|
||||
if (FSCANF (fp, L(" %i - %i %n"), &i, &j, &n) < 2)
|
||||
{
|
||||
printf ("FSCANF couldn't read all parameters %d\n", errno);
|
||||
result = 1;
|
||||
}
|
||||
|
||||
printf ("found %i-%i (length=%i)\n", i, j, n);
|
||||
|
||||
int result = 0;
|
||||
if (i != 7)
|
||||
{
|
||||
printf ("i is %d, expected 7\n", i);
|
||||
|
@ -7,16 +7,16 @@ main (void)
|
||||
int i;
|
||||
int lost = 0;
|
||||
|
||||
scanf ("%2s", buf);
|
||||
lost = (scanf ("%2s", buf) < 0);
|
||||
lost |= (buf[0] != 'X' || buf[1] != 'Y' || buf[2] != '\0');
|
||||
if (lost)
|
||||
puts ("test of %2s failed.");
|
||||
scanf (" ");
|
||||
scanf ("%d", &i);
|
||||
lost |= (scanf (" ") < 0);
|
||||
lost |= (scanf ("%d", &i) < 0);
|
||||
lost |= (i != 1234);
|
||||
if (lost)
|
||||
puts ("test of %d failed.");
|
||||
scanf ("%c", buf);
|
||||
lost |= (scanf ("%c", buf) < 0);
|
||||
lost |= (buf[0] != 'L');
|
||||
if (lost)
|
||||
puts ("test of %c failed.\n");
|
||||
|
@ -120,7 +120,12 @@ main (int argc, char **argv)
|
||||
int i;
|
||||
float x;
|
||||
char name[50];
|
||||
(void) fscanf (in, "%2d%f%*d %[0123456789]", &i, &x, name);
|
||||
if (fscanf (in, "%2d%f%*d %[0123456789]", &i, &x, name) < 3)
|
||||
{
|
||||
fputs ("test failed!\n", stdout);
|
||||
result = 1;
|
||||
}
|
||||
|
||||
fprintf (out, "i = %d, x = %f, name = \"%.50s\"\n", i, x, name);
|
||||
if (i != 56 || x != 789.0F || strcmp (name, "56"))
|
||||
{
|
||||
@ -164,7 +169,12 @@ main (int argc, char **argv)
|
||||
quant = 0.0;
|
||||
units[0] = item[0] = '\0';
|
||||
count = fscanf (in, "%f%20s of %20s", &quant, units, item);
|
||||
(void) fscanf (in, "%*[^\n]");
|
||||
if (fscanf (in, "%*[^\n]") < 0 && ferror (in))
|
||||
{
|
||||
fputs ("test failed!\n", stdout);
|
||||
result = 1;
|
||||
}
|
||||
|
||||
fprintf (out, "count = %d, quant = %f, item = %.21s, units = %.21s\n",
|
||||
count, quant, item, units);
|
||||
if (count != ok[rounds-1].count || quant != ok[rounds-1].quant
|
||||
|
@ -123,8 +123,13 @@ do_test (int argc, char ** argv)
|
||||
int i, errors = 0;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
getcwd (cwd, sizeof (buf));
|
||||
if (getcwd (cwd, sizeof (buf)))
|
||||
cwd_len = strlen (cwd);
|
||||
else
|
||||
{
|
||||
printf ("%s: current working directory couldn't be retrieved\n", argv[0]);
|
||||
++errors;
|
||||
}
|
||||
|
||||
errno = 0;
|
||||
if (realpath (NULL, buf) != NULL || errno != EINVAL)
|
||||
@ -205,7 +210,12 @@ do_test (int argc, char ** argv)
|
||||
free (result2);
|
||||
}
|
||||
|
||||
getcwd (buf, sizeof (buf));
|
||||
if (!getcwd (buf, sizeof (buf)))
|
||||
{
|
||||
printf ("%s: current working directory couldn't be retrieved\n", argv[0]);
|
||||
++errors;
|
||||
}
|
||||
|
||||
if (strcmp (buf, cwd))
|
||||
{
|
||||
printf ("%s: current working directory changed from %s to %s\n",
|
||||
|
@ -714,8 +714,8 @@ check_for_unshare_hints (int require_pidns)
|
||||
continue;
|
||||
|
||||
val = -1; /* Sentinel. */
|
||||
fscanf (f, "%d", &val);
|
||||
if (val != files[i].bad_value)
|
||||
int cnt = fscanf (f, "%d", &val);
|
||||
if (cnt == 1 && val != files[i].bad_value)
|
||||
continue;
|
||||
|
||||
printf ("To enable test-container, please run this as root:\n");
|
||||
|
@ -50,7 +50,11 @@ tf (void *arg)
|
||||
pthread_cleanup_push (cl, NULL);
|
||||
|
||||
/* This call should never return. */
|
||||
(void) lockf (fd, F_LOCK, 0);
|
||||
if (lockf (fd, F_LOCK, 0))
|
||||
{
|
||||
puts ("child thread: lockf failed");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
pthread_cleanup_pop (0);
|
||||
|
||||
|
@ -1009,7 +1009,8 @@ tf_pread (void *arg)
|
||||
pthread_cleanup_push (cl, NULL);
|
||||
|
||||
char mem[10];
|
||||
pread (tempfd, mem, sizeof (mem), 0);
|
||||
if (pread (tempfd, mem, sizeof (mem), 0) < 0)
|
||||
FAIL_EXIT1 ("pread failed: %m");
|
||||
|
||||
pthread_cleanup_pop (0);
|
||||
|
||||
@ -1038,7 +1039,8 @@ tf_pwrite (void *arg)
|
||||
pthread_cleanup_push (cl, NULL);
|
||||
|
||||
char mem[10];
|
||||
pwrite (tempfd, mem, sizeof (mem), 0);
|
||||
if (pwrite (tempfd, mem, sizeof (mem), 0) <0)
|
||||
FAIL_EXIT1 ("pwrite failed: %m");
|
||||
|
||||
pthread_cleanup_pop (0);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user