From mboxrd@z Thu Jan 1 00:00:00 1970 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=-9.7 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,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 C874FC47247 for ; Thu, 30 Apr 2020 21:33:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ACAA5214D8 for ; Thu, 30 Apr 2020 21:33:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727944AbgD3VdC (ORCPT ); Thu, 30 Apr 2020 17:33:02 -0400 Received: from mout.kundenserver.de ([212.227.126.134]:51723 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727916AbgD3Vc6 (ORCPT ); Thu, 30 Apr 2020 17:32:58 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.129]) with ESMTPA (Nemesis) id 1N4Qbu-1j4WWI3CFi-011OpV; Thu, 30 Apr 2020 23:32:52 +0200 From: Arnd Bergmann To: linux-kernel@vger.kernel.org, Mikulas Patocka Cc: Arnd Bergmann Subject: [PATCH 10/15] hpfs: avoid gcc-10 zero-length-bounds warning Date: Thu, 30 Apr 2020 23:30:52 +0200 Message-Id: <20200430213101.135134-11-arnd@arndb.de> X-Mailer: git-send-email 2.26.0 In-Reply-To: <20200430213101.135134-1-arnd@arndb.de> References: <20200430213101.135134-1-arnd@arndb.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Provags-ID: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aEceUO4JLXvqkeUHK+7 WXfkZrHUcs/toSho+vCgiM6cDMoa2Nkck7K3qKVZSA4goLCKsA= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org gcc-10 now warns about accessing members of a zero-length array field: fs/hpfs/anode.c: In function 'hpfs_add_sector_to_btree': fs/hpfs/anode.c:209:27: error: array subscript 0 is outside the bounds of an interior zero-length array 'struct bplus_internal_node[0]' [-Werror=zero-length-bounds] 209 | anode->btree.u.internal[0].down = cpu_to_le32(a); | ~~~~~~~~~~~~~~~~~~~~~~~^~~ In file included from fs/hpfs/hpfs_fn.h:26, from fs/hpfs/anode.c:10: fs/hpfs/hpfs.h:411:32: note: while referencing 'internal' 411 | struct bplus_internal_node internal[0]; /* (internal) 2-word entries giving | ^~~~~~~~ It would be nice to make it a flexible-array member, but that is not possible inside of a union, so work around the warnings by adding a temporary pointer that hides the problem. Signed-off-by: Arnd Bergmann --- fs/hpfs/anode.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/hpfs/anode.c b/fs/hpfs/anode.c index c14c9a035ee0..55788ca7969f 100644 --- a/fs/hpfs/anode.c +++ b/fs/hpfs/anode.c @@ -200,14 +200,17 @@ secno hpfs_add_sector_to_btree(struct super_block *s, secno node, int fnod, unsi brelse(bh); a = na; if ((new_anode = hpfs_alloc_anode(s, a, &na, &bh))) { + struct bplus_internal_node *internal; + anode = new_anode; /*anode->up = cpu_to_le32(up != -1 ? up : ra);*/ anode->btree.flags |= BP_internal; anode->btree.n_used_nodes = 1; anode->btree.n_free_nodes = 59; anode->btree.first_free = cpu_to_le16(16); - anode->btree.u.internal[0].down = cpu_to_le32(a); - anode->btree.u.internal[0].file_secno = cpu_to_le32(-1); + internal = anode->btree.u.internal; + internal->down = cpu_to_le32(a); + internal->file_secno = cpu_to_le32(-1); mark_buffer_dirty(bh); brelse(bh); if ((anode = hpfs_map_anode(s, a, &bh))) { -- 2.26.0