Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3543128ybf; Tue, 3 Mar 2020 07:51:04 -0800 (PST) X-Google-Smtp-Source: ADFU+vveBmUvNwBYDeGDB4hCzRiAbPWkc8jWkZPbXzKY7aTmLIa7iDlYzvTrrmcBvrPI58TuAyZv X-Received: by 2002:aca:57ce:: with SMTP id l197mr2908333oib.76.1583250664803; Tue, 03 Mar 2020 07:51:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583250664; cv=none; d=google.com; s=arc-20160816; b=cfAwc74W6dB1XFqwVkroN1i54mqMW8+vvbCJRJB9uaWOXwpk+4NNYKcbAGzaURVYtA J1sRgLEokMovmVsv2yafec9mKGU44Y3BiPUnzZTcpXYA0Jxf1Bzv2K2THZOOtegU/+fX 3zoc+1Sx5vZpvTD3D3aziZ7Y+R+GY3U6CLFND8uWqar/mm/uyQZCWESYP9oWaNUCvmzh QzPn6x+c5Wwy/EBbSdU3nCOZfiNOcO4we2downFo4M5TwoxeG/M44SFMivjk/i7nzQfI zKCWspuSreAHtDOK3EvG0vXjMbblbH19WxhuEOKlqUKuH784AKf7/1e5DNt1d1foEhno F8hA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature:dkim-filter; bh=fHJ6LKpn2NcjSEDGxLEy1LxyGgY1Hobk/cTjUJ8XOKg=; b=iy6ApAvscOdt5YN3XIp8iHd//zvcGYiWByGPauM4cNzgU+7/tpSH+o9lBVRj2qTO2d M02l/srYC3SthrdxGACQ4eKQ3JTrg3fKXTDdtuqKdjbi1hfi29B0sk/LV1AQ5vbOcKdr GBRo+QLKVT+i1aOou4v79c78gVtf8BwL6/fo5ATa3Ez+La65CjgnLXg5xU+uigenDPMF AzjPaFDWwXoyia0mw0r5piQ2kgtFoPsUmDSkETSLOrX3QNlDaoW//q2a9ZeSfFcbyCya Dd3Ht49Hq0PwuAzPUs9Ipqfps2t6e4kqC/mbkLTD58iPe3wEL07575RSdI1E0K8K+1lp vhvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=NCBHrIN3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x7si5891213otp.114.2020.03.03.07.50.52; Tue, 03 Mar 2020 07:51:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nifty.com header.s=dec2015msa header.b=NCBHrIN3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729891AbgCCPYV (ORCPT + 99 others); Tue, 3 Mar 2020 10:24:21 -0500 Received: from conssluserg-02.nifty.com ([210.131.2.81]:58973 "EHLO conssluserg-02.nifty.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725932AbgCCPYV (ORCPT ); Tue, 3 Mar 2020 10:24:21 -0500 Received: from mail-ua1-f41.google.com (mail-ua1-f41.google.com [209.85.222.41]) (authenticated) by conssluserg-02.nifty.com with ESMTP id 023FOAiB018878 for ; Wed, 4 Mar 2020 00:24:10 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conssluserg-02.nifty.com 023FOAiB018878 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1583249050; bh=fHJ6LKpn2NcjSEDGxLEy1LxyGgY1Hobk/cTjUJ8XOKg=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=NCBHrIN3mkJpXiH1qBKeKcnlH+w4rzDsA2F9B3o3YgAPsNbX8hjAmAb/It6y2fZ4N /j0byu2OshWWrmP0MFR1g/HA3/zcqUqHd+osfpLC5Vqq96DjBKw5cwjuRuLAYFq+LN DO6w3H6MCi+j94zY1z2BuSd3mc2e8i2NoYjOj8kypyyBQNgfQOYOyOeuUNaaUmTjKM 1/e8M0GwYRZunA/a+YQqpXve1HHYaFmY5BMmIhVFjKN1TuaCKzDHugEeoND/I/Cyey xWTu3LmyP/egqrA/v/IlfTe0NgjP7L5QcCm+FFg0TrN39+axQ5lNKlU4JCHSdVZjDg r9Ry1Cr3p65oQ== X-Nifty-SrcIP: [209.85.222.41] Received: by mail-ua1-f41.google.com with SMTP id 1so1267092uao.1 for ; Tue, 03 Mar 2020 07:24:10 -0800 (PST) X-Gm-Message-State: ANhLgQ3Y+1M/3bMHqgez0FdwetzoRGqxn3S5ZpzUQlZpWX2luv5o0CZP ahNjbbNfgSjIG9Rwr5R6GdmGiDdPzqbZmjDxnrI= X-Received: by 2002:a9f:32da:: with SMTP id f26mr1872157uac.40.1583249049570; Tue, 03 Mar 2020 07:24:09 -0800 (PST) MIME-Version: 1.0 References: <20200226142608.19499-1-jeyu@kernel.org> In-Reply-To: <20200226142608.19499-1-jeyu@kernel.org> From: Masahiro Yamada Date: Wed, 4 Mar 2020 00:23:33 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/2] modpost: rework and consolidate logging interface To: Jessica Yu Cc: Matthias Maennich , Joe Perches , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 26, 2020 at 11:26 PM Jessica Yu wrote: > > Rework modpost's logging interface by consolidating merror(), warn(), > and fatal() to use a single function, modpost_log(). Introduce different > logging levels (WARN, ERROR, FATAL) as well as a conditional warn > (warn_unless()). The conditional warn is useful in determining whether > to use merror() or warn() based on a condition. This reduces code > duplication overall. > > Signed-off-by: Jessica Yu > --- > v2: > - modpost_log: initialize level to "" > - remove parens () from case labels > > scripts/mod/modpost.c | 69 +++++++++++++++++++++++---------------------------- > scripts/mod/modpost.h | 22 +++++++++++++--- > 2 files changed, 50 insertions(+), 41 deletions(-) > > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c > index 7edfdb2f4497..3201a2ac5cc4 100644 > --- a/scripts/mod/modpost.c > +++ b/scripts/mod/modpost.c > @@ -51,41 +51,37 @@ enum export { > > #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) > > -#define PRINTF __attribute__ ((format (printf, 1, 2))) > +#define PRINTF __attribute__ ((format (printf, 2, 3))) > > -PRINTF void fatal(const char *fmt, ...) > +PRINTF void modpost_log(enum loglevel loglevel, const char *fmt, ...) > { > + char *level = ""; > va_list arglist; > > - fprintf(stderr, "FATAL: "); > - > - va_start(arglist, fmt); > - vfprintf(stderr, fmt, arglist); > - va_end(arglist); > - > - exit(1); > -} > - > -PRINTF void warn(const char *fmt, ...) > -{ > - va_list arglist; > + switch(loglevel) { One nit: Please insert a space after 'switch'. I see this checkpatch error: ERROR: space required before the open parenthesis '(' #102: FILE: scripts/mod/modpost.c:61: + switch(loglevel) { -- Best Regards Masahiro Yamada