Fix this warning when building with GCC9 on Fedora 30: In function ‘strncpy’, inlined from ‘sys_uname’ at /home/alistair/qemu/linux-user/uname.c:94:3: /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output may be truncated copying 64 bytes from a string of length 64 [-Werror=stringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Alistair Francis <alistair.fran...@wdc.com> --- linux-user/uname.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linux-user/uname.c b/linux-user/uname.c index 313b79dbad..293b2238f2 100644 --- a/linux-user/uname.c +++ b/linux-user/uname.c @@ -90,6 +90,11 @@ int sys_uname(struct new_utsname *buf) * struct linux kernel uses). */ +#if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) && QEMU_GNUC_PREREQ(9, 0) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-truncation" +#endif + memset(buf, 0, sizeof(*buf)); COPY_UTSNAME_FIELD(buf->sysname, uts_buf.sysname); COPY_UTSNAME_FIELD(buf->nodename, uts_buf.nodename); @@ -101,6 +106,9 @@ int sys_uname(struct new_utsname *buf) #endif return (0); +#if defined(CONFIG_PRAGMA_DIAGNOSTIC_AVAILABLE) && QEMU_GNUC_PREREQ(9, 0) +#pragma GCC diagnostic pop +#endif #undef COPY_UTSNAME_FIELD } -- 2.21.0