Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp762632iob; Thu, 12 May 2022 04:15:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+zvA0p8FL68H0pMeYkJ6MxzDb0k4afFvRTrjFkL9XqbWXBP/ueilws6c7zW61ydyP+VGa X-Received: by 2002:a63:2c55:0:b0:3aa:b620:a81 with SMTP id s82-20020a632c55000000b003aab6200a81mr25276617pgs.625.1652354128817; Thu, 12 May 2022 04:15:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652354128; cv=none; d=google.com; s=arc-20160816; b=HENRkyVo9hQQ7inXexUHVrCAf4rJpb99X4KOJEzrxp8hfg+m83d0fE0wtRHTXLbQI2 7fhVnlaYeDc1oYtwlQ8vGugmP+IM5wwgQgNVsA5+sFvGdpDgMBClBHctH2i9zQRmzUQN mKaW3/wV9HjWizaVob5zfgClCfdn4lFaDZt7+s1XubuMrEXrCYYWoe18IVjg8uWXySun QoOz2vWkAZ9vV0DGPUWzGuQCCupZIbGVdToWq02MF4a0KWB9BF4yiRZYa5WMamn10q7D IEfv4bHBI9yXX3lsRphGcIKtgzWBpWcFRg4sEsrHtpntk6q3cYsnFp8zSDDIsA9hR/uw Iwlw== 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=LjOBAquXwgrrgXm8VNOmvziGW6n+WunCBS4qV3JJbEM=; b=DRJC1hLO4WFvi8VedBIKLmIpSfjWVjSyCwSLVbZpRZwM7aIDYPKUCtvVZTbb+JzkcW rOKQ0yVmVAMQLvidAAf+mElPQZaGCZnPM1vQyX4p8fTEdtAMuc3Nf++0xDEjEvwNx5yE k/5aqfS3OOP81CbLvApBPjr3rfR/dlqrfme2ScgECBfRCdTMQy1Bfn2xiUsxClp92k3s 9PMIyywAKvgU7SOzs/9EvYp4DnTVBlXuUPvrKe1x/mM00xKMw4BmOd3biMDjYlkNXV1O 57S9D1znXsmS13oGnP9q2t31giAL3MDx/lv1SxEbFjIOEDETpGzjFN7AvQIZsEV6eMxt aRYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=cA8UQtFo; 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 g7-20020a656cc7000000b003daee299c49si3105280pgw.580.2022.05.12.04.15.16; Thu, 12 May 2022 04:15:28 -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=cA8UQtFo; 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 S1344985AbiEKSsM (ORCPT + 99 others); Wed, 11 May 2022 14:48:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55664 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241219AbiEKSsK (ORCPT ); Wed, 11 May 2022 14:48:10 -0400 Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5719E1A4933 for ; Wed, 11 May 2022 11:48:09 -0700 (PDT) Received: by mail-lf1-x136.google.com with SMTP id j4so5117476lfh.8 for ; Wed, 11 May 2022 11:48:09 -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=LjOBAquXwgrrgXm8VNOmvziGW6n+WunCBS4qV3JJbEM=; b=cA8UQtFoVUliUtfWSv912J6B0ub0HcxW8gmIXite+joZhlMbpeCS+bUAZWYfMzZ8Xa G/fJOfLTcngtIL8G90CQr+73lLbCL1AHxsh2R+qmJrgmJRTCuyNKXj7cliEo28pPuXQj 6w3VaEUFPmnSDKtF91NPiV/sgjc8ZRv71y4uYb9hxeHwZUr5je/pDiqFgm2aSZ7bIISf /1UJjBBsIPYSlsXi1kwAQ99jbSUPR+9P2r7SaKBX1wGFQEJXaWfpYonbpRKCQDD6CxUK Dp+b87CVNCLP2zVCceaShTI1HSRNKEIjVASMSKh/ElRg8CR6aP+J3pZQ1S3J5UZUSIaH 1EZQ== 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=LjOBAquXwgrrgXm8VNOmvziGW6n+WunCBS4qV3JJbEM=; b=INXhJsDSs3oPQXkJp9S6pYCHqOdMajiac4HzhRRX8glf3w916IzwOYGrajxPFn1kHu ZoAfrf+CGou1WjOOsGzX1GMyl8H098mLMYtalNqtqL8Uk14VG5mZSUtcHdnd94zifNMV l+k56XlPXDcUiC/6mLieqYIT6eM8rqiTbxA/0H9oQa/G7A/OwvD5TmFGjD0/W4ObZlzo 7r3CmXU77m57pF/b/sMpvGcIO8n6EXVj5RIuKzh/DnmmN6e1sh8NmoxjncAOZi9Kf3Ao eOU39CrGzrahturaUfh20E/QCfKVYwveKgFiYSZpHeGXZXpXHa6tka/jzb8mgmASZR84 9+rw== X-Gm-Message-State: AOAM531A31JoeS5EnKPhn7kbLWvoNnYc/2t8YSY4nn3tGhQ2KuSVKnUd 329clrlpLawqoytdnW2emS6jgjoLw/l6OKyvaUm76Q== X-Received: by 2002:a05:6512:1d1:b0:471:f63a:b182 with SMTP id f17-20020a05651201d100b00471f63ab182mr20624164lfp.392.1652294887500; Wed, 11 May 2022 11:48:07 -0700 (PDT) MIME-Version: 1.0 References: <20220508190631.2386038-1-masahiroy@kernel.org> <20220508190631.2386038-4-masahiroy@kernel.org> In-Reply-To: From: Nick Desaulniers Date: Wed, 11 May 2022 11:47:56 -0700 Message-ID: Subject: Re: [PATCH v4 03/14] modpost: split the section mismatch checks into section-check.c To: Masahiro Yamada Cc: Linux Kbuild mailing list , Linux Kernel Mailing List , Nathan Chancellor , Nicolas Schier , Peter Zijlstra , linux-modules , linux-s390 , linuxppc-dev , Ard Biesheuvel , Sami Tolvanen , clang-built-linux 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 9, 2022 at 11:57 PM Masahiro Yamada wrote: > > > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > > > index a78b75f0eeb0..e7e2c70a98f5 100644 > > > --- a/scripts/mod/modpost.c > > > +++ b/scripts/mod/modpost.c > > > @@ -31,7 +31,7 @@ static bool external_module; > > > /* Only warn about unresolved symbols */ > > > static bool warn_unresolved; > > > > > > -static int sec_mismatch_count; > > > +int sec_mismatch_count; > > > > ^ this should go in modpost.h if it is to be used in two translation > > units, rather than forward declaring it in section-check.c. You did > > this for the functions. > > > Sorry, I do not understand. > > > In modpost.h, I put the declaration: > > extern int sec_mismatch_count; > > If I moved it to the header without 'extern' > I would get multiple definitions. Yeah, you need to _declare_ it w/ extern in the header, then _define_ it in one source file. That way, if the type ever changes, the sources will agree on type in all source files. You will get a redefinition error if the definition changes the type of the variable since the last declaration. What you're doing is forward declaring, which works, and is a common pattern for (bloated) C++, but is less type safe than sharing a single common declaration between multiple source files via a single common shared header. (Sorry I didn't respond before you sent v5) -- Thanks, ~Nick Desaulniers