All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jessica Yu <jeyu@kernel.org>
To: Joe Perches <joe@perches.com>
Cc: Masahiro Yamada <yamada.masahiro@socionext.com>,
	Matthias Maennich <maennich@google.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] modpost: rework and consolidate logging interface
Date: Wed, 26 Feb 2020 14:38:13 +0100	[thread overview]
Message-ID: <20200226133812.GA20449@linux-8ccs> (raw)
In-Reply-To: <635523a920bcc317eaf48230f003cd050f51c9bb.camel@perches.com>

+++ Joe Perches [25/02/20 14:30 -0800]:
>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;
>	...
>	}
>
>

Thanks for the review! Will fix this in v2 shortly.



  reply	other threads:[~2020-02-26 13:38 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-25 17:35 [PATCH 1/2] modpost: rework and consolidate logging interface Jessica Yu
2020-02-25 17:35 ` [PATCH 2/2] modpost: return error if module is missing ns imports and MODULE_ALLOW_MISSING_NAMESPACE_IMPORTS=n Jessica Yu
2020-02-25 22:30 ` [PATCH 1/2] modpost: rework and consolidate logging interface Joe Perches
2020-02-26 13:38   ` Jessica Yu [this message]
2020-02-26  1:58 ` kbuild test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200226133812.GA20449@linux-8ccs \
    --to=jeyu@kernel.org \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maennich@google.com \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.