aboutsummaryrefslogtreecommitdiff
path: root/stdio-common
diff options
context:
space:
mode:
authorFrédéric Bérat <fberat@redhat.com>2023-06-01 16:27:47 +0200
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2023-06-01 13:01:32 -0400
commit29e25f6f136182fb3756d51e03dea7c4d1919dd9 (patch)
tree4d3950068c9fec569ae21055641b986632371fbb /stdio-common
parenta952fcda58cd7aa191140fc9e7d453df212b9117 (diff)
downloadglibc-29e25f6f136182fb3756d51e03dea7c4d1919dd9.zip
glibc-29e25f6f136182fb3756d51e03dea7c4d1919dd9.tar.gz
glibc-29e25f6f136182fb3756d51e03dea7c4d1919dd9.tar.bz2
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>
Diffstat (limited to 'stdio-common')
-rw-r--r--stdio-common/bug19.c9
-rw-r--r--stdio-common/bug6.c8
-rw-r--r--stdio-common/tstscanf.c14
3 files changed, 23 insertions, 8 deletions
diff --git a/stdio-common/bug19.c b/stdio-common/bug19.c
index e083304..9a3deac 100644
--- a/stdio-common/bug19.c
+++ b/stdio-common/bug19.c
@@ -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);
diff --git a/stdio-common/bug6.c b/stdio-common/bug6.c
index 0db63a3..50098bf 100644
--- a/stdio-common/bug6.c
+++ b/stdio-common/bug6.c
@@ -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");
diff --git a/stdio-common/tstscanf.c b/stdio-common/tstscanf.c
index 3a4ebf7..7e92df4 100644
--- a/stdio-common/tstscanf.c
+++ b/stdio-common/tstscanf.c
@@ -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