[email protected], le dim. 28 sept. 2025 00:46:02 +0100, a ecrit: > From: Diego Nieto Cid <[email protected]> > > ../../libps/fmt.c: In function '_fmt_create': > ../../libps/fmt.c:181:21: warning: ignoring return value of 'asprintf' > declared with attribute 'warn_unused_result' [-Wunused-result] > 181 | asprintf (err_string, "%s: Unknown format > spec", src); > | > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ../../libps/fmt.c:250:17: warning: ignoring return value of 'asprintf' > declared with attribute 'warn_unused_result' [-Wunused-result] > 250 | asprintf (err_string, "%s: Unknown format spec", > name); > | > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > ../../libps/fmt.c: In function 'ps_fmt_creation_error': > ../../libps/fmt.c:340:5: warning: ignoring return value of 'asprintf' > declared with attribute 'warn_unused_result' [-Wunused-result] > 340 | asprintf (error, "%s", strerror (err)); > --- > libps/fmt.c | 18 +++++++++++++----- > 1 file changed, 13 insertions(+), 5 deletions(-) > > diff --git a/libps/fmt.c b/libps/fmt.c > index 853a610c..c0d1c998 100644 > --- a/libps/fmt.c > +++ b/libps/fmt.c > @@ -337,7 +339,13 @@ ps_fmt_creation_error (char *src, int posix, struct > ps_fmt_specs *fmt_specs, > struct ps_fmt *fmt; > error_t err = _fmt_create (src, posix, fmt_specs, &fmt, error); > if (err != EINVAL) /* ? */ > - asprintf (error, "%s", strerror (err)); > + { > + int err2 = asprintf (error, "%s", strerror (err)); > + /* XXX silence unused variable warning, if memory fails (again) we > have no way > + * of notifying the caller. > + */
Then better crash than silencing an error. > + (void) err2; > + } > if (! err) > ps_fmt_free (fmt); > } > -- > 2.51.0 > >
