Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp2088036ioo; Mon, 23 May 2022 09:48:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXcsXJ6afyfdgVz9aSKGzIppjlQYz03mSjF53WoLZMdGWBTw5HyfPqkrLSpCh3JJepugf0 X-Received: by 2002:a17:902:cf0c:b0:15b:63a4:9f47 with SMTP id i12-20020a170902cf0c00b0015b63a49f47mr23275414plg.1.1653324532389; Mon, 23 May 2022 09:48:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653324532; cv=none; d=google.com; s=arc-20160816; b=I/Wh18QR8Ry4jA41zH5TWBXbS77dqSxIuAaakhjUGQefv/euGHzcRt1TDhSWh8+GR4 Zwv09uKzGUxyp2qRF60tY4xZ9oHSWiNzwyZ5iWaeroF+To1e+BUzSFLupY+MZeP0GMfS jeHa7jmsCxUEb3jUPzAc3S98HalCwsbylh+PZ+t+D14s9rqO/41gjhhO52EcZIc054fA nJrISIlbGovii53VgbocsSLs4e6FAOPv5FVwYVrqSC+4zhZZhCfwTzjgLDvvk7/0PHSH i2zzgI8eyewyhu6ZqHXkHNr3OdfYcLDbrwJyHMMTDmzL++/3Jsvz0TSBbMMZKBebp4Si 9JLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=OPPqcQX7KRBrP4YgLtPFe5APY9NxrEXk3WDczoy7XFA=; b=sC3421gBSAg2d5OM1a7mBB5FkjsheAlNSwvLH1xOoooMJleH15J2h0/sdsREoBmpKa TPEoNSFgQN+0+U5dnBWeb+dwwEDnqBZs0rAjJEWjYzTaCmh29Av4xCaxatTQcepIKqSS AmIZBnfn5KdK75892cPAJQ6ftRVc87RulGiENmEjlvkdRpXcXbf+oMOzmmnO1ykn9K/h 82/Ha0+RyB4bij4VYJ2c+VhlOHz7wIbiQ6OGiSuqZC/PM6+WdTsAnMaf8VyEHTnIsaW0 onJV67FuHwItHLrZD5P3P0C45warKR+KAikuYRI1VdRnRTWFikmuOSxcpa3zOxc8R3A8 pmcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KXobn1tM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id q3-20020a170902eb8300b0016174b91bb5si9623620plg.341.2022.05.23.09.48.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 May 2022 09:48:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=KXobn1tM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 8909135254; Mon, 23 May 2022 09:48:45 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239162AbiEWQsg (ORCPT + 99 others); Mon, 23 May 2022 12:48:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58242 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238868AbiEWQsf (ORCPT ); Mon, 23 May 2022 12:48:35 -0400 Received: from conuserg-09.nifty.com (conuserg-09.nifty.com [210.131.2.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F280D64711; Mon, 23 May 2022 09:48:28 -0700 (PDT) Received: from grover.sesame (133-32-177-133.west.xps.vectant.ne.jp [133.32.177.133]) (authenticated) by conuserg-09.nifty.com with ESMTP id 24NGlJD3027017; Tue, 24 May 2022 01:47:21 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-09.nifty.com 24NGlJD3027017 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1653324442; bh=OPPqcQX7KRBrP4YgLtPFe5APY9NxrEXk3WDczoy7XFA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KXobn1tM1jO44veJR9t6DyZzix/Smavyiyz/0ke8gujtlblK2LG98W2h97RT36vGc K2lxPHqfZqv1gjnr6Jreae4moShUp+H0IRyE/YblJzFBFHavCF+S39CrnA8oSiA/56 YXxJLJC8oCWV9ncTyfFwX9eqXW1grGGvmiyBJ3sd7j6Xh5MjSqtRMOOgQeyfKfxB+B TBsx4GVKQa8SAXNnLY16QsK+oEdTDAKtxcQat/RduDumC+PH2KadmJWcuO1TBGj2IB 6dWRdBiYh/nzCeDlIRGpA2f3oMjtewPtZ84ywRmw4HJk6WkQrx+e8CgKKCur24mPeA vEp7aGJ3/Hxdw== X-Nifty-SrcIP: [133.32.177.133] From: Masahiro Yamada To: linux-kbuild@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Masahiro Yamada , Michal Marek , Nick Desaulniers Subject: [PATCH 4/5] modpost: reuse ARRAY_SIZE() macro for section_mismatch() Date: Tue, 24 May 2022 01:46:25 +0900 Message-Id: <20220523164626.858340-4-masahiroy@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220523164626.858340-1-masahiroy@kernel.org> References: <20220523164626.858340-1-masahiroy@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Move ARRAY_SIZE() from file2alias.c to modpost.h to reuse it in section_mismatch(). Also, move the variable 'check' inside the for-loop. Signed-off-by: Masahiro Yamada --- scripts/mod/file2alias.c | 2 -- scripts/mod/modpost.c | 7 +++---- scripts/mod/modpost.h | 3 +++ 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 5258247d78ac..e8a9c6816fec 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -734,8 +734,6 @@ static int do_vio_entry(const char *filename, void *symval, return 1; } -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) - static void do_input(char *alias, kernel_ulong_t *arr, unsigned int min, unsigned int max) { diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 77c315dea1a3..48a18b59f908 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1049,8 +1049,6 @@ static const struct sectioncheck *section_mismatch( const char *fromsec, const char *tosec) { int i; - int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck); - const struct sectioncheck *check = §ioncheck[0]; /* * The target section could be the SHT_NUL section when we're @@ -1061,14 +1059,15 @@ static const struct sectioncheck *section_mismatch( if (*tosec == '\0') return NULL; - for (i = 0; i < elems; i++) { + for (i = 0; i < ARRAY_SIZE(sectioncheck); i++) { + const struct sectioncheck *check = §ioncheck[i]; + if (match(fromsec, check->fromsec)) { if (check->bad_tosec[0] && match(tosec, check->bad_tosec)) return check; if (check->good_tosec[0] && !match(tosec, check->good_tosec)) return check; } - check++; } return NULL; } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index d9daeff07b83..044bdfb894b7 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -97,6 +97,9 @@ static inline void __endian(const void *src, void *dest, unsigned int size) #endif #define NOFAIL(ptr) do_nofail((ptr), #ptr) + +#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) + void *do_nofail(void *ptr, const char *expr); struct buffer { -- 2.32.0