Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2072642rdb; Sun, 3 Dec 2023 01:03:59 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOo7aslFy8emZm09RVzNQRsamqmB1WMsAr5J5EEDTEprOMCDeCnDw6QT2+DLInM6ltREo6 X-Received: by 2002:a05:6808:1817:b0:3b8:b67f:b7d4 with SMTP id bh23-20020a056808181700b003b8b67fb7d4mr1338496oib.68.1701594239607; Sun, 03 Dec 2023 01:03:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701594239; cv=none; d=google.com; s=arc-20160816; b=aRqF90asnslTQjsYe3/jbB+Rx5yXLejkgATGWjkfZya/98rEmseZv6uJzqec0S3foO 939LX4wY38PrsDujf8pgH53sxOgYU0sxmfM0qP+0yRLYwzENJuT3BgfQafEhCPcmMsbW F3SDsaEA5uTIr+HjkNuzhitDUISqYX/ZGqnvaZ40SdXxgCkBI9TG2MsR8KJ99w4qvvR3 2WovzAfHlSeI4DtowhlGsu9TQkMSJJVpTnCcQj5CQ2FZvAv4sQZS3Xz0oIF0BGM2f7An edLb87BshEi8mEiaL0bWKhhfOO67usHeA1hS1NLcPJRMayMOPDcrCwRfLVDDwjXLc67l oPxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=PtFPitjUPYHU/1hndJzWx/EL1tUHJpSEsSs1Axub11E=; fh=06/y6RfblHpEZ/OZHslz7t/HsnMayHlSwkVKNOSAZWw=; b=bz25xOJ0MEueY73r9f9KM91ccA9on9wMovpmiuqI4soY5WfSEQqvhcYWDx2lWubmAD 9h5R+IkoLc6HQq9ksikAjJcGJAe8mbbAjmrd6/cRFXGlI4tQs5Fp+YEjk7Zwe6RaCMaf Pu7Jh6PIVMj+OiVuk603QBkZqYzOFmNE4ztKIb3jDkKLR1p72f3a+EKSD7ikk3LQrJGK hGnlhB+tQuWJ9C3nc631TfO1ITp/kid7j3E8EQy55DFUcTQI46E9yLmSn9DIJODorhkc MT4RoI445IzEfa0+fdrQyixTylIfnASXvvTlvw0SwVi4Hh6YfMZXtFd9eJY+C0ZMevCi VuVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JqlW4Wzz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id 5-20020a630005000000b005bd66bfc256si6181756pga.869.2023.12.03.01.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 01:03:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JqlW4Wzz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id AF29880239AC; Sun, 3 Dec 2023 01:03:56 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233208AbjLCJDm (ORCPT + 99 others); Sun, 3 Dec 2023 04:03:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54646 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229450AbjLCJDm (ORCPT ); Sun, 3 Dec 2023 04:03:42 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 711BACD for ; Sun, 3 Dec 2023 01:03:48 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D46F0C433C9; Sun, 3 Dec 2023 09:03:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701594227; bh=/m4mHtHGOL+crjtJjRxsecSylMbkbNNuLEgBcv9uqug=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JqlW4WzzYiQA8IvJvRyJCoQjfBevizDkHFUMPIL9/3WNjpjhZKlu9GgdEXwasOwub T2A34KhkC/iN4CKEYXdCSH92MBvYeONoB2lFvVd27sDIZJXUC30nTuzCrRVAd4ulsr xDuAKAwzL+CEKxRxsnzAjlceMvVOQR97JDax4J61h9p+rHyrbGm9dndqiqwe57ZPhB RPsF17XTsSaZ0FpMC9cPPjlHH2A//ytpPOjpB3xFXfV1txNqnaO5XwjFAdzBMAn0yZ S+sO+hvbyyoWd5kOT112kjTNP+iOGu/cnCJhPW56gWzj4DBCwm3t7DOlHM4+wfQ0YF 5Pa5Bx36kH0Ig== Received: by mail-oa1-f41.google.com with SMTP id 586e51a60fabf-1f5da5df68eso1820430fac.2; Sun, 03 Dec 2023 01:03:47 -0800 (PST) X-Gm-Message-State: AOJu0Yz/SFYQzt2IhlaDya3Ffx8/2aXRmOZeS37H1cLKaUKJBF54Chfc iQSVcE9G872sOP2SoRDgniKFgOHzJO2LNwXq/zw= X-Received: by 2002:a05:6871:2314:b0:1fb:75b:12fb with SMTP id sf20-20020a056871231400b001fb075b12fbmr2808307oab.77.1701594227210; Sun, 03 Dec 2023 01:03:47 -0800 (PST) MIME-Version: 1.0 References: <20231125103116.797608-1-masahiroy@kernel.org> <20231125103116.797608-3-masahiroy@kernel.org> <20231130003207.GD2513828@dev-arch.thelio-3990X> In-Reply-To: <20231130003207.GD2513828@dev-arch.thelio-3990X> From: Masahiro Yamada Date: Sun, 3 Dec 2023 18:03:10 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 3/3] modpost: move exit(1) for fatal() to modpost.h To: Nathan Chancellor Cc: linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org, Nicolas Schier Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,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 pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Sun, 03 Dec 2023 01:03:56 -0800 (PST) On Thu, Nov 30, 2023 at 9:32=E2=80=AFAM Nathan Chancellor wrote: > > On Sat, Nov 25, 2023 at 07:31:16PM +0900, Masahiro Yamada wrote: > > fatal() never returns, but compilers are not aware of this fact because > > exit(1) is called within the modpost_log() definition. > > > > Move exit(1) to the fatal() macro so that compilers can identify > > unreachable code flows. > > > > Remove the initializer for 'taddr' in section_rel(), as compilers now > > recognize this is not an uninitialized bug. > > > > Signed-off-by: Masahiro Yamada > > While I did not see any warnings when testing, it seems like this patch > should come before patch 2 to avoid any potential problems from dropping > the unreachable code (since the compiler won't be able to infer that > fatal() is __noreturn without this change); doesn't really matter though > so: My eyes spotted 2/3, but I can swap the patch order and rephase the patch description because clang can detect the unreachable code. > Reviewed-by: Nathan Chancellor > > > --- > > > > scripts/mod/modpost.c | 4 +--- > > scripts/mod/modpost.h | 2 +- > > 2 files changed, 2 insertions(+), 4 deletions(-) > > > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > > index 013fc5031bc7..696c583a14ec 100644 > > --- a/scripts/mod/modpost.c > > +++ b/scripts/mod/modpost.c > > @@ -84,8 +84,6 @@ void modpost_log(enum loglevel loglevel, const char *= fmt, ...) > > vfprintf(stderr, fmt, arglist); > > va_end(arglist); > > > > - if (loglevel =3D=3D LOG_FATAL) > > - exit(1); > > if (loglevel =3D=3D LOG_ERROR) > > error_occurred =3D true; > > } > > @@ -1415,7 +1413,7 @@ static void section_rel(struct module *mod, struc= t elf_info *elf, > > > > for (rel =3D start; rel < stop; rel++) { > > Elf_Sym *tsym; > > - Elf_Addr taddr =3D 0, r_offset; > > + Elf_Addr taddr, r_offset; > > unsigned int r_type, r_sym; > > void *loc; > > > > diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h > > index 9fe974dc1a52..aaa67b24775e 100644 > > --- a/scripts/mod/modpost.h > > +++ b/scripts/mod/modpost.h > > @@ -215,4 +215,4 @@ modpost_log(enum loglevel loglevel, const char *fmt= , ...); > > */ > > #define warn(fmt, args...) modpost_log(LOG_WARN, fmt, ##args) > > #define error(fmt, args...) modpost_log(LOG_ERROR, fmt, ##args) > > -#define fatal(fmt, args...) modpost_log(LOG_FATAL, fmt, ##args) > > +#define fatal(fmt, args...) do { modpost_log(LOG_FATAL, fmt, ##args);= exit(1); } while (1) > > -- > > 2.40.1 > > > --=20 Best Regards Masahiro Yamada