Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1jHM8t-00081d-RJ for mharc-grub-devel@gnu.org; Thu, 26 Mar 2020 02:37:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51519) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHM8r-00081P-Go for grub-devel@gnu.org; Thu, 26 Mar 2020 02:37:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHM8p-0000PR-3l for grub-devel@gnu.org; Thu, 26 Mar 2020 02:37:24 -0400 Received: from m4a0072g.houston.softwaregrp.com ([15.124.2.130]:50841) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1jHM8o-0000G3-Tm for grub-devel@gnu.org; Thu, 26 Mar 2020 02:37:23 -0400 Received: FROM m4a0072g.houston.softwaregrp.com (15.120.17.147) BY m4a0072g.houston.softwaregrp.com WITH ESMTP; Thu, 26 Mar 2020 06:36:03 +0000 Received: from M9W0068.microfocus.com (2002:f79:bf::f79:bf) by M4W0335.microfocus.com (2002:f78:1193::f78:1193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Thu, 26 Mar 2020 06:35:54 +0000 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (15.124.72.14) by M9W0068.microfocus.com (15.121.0.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10 via Frontend Transport; Thu, 26 Mar 2020 06:35:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fAp9iPgQHd27D7MR5Lh2FmcqDvn14fNE6YFKaKyCRiqv56QgiFdyBNdH0ie+5kvvvU+qKx7qQ4VzCVpXKiowIs9k9vF8VwZuL2LgPfuF/ljDrFSFIJcOWcjWdAI/x+tUUwHyuXAxn6emRnFns57KMZh+jdnDUqtU/HJiwTgXW7Jva0LW5yvFHZxv2hdu443fmryAZkO/TheN/PE/XZI4N6PkzjhmrvF+sOwo1PyFRv/qqk4rW+L0KnImVpVIy2uLDOvMwijabYVilzMQWbribvUGr1dYNlozgRammHxGw4zd0ze5YSRqpnO3QLb81X9UeDivDls1cJY2OeoCBWdMQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DGGluKXKxbChXP9g98OA+H9kpoourKU3AcH1vMbkCF8=; b=nAdJJsZwrPQeBhnHjWTT9lv1WqZKbF76N1gPLJQCzGXVm/2DOuqLscFqb7shVaZpgmKv5JnrnSmUX9b+ieB55kkZrpfpqnKw/awAHssUapY+DdHWEeviQeNOGfGMv6ZB7IpTiqhdFhxtsWu2DSFN2rePLrew2wYd70zioV/vvm4o13/b0A6Op1C6a1xtx5eOO7Ay8qFhrkbN3hN+n1kaNnR9fznQYLhda7Ao9K98eGa5moODUkRXrfTSjvuUgb+5lauJe/rbaM9yutX3EK4lbg78RDT60rs9jRZKWoETq33ccL8kmgd4LNm3hTtUqsOTXmeRwPWKk7W8N+UySRMozQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=suse.com; dmarc=pass action=none header.from=suse.com; dkim=pass header.d=suse.com; arc=none Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=MChang@suse.com; Received: from BY5PR18MB3140.namprd18.prod.outlook.com (2603:10b6:a03:1a1::17) by BY5PR18MB3297.namprd18.prod.outlook.com (2603:10b6:a03:1a1::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.19; Thu, 26 Mar 2020 06:35:52 +0000 Received: from BY5PR18MB3140.namprd18.prod.outlook.com ([fe80::a404:f256:fbe8:c2d]) by BY5PR18MB3140.namprd18.prod.outlook.com ([fe80::a404:f256:fbe8:c2d%4]) with mapi id 15.20.2856.019; Thu, 26 Mar 2020 06:35:51 +0000 From: Michael Chang To: CC: PGNet Dev , Paul Menzel , Daniel Kiper , Thomas Schmitt Subject: [PATCH 1/2] mdraid1x_linux: Fix gcc10 error -Werror=array-bounds Date: Thu, 26 Mar 2020 14:35:34 +0800 Message-ID: <20200326063535.28022-1-mchang@suse.com> X-Mailer: git-send-email 2.16.4 Content-Type: text/plain X-ClientProxiedBy: LO2P265CA0390.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:f::18) To BY5PR18MB3140.namprd18.prod.outlook.com (2603:10b6:a03:1a1::17) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mercury.suse.cz (36.226.146.226) by LO2P265CA0390.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:f::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2856.18 via Frontend Transport; Thu, 26 Mar 2020 06:35:47 +0000 X-Mailer: git-send-email 2.16.4 X-Originating-IP: [36.226.146.226] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 637aba9a-c85a-421b-d491-08d7d14fed12 X-MS-TrafficTypeDiagnostic: BY5PR18MB3297: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-Forefront-PRVS: 0354B4BED2 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4636009)(136003)(396003)(376002)(366004)(39860400002)(346002)(478600001)(6486002)(2906002)(6512007)(316002)(54906003)(52116002)(6506007)(8936002)(8676002)(81166006)(81156014)(36756003)(86362001)(2616005)(26005)(186003)(956004)(16526019)(66476007)(66556008)(6916009)(1076003)(6666004)(5660300002)(4326008)(66946007); DIR:OUT; SFP:1102; SCL:1; SRVR:BY5PR18MB3297; H:BY5PR18MB3140.namprd18.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; Received-SPF: None (protection.outlook.com: suse.com does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BcRSxJeHEjgpggKvBzrAjQd1gKkYD+8BJavLwNVkJeWFeuDdcNTkNM4AMil1rW20cQBosO4xjUE6wPq5jnp8+ZE2OyN+/xUIuxydzxf06g4d5C0pgIr3U5eLTKEYGMAgHFhPDwMPUOAjffawD93rjB66KPmXak26hm/SOZsb/Fzu479IL+NV0Px9BEbEDZ8D6GTESWIxjnljHeLEaalgyCItCc7oyy6Lr0bm/wnHD8eXGP9wUIPXrbnLXqFNmWvpAyl1Pjl2QuDVARKfmGqc2fx0/2EuYo4BsSpz/7Qu3Pa7Vim5fheHTr2f5n8eDQI5ktV7hKWSHoOyv/0Cb7BWNkFb59gTGEe+EhU3sGi0Dmzy15yl5syfMJyVKf3Iwq3gVkUxSR0iMqL+D+8egOuh+hHjtSKKtgorLGii63LoMVzXmA+wbGofT47hwhaswplo X-MS-Exchange-AntiSpam-MessageData: v0KdQgKn7C2w/7LlTjbsPlE5ywx+t+6HM7F4L4U1w6uxauRBRteYHhEHB89RnW7EKTCPgNT/cXzOmBk4Uob5kOg3lUcOhQ+rbZFXJFqS6ro+rkMEmaQLqzrWwEyzikQYCHE+N3tO7qjcAUmIGzunhw== X-MS-Exchange-CrossTenant-Network-Message-Id: 637aba9a-c85a-421b-d491-08d7d14fed12 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Mar 2020 06:35:51.6864 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 856b813c-16e5-49a5-85ec-6f081e13b527 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: f7rasKRjvWngTvLrceTah7AWEek4zcopxV1uzklTeGKcM02viw9eUGsLpyMa1qT4 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR18MB3297 X-OriginatorOrg: suse.com X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 15.124.2.130 X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Mar 2020 06:37:26 -0000 We bumped into the build error while testing gcc-10 pre-release. ../../grub-core/disk/mdraid1x_linux.c: In function 'grub_mdraid_detect': ../../grub-core/disk/mdraid1x_linux.c:181:15: error: array subscript is outside array bounds of 'grub_uint16_t[0]' {aka 'short unsigned int[0]'} [-Werror=array-bounds] 181 | (char *) &sb.dev_roles[grub_le_to_cpu32 (sb.dev_number)] | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../grub-core/disk/mdraid1x_linux.c:98:17: note: while referencing 'dev_roles' 98 | grub_uint16_t dev_roles[0]; /* Role in array, or 0xffff for a spare, or 0xfffe for faulty. */ | ^~~~~~~~~ ../../grub-core/disk/mdraid1x_linux.c:127:33: note: defined here 'sb' 127 | struct grub_raid_super_1x sb; | ^~ cc1: all warnings being treated as errors Apparently gcc issues the warning when trying to access sb.dev_roles array's member, since it is a zero length array as the last element of struct grub_raid_super_1x that is allocated sparsely without extra chunks for the trailing bits, so the warning looks legitimate in this regard. As the whole thing here is doing offset computation, it is undue to use syntax that would imply array member access then take address from it later. Instead we could accomplish the same thing through basic array pointer arithmetic to pacify the warning. Signed-off-by: Michael Chang Reviewed-by: Daniel Kiper --- grub-core/disk/mdraid1x_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/grub-core/disk/mdraid1x_linux.c b/grub-core/disk/mdraid1x_linux.c index 7cc80d3df..c980feba4 100644 --- a/grub-core/disk/mdraid1x_linux.c +++ b/grub-core/disk/mdraid1x_linux.c @@ -178,7 +178,7 @@ grub_mdraid_detect (grub_disk_t disk, return NULL; if (grub_disk_read (disk, sector, - (char *) &sb.dev_roles[grub_le_to_cpu32 (sb.dev_number)] + (char *) (sb.dev_roles + grub_le_to_cpu32 (sb.dev_number)) - (char *) &sb, sizeof (role), &role)) return NULL; -- 2.16.4