From patchwork Thu Jun 22 23:43:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 13289902 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 E1685EB64DA for ; Thu, 22 Jun 2023 23:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231518AbjFVXnE (ORCPT ); Thu, 22 Jun 2023 19:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbjFVXnE (ORCPT ); Thu, 22 Jun 2023 19:43:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD2542121; Thu, 22 Jun 2023 16:43:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 650D661710; Thu, 22 Jun 2023 23:43:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1D7A8C433C8; Thu, 22 Jun 2023 23:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687477381; bh=XiHdQW2COChuhdW8/pHNZiGOCWZC/cyIHQHJxwAaX/w=; h=Date:From:To:Cc:Subject:From; b=XPuPi2nRjJ1ZKqb8yiXgAFJRBNAh6RfTKlUPPDka5LPaOpshTka603rNJuU+b4y2m ljolB9PryWxis7ZnW5nFJaw1HMfbgeSkAwDA3Sa0K6OO8pXiGYyrsq5zsJRcGPc4Vn 6h6aPvzWpPKlfR7i50bq7i9w4l0//9U0t1ROgvG/91lJQ8UwSe+TvN/oUVesRG9lHN 0lcoLWBGCaqJi+DQ1Cd7F/I8UL4pOvv8pI/1rllpFNr5UHMHmlk5x78DUkVtiioOix OyJK4eEnRv3RVNEyD2V08kzKG//OH42lrGCImJxknwqypnT75CzHyECwtT+aFYDaOl rpGcJXJg2iKVw== Date: Thu, 22 Jun 2023 17:43:57 -0600 From: "Gustavo A. R. Silva" To: "Maciej W. Rozycki" , Thomas Bogendoerfer Cc: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" , linux-hardening@vger.kernel.org Subject: [PATCH][next] MIPS: dec: prom: Address -Warray-bounds warning Message-ID: MIME-Version: 1.0 Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org Zero-length arrays are deprecated, and we are replacing them with flexible array members instead. So, replace zero-length array with flexible-array member in struct memmap. Address the following warning found after building (with GCC-13) mips64 with decstation_64_defconfig: In function 'rex_setup_memory_region', inlined from 'prom_meminit' at arch/mips/dec/prom/memory.c:91:3: arch/mips/dec/prom/memory.c:72:31: error: array subscript i is outside array bounds of 'unsigned char[0]' [-Werror=array-bounds=] 72 | if (bm->bitmap[i] == 0xff) | ~~~~~~~~~~^~~ In file included from arch/mips/dec/prom/memory.c:16: ./arch/mips/include/asm/dec/prom.h: In function 'prom_meminit': ./arch/mips/include/asm/dec/prom.h:73:23: note: while referencing 'bitmap' 73 | unsigned char bitmap[0]; This helps with the ongoing efforts to globally enable -Warray-bounds. This results in no differences in binary output. Link: https://github.com/KSPP/linux/issues/79 Link: https://github.com/KSPP/linux/issues/323 Signed-off-by: Gustavo A. R. Silva Acked-by: Maciej W. Rozycki --- arch/mips/include/asm/dec/prom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/include/asm/dec/prom.h b/arch/mips/include/asm/dec/prom.h index 1e1247add1cf..908e96e3a311 100644 --- a/arch/mips/include/asm/dec/prom.h +++ b/arch/mips/include/asm/dec/prom.h @@ -70,7 +70,7 @@ static inline bool prom_is_rex(u32 magic) */ typedef struct { int pagesize; - unsigned char bitmap[0]; + unsigned char bitmap[]; } memmap;