Skip to contentSkip to conversation

batman-adv: Avoid sizeof on flexible structure

PATCH New Sven Eckelmann 1 participant 1 message Dec 29, 2020 Batman advanced

lore
Share & tools
lore

Sven Eckelmann

author maintainer
#0 lore raw

PATCH 1/1 batman-adv: Avoid sizeof on flexible structure

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.

---
 net/batman-adv/distributed-arp-table.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/batman-adv/distributed-arp-table.c +1 -1
index fd7ba6bb..d2ec419d 100644
@@ -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)
Signature · 1 line
2.29.2