netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 net-next] selftests: net: af_unix: Fix a build error of unix_connect.c.
@ 2022-07-18 16:23 Kuniyuki Iwashima
  2022-07-20  0:32 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-18 16:23 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Kuniyuki Iwashima, Kuniyuki Iwashima, netdev, kernel test robot

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;
              ^~~~~~~~

The checkpatch.pl will complain about this change, but the root cause of
the build failure is that I fixed this in the v2 -> v3 change. [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)

[0]: https://lore.kernel.org/linux-mm/202207182205.FrkMeDZT-lkp@intel.com/
[1]: https://lore.kernel.org/netdev/20220702154818.66761-1-kuniyu@amazon.com/

Fixes: e95ab1d85289 ("selftests: net: af_unix: Test connect() with different netns.")
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
---
 tools/testing/selftests/net/af_unix/unix_connect.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/af_unix/unix_connect.c b/tools/testing/selftests/net/af_unix/unix_connect.c
index 157e44ef7f37..5b231d8c4683 100644
--- a/tools/testing/selftests/net/af_unix/unix_connect.c
+++ b/tools/testing/selftests/net/af_unix/unix_connect.c
@@ -112,7 +112,7 @@ FIXTURE_TEARDOWN(unix_connect)
 		remove("test");
 }
 
-#define offsetof(type, member) ((size_t)&((type *)0)->(member))
+#define offsetof(type, member) ((size_t)&((type *)0)->member)
 
 TEST_F(unix_connect, test)
 {
-- 
2.30.2


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

* Re: [PATCH v1 net-next] selftests: net: af_unix: Fix a build error of unix_connect.c.
  2022-07-18 16:23 [PATCH v1 net-next] selftests: net: af_unix: Fix a build error of unix_connect.c Kuniyuki Iwashima
@ 2022-07-20  0:32 ` Jakub Kicinski
  2022-07-20  0:43   ` Kuniyuki Iwashima
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2022-07-20  0:32 UTC (permalink / raw)
  To: Kuniyuki Iwashima
  Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Kuniyuki Iwashima,
	netdev, kernel test robot

On Mon, 18 Jul 2022 09:23:50 -0700 Kuniyuki Iwashima wrote:
> 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;
>               ^~~~~~~~

Can we delete this define and use stddef.h instead?  man offsetof
This is not kernel code the C standard lib is at our disposal.

> The checkpatch.pl will complain about this change, but the root cause of
> the build failure is that I fixed this in the v2 -> v3 change. [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)
> 
> [0]: https://lore.kernel.org/linux-mm/202207182205.FrkMeDZT-lkp@intel.com/
> [1]: https://lore.kernel.org/netdev/20220702154818.66761-1-kuniyu@amazon.com/
> 
> Fixes: e95ab1d85289 ("selftests: net: af_unix: Test connect() with different netns.")
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
> ---
>  tools/testing/selftests/net/af_unix/unix_connect.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/tools/testing/selftests/net/af_unix/unix_connect.c b/tools/testing/selftests/net/af_unix/unix_connect.c
> index 157e44ef7f37..5b231d8c4683 100644
> --- a/tools/testing/selftests/net/af_unix/unix_connect.c
> +++ b/tools/testing/selftests/net/af_unix/unix_connect.c
> @@ -112,7 +112,7 @@ FIXTURE_TEARDOWN(unix_connect)
>  		remove("test");
>  }
>  
> -#define offsetof(type, member) ((size_t)&((type *)0)->(member))
> +#define offsetof(type, member) ((size_t)&((type *)0)->member)
>  
>  TEST_F(unix_connect, test)
>  {


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

* Re: [PATCH v1 net-next] selftests: net: af_unix: Fix a build error of unix_connect.c.
  2022-07-20  0:32 ` Jakub Kicinski
@ 2022-07-20  0:43   ` Kuniyuki Iwashima
  0 siblings, 0 replies; 3+ messages in thread
From: Kuniyuki Iwashima @ 2022-07-20  0:43 UTC (permalink / raw)
  To: kuba; +Cc: davem, edumazet, kuni1840, kuniyu, lkp, netdev, pabeni

From:   Jakub Kicinski <kuba@kernel.org>
Date:   Tue, 19 Jul 2022 17:32:01 -0700
> On Mon, 18 Jul 2022 09:23:50 -0700 Kuniyuki Iwashima wrote:
> > 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;
> >               ^~~~~~~~
> 
> Can we delete this define and use stddef.h instead?  man offsetof
> This is not kernel code the C standard lib is at our disposal.

Ah, it works.
I'll respin v2.

Thank you!

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

end of thread, other threads:[~2022-07-20  0:43 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-18 16:23 [PATCH v1 net-next] selftests: net: af_unix: Fix a build error of unix_connect.c Kuniyuki Iwashima
2022-07-20  0:32 ` Jakub Kicinski
2022-07-20  0:43   ` Kuniyuki Iwashima

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).