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] [thread-next>] [day] [month] [year] [list]
Message-ID: <1291279035.1761.58.camel@Joe-Laptop>
Date:	Thu, 02 Dec 2010 00:37:15 -0800
From:	Joe Perches <joe@...ches.com>
To:	Huang Ying <ying.huang@...el.com>
Cc:	Len Brown <lenb@...nel.org>, linux-kernel@...r.kernel.org,
	Andi Kleen <andi@...stfloor.org>,
	Tony Luck <tony.luck@...el.com>, linux-acpi@...r.kernel.org,
	Peter Zijlstra <peterz@...radead.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Linus Torvalds <torvalds@...ux-foundation.org>,
	Ingo Molnar <mingo@...e.hu>
Subject: Re: [PATCH -v3 1/4] printk, Add pr_pfx for library functions

On Thu, 2010-12-02 at 16:05 +0800, Huang Ying wrote:
> For library functions doing printk, the log level and line prefix
> usually need to be specified by the caller. So this patch adds
> "pr_pfx" to make the life of these library functions easier.
[]
> +#define pr_pfx(pfx, fmt, ...) \
> +	printk("%s" fmt, pfx, ##__VA_ARGS__)

I think this would be a very error prone style.

pr_<foo> uses are log levels.

For an casual reader, is pfx a new log level or
is it a prefix or is it both?  I do understand
what you intend.

Mutability of the KERN_<level> is pretty unusual.
Most all of the uses are ?: style

Here are the first uses in each file that has them:
There aren't many.

$ grep -rP -m1 --include=*.[ch] "KERN_[A-Z]+\s*:\s*KERN" *
arch/avr32/mm/fault.c:			       is_global_init(tsk) ? KERN_EMERG : KERN_INFO,
arch/sparc/kernel/traps_64.c:	       (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
arch/sparc/mm/fault_64.c:	       task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
arch/sparc/mm/fault_32.c:	       task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
arch/x86/kernel/signal.c:		       task_pid_nr(current) > 1 ? KERN_INFO : KERN_EMERG,
arch/x86/mm/fault.c:		task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
arch/parisc/kernel/traps.c:	level = user ? KERN_DEBUG : KERN_CRIT;
drivers/pci/pcie/aer/aerdrv_errprint.c:		KERN_WARNING : KERN_ERR, dev_driver_string(&pdev->dev),	\
include/linux/arcdevice.h:            		: x < D_DURING ? KERN_INFO : KERN_DEBUG, \
mm/internal.h:		printk(level <= MMINIT_WARNING ? KERN_WARNING : KERN_DEBUG); \
sound/core/misc.c:	const char *pfx = level ? KERN_DEBUG : KERN_DEFAULT;

I don't see why you can't use something like that
with a simpler flag for level.

You also miss a chance to use pr_pfx in ghes_print_estatus:

+       if (__ratelimit(&ratelimit)) {
+               printk(
+       "%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
+       pfx, ghes->generic->header.source_id);
+               apei_estatus_print(pfx, ghes->estatus);
+

ghes_print_estatus is only called with a NULL first argument.
so the code use of pr_pfx seems dubious in any case.


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ