b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: Simon Wunderlich <sw@simonwunderlich.de>
To: kuba@kernel.org, davem@davemloft.net
Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org,
	Sven Eckelmann <sven@narfation.org>,
	Simon Wunderlich <sw@simonwunderlich.de>
Subject: [PATCH 3/4] batman-adv: Avoid sizeof on flexible structure
Date: Tue,  2 Feb 2021 18:40:35 +0100	[thread overview]
Message-ID: <20210202174037.7081-4-sw@simonwunderlich.de> (raw)
In-Reply-To: <20210202174037.7081-1-sw@simonwunderlich.de>

From: Sven Eckelmann <sven@narfation.org>

The batadv_dhcp_packet is used to read in parts of the DHCP packet and
extract relevant information for the distributed arp table. But the
structure contained the flexible member "options" which is no where used in
the code.

A sizeof on this kind of type would return the size of everything except
the flexible member. But sparse will detect this kind of sizeof and warn
with

  warning: using sizeof on a flexible structure

This can be avoided by dropping the unused flexible member.

Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c
index 443682a95af2..61a6cfef2742 100644
--- a/net/batman-adv/distributed-arp-table.c
+++ b/net/batman-adv/distributed-arp-table.c
@@ -87,7 +87,7 @@ struct batadv_dhcp_packet {
 	__u8 sname[64];
 	__u8 file[128];
 	__be32 magic;
-	__u8 options[];
+	/* __u8 options[]; */
 };
 
 #define BATADV_DHCP_YIADDR_LEN sizeof(((struct batadv_dhcp_packet *)0)->yiaddr)
-- 
2.20.1


  parent reply	other threads:[~2021-02-02 17:40 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-02 17:40 [PATCH 0/4] pull request for net-next: batman-adv 2021-02-02 Simon Wunderlich
2021-02-02 17:40 ` [PATCH 1/4] batman-adv: Start new development cycle Simon Wunderlich
2021-02-04  0:33   ` Jakub Kicinski
2021-02-04  7:41     ` Sven Eckelmann
2021-02-02 17:40 ` [PATCH 2/4] batman-adv: Update copyright years for 2021 Simon Wunderlich
2021-02-04  0:35   ` Jakub Kicinski
2021-02-04  0:37     ` Randy Dunlap
2021-02-04  7:54     ` Sven Eckelmann
2021-02-04 19:58       ` Jakub Kicinski
2021-02-05  7:47         ` Sven Eckelmann
2021-02-05 19:37           ` Jakub Kicinski
2021-02-02 17:40 ` Simon Wunderlich [this message]
2021-02-02 17:40 ` [PATCH 4/4] batman-adv: Fix names for kernel-doc blocks Simon Wunderlich
2021-02-08 16:59 [PATCH 0/4] pull request for net-next: batman-adv 2021-02-08 Simon Wunderlich
2021-02-08 16:59 ` [PATCH 3/4] batman-adv: Avoid sizeof on flexible structure Simon Wunderlich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210202174037.7081-4-sw@simonwunderlich.de \
    --to=sw@simonwunderlich.de \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sven@narfation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).