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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160701102018.GB8787@gmail.com>
Date:	Fri, 1 Jul 2016 12:20:18 +0200
From:	Ingo Molnar <mingo@...nel.org>
To:	Borislav Petkov <bp@...en8.de>
Cc:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Steven Rostedt <rostedt@...dmis.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Peter Zijlstra <peterz@...radead.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>, Franck Bui <fbui@...e.com>,
	LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -v2 2/2] printk: Add kernel parameter to control writes
 to /dev/kmsg


* Borislav Petkov <bp@...en8.de> wrote:

> On Fri, Jul 01, 2016 at 11:04:13AM +0200, Ingo Molnar wrote:
> 
> ...
> 
> > So the most robust way to define such bitfields is via a pattern like this:
> > 
> > enum devkmsg_log_bits {
> > 	__DEVKMSG_LOG_BIT_ON,
> > 	__DEVKMSG_LOG_BIT_OFF,
> > 	__DEVKMSG_LOG_BIT_LOCK,
> > };
> > 
> > enum devkmsg_log_masks {
> > 	DEVKMSG_LOG_MASK_ON		= BIT(__DEVKMSG_LOG_BIT_ON),
> > 	DEVKMSG_LOG_MASK_OFF		= BIT(__DEVKMSG_LOG_BIT_OFF),
> > 	DEVKMSG_LOG_MASK_LOCK		= BIT(__DEVKMSG_LOG_BIT_LOCK),
> 
> Agreed with so far, I'd only drop the "_MASK" thing and make it even
> easier on the eyes:
> 
> enum devkmsg_log_state {
> 	DEVKMSG_LOG_ON		= BIT(__DEVKMSG_LOG_BIT_ON),
> 	DEVKMSG_LOG_OFF		= BIT(__DEVKMSG_LOG_BIT_OFF),
> 	DEVKMSG_LOCK		= BIT(__DEVKMSG_LOG_BIT_LOCK),
> };

It's just a nit, but generally it's nice to know the character of such values - 
i.e. in case that it's a bit mask that has to be used with bit ops. That's more 
important IMHO than brevity. This means that possibly buggy code like this stands 
out immediately:

	if (devkmgs_log == DEVKMSG_LOG_MASK_ON)

while this one:

	if (devkmgs_log == DEVKMSG_LOG_ON)

might slip through.

But no strong feelings either way!

Thanks,

	Ingo

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ