include: Silence gcc warning in linux_list.h
Phil Sutter
reviewerPATCH 1/2 include: Silence gcc warning in linux_list.h
Compiler complained about empty prefetch() macro:
| ../include/linux_list.h:385:66: warning: right-hand operand of comma expression has no effect [-Wunused-value] | 385 | for (pos = list_entry((head)->next, typeof(*pos), member), \ | | ^
Use nftables' variant instead which gcc seems to like more.
Fixes 36d2ed3de20a3 ("major cleanup of index2name infrastructure: use linux list (and fix leak in the nlif_close path)")
Signed-off-by Phil Sutter <[email protected]>
--- include/linux_list.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux_list.h +1 -1
@@ -29,7 +29,7 @@1 ; \ }) -#define prefetch (x) 1 +#define prefetch (x) ((void)0)/* empty define to make this work in userspace -HW */ #ifndef smp_wmb
Signature · 1 line
2.34.1
Phil Sutter
reviewerPATCH 2/2 libnfnetlink: Check getsockname() return code
The function may return -1 (and set errno). Assume it will leave addr_len value unchanged, so checking is necessary to not hide the error.
Fixes 4248314d40187 ("nfnl: fix compilation warning with gcc-4.7")
Signed-off-by Phil Sutter <[email protected]>
--- src/libnfnetlink.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
src/libnfnetlink.c +4 -2
@@ -210,7 +210,8 @@ struct nfnl_handle *nfnl_open(void) nfnlh->peer.nl_family =AF_NETLINK ; addr_len =sizeof (nfnlh->local); -getsockname (nfnlh->fd, (struct sockaddr *)&nfnlh->local, &addr_len); +if (getsockname (nfnlh->fd, (struct sockaddr *)&nfnlh->local, &addr_len)) + goto err_close;if (addr_len !=sizeof (nfnlh->local)) { errno =EINVAL ; goto err_close;
@@ -231,7 +232,8 @@ struct nfnl_handle *nfnl_open(void)/* use getsockname to get the netlink pid that the kernel assigned us */ addr_len =sizeof (nfnlh->local); -getsockname (nfnlh->fd, (struct sockaddr *)&nfnlh->local, &addr_len); +if (getsockname (nfnlh->fd, (struct sockaddr *)&nfnlh->local, &addr_len)) + goto err_close;if (addr_len !=sizeof (nfnlh->local)) { errno =EINVAL ; goto err_close;
Signature · 1 line
2.34.1
Pablo Neira Ayuso
maintainerRe: [libnfnetlink PATCH 2/2] libnfnetlink: Check getsockname() return code
Quoted 3 lines · Phil Sutter
The function may return -1 (and set errno). Assume it will leave
addr_lenvalue unchanged, so checking is necessary to not hide the error.
LGTM.
Quoted 2 lines
Fixes 4248314d40187 ("nfnl: fix compilation warning with gcc-4.7")Signed-off-by Phil Sutter <[email protected]>
Pablo Neira Ayuso
maintainerQuoted 7 lines · Phil Sutter
Compiler complained about empty
prefetch()macro:| ../include/linux_list.h:385:66: warning: right-hand operand of comma expression has no effect [-Wunused-value] | 385 | for (pos = list_entry((head)->next, typeof(*pos), member), \ | | ^Use nftables' variant instead which gcc seems to like more.
LGTM, thanks
Quoted 2 lines
Fixes 36d2ed3de20a3 ("major cleanup of index2name infrastructure: use linux list (and fix leak in the nlif_close path)")Signed-off-by Phil Sutter <[email protected]>