Re: guard coding style (was: Re: [PATCH v1 05/10] gpio: pca953x: Simplify code with cleanup helpers)

From: Peter Zijlstra
Date: Thu Sep 14 2023 - 18:30:28 EST


On Thu, Sep 14, 2023 at 09:47:07AM +0200, Geert Uytterhoeven wrote:

> > > > + scoped_guard(mutex, &chip->i2c_lock)
> > > > + ret = regmap_read(chip->regmap, inreg, &reg_val);
> > >
> > > I can't say I'm thrilled about the lack of curly braces. I was also
> > > surprised to discover that checkpatch nor gcc W=1 complain about the
> > > indentation change.

So in my kernel/events/core.c changes (that I still need to re-post and
aren't yet upstream) I have found a single instance where I've done the
same lack of curlies:

scoped_guard (rcu)
pmu = idr_find(&pmu_idr, type);

clearly self-consistency mandates I should not object to this style.

That said, I see the argument for having them, they do more clearly
demarcate the scope.

As with everything, small variations in style are bound to happen from
one maintainer to another... (or one self to itself over time).