linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpu: microcode: Add comma to 0
@ 2019-11-26 22:15 Jules Irenge
  2019-11-27  6:54 ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Jules Irenge @ 2019-11-26 22:15 UTC (permalink / raw)
  To: bp; +Cc: tglx, linux-kernel, x86, hpa, mingo, Jules Irenge

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@gmail.com>
---
 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, };
 	u8 (*patch)[PATCH_MAX_SIZE];
 	struct microcode_amd *mc;
 	u32 rev, dummy, *new_rev;
-- 
2.23.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] cpu: microcode: Add comma to 0
  2019-11-26 22:15 [PATCH] cpu: microcode: Add comma to 0 Jules Irenge
@ 2019-11-27  6:54 ` Ingo Molnar
  2019-11-27 11:26   ` Borislav Petkov
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2019-11-27  6:54 UTC (permalink / raw)
  To: Jules Irenge; +Cc: bp, tglx, linux-kernel, x86, hpa, mingo


* Jules Irenge <jbi.octave@gmail.com> 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@gmail.com>
> ---
>  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.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cpu: microcode: Add comma to 0
  2019-11-27  6:54 ` Ingo Molnar
@ 2019-11-27 11:26   ` Borislav Petkov
  2019-11-27 16:50     ` Ingo Molnar
  0 siblings, 1 reply; 5+ messages in thread
From: Borislav Petkov @ 2019-11-27 11:26 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Jules Irenge, tglx, linux-kernel, x86, hpa, mingo

On Wed, Nov 27, 2019 at 07:54:36AM +0100, Ingo Molnar wrote:
> 
> * Jules Irenge <jbi.octave@gmail.com> 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@gmail.com>
> > ---
> >  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.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cpu: microcode: Add comma to 0
  2019-11-27 11:26   ` Borislav Petkov
@ 2019-11-27 16:50     ` Ingo Molnar
  2019-11-27 17:15       ` Borislav Petkov
  0 siblings, 1 reply; 5+ messages in thread
From: Ingo Molnar @ 2019-11-27 16:50 UTC (permalink / raw)
  To: Borislav Petkov; +Cc: Jules Irenge, tglx, linux-kernel, x86, hpa, mingo


* Borislav Petkov <bp@alien8.de> wrote:

> On Wed, Nov 27, 2019 at 07:54:36AM +0100, Ingo Molnar wrote:
> > 
> > * Jules Irenge <jbi.octave@gmail.com> 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@gmail.com>
> > > ---
> > >  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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] cpu: microcode: Add comma to 0
  2019-11-27 16:50     ` Ingo Molnar
@ 2019-11-27 17:15       ` Borislav Petkov
  0 siblings, 0 replies; 5+ messages in thread
From: Borislav Petkov @ 2019-11-27 17:15 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Jules Irenge, tglx, linux-kernel, x86, hpa, mingo

On Wed, Nov 27, 2019 at 05:50:25PM +0100, Ingo Molnar wrote:
> 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
> 
> :-)

Ok then, keeping it as is.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-11-27 17:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-26 22:15 [PATCH] cpu: microcode: Add comma to 0 Jules Irenge
2019-11-27  6:54 ` Ingo Molnar
2019-11-27 11:26   ` Borislav Petkov
2019-11-27 16:50     ` Ingo Molnar
2019-11-27 17:15       ` Borislav Petkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).