From nobody Wed Dec 31 06:36:40 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C16E2C4167B for ; Mon, 6 Nov 2023 22:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233218AbjKFW1L (ORCPT ); Mon, 6 Nov 2023 17:27:11 -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 ); 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" To: Kent Overstreet , Brian Foster Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] bcachefs: Use DECLARE_FLEX_ARRAY() helper and fix multiple -Warray-bounds warnings Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 is outside= array bounds of 'struct snapshot_t[0]' [-Warray-bounds=3D] fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside= array bounds of 'struct snapshot_t[0]' [-Warray-bounds=3D] fs/bcachefs/snapshot.c:135:70: warning: array subscript is outsid= e array bounds of 'struct snapshot_t[0]' [-Warray-bounds=3D] fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside= array bounds of 'struct snapshot_t[0]' [-Warray-bounds=3D] fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside= array bounds of 'struct snapshot_t[0]' [-Warray-bounds=3D] fs/bcachefs/snapshot.h:36:21: warning: array subscript is outside= array bounds of 'struct snapshot_t[0]' [-Warray-bounds=3D] This helps with the ongoing efforts to globally enable -Warray-bounds. Signed-off-by: Gustavo A. R. Silva Reviewed-by: Kees Cook --- 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 { }; =20 struct snapshot_table { - struct snapshot_t s[0]; + DECLARE_FLEX_ARRAY(struct snapshot_t, s); }; =20 typedef struct { --=20 2.34.1