Re: checkpatch.pl bug? (was Re: [PATCH] random: Make CPU trust a boot parameter)

From: Joe Perches
Date: Tue Aug 28 2018 - 01:12:25 EST


On Mon, 2018-08-27 at 14:55 -0700, Kees Cook wrote:
> On Mon, Aug 27, 2018 at 2:51 PM, Kees Cook <keescook@xxxxxxxxxxxx> wrote:
> > Instead of forcing a distro or other system builder to choose
> > at build time whether the CPU is trusted for CRNG seeding via
> > CONFIG_RANDOM_TRUST_CPU, provide a boot-time parameter for end users to
> > control the choice. The CONFIG will set the default state instead.
[]
> > diff --git a/drivers/char/random.c b/drivers/char/random.c
[]
> > @@ -779,6 +779,13 @@ static struct crng_state **crng_node_pool __read_mostly;
> >
> > static void invalidate_batched_entropy(void);
> >
> > +static bool trust_cpu __ro_after_init = IS_ENABLED(CONFIG_RANDOM_TRUST_CPU);
> > +static int __init parse_trust_cpu(char *arg)
> > +{
> > + return kstrtobool(arg, &trust_cpu);
> > +}
> > +early_param("random.trust_cpu", parse_trust_cpu);
> > +
> > static void crng_initialize(struct crng_state *crng)
> > {
> > int i;
> > @@ -799,12 +806,10 @@ static void crng_initialize(struct crng_state *crng)
> > }
> > crng->state[i] ^= rv;
> > }
> > -#ifdef CONFIG_RANDOM_TRUST_CPU
> > - if (arch_init) {
> > + if (trust_cpu && arch_init) {
>
> checkpatch.pl complains:
>
> ERROR: space prohibited after that '&&' (ctx:WxW)
> #79: FILE: drivers/char/random.c:809:
> + if (trust_cpu && arch_init) {
> ^
>
> I can't figure out what is going on here. Using "||" doesn't trigger
> the issue; it seems related to the earlier "&trust_cpu" use in the
> patch, but I can't figure out what checkpatch was trying to do with
> this...

It's the __ro_after_init after the declaration of
static bool trust_cpu that confuses checkpatch.

I'll see what can be done for that.