lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20200226133812.GA20449@linux-8ccs>
Date:   Wed, 26 Feb 2020 14:38:13 +0100
From:   Jessica Yu <jeyu@...nel.org>
To:     Joe Perches <joe@...ches.com>
Cc:     Masahiro Yamada <yamada.masahiro@...ionext.com>,
        Matthias Maennich <maennich@...gle.com>,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/2] modpost: rework and consolidate logging interface

+++ 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.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ