Re: [PATCH] cpu: microcode: Add comma to 0

From: Ingo Molnar
Date: Wed Nov 27 2019 - 11:50:32 EST



* Borislav Petkov <bp@xxxxxxxxx> wrote:

> On Wed, Nov 27, 2019 at 07:54:36AM +0100, Ingo Molnar wrote:
> >
> > * Jules Irenge <jbi.octave@xxxxxxxxx> wrote:
> >
> > > Add "," after 0
> > > Because memory for the struct is being cleared
> > > and elements after "," are missing on purpose
> > > as they are being cleared to
> > >
> > > Recommended by Boris Petkov
> > >
> > > Signed-off-by: Jules Irenge <jbi.octave@xxxxxxxxx>
> > > ---
> > > arch/x86/kernel/cpu/microcode/amd.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
> > > index a0e52bd00ecc..04ee649f4acb 100644
> > > --- a/arch/x86/kernel/cpu/microcode/amd.c
> > > +++ b/arch/x86/kernel/cpu/microcode/amd.c
> > > @@ -418,7 +418,7 @@ static int __apply_microcode_amd(struct microcode_amd *mc)
> > > static bool
> > > apply_microcode_early_amd(u32 cpuid_1_eax, void *ucode, size_t size, bool save_patch)
> > > {
> > > - struct cont_desc desc = { 0 };
> > > + struct cont_desc desc = { 0, };
> >
> > This is 100% unnecessary - " = { }" is enough of a structure initializer.
>
> That was my initial thought but empty initializers are not ISO C
> compliant, I've been told.

Yeah, but the kernel isn't ISO C, and the hive mind has spoken in favor
of the shortest variant:

dagon:~/tip> git grep '= { }' | wc -l
647

dagon:~/tip> git grep '= { 0, }' | wc -l
231

dagon:~/tip> git grep '= { NULL, }' | wc -l
38

:-)

Thanks,

Ingo