From nobody Wed Dec 31 04:51:07 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 C85A7C4332F for ; Tue, 7 Nov 2023 20:55:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235206AbjKGUzT (ORCPT ); Tue, 7 Nov 2023 15:55:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234647AbjKGUzR (ORCPT ); Tue, 7 Nov 2023 15:55:17 -0500 Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABB7A10D4 for ; Tue, 7 Nov 2023 12:55:15 -0800 (PST) From: Sam James To: Josh Poimboeuf , Peter Zijlstra Cc: linux-kernel@vger.kernel.org, Sam James Subject: [PATCH] objtool: Fix calloc call for new -Walloc-size Date: Tue, 7 Nov 2023 20:55:00 +0000 Message-ID: <20231107205504.1470006-1-sam@gentoo.org> X-Mailer: git-send-email 2.42.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org GCC 14 introduces a new -Walloc-size included in -Wextra which errors out like: ``` check.c: In function =E2=80=98cfi_alloc=E2=80=99: check.c:294:33: error: allocation of insufficient size =E2=80=981=E2=80=99 = for type =E2=80=98struct cfi_state=E2=80=99 with size =E2=80=98320=E2=80=99= [-Werror=3Dalloc-size] 294 | struct cfi_state *cfi =3D calloc(sizeof(struct cfi_state), = 1); | ^~~~~~ ``` The calloc prototype is: ``` void *calloc(size_t nmemb, size_t size); ``` So, just swap the number of members and size arguments to match the prototy= pe, as we're initialising 1 struct of size `sizeof(struct ...)`. GCC then sees we'= re not doing anything wrong. Signed-off-by: Sam James Acked-by: Josh Poimboeuf --- tools/objtool/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/check.c b/tools/objtool/check.c index e94756e09ca9..548ec3cd7c00 100644 --- a/tools/objtool/check.c +++ b/tools/objtool/check.c @@ -291,7 +291,7 @@ static void init_insn_state(struct objtool_file *file, = struct insn_state *state, =20 static struct cfi_state *cfi_alloc(void) { - struct cfi_state *cfi =3D calloc(sizeof(struct cfi_state), 1); + struct cfi_state *cfi =3D calloc(1, sizeof(struct cfi_state)); if (!cfi) { WARN("calloc failed"); exit(1); --=20 2.42.1