Silence gcc-8 warnings

Jan Beulich JBeulich@suse.com
Mon Apr 23 08:54:00 GMT 2018


>>> On 23.04.18 at 10:48, <amodra@gmail.com> wrote:
> --- a/bfd/elf-linux-core.h
> +++ b/bfd/elf-linux-core.h
> @@ -69,8 +69,12 @@ swap_linux_prpsinfo32_ugid32_out
>    bfd_put_32 (obfd, from->pr_ppid, to->pr_ppid);
>    bfd_put_32 (obfd, from->pr_pgrp, to->pr_pgrp);
>    bfd_put_32 (obfd, from->pr_sid, to->pr_sid);
> +#pragma GCC diagnostic push
> +#pragma GCC diagnostic ignored "-Wpragmas"
> +#pragma GCC diagnostic ignored "-Wstringop-truncation"
>    strncpy (to->pr_fname, from->pr_fname, sizeof (to->pr_fname));
>    strncpy (to->pr_psargs, from->pr_psargs, sizeof (to->pr_psargs));
> +#pragma GCC diagnostic pop
>  }

We've tried to use this approach in the Xen hypervisor sources too in at least
one place: Older gcc isn't happy about such #pragma-s inside functions. Sadly
we haven't found a neat alternative (yet).

Jan




More information about the Binutils mailing list