* [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end.
@ 2025-08-11 21:53 Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS Kuniyuki Iwashima
` (4 more replies)
0 siblings, 5 replies; 8+ messages in thread
From: Kuniyuki Iwashima @ 2025-08-11 21:53 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
This series fix 4 warnings caught by -Wall and
-Wflex-array-member-not-at-end.
Kuniyuki Iwashima (4):
selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end.
selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for
scm_inq.c.
selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for
scm_rights.c.
selftest: af_unix: Silence -Wall warning for scm_pid.c.
tools/testing/selftests/net/af_unix/Makefile | 2 +-
tools/testing/selftests/net/af_unix/scm_inq.c | 26 ++++++++---------
.../testing/selftests/net/af_unix/scm_pidfd.c | 2 --
.../selftests/net/af_unix/scm_rights.c | 28 +++++++++----------
4 files changed, 26 insertions(+), 32 deletions(-)
--
2.51.0.rc0.155.g4a0f42376b-goog
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v1 net-next 1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS.
2025-08-11 21:53 [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end Kuniyuki Iwashima
@ 2025-08-11 21:53 ` Kuniyuki Iwashima
2025-08-13 1:02 ` Jakub Kicinski
2025-08-11 21:53 ` [PATCH v1 net-next 2/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_inq.c Kuniyuki Iwashima
` (3 subsequent siblings)
4 siblings, 1 reply; 8+ messages in thread
From: Kuniyuki Iwashima @ 2025-08-11 21:53 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
-Wall and -Wflex-array-member-not-at-end caught some warnings that
will be fixed in later patches.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
tools/testing/selftests/net/af_unix/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/net/af_unix/Makefile b/tools/testing/selftests/net/af_unix/Makefile
index a4b61c6d0290..0a20c98bbcfd 100644
--- a/tools/testing/selftests/net/af_unix/Makefile
+++ b/tools/testing/selftests/net/af_unix/Makefile
@@ -1,4 +1,4 @@
-CFLAGS += $(KHDR_INCLUDES)
+CFLAGS += $(KHDR_INCLUDES) -Wall -Wflex-array-member-not-at-end
TEST_GEN_PROGS := diag_uid msg_oob scm_inq scm_pidfd scm_rights unix_connect
include ../../lib.mk
--
2.51.0.rc0.155.g4a0f42376b-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 net-next 2/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_inq.c.
2025-08-11 21:53 [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS Kuniyuki Iwashima
@ 2025-08-11 21:53 ` Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 3/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_rights.c Kuniyuki Iwashima
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Kuniyuki Iwashima @ 2025-08-11 21:53 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
scm_inq.c has no problem in functionality, but when compiled with
-Wflex-array-member-not-at-end, it shows this warning:
scm_inq.c:15:24: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
15 | struct cmsghdr cmsghdr;
| ^~~~~~~
Let's silence it.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
tools/testing/selftests/net/af_unix/scm_inq.c | 26 +++++++++----------
1 file changed, 12 insertions(+), 14 deletions(-)
diff --git a/tools/testing/selftests/net/af_unix/scm_inq.c b/tools/testing/selftests/net/af_unix/scm_inq.c
index 9d22561e7b8f..fc467714387e 100644
--- a/tools/testing/selftests/net/af_unix/scm_inq.c
+++ b/tools/testing/selftests/net/af_unix/scm_inq.c
@@ -11,11 +11,6 @@
#define NR_CHUNKS 100
#define MSG_LEN 256
-struct scm_inq {
- struct cmsghdr cmsghdr;
- int inq;
-};
-
FIXTURE(scm_inq)
{
int fd[2];
@@ -70,35 +65,38 @@ static void send_chunks(struct __test_metadata *_metadata,
static void recv_chunks(struct __test_metadata *_metadata,
FIXTURE_DATA(scm_inq) *self)
{
+ char cmsg_buf[CMSG_SPACE(sizeof(int))];
struct msghdr msg = {};
struct iovec iov = {};
- struct scm_inq cmsg;
+ struct cmsghdr *cmsg;
char buf[MSG_LEN];
int i, ret;
int inq;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
- msg.msg_control = &cmsg;
- msg.msg_controllen = CMSG_SPACE(sizeof(cmsg.inq));
+ msg.msg_control = cmsg_buf;
+ msg.msg_controllen = sizeof(cmsg_buf);
iov.iov_base = buf;
iov.iov_len = sizeof(buf);
for (i = 0; i < NR_CHUNKS; i++) {
memset(buf, 0, sizeof(buf));
- memset(&cmsg, 0, sizeof(cmsg));
+ memset(cmsg_buf, 0, sizeof(cmsg_buf));
ret = recvmsg(self->fd[1], &msg, 0);
ASSERT_EQ(MSG_LEN, ret);
- ASSERT_NE(NULL, CMSG_FIRSTHDR(&msg));
- ASSERT_EQ(CMSG_LEN(sizeof(cmsg.inq)), cmsg.cmsghdr.cmsg_len);
- ASSERT_EQ(SOL_SOCKET, cmsg.cmsghdr.cmsg_level);
- ASSERT_EQ(SCM_INQ, cmsg.cmsghdr.cmsg_type);
+
+ cmsg = CMSG_FIRSTHDR(&msg);
+ ASSERT_NE(NULL, cmsg);
+ ASSERT_EQ(CMSG_LEN(sizeof(int)), cmsg->cmsg_len);
+ ASSERT_EQ(SOL_SOCKET, cmsg->cmsg_level);
+ ASSERT_EQ(SCM_INQ, cmsg->cmsg_type);
ret = ioctl(self->fd[1], SIOCINQ, &inq);
ASSERT_EQ(0, ret);
- ASSERT_EQ(cmsg.inq, inq);
+ ASSERT_EQ(*(int *)CMSG_DATA(cmsg), inq);
}
}
--
2.51.0.rc0.155.g4a0f42376b-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 net-next 3/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_rights.c.
2025-08-11 21:53 [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 2/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_inq.c Kuniyuki Iwashima
@ 2025-08-11 21:53 ` Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 4/4] selftest: af_unix: Silence -Wall warning for scm_pid.c Kuniyuki Iwashima
2025-08-13 1:10 ` [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end patchwork-bot+netdevbpf
4 siblings, 0 replies; 8+ messages in thread
From: Kuniyuki Iwashima @ 2025-08-11 21:53 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
scm_rights.c has no problem in functionality, but when compiled with
-Wflex-array-member-not-at-end, it shows this warning:
scm_rights.c: In function ‘__send_fd’:
scm_rights.c:275:32: warning: structure containing a flexible array member is not at the end of another structure [-Wflex-array-member-not-at-end]
275 | struct cmsghdr cmsghdr;
| ^~~~~~~
Let's silence it.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
.../selftests/net/af_unix/scm_rights.c | 28 +++++++++----------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/tools/testing/selftests/net/af_unix/scm_rights.c b/tools/testing/selftests/net/af_unix/scm_rights.c
index 8b015f16c03d..914f99d153ce 100644
--- a/tools/testing/selftests/net/af_unix/scm_rights.c
+++ b/tools/testing/selftests/net/af_unix/scm_rights.c
@@ -271,20 +271,11 @@ void __send_fd(struct __test_metadata *_metadata,
{
#define MSG "x"
#define MSGLEN 1
- struct {
- struct cmsghdr cmsghdr;
- int fd[2];
- } cmsg = {
- .cmsghdr = {
- .cmsg_len = CMSG_LEN(sizeof(cmsg.fd)),
- .cmsg_level = SOL_SOCKET,
- .cmsg_type = SCM_RIGHTS,
- },
- .fd = {
- self->fd[inflight * 2],
- self->fd[inflight * 2],
- },
+ int fds[2] = {
+ self->fd[inflight * 2],
+ self->fd[inflight * 2],
};
+ char cmsg_buf[CMSG_SPACE(sizeof(fds))];
struct iovec iov = {
.iov_base = MSG,
.iov_len = MSGLEN,
@@ -294,11 +285,18 @@ void __send_fd(struct __test_metadata *_metadata,
.msg_namelen = 0,
.msg_iov = &iov,
.msg_iovlen = 1,
- .msg_control = &cmsg,
- .msg_controllen = CMSG_SPACE(sizeof(cmsg.fd)),
+ .msg_control = cmsg_buf,
+ .msg_controllen = sizeof(cmsg_buf),
};
+ struct cmsghdr *cmsg;
int ret;
+ cmsg = CMSG_FIRSTHDR(&msg);
+ cmsg->cmsg_level = SOL_SOCKET;
+ cmsg->cmsg_type = SCM_RIGHTS;
+ cmsg->cmsg_len = CMSG_LEN(sizeof(fds));
+ memcpy(CMSG_DATA(cmsg), fds, sizeof(fds));
+
ret = sendmsg(self->fd[receiver * 2 + 1], &msg, variant->flags);
if (variant->disabled) {
--
2.51.0.rc0.155.g4a0f42376b-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v1 net-next 4/4] selftest: af_unix: Silence -Wall warning for scm_pid.c.
2025-08-11 21:53 [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end Kuniyuki Iwashima
` (2 preceding siblings ...)
2025-08-11 21:53 ` [PATCH v1 net-next 3/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_rights.c Kuniyuki Iwashima
@ 2025-08-11 21:53 ` Kuniyuki Iwashima
2025-08-13 1:10 ` [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end patchwork-bot+netdevbpf
4 siblings, 0 replies; 8+ messages in thread
From: Kuniyuki Iwashima @ 2025-08-11 21:53 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
Cc: Simon Horman, Kuniyuki Iwashima, Kuniyuki Iwashima, netdev
-Wall found 2 unused variables in scm_pid.c:
scm_pidfd.c: In function ‘parse_cmsg’:
scm_pidfd.c:140:13: warning: unused variable ‘data’ [-Wunused-variable]
140 | int data = 0;
| ^~~~
scm_pidfd.c: In function ‘cmsg_check_dead’:
scm_pidfd.c:246:15: warning: unused variable ‘client_pid’ [-Wunused-variable]
246 | pid_t client_pid;
| ^~~~~~~~~~
Let's remove these variables.
Signed-off-by: Kuniyuki Iwashima <kuniyu@google.com>
---
tools/testing/selftests/net/af_unix/scm_pidfd.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/tools/testing/selftests/net/af_unix/scm_pidfd.c b/tools/testing/selftests/net/af_unix/scm_pidfd.c
index 37e034874034..ef2921988e5f 100644
--- a/tools/testing/selftests/net/af_unix/scm_pidfd.c
+++ b/tools/testing/selftests/net/af_unix/scm_pidfd.c
@@ -137,7 +137,6 @@ struct cmsg_data {
static int parse_cmsg(struct msghdr *msg, struct cmsg_data *res)
{
struct cmsghdr *cmsg;
- int data = 0;
if (msg->msg_flags & (MSG_TRUNC | MSG_CTRUNC)) {
log_err("recvmsg: truncated");
@@ -243,7 +242,6 @@ static int cmsg_check_dead(int fd, int expected_pid)
int data = 0;
char control[CMSG_SPACE(sizeof(struct ucred)) +
CMSG_SPACE(sizeof(int))] = { 0 };
- pid_t client_pid;
struct pidfd_info info = {
.mask = PIDFD_INFO_EXIT,
};
--
2.51.0.rc0.155.g4a0f42376b-goog
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v1 net-next 1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS.
2025-08-11 21:53 ` [PATCH v1 net-next 1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS Kuniyuki Iwashima
@ 2025-08-13 1:02 ` Jakub Kicinski
2025-08-13 5:33 ` Kuniyuki Iwashima
0 siblings, 1 reply; 8+ messages in thread
From: Jakub Kicinski @ 2025-08-13 1:02 UTC (permalink / raw)
To: Kuniyuki Iwashima
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
Kuniyuki Iwashima, netdev
On Mon, 11 Aug 2025 21:53:04 +0000 Kuniyuki Iwashima wrote:
> -Wall and -Wflex-array-member-not-at-end caught some warnings that
> will be fixed in later patches.
Makes sense to enable the warnings first when writing the patches,
but I think we should commit in the opposite order. Fixes fix then
arm the warnings. I'll reorder when applying.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end.
2025-08-11 21:53 [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end Kuniyuki Iwashima
` (3 preceding siblings ...)
2025-08-11 21:53 ` [PATCH v1 net-next 4/4] selftest: af_unix: Silence -Wall warning for scm_pid.c Kuniyuki Iwashima
@ 2025-08-13 1:10 ` patchwork-bot+netdevbpf
4 siblings, 0 replies; 8+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-08-13 1:10 UTC (permalink / raw)
To: Kuniyuki Iwashima; +Cc: davem, edumazet, kuba, pabeni, horms, kuni1840, netdev
Hello:
This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 11 Aug 2025 21:53:03 +0000 you wrote:
> This series fix 4 warnings caught by -Wall and
> -Wflex-array-member-not-at-end.
>
>
> Kuniyuki Iwashima (4):
> selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end.
> selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for
> scm_inq.c.
> selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for
> scm_rights.c.
> selftest: af_unix: Silence -Wall warning for scm_pid.c.
>
> [...]
Here is the summary with links:
- [v1,net-next,1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS.
https://git.kernel.org/netdev/net-next/c/1838731f1072
- [v1,net-next,2/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_inq.c.
https://git.kernel.org/netdev/net-next/c/942224e6baca
- [v1,net-next,3/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_rights.c.
https://git.kernel.org/netdev/net-next/c/9a58d8e68252
- [v1,net-next,4/4] selftest: af_unix: Silence -Wall warning for scm_pid.c.
https://git.kernel.org/netdev/net-next/c/fd9faac372cc
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v1 net-next 1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS.
2025-08-13 1:02 ` Jakub Kicinski
@ 2025-08-13 5:33 ` Kuniyuki Iwashima
0 siblings, 0 replies; 8+ messages in thread
From: Kuniyuki Iwashima @ 2025-08-13 5:33 UTC (permalink / raw)
To: Jakub Kicinski
Cc: David S. Miller, Eric Dumazet, Paolo Abeni, Simon Horman,
Kuniyuki Iwashima, netdev
On Tue, Aug 12, 2025 at 6:02 PM Jakub Kicinski <kuba@kernel.org> wrote:
>
> On Mon, 11 Aug 2025 21:53:04 +0000 Kuniyuki Iwashima wrote:
> > -Wall and -Wflex-array-member-not-at-end caught some warnings that
> > will be fixed in later patches.
>
> Makes sense to enable the warnings first when writing the patches,
> but I think we should commit in the opposite order. Fixes fix then
> arm the warnings. I'll reorder when applying.
Exactly, thank you Jakub!
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-08-13 5:33 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-11 21:53 [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 1/4] selftest: af_unix: Add -Wall and -Wflex-array-member-not-at-end to CFLAGS Kuniyuki Iwashima
2025-08-13 1:02 ` Jakub Kicinski
2025-08-13 5:33 ` Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 2/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_inq.c Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 3/4] selftest: af_unix: Silence -Wflex-array-member-not-at-end warning for scm_rights.c Kuniyuki Iwashima
2025-08-11 21:53 ` [PATCH v1 net-next 4/4] selftest: af_unix: Silence -Wall warning for scm_pid.c Kuniyuki Iwashima
2025-08-13 1:10 ` [PATCH v1 net-next 0/4] selftest: af_unix: Enable -Wall and -Wflex-array-member-not-at-end patchwork-bot+netdevbpf
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).