From patchwork Tue Feb 2 17:40:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Wunderlich X-Patchwork-Id: 12062461 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3BAAEC433E0 for ; Tue, 2 Feb 2021 17:53:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 09F6664F6F for ; Tue, 2 Feb 2021 17:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238002AbhBBRxG (ORCPT ); Tue, 2 Feb 2021 12:53:06 -0500 Received: from simonwunderlich.de ([79.140.42.25]:33358 "EHLO simonwunderlich.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237871AbhBBRu5 (ORCPT ); Tue, 2 Feb 2021 12:50:57 -0500 Received: from kero.packetmixer.de (p4fd575e2.dip0.t-ipconnect.de [79.213.117.226]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simonwunderlich.de (Postfix) with ESMTPSA id 05440174021; Tue, 2 Feb 2021 18:40:39 +0100 (CET) From: Simon Wunderlich To: kuba@kernel.org, davem@davemloft.net Cc: netdev@vger.kernel.org, b.a.t.m.a.n@lists.open-mesh.org, Sven Eckelmann , Simon Wunderlich Subject: [PATCH 3/4] batman-adv: Avoid sizeof on flexible structure Date: Tue, 2 Feb 2021 18:40:35 +0100 Message-Id: <20210202174037.7081-4-sw@simonwunderlich.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210202174037.7081-1-sw@simonwunderlich.de> References: <20210202174037.7081-1-sw@simonwunderlich.de> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Sven Eckelmann 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 Signed-off-by: Simon Wunderlich --- 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)