Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp241543ioo; Thu, 26 May 2022 02:37:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYD/4L4iZ1/qGBrOSYdsYCDowFKDKZ51wT8kffO8AaBBpb1b9MSDWQBdNcxYqNaV/lHPgl X-Received: by 2002:a05:6402:42c6:b0:42b:32e5:da26 with SMTP id i6-20020a05640242c600b0042b32e5da26mr30298879edc.64.1653557846318; Thu, 26 May 2022 02:37:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653557846; cv=none; d=google.com; s=arc-20160816; b=sniaY8s9AjK9ufno2mAR8u4fZcKNPEZp/yJjT+Jg+qjoh70nmA9hRWzNd0Ie3um4/0 wgx0kn0gvtMOcC72nHkU1bI1bB67WFX4qCKq95zSOy+onUrxbBuVFRdRwF/FTqC3Ry1I NiNsELIq9tnz6jIYdr3uUaltXno1ARyruXnv+7CkOXvUVmtb8vHpfAhSNH51/qviOVN+ IBS0Wj4dsvwZXbPzGIUHEOp+Ch2587OV8aKkzz22OkL0Beai/xv1BsXziwXluWvpxxnL +xxHIvAS+rYh1dxZommPv6i8wlvis8QwV8EQRPeG8feaU5kFcYkXF2UXEOAHezgTzOfp rlug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=xu6EHDS01LsOIawXUSDVH/r2oXuTsWqPdMuqTq7O8gE=; b=vVtFF4BjdIg+1A1fqhaxec1UpTu738NpcREquHSMZgsGiGSXpwv+bbr1fAI9vaawyj xmpODDDt9s7OchTgePtx3ch3c1A+IlLHd2SExmiBBrRVHzl2oGzLvVon8z7stiuXQLeD j3X64+SB+1XoNA4OopiFU9cZ4GmsmSQgoaJKZFspY+1ttwzQaXg7eUUMbk0u7Wdf6bHP c08oTRgSJ5yr+giRV80x5DDLoEY/LtE6MzX6mTjTM4+sRwakOtrA4PTa2jUWAgkDppHx sLO9rxIeOkkoTfoLKkJoOLLsrEXdWO8oOlcUrBIPjrY5BXbfsYjIi/8TC+F4iZ47I414 mr6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Z2hxmeMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r12-20020a50d68c000000b0042ab4eebd42si952207edi.112.2022.05.26.02.37.00; Thu, 26 May 2022 02:37:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Z2hxmeMr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241720AbiEXUuJ (ORCPT + 99 others); Tue, 24 May 2022 16:50:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239028AbiEXUuH (ORCPT ); Tue, 24 May 2022 16:50:07 -0400 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B041737A0 for ; Tue, 24 May 2022 13:50:06 -0700 (PDT) Received: by mail-lf1-x12a.google.com with SMTP id w14so32760944lfl.13 for ; Tue, 24 May 2022 13:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xu6EHDS01LsOIawXUSDVH/r2oXuTsWqPdMuqTq7O8gE=; b=Z2hxmeMr7k/9U4EfcQyebztkuf6MneNT2zAKD72w7RpTggD7ZjCpMMA+AG0iEZYZKM nOv7+3nIHvnBr5jgJfjTANm4EXdEmDCo8F/IpMM9lU6y+ts6orITJzVAE8boMr5q+Eoa ByPPQHu+fV51HhIJ8ProKLOEOz2Xtc7SmJo/AGhQGcfaeKUFha4vIjRO+ML3+eEZfL7V q/J83Wecu938JJEhD81Z1yrhLoS8N0dkLwtyvSWexc3D+ObPIISMyWEpfg6lOtYCkh4c aNwCpw7UoT3wICVZZlCRluqnisVWjS5dvL9P6H0hxrfkZk2Z3uD+2bzaO7XMNSuuZ/6C jrSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xu6EHDS01LsOIawXUSDVH/r2oXuTsWqPdMuqTq7O8gE=; b=aDzlALbGo5Zaau97DI4PtiSOYGMZQeFRMleSMXQq2lNAWKhftWSeq3nBL5EQjDSC3f 0+4PxIB8yeD62gqZxbe+a7j/u1a943H5/0hZFmeOX5TnuGhoqFliBNn7rfMfgZBcKB3q eXnWFMBcMNxDjht4NLUM7vv8E2K3Nl+QeGp7H2lNBvINlJJhPZCKhRy84TxJJTJHZJCW jh1o7eqcnz9bKLD/p6UFt5pmK1dWsR1DvponJRAWCTpMjD0m9qzp2deQb1/DzEHuTd6Y 2KpykGrjjUfPPz2xYIjO6ut51yP+nr3u/5Ny894YeEcO25TmVt2HQHUbmQMTvJbBxX8o 9LMQ== X-Gm-Message-State: AOAM533XfXwrgZap4JmhDbHDdz/G/jrEKbbgqqsLqu/jmn8nlNO4q7+t htSnAGafJFy1NAPr3k4ILT1nT6EB5X0in31gDJxT9nZgqvs= X-Received: by 2002:a05:6512:ace:b0:478:9af3:d9cb with SMTP id n14-20020a0565120ace00b004789af3d9cbmr1136279lfu.103.1653425404449; Tue, 24 May 2022 13:50:04 -0700 (PDT) MIME-Version: 1.0 References: <20220523164626.858340-1-masahiroy@kernel.org> <20220523164626.858340-4-masahiroy@kernel.org> In-Reply-To: <20220523164626.858340-4-masahiroy@kernel.org> From: Nick Desaulniers Date: Tue, 24 May 2022 13:49:53 -0700 Message-ID: Subject: Re: [PATCH 4/5] modpost: reuse ARRAY_SIZE() macro for section_mismatch() To: Masahiro Yamada Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Michal Marek Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham 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 On Mon, May 23, 2022 at 9:48 AM Masahiro Yamada wrote: > > 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 Thanks for the patch! Reviewed-by: Nick Desaulniers > --- > > 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 > -- Thanks, ~Nick Desaulniers