With --enable-Werror and --with-dpdk=no, with gcc (Ubuntu 11.2.0-19ubuntu1), there are the following warnings (errors) emmitted. Those are reported in [1] to be GCC bug. Workaround it.
In function 'memset', inlined from 'nl_msg_put_uninit' at ../lib/netlink.c:212:9, inlined from 'nl_msg_put_unspec_uninit' at ../lib/netlink.c:248:26, inlined from 'nl_msg_put_unspec' at ../lib/netlink.c:276:11, inlined from 'nl_msg_put_u8' at ../lib/netlink.c:294:5: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:10: error: '__builtin_memset' writing 3 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] 59 | return __builtin___memset_chk (__dest, __ch, __len, | ^ In function 'memset', inlined from 'nl_msg_put_uninit' at ../lib/netlink.c:212:9, inlined from 'nl_msg_put_unspec_uninit' at ../lib/netlink.c:248:26, inlined from 'nl_msg_put_unspec' at ../lib/netlink.c:276:11, inlined from 'nl_msg_put_u16' at ../lib/netlink.c:302:5: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:59:10: error: '__builtin_memset' writing 2 bytes into a region of size 0 overflows the destination [-Werror=stringop-overflow=] 59 | return __builtin___memset_chk (__dest, __ch, __len, | ^ [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=92718 Signed-off-by: Eli Britstein <el...@nvidia.com> --- lib/netlink.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/netlink.c b/lib/netlink.c index 6215282d6..c30620fdb 100644 --- a/lib/netlink.c +++ b/lib/netlink.c @@ -200,6 +200,14 @@ nl_msg_put(struct ofpbuf *msg, const void *data, size_t size) memcpy(nl_msg_put_uninit(msg, size), data, size); } +static void +nl_msg_zero_pad(char *pad_ptr, size_t pad_size) +{ + while (pad_size--) { + *pad_ptr++ = 0; + } +} + /* Appends 'size' bytes of data, plus Netlink padding if needed, to the tail * end of 'msg', reallocating and copying its data if necessary. Returns a * pointer to the first byte of the new data, which is left uninitialized. */ @@ -208,9 +216,7 @@ nl_msg_put_uninit(struct ofpbuf *msg, size_t size) { size_t pad = PAD_SIZE(size, NLMSG_ALIGNTO); char *p = ofpbuf_put_uninit(msg, size + pad); - if (pad) { - memset(p + size, 0, pad); - } + nl_msg_zero_pad(p + size, pad); return p; } @@ -231,9 +237,7 @@ nl_msg_push_uninit(struct ofpbuf *msg, size_t size) { size_t pad = PAD_SIZE(size, NLMSG_ALIGNTO); char *p = ofpbuf_push_uninit(msg, size + pad); - if (pad) { - memset(p + size, 0, pad); - } + nl_msg_zero_pad(p + size, pad); return p; } -- 2.26.2.1730.g385c171 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev