bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: c-stack.c and DEBUG: missing import


From: Marc Nieper-Wißkirchen
Subject: Re: c-stack.c and DEBUG: missing import
Date: Thu, 14 May 2020 16:01:13 +0200

Hi Bruno,

there is one more issue with c-stack when all warnings are enabled
(and the DEBUG flag is set):

c-stack.c: In function ‘segv_handler’:
c-stack.c:175:5: warning: ignoring return value of ‘write’, declared
with attribute warn_unused_result [-Wunused-result]
  175 |     write (STDERR_FILENO, buf, strlen (buf));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
c-stack.c: In function ‘overflow_handler’:
c-stack.c:198:5: warning: ignoring return value of ‘write’, declared
with attribute warn_unused_result [-Wunused-result]
  198 |     write (STDERR_FILENO, buf, strlen (buf));
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This will be a nice use case for the newly created attribute module
and MAYBE_UNUSED.

Thanks,

Marc

Am Sa., 9. Mai 2020 um 13:34 Uhr schrieb Bruno Haible <address@hidden>:
>
> Hi Marc,
>
> > Please add
> >
> > #ifdef DEBUG
> > # include <stdio.h>
> > #endif
> >
> > at the beginning of c-stack.c.
> >
> > When the DEBUG flag is enabled, c-stack.c uses sprintf and without the
> > suggested addition gcc complains about an implicit declaration of the
> > function sprintf.
>
> Yup. Thanks for the suggestion. Done.
>
>
> 2020-05-09  Bruno Haible  <address@hidden>
>
>         c-stack: Fix warning when DEBUG is enabled.
>         Patch suggested by Marc Nieper-Wißkirchen <address@hidden> in
>         <https://lists.gnu.org/archive/html/bug-gnulib/2020-05/msg00081.html>.
>         * lib/c-stack.c: Include <stdio.h>.
>
> diff --git a/lib/c-stack.c b/lib/c-stack.c
> index 4050d08..e486591 100644
> --- a/lib/c-stack.c
> +++ b/lib/c-stack.c
> @@ -65,6 +65,10 @@ typedef struct sigaltstack stack_t;
>
>  #include <unistd.h>
>
> +#if DEBUG
> +# include <stdio.h>
> +#endif
> +
>  #if HAVE_LIBSIGSEGV
>  # include <sigsegv.h>
>  #endif
>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]