Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp973254iob; Fri, 13 May 2022 18:12:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJygmqt0EGafO1J3HAxHTwcoYPVq8lKnTrSSY+qZmP7nk45Zp3Jajy+el4XIM+UaRmi4HG/J X-Received: by 2002:a05:600c:3515:b0:394:8c7e:fbde with SMTP id h21-20020a05600c351500b003948c7efbdemr17002699wmq.165.1652490761676; Fri, 13 May 2022 18:12:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652490761; cv=none; d=google.com; s=arc-20160816; b=f/O1QfNdlkVxfoKOW/8mJ+fPRjvYnVWoe+r6bTeCUsHwfSC9Uv+tCO7DDEy0srGTtf S4JIHtUazl+Y1ysTdz/KO7aUNI9OQuHYwdcDb/O7nTASu57YYqtc1eIgc7ZME2Khg1Zh 4wojDOSdSpbUiJeotfbR7kokKMC6bfCYoeCmmds+L6CuzAiLfbvoGd8MW98ou/DBF46n tu4lQfMPq+RLTX+VwvDpaNpJMvvyhVbldtJnAFA5mdPCPb2hT+X6JiJxe4aWrc+bh3kq FZT2KbEscVgMVeMZ+vC0L1raCwEgwSS2wyQxW7IhZzcO0moyVH+irunJIzSZpERFBjKI UJ+w== 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=aIr7kufHqh1aklBFT48PcfwiGgRwuFks7DI5SiM+9Q0=; b=pA2NbS8xrythEhm2pjc9DzopXu6mqCjedC7Ig73gN4+a/pmKzJH73KDN7lTIgRKF0o MJaC04RyBX1tiBu3iTfpCcsbrrCEt6fLshDprhZzhOzChO+b+kbGJYTy/2UHOT8INmjy VPmdVDEgg3RqSPa/+NPRTOmTiMBiBGFmJzLnS8QGZQSnyGIghrrU2ssQQrkVPQ+sub6+ 3xmmRYf0+rgVXBKXFe3yFBAggb4t0Apn5mwlyrVs/Z+v5JVg/lmUyFx7tzjgBs37BJHI +xj38kicK7UQyi1yGfQfyptdYHpaO64sQWA6fM4phxEi9DHtF+YtQzAJmRdxeN8QVrtq fy7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aDFV+CNg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id b8-20020a056000054800b0020ada1e255asi3890263wrf.400.2022.05.13.18.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 18:12:41 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aDFV+CNg; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3382039E7E6; Fri, 13 May 2022 16:43:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347488AbiEKUBf (ORCPT + 99 others); Wed, 11 May 2022 16:01:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347497AbiEKUBa (ORCPT ); Wed, 11 May 2022 16:01:30 -0400 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47E162311EE for ; Wed, 11 May 2022 13:01:27 -0700 (PDT) Received: by mail-lf1-x134.google.com with SMTP id b18so5404131lfv.9 for ; Wed, 11 May 2022 13:01:27 -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=aIr7kufHqh1aklBFT48PcfwiGgRwuFks7DI5SiM+9Q0=; b=aDFV+CNgCaB8HAuXCMaTOeqfz3Euqlc9UfykqEg/M7trT+lMOcwb6NTqEGZJ7SsVNZ wKPGERgQdDUkJumgL37urxFlDsGkmX7PqdKJaBJZ9MZbdtLV8cQTIpE0yfVn6cMSgZyZ GDcUvdJSKIpdCHdovd/rPOddBCdGdf7Tcs7gNO1JNMXTpaAKmIBz3TFWivhPzhsqWiWP vJ/31TdyTBLQqry7t/YKe6QWlgU/ihp+YfVohSDDCIs1NWIXVc6t8SiZYJv7SQNHxS8u uvm0zjVSH3yCGxEApXJnHd78LwJfVPsGlD2n86/VBo9AQNLgEv62rjfzxd444XLv3wC4 k+Ew== 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=aIr7kufHqh1aklBFT48PcfwiGgRwuFks7DI5SiM+9Q0=; b=zV9A1jAvLxEeixbbJC3QFmiTn3Ny16jP0ziantu6UP9OLiQ6T0N8ZSrl/uu2Iwowt9 Qg0uKBQVacYgtxug4eTakEreK/Moz/ePEOj2G/yjn671b/r1iSdDdRTMmkt4VBGhHhND CEjz13hkz3ohWrF/Z6vdd+iImW8a974kQaeHlMbEYzt/ZCq4WA6853dd4UtogFjneUSV Sr/PubI9rHq+P3oNKnVDcqw2DzxLyuvaNqeQr6CNZz+PMR3ESlblWDewQoV1/rt4UMZe zrBBLE0DOuzTL1Y9oncl+Nlfp2m1IvYxKNJ5K/G3O8ge+mngqvlOdPhI0tUuUucmNixd RNjA== X-Gm-Message-State: AOAM533XL4LrlH9eg6VzqbDzelZo0X0UJZ6t+GonjRHxaAywNWeOv7Ue KiprKGS6ZmhNUMr4QJ9eNJB9TCA8/eR1nrCJo+EO3A== X-Received: by 2002:a19:4303:0:b0:473:f5fb:27b2 with SMTP id q3-20020a194303000000b00473f5fb27b2mr20127658lfa.626.1652299285108; Wed, 11 May 2022 13:01:25 -0700 (PDT) MIME-Version: 1.0 References: <20220508190631.2386038-1-masahiroy@kernel.org> <20220508190631.2386038-4-masahiroy@kernel.org> <8babc23b-5e24-f662-6c4a-eb1c30e0e6da@quicinc.com> In-Reply-To: <8babc23b-5e24-f662-6c4a-eb1c30e0e6da@quicinc.com> From: Nick Desaulniers Date: Wed, 11 May 2022 13:01:13 -0700 Message-ID: Subject: Re: [PATCH v4 03/14] modpost: split the section mismatch checks into section-check.c To: Jeff Johnson Cc: Masahiro Yamada , 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=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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 On Wed, May 11, 2022 at 12:51 PM Jeff Johnson wrote: > > On 5/11/2022 12:27 PM, Masahiro Yamada wrote: > > On Thu, May 12, 2022 at 3:48 AM Nick Desaulniers > > wrote: > >> > >> 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) > > > > Sorry, I still do not understand your suggestion. > > > > > > Could you provide me with a code diff > > showing how to do this better? > > I think you are doing exactly what he's asking for: > declare it with extern in the header (modpost.h change) > define it in one source file (modpost.c change) > Oh! Indeed, sorry, I'm getting lost here in the review. Sorry for the noise then. -- Thanks, ~Nick Desaulniers