[next] bcachefs: Use DECLARE_FLEX_ARRAY() helper and fix multiple -Warray-bounds warnings
Message ID | ZUloNt0HSulJgZNH@work |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp2964039vqu; Mon, 6 Nov 2023 14:27:25 -0800 (PST) X-Google-Smtp-Source: AGHT+IFPrFraODCAXc4UvjXv+u3EBk7bj4iudFVM2qXxy0jRYZhJBYCDikCCu3uRWTqVe+SXs+S3 X-Received: by 2002:a17:902:d306:b0:1c9:fdf0:f69 with SMTP id b6-20020a170902d30600b001c9fdf00f69mr28220053plc.63.1699309645666; Mon, 06 Nov 2023 14:27:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699309645; cv=none; d=google.com; s=arc-20160816; b=hr23YreByuyXx0no/XfQfe070MCmVnbFoNdXJOFzTSdjNVDWAmnIIlxZCAR6LxrHN2 LI6tFqQLPoJjegioN4gKaU2SMbP39NbaHtIsbIZtrtH3gGrEZ0faxKlCI5YL4aJyoLwr BYG58AjAJMsPloqDEQlK43+FMQCEpomIrpTG1dQSUOL1HicDp/02aYo4rhfwy4bvL/aq rCd4OjFluKNZfpgwNDpPnPUETNyncClWbMCgroJmEqOYTp5G1x0XSFG3qCbo0hvHc7hx zItrxeEBDJ1UPHeQxVkULnRs/r/JudYq6Mll/iy6yQIDNI6yWm+E6W6cC7v2lPqXL7JV +QJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=jvCMqxtPP4wRPE5J3j+8+Lfz8PVyM9K7jyMYcihDh04=; fh=a9DUR2BkWEeP0cACbiaI2xwcDvDVC/gt15O7/cIFKdk=; b=mETx58KV6L+E7VqepiGoNfFJtU32qKe7icVfM7ZoVhJrRmxGZe3+asDk1nhadoiPhD 6u2afCLy7e8coCEdbbVZg9VP7ZzZhbGI9Ttbp2A1mFodp2fUsKTVfhJKmIFBv6kF4zbU CqTp8v+qjZss7WRx30LRkETkAgasFLr5DATpQUuzP46DYrwawmNIh66i9TesLbcEEvJk 7Zo0DvWpCgP4Mine49MJC1IFkJ9CmoccLLVzLD3GQUomI2sgsrJRhG5AB/9xRdN9rOJQ BbXZBfi7GtreMjfsYmvvzfCrJKSfKo89+fRKwMsFubwDz8nJiDBIFenWTsv+s5Ovd9P3 ShkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LJNtc0SC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id kv16-20020a17090328d000b001ca000e889bsi8994865plb.175.2023.11.06.14.27.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 14:27:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LJNtc0SC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 9B7DD80A9ABF; Mon, 6 Nov 2023 14:27:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233215AbjKFW1K (ORCPT <rfc822;lhua1029@gmail.com> + 34 others); Mon, 6 Nov 2023 17:27:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232005AbjKFW1K (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 6 Nov 2023 17:27:10 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1ABDAD71; Mon, 6 Nov 2023 14:27:06 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0E783C433C8; Mon, 6 Nov 2023 22:27:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699309625; bh=OsFOBVxFJvsI/uYfcFoJ/iuijJol3ip7nWPD89kIj7w=; h=Date:From:To:Cc:Subject:From; b=LJNtc0SCBRgrlXe9i7WinH43s6BN62vqpq0jBsRmbjYjUQ10dmyFxffqoAkOPTujA x9KpU3bL4vQxmAna3pwHcrNu4HyqNKvCBuZATQPM/zJdE8RhfVVKfsmdRxyprCCIwW zpUCgsSkexes4U7+l8Ws3DkuMD16cA+R/ddC14mmV8j9xLCH8ed/6DZOgQUgVpS169 RJPGeVn3NuceU8OKi1EnDMszJ3YqD5Zxd2zu5hP+/hv1T94Jb6YIVEKuFYD/5NuCZg DcdWRXPRY7Iigop7zvgsz1pv3Z3uScg25tF52dNbpLk1QtA5Kjg6qpkBaQ32j8CVLr KSlPEjWXmQEiQ== Date: Mon, 6 Nov 2023 16:27:02 -0600 From: "Gustavo A. R. Silva" <gustavoars@kernel.org> To: Kent Overstreet <kent.overstreet@linux.dev>, Brian Foster <bfoster@redhat.com> Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" <gustavoars@kernel.org>, linux-hardening@vger.kernel.org Subject: [PATCH][next] bcachefs: Use DECLARE_FLEX_ARRAY() helper and fix multiple -Warray-bounds warnings Message-ID: <ZUloNt0HSulJgZNH@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Mon, 06 Nov 2023 14:27:23 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781855310694935474 X-GMAIL-MSGID: 1781855310694935474 |
Series |
[next] bcachefs: Use DECLARE_FLEX_ARRAY() helper and fix multiple -Warray-bounds warnings
|
|
Commit Message
Gustavo A. R. Silva
Nov. 6, 2023, 10:27 p.m. UTC
Transform zero-length array `s` into a proper flexible-array
member in `struct snapshot_table` via the DECLARE_FLEX_ARRAY()
helper; and fix tons of the following -Warray-bounds warnings:
fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=]
fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=]
fs/bcachefs/snapshot.c:135:70: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=]
fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=]
fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=]
fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=]
This helps with the ongoing efforts to globally enable -Warray-bounds.
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
fs/bcachefs/subvolume_types.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Mon, Nov 06, 2023 at 04:27:02PM -0600, Gustavo A. R. Silva wrote: > Transform zero-length array `s` into a proper flexible-array > member in `struct snapshot_table` via the DECLARE_FLEX_ARRAY() > helper; and fix tons of the following -Warray-bounds warnings: > > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.c:135:70: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > > This helps with the ongoing efforts to globally enable -Warray-bounds. > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> > --- > fs/bcachefs/subvolume_types.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/bcachefs/subvolume_types.h b/fs/bcachefs/subvolume_types.h > index 86833445af20..2d2e66a4e468 100644 > --- a/fs/bcachefs/subvolume_types.h > +++ b/fs/bcachefs/subvolume_types.h > @@ -20,7 +20,7 @@ struct snapshot_t { > }; > > struct snapshot_table { > - struct snapshot_t s[0]; > + DECLARE_FLEX_ARRAY(struct snapshot_t, s); > }; Yup, this is the current way forward for 0-to-flex transformations in unions or alone in structs (until it's supported correctly by GCC and Clang, which is in progress). Reviewed-by: Kees Cook <keescook@chromium.org> -Kees
On Mon, Nov 06, 2023 at 04:27:02PM -0600, Gustavo A. R. Silva wrote: > Transform zero-length array `s` into a proper flexible-array > member in `struct snapshot_table` via the DECLARE_FLEX_ARRAY() > helper; and fix tons of the following -Warray-bounds warnings: > > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.c:135:70: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > fs/bcachefs/snapshot.h:36:21: warning: array subscript <unknown> is outside array bounds of 'struct snapshot_t[0]' [-Warray-bounds=] > > This helps with the ongoing efforts to globally enable -Warray-bounds. > > Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Thanks, applied
diff --git a/fs/bcachefs/subvolume_types.h b/fs/bcachefs/subvolume_types.h index 86833445af20..2d2e66a4e468 100644 --- a/fs/bcachefs/subvolume_types.h +++ b/fs/bcachefs/subvolume_types.h @@ -20,7 +20,7 @@ struct snapshot_t { }; struct snapshot_table { - struct snapshot_t s[0]; + DECLARE_FLEX_ARRAY(struct snapshot_t, s); }; typedef struct {