Re: [PATCH 03/13] x86/microcode/AMD: Clean up find_equiv_id()

From: Thomas Gleixner
Date: Tue Jan 17 2017 - 14:03:19 EST


On Tue, 17 Jan 2017, Borislav Petkov wrote:
> + for (; equiv_table && equiv_table->installed_cpu; equiv_table++)
> + if (sig == equiv_table->installed_cpu)
> + return equiv_table->equiv_cpu;

This would be perfect if you just kept the braces around the for loop.

for (; cond; incr)
do_something();

parses perfectly fine as it matches the expectation of a single line statement
following the for().

for (; cond; incr)
if (othercond)
do_something();

not so much because we expect a single line statement due to the lack of a
opening brace after the for()

for (; cond; incr) {
if (othercond)
do_something();
}

That's how it parses best. The opening brace after the for() tells us: here
comes a multiline statement. And the inner if (othercond) w/o the opening
brace tells: here comes a single line statement.

Reading code/patches very much depends on patterns and structuring. If they
are consistent the reading flow is undisturbed.

Thanks,

tglx