Skip to content

Commit f12b86c

Browse files
q2venkuba-moo
authored andcommitted
selftests: net: af_unix: Fix a build error of unix_connect.c.
This patch fixes a build error reported in the link. [0] unix_connect.c: In function ‘unix_connect_test’: unix_connect.c:115:55: error: expected identifier before ‘(’ token #define offsetof(type, member) ((size_t)&((type *)0)->(member)) ^ unix_connect.c:128:12: note: in expansion of macro ‘offsetof’ addrlen = offsetof(struct sockaddr_un, sun_path) + variant->len; ^~~~~~~~ We can fix this by removing () around member, but checkpatch will complain about it, and the root cause of the build failure is that I followed the warning and fixed this in the v2 -> v3 change of the blamed commit. [1] CHECK: Macro argument 'member' may be better as '(member)' to avoid precedence issues #33: FILE: tools/testing/selftests/net/af_unix/unix_connect.c:115: +#define offsetof(type, member) ((size_t)&((type *)0)->member) To avoid this warning, let's use offsetof() defined in stddef.h instead. [0]: https://lore.kernel.org/linux-mm/[email protected]/ [1]: https://lore.kernel.org/netdev/[email protected]/ Fixes: e95ab1d ("selftests: net: af_unix: Test connect() with different netns.") Reported-by: kernel test robot <[email protected]> Suggested-by: Jakub Kicinski <[email protected]> Signed-off-by: Kuniyuki Iwashima <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 09765fc commit f12b86c

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

tools/testing/selftests/net/af_unix/unix_connect.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#define _GNU_SOURCE
44
#include <sched.h>
55

6+
#include <stddef.h>
67
#include <stdio.h>
78
#include <unistd.h>
89

@@ -112,8 +113,6 @@ FIXTURE_TEARDOWN(unix_connect)
112113
remove("test");
113114
}
114115

115-
#define offsetof(type, member) ((size_t)&((type *)0)->(member))
116-
117116
TEST_F(unix_connect, test)
118117
{
119118
socklen_t addrlen;

0 commit comments

Comments
 (0)