Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4165217ybv; Tue, 25 Feb 2020 14:32:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxZ7vEW2ZsZNogu52qnJA6utn/q6Sjj4jfjZgoBNPKpWAL+axmE6h9fuqUfzE8jAafPf9C9 X-Received: by 2002:aca:d484:: with SMTP id l126mr846772oig.114.1582669970764; Tue, 25 Feb 2020 14:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582669970; cv=none; d=google.com; s=arc-20160816; b=nHK3+hNujjk/Z5hjkBVlLeK127Y9aFmYYcfR7CF655uiqLtGDtIiwMC4K3jnb15YKG PJd1/QUNKL/aRkRr9u9LEC3rqjLNo8v/LAFpQnzElPWCnh5sZrT31dqk7Qt6tJWg+ciw zV46ZRUlT2u/h9mnmEj2X9t2M/PxA/vp6S87qtO2j7dff00dxtYlb/iPbn0tli8IenBO fGdPTGwhXtbJ3+NDXeWgOerH5/ZTlCwg0hCILw3d6jKMBEb0xNC5+SaT5pdBlmnzcYEr WmOCuPV8VGVWYaTn0EQgupFQP34rHDk9tU46TiNX84YnLLRhKyUogsOXBHGZGfotsoSS f7fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=SrOwJfUm4t7MW3dkVC1MiKq5HfQnDya3tFEDo1eoePs=; b=N6Z0P/x6QZQJqykUJX0OzY60stcKTxj6KYuNNfmyVMcntPIUdqY0gb6cJF2UfseYwU wIkEOtZx+xXZLBB5cqGar7b+m3DfNp/qoyGGz273fU4yvm+klE3qf8AqeIYtGh8re21X Bm9pC4I8zGwGm3BvkJ4tD2608lhqh8wrHY2E0SRE6wE9Usj6KVXoZecN66L7SOjbUq1O Tjtja/CYwd89a1YhsXAkNx1BiJBikv7LFdZSxVHnzSwcdsB88YKHhJV+TFxv+wBrclda MPLzCZ7ABQanGAdNRxNGu8naaYVu63Wu4r+asaqPsLipbx6WkK0MaB2YRJTtROVrm3i7 M5hw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t20si119631otr.64.2020.02.25.14.32.37; Tue, 25 Feb 2020 14:32:50 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728806AbgBYWc1 (ORCPT + 99 others); Tue, 25 Feb 2020 17:32:27 -0500 Received: from smtprelay0184.hostedemail.com ([216.40.44.184]:34866 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726827AbgBYWc0 (ORCPT ); Tue, 25 Feb 2020 17:32:26 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay07.hostedemail.com (Postfix) with ESMTP id 710EC181D3030; Tue, 25 Feb 2020 22:32:25 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:982:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3870:3871:4321:5007:7875:7903:9707:10004:10400:10848:11026:11232:11473:11658:11914:12297:12740:12760:12895:13069:13311:13357:13439:14096:14097:14659:14721:21080:21451:21611:21627:21740:30012:30054:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: fowl93_894fd78211c48 X-Filterd-Recvd-Size: 2234 Received: from XPS-9350 (unknown [172.58.27.58]) (Authenticated sender: joe@perches.com) by omf11.hostedemail.com (Postfix) with ESMTPA; Tue, 25 Feb 2020 22:32:23 +0000 (UTC) Message-ID: <635523a920bcc317eaf48230f003cd050f51c9bb.camel@perches.com> Subject: Re: [PATCH 1/2] modpost: rework and consolidate logging interface From: Joe Perches To: Jessica Yu , Masahiro Yamada , Matthias Maennich Cc: linux-kernel@vger.kernel.org Date: Tue, 25 Feb 2020 14:30:51 -0800 In-Reply-To: <20200225173526.9617-1-jeyu@kernel.org> References: <20200225173526.9617-1-jeyu@kernel.org> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2020-02-25 at 18:35 +0100, 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. [] > diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c [] > @@ -51,41 +51,39 @@ 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 = NULL; > va_list arglist; > > - fprintf(stderr, "FATAL: "); > + switch(loglevel) { > + case(LOG_WARN): > + level = "WARNING: "; > + break; > + case(LOG_ERROR): > + level = "ERROR: "; > + break; > + case(LOG_FATAL): > + level = "FATAL: "; > + break; > + default: /* invalid loglevel, ignore */ > + break; Odd parentheses around case labels and likely level should be initialized as "" and not NULL. const char *level = ""; ... switch (loglevel) { case LOG_WARN: level = "WARNING: "; break; ... }