From patchwork Sat Oct 7 17:04:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13412429 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 83149E95A64 for ; Sat, 7 Oct 2023 17:05:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344046AbjJGRFD (ORCPT ); Sat, 7 Oct 2023 13:05:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344105AbjJGRFC (ORCPT ); Sat, 7 Oct 2023 13:05:02 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7DB12BA; Sat, 7 Oct 2023 10:05:01 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D892FC433CB; Sat, 7 Oct 2023 17:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696698301; bh=TTLYNPGjyBivwozdoa07Smf/suztpzKvRG2LWS6FNas=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b8HZlTL4Afo59CcwyOtgb4Y93r5LNHEiDZEKyeCjOhuDNWTEokl9GgaNHBDGyQl1m k98Volk7bHlMt8cG0kuf/X3YROh35Oz+RhlBeaNSQvs0X0nifaBb4BxkSA5iNpwmTK 9iW+aoM6iguuZVAIQnuN2KeXyNwMyiaGCWXPNG+Sn/NlT+R4sOQLgIvk6685gIjDdx 63f1dugnXyAhbGubHI/ZKunvbkiuu32lOajBgwSdiDrzzZilDkZDZybvabEJOA5Rnc w/pf5cUTLzYO+89crg7fWJMZBsp5CI260rVEUWjRUaoVlTxz8GdyxUWnty3p5PH4Z6 uocIjpipmOmtQ== From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Nick Desaulniers , Nathan Chancellor , Nicolas Schier Subject: [PATCH 4/5] modpost: refactor check_sec_ref() Date: Sun, 8 Oct 2023 02:04:47 +0900 Message-Id: <20231007170448.505487-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231007170448.505487-1-masahiroy@kernel.org> References: <20231007170448.505487-1-masahiroy@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org We can replace &elf->sechdrs[i] with &sechdrs[i] to slightly shorten the code because we already have the local variable 'sechdrs'. However, defining 'sechdr' instead shortens the code further. Signed-off-by: Masahiro Yamada Reviewed-by: Nick Desaulniers --- scripts/mod/modpost.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 99476a9695c5..441d57ee3275 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1518,16 +1518,17 @@ static void section_rel(struct module *mod, struct elf_info *elf, static void check_sec_ref(struct module *mod, struct elf_info *elf) { int i; - Elf_Shdr *sechdrs = elf->sechdrs; /* Walk through all sections */ for (i = 0; i < elf->num_sections; i++) { - check_section(mod->name, elf, &elf->sechdrs[i]); + Elf_Shdr *sechdr = &elf->sechdrs[i]; + + check_section(mod->name, elf, sechdr); /* We want to process only relocation sections and not .init */ - if (sechdrs[i].sh_type == SHT_RELA) - section_rela(mod, elf, &elf->sechdrs[i]); - else if (sechdrs[i].sh_type == SHT_REL) - section_rel(mod, elf, &elf->sechdrs[i]); + if (sechdr->sh_type == SHT_RELA) + section_rela(mod, elf, sechdr); + else if (sechdr->sh_type == SHT_REL) + section_rel(mod, elf, sechdr); } }