Messages in this thread | | | From | Linus Torvalds <> | Date | Tue, 27 Aug 2019 09:55:08 -0700 | Subject | Re: [GIT pull] x86/urgent for 5.3-rc5 |
| |
On Mon, Aug 26, 2019 at 5:53 AM Borislav Petkov <bp@suse.de> wrote: > > + if (!changed) { > + pr_emerg( > +"RDRAND gives funky smelling output, might consider not using it by booting with \"nordrand\""); > + WARN_ON_ONCE(1); > + }
Side note: I'd suggest
if (WARN_ON_ONCE(!changed)) pr_emerg("RDRAND gives funky smelling output, might consider not using it by booting with \"nordrand\"");
instead.
Note that WARN_ON_ONCE() will only _warn_ once, but it always returns the conditional.
So it's equivalent to your version ("always print, warn once") except for:
(a) smaller (b) different order of warning and pr_emerg() (c) the WARN_ON_ONCE() also contains the proper "unlikely()", so it generates better code
and I just try to encourage people to use that "if (WARN_ON())" format for these kinds of "shouldn't happen, so warn and then do something".
Although usually the "do something" is just "return and refuse to do anything further" rather than the additional printk.
Linus
| |