From: Patrick McHardy Date: Thu, 20 Nov 2008 12:08:29 +0000 (-0800) Subject: netlink: avoid memset of 0 bytes sparse warning X-Git-Tag: v2.6.29-rc1~581^2~626 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0c19b0adb8dd33dbd10ff48e41971231c486855c;p=profile%2Fivi%2Fkernel-adaptation-intel-automotive.git netlink: avoid memset of 0 bytes sparse warning A netlink attribute padding of zero triggers this sparse warning: include/linux/netlink.h:245:8: warning: memset with byte count of 0 Avoid the memset when the size parameter is constant and requires no padding. Signed-off-by: Patrick McHardy Signed-off-by: David S. Miller --- diff --git a/include/linux/netlink.h b/include/linux/netlink.h index 9ff1b54..51b09a1 100644 --- a/include/linux/netlink.h +++ b/include/linux/netlink.h @@ -242,7 +242,8 @@ __nlmsg_put(struct sk_buff *skb, u32 pid, u32 seq, int type, int len, int flags) nlh->nlmsg_flags = flags; nlh->nlmsg_pid = pid; nlh->nlmsg_seq = seq; - memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size); + if (!__builtin_constant_p(size) || NLMSG_ALIGN(size) - size != 0) + memset(NLMSG_DATA(nlh) + len, 0, NLMSG_ALIGN(size) - size); return nlh; }