Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp996238iob; Fri, 13 May 2022 19:01:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFx+xMhSNXTJYEwOqlZMM0xMMLLK3zQ219UEe4LQJdN1NvGsym+Gi3vSh+izOouXE5NFJa X-Received: by 2002:a5d:498d:0:b0:20a:dc6b:35c9 with SMTP id r13-20020a5d498d000000b0020adc6b35c9mr6048477wrq.176.1652493697568; Fri, 13 May 2022 19:01:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652493697; cv=none; d=google.com; s=arc-20160816; b=GFmaP3D4QNo1WQkZJlGmVbuMY4bk4DpZc3lvt4FhQ3gOLsCsdNl9EcIcwDI5MhZ8/v 4dP91NbRDbeGK9oFAxuu/itO2VbjMOPUCjQlv0rxP4FBNEx4WgqjXR8BaxTuG4qBmPFw pgTxsFsuR8zlvbl4jYrrXxWxGOP2qqCFJnVIS6NQuTJtmn6ZmxrCTlg/w5JEjFMoJeNZ m/OIB+UDTMbkiRXcG1dTHsjqEtl8VSyST3seU0DGklSoBC4GKO/TKzAUY9IsXIYTkYeM 8T37mmGdNlzqLeLl7Jv1ON2+JeW4WdUf6C5SAaGEgDqZtgZEny1rX4LlhfeuMhzbv9ka 5MaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=tJUoH32r2DhYogH9Td6X47AQDJfM19sTpFtOpSyDiTg=; b=uSn329tBC3V1sdQZZmyW4o8IAc1VUedSccctaatzIZhklxmMAT+TUYEUyUaNMu+Jq6 JJYSbPRqY5eGhMnW1Bg1wSjEJ72OGn+Xd6JPJDN3aSaJ7FY3h0uVubGWo50AEK0c25dd DaSECZIHPdXF7OH62C3xT4ftCnRqf2rY63zrdrRes7NVgytK4wsv+7VuMpP2kdDFaKH3 Zy5XvuFWD8kOJlVXwWpELInwgLrMnlFgTF2GRa4UmW0Nkdf1nmmaNhzuAPOLYt9Og6Hj w4ZZgJ9yuC5WJ1ShmQ/xafSV3ehFPd1B/6mYOsPjt/ImHLBlvkZFJZmgAK+CyUisML6A YK4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quicinc.com header.s=qcdkim header.b=xJNFQx4a; 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=NONE sp=NONE dis=NONE) header.from=quicinc.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id c4-20020a5d4f04000000b0020ace36394dsi3796358wru.230.2022.05.13.19.01.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 May 2022 19:01:37 -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=@quicinc.com header.s=qcdkim header.b=xJNFQx4a; 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=NONE sp=NONE dis=NONE) header.from=quicinc.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 97AA3476CDD; Fri, 13 May 2022 17:23:25 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347234AbiEKTvs (ORCPT + 99 others); Wed, 11 May 2022 15:51:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347313AbiEKTvm (ORCPT ); Wed, 11 May 2022 15:51:42 -0400 Received: from alexa-out-sd-01.qualcomm.com (alexa-out-sd-01.qualcomm.com [199.106.114.38]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6196655340; Wed, 11 May 2022 12:51:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; i=@quicinc.com; q=dns/txt; s=qcdkim; t=1652298699; x=1683834699; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=tJUoH32r2DhYogH9Td6X47AQDJfM19sTpFtOpSyDiTg=; b=xJNFQx4anUWODkse2PIp4TXEzmu5fCpfF/pOUoH6JRC+a01WEBpL2mAu mG9LIfKRCCSWQU0Jn2gm+H9BD5PdyiZSx8LswtDJvPV/cB/sHjDtaLYVn YajV+PiTZgLc+5qlcRxrJvD0HC0LwGtFfYZsjtNw0kBaRuyFbwv2ndKOP 4=; Received: from unknown (HELO ironmsg03-sd.qualcomm.com) ([10.53.140.143]) by alexa-out-sd-01.qualcomm.com with ESMTP; 11 May 2022 12:51:39 -0700 X-QCInternal: smtphost Received: from nasanex01c.na.qualcomm.com ([10.47.97.222]) by ironmsg03-sd.qualcomm.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 11 May 2022 12:51:38 -0700 Received: from nalasex01a.na.qualcomm.com (10.47.209.196) by nasanex01c.na.qualcomm.com (10.47.97.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 11 May 2022 12:51:38 -0700 Received: from [10.110.84.131] (10.80.80.8) by nalasex01a.na.qualcomm.com (10.47.209.196) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Wed, 11 May 2022 12:51:37 -0700 Message-ID: <8babc23b-5e24-f662-6c4a-eb1c30e0e6da@quicinc.com> Date: Wed, 11 May 2022 12:51:36 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: [PATCH v4 03/14] modpost: split the section mismatch checks into section-check.c Content-Language: en-US To: Masahiro Yamada , Nick Desaulniers 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 References: <20220508190631.2386038-1-masahiroy@kernel.org> <20220508190631.2386038-4-masahiroy@kernel.org> From: Jeff Johnson In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.80.80.8] X-ClientProxiedBy: nasanex01a.na.qualcomm.com (10.52.223.231) To nalasex01a.na.qualcomm.com (10.47.209.196) X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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)