All of lore.kernel.org
 help / color / mirror / Atom feed
* [libnfnetlink PATCH 1/2] include: Silence gcc warning in linux_list.h
@ 2022-03-25 17:34 Phil Sutter
  2022-03-25 17:34 ` [libnfnetlink PATCH 2/2] libnfnetlink: Check getsockname() return code Phil Sutter
  2022-03-29 21:28 ` [libnfnetlink PATCH 1/2] include: Silence gcc warning in linux_list.h Pablo Neira Ayuso
  0 siblings, 2 replies; 4+ messages in thread
From: Phil Sutter @ 2022-03-25 17:34 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

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 <phil@nwl.cc>
---
 include/linux_list.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux_list.h b/include/linux_list.h
index de182a4764706..cf71837f18347 100644
--- a/include/linux_list.h
+++ b/include/linux_list.h
@@ -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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [libnfnetlink PATCH 2/2] libnfnetlink: Check getsockname() return code
  2022-03-25 17:34 [libnfnetlink PATCH 1/2] include: Silence gcc warning in linux_list.h Phil Sutter
@ 2022-03-25 17:34 ` Phil Sutter
  2022-03-29 21:28   ` Pablo Neira Ayuso
  2022-03-29 21:28 ` [libnfnetlink PATCH 1/2] include: Silence gcc warning in linux_list.h Pablo Neira Ayuso
  1 sibling, 1 reply; 4+ messages in thread
From: Phil Sutter @ 2022-03-25 17:34 UTC (permalink / raw)
  To: Pablo Neira Ayuso; +Cc: netfilter-devel

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 <phil@nwl.cc>
---
 src/libnfnetlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libnfnetlink.c b/src/libnfnetlink.c
index 1cb6a820fee3d..667e5ef8f82a5 100644
--- a/src/libnfnetlink.c
+++ b/src/libnfnetlink.c
@@ -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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [libnfnetlink PATCH 2/2] libnfnetlink: Check getsockname() return code
  2022-03-25 17:34 ` [libnfnetlink PATCH 2/2] libnfnetlink: Check getsockname() return code Phil Sutter
@ 2022-03-29 21:28   ` Pablo Neira Ayuso
  0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-29 21:28 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel

On Fri, Mar 25, 2022 at 06:34:26PM +0100, Phil Sutter wrote:
> 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.

LGTM.

> Fixes: 4248314d40187 ("nfnl: fix compilation warning with gcc-4.7")
> Signed-off-by: Phil Sutter <phil@nwl.cc>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [libnfnetlink PATCH 1/2] include: Silence gcc warning in linux_list.h
  2022-03-25 17:34 [libnfnetlink PATCH 1/2] include: Silence gcc warning in linux_list.h Phil Sutter
  2022-03-25 17:34 ` [libnfnetlink PATCH 2/2] libnfnetlink: Check getsockname() return code Phil Sutter
@ 2022-03-29 21:28 ` Pablo Neira Ayuso
  1 sibling, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2022-03-29 21:28 UTC (permalink / raw)
  To: Phil Sutter; +Cc: netfilter-devel

On Fri, Mar 25, 2022 at 06:34:25PM +0100, Phil Sutter wrote:
> 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

> Fixes: 36d2ed3de20a3 ("major cleanup of index2name infrastructure: use linux list (and fix leak in the nlif_close path)")
> Signed-off-by: Phil Sutter <phil@nwl.cc>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-03-29 21:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-25 17:34 [libnfnetlink PATCH 1/2] include: Silence gcc warning in linux_list.h Phil Sutter
2022-03-25 17:34 ` [libnfnetlink PATCH 2/2] libnfnetlink: Check getsockname() return code Phil Sutter
2022-03-29 21:28   ` Pablo Neira Ayuso
2022-03-29 21:28 ` [libnfnetlink PATCH 1/2] include: Silence gcc warning in linux_list.h Pablo Neira Ayuso

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.