public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc] sysdeps/ieee754/ldbl-128ibm-compat: Fix warn unused result
@ 2023-07-05 15:05 Frederic Berat
0 siblings, 0 replies; only message in thread
From: Frederic Berat @ 2023-07-05 15:05 UTC (permalink / raw)
To: glibc-cvs
https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=02261d1bd930b50e9166086462dca885e9847826
commit 02261d1bd930b50e9166086462dca885e9847826
Author: Frédéric Bérat <fberat@redhat.com>
Date: Mon Jun 19 14:56:49 2023 +0200
sysdeps/ieee754/ldbl-128ibm-compat: Fix warn unused result
Return value from *scanf and *asprintf routines are now properly checked
in test-scanf-ldbl-compat-template.c and test-printf-ldbl-compat.c.
Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>
Diff:
---
.../ldbl-128ibm-compat/test-printf-ldbl-compat.c | 10 ++++++----
.../test-scanf-ldbl-compat-template.c | 21 +++++++++++----------
2 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
index 3c759e1427..be37af7c31 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-printf-ldbl-compat.c
@@ -30,12 +30,13 @@ do_test_call_varg (FILE *stream, const char *format, ...)
char *buffer = NULL;
char string[128];
va_list args;
+ int ret;
printf ("%15s", "vasprintf: ");
va_start (args, format);
- vasprintf (&buffer, format, args);
+ ret = vasprintf (&buffer, format, args);
va_end (args);
- if (buffer == NULL)
+ if (ret == -1 || buffer == NULL)
printf ("Error using vasprintf\n");
else
{
@@ -82,10 +83,11 @@ do_test_call_rarg (FILE *stream, const char *format, long double ld, double d)
{
char *buffer = NULL;
char string[128];
+ int ret;
printf ("%15s", "asprintf: ");
- asprintf (&buffer, format, ld, d);
- if (buffer == NULL)
+ ret = asprintf (&buffer, format, ld, d);
+ if (ret == -1 || buffer == NULL)
printf ("Error using asprintf\n");
else
{
diff --git a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
index e8da3a67f0..776c12dd16 100644
--- a/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
+++ b/sysdeps/ieee754/ldbl-128ibm-compat/test-scanf-ldbl-compat-template.c
@@ -37,10 +37,10 @@
ldptr = va_arg (args, long double *); \
fptr = va_arg (args, float *); \
va_end (args); \
- if (*ldptr == -1 && *fptr == -2) \
+ if (*ldptr == -1 && *fptr == -2 && ret == 2) \
printf ("OK"); \
else \
- printf ("ERROR (%Lf %f)", *ldptr, *fptr); \
+ printf ("ERROR (%Lf %f %d)", *ldptr, *fptr, ret); \
printf ("\n");
#define CLEAR_VALUE \
@@ -48,10 +48,10 @@
f = 0;
#define CHECK_VALUE \
- if (ld == -1 && f == -2) \
+ if (ld == -1 && f == -2 && ret == 2) \
printf ("OK"); \
else \
- printf ("ERROR (%Lf %f)", ld, f); \
+ printf ("ERROR (%Lf %f %d)", ld, f, ret); \
printf ("\n");
static void
@@ -62,40 +62,41 @@ do_test_call (FILE *stream, CHAR *string, const CHAR *format, ...)
float *fptr;
long double *ldptr;
va_list args;
+ int ret;
CLEAR_VALUE
printf ("fscanf: ");
- FSCANF (stream, format, &ld, &f);
+ ret = FSCANF (stream, format, &ld, &f);
CHECK_VALUE
CLEAR_VALUE
printf ("scanf: ");
- SCANF (format, &ld, &f);
+ ret = SCANF (format, &ld, &f);
CHECK_VALUE
CLEAR_VALUE
printf ("sscanf: ");
- SSCANF (string, format, &ld, &f);
+ ret = SSCANF (string, format, &ld, &f);
CHECK_VALUE
CLEAR_VARGS
printf ("vfscanf: ");
va_start (args, format);
- VFSCANF (stream, format, args);
+ ret = VFSCANF (stream, format, args);
va_end (args);
CHECK_VARGS
CLEAR_VARGS
printf ("vscanf: ");
va_start (args, format);
- VSCANF (format, args);
+ ret = VSCANF (format, args);
va_end (args);
CHECK_VARGS
CLEAR_VARGS
printf ("vsscanf: ");
va_start (args, format);
- VSSCANF (string, format, args);
+ ret = VSSCANF (string, format, args);
va_end (args);
CHECK_VARGS
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-07-05 15:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-07-05 15:05 [glibc] sysdeps/ieee754/ldbl-128ibm-compat: Fix warn unused result Frederic Berat
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).