Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1435191
| From | Borislav Petkov <bp@alien8.de> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH -v2 2/2] printk: Add kernel parameter to control writes to /dev/kmsg |
| Date | 2016-07-01 11:20 +0200 |
| Message-ID | <rQ2Ma-4Op-39@gated-at.bofh.it> (permalink) |
| References | <rPkrL-2AI-9@gated-at.bofh.it> <rPkrM-2AI-23@gated-at.bofh.it> <rQ2Ma-4Op-41@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
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),
};
Now this makes the checking code even more readable!
if (devkmsg_log & DEVKMSG_LOCK) {
and
if (devkmsg_log & DEVKMSG_LOG_OFF)
and
if ((system_state != SYSTEM_BOOTING) && (!(devkmsg_log & DEVKMSG_LOG_ON)) {
And this way you can read it straight-away as english text.
:-)))
Thanks.
--
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH -v2 0/2] printk.kmsg: Ratelimit it by default Borislav Petkov <bp@alien8.de> - 2016-06-29 12:00 +0200
[PATCH -v2 1/2] ratelimit: Extend to print suppressed messages on release Borislav Petkov <bp@alien8.de> - 2016-06-29 12:00 +0200
Re: [PATCH -v2 1/2] ratelimit: Extend to print suppressed messages on release Joe Perches <joe@perches.com> - 2016-06-29 12:30 +0200
Re: [PATCH -v2 1/2] ratelimit: Extend to print suppressed messages on release Borislav Petkov <bp@alien8.de> - 2016-06-29 16:30 +0200
Re: [PATCH -v2 1/2] ratelimit: Extend to print suppressed messages on release Ingo Molnar <mingo@kernel.org> - 2016-07-01 10:30 +0200
Re: [PATCH -v2 1/2] ratelimit: Extend to print suppressed messages on release Borislav Petkov <bp@alien8.de> - 2016-07-01 11:20 +0200
Re: [PATCH -v2 1/2] ratelimit: Extend to print suppressed messages on release Ingo Molnar <mingo@kernel.org> - 2016-07-01 12:40 +0200
Re: [PATCH -v2 1/2] ratelimit: Extend to print suppressed messages on release Borislav Petkov <bp@alien8.de> - 2016-07-01 12:40 +0200
Re: [PATCH -v2 1/2] ratelimit: Extend to print suppressed messages on release Ingo Molnar <mingo@kernel.org> - 2016-07-01 13:30 +0200
[PATCH -v2 2/2] printk: Add kernel parameter to control writes to /dev/kmsg Borislav Petkov <bp@alien8.de> - 2016-06-29 12:00 +0200
Re: [PATCH -v2 2/2] printk: Add kernel parameter to control writes to /dev/kmsg Borislav Petkov <bp@alien8.de> - 2016-07-01 11:20 +0200
Re: [PATCH -v2 2/2] printk: Add kernel parameter to control writes to /dev/kmsg Ingo Molnar <mingo@kernel.org> - 2016-07-01 12:40 +0200
Re: [PATCH -v2 2/2] printk: Add kernel parameter to control writes to /dev/kmsg Ingo Molnar <mingo@kernel.org> - 2016-07-01 11:20 +0200
csiph-web