mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Jules Irenge <jbi.octave@gmail.com>, Borislav Petkov <bp@alien8.de>
Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, x86@kernel.org,
	hpa@zytor.com, mingo@redhat.com
Subject: Re: [PATCH] cpu: microcode: replace 0 with NULL
Date: Wed, 27 Nov 2019 13:11:31 -0800	[thread overview]
Message-ID: <074cc723b3874f95b1b1ad89c1d2dcbae982deba.camel@perches.com> (raw)
In-Reply-To: <alpine.LFD.2.21.1911261554100.156067@ninjahub.org>

On Tue, 2019-11-26 at 16:03 +0000, Jules Irenge wrote:
> 
> On Tue, 26 Nov 2019, Borislav Petkov wrote:
> 
> > On Tue, Nov 26, 2019 at 12:27:34AM +0000, Jules Irenge wrote:
> > > Replace 0 with NULL to fix sparse tool  warning
> > >  warning: Using plain integer as NULL pointer
> > > 
> > > Signed-off-by: Jules Irenge <jbi.octave@gmail.com>
> > > ---
> > >  arch/x86/kernel/cpu/microcode/amd.c | 4 ++--
> > >  1 file changed, 2 insertions(+), 2 deletions(-)
> > > 
> > > diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
> > > index a0e52bd00ecc..4934aa7c94e7 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 = { NULL };
> > 
> > So my gcc guy says that 0 and NULL are equivalent as designated
> > initializers in this case. And if you look at the resulting asm, it
> > doesn't change:
> > 
> > # arch/x86/kernel/cpu/microcode/amd.c:421: 	struct cont_desc desc = { 0 };
> > 	movq	$0, 8(%rsp)	#, desc
> > 	movq	$0, (%rsp)	#, desc
> > 	movq	$0, 16(%rsp)	#, desc
> > 	movq	$0, 24(%rsp)	#, desc
> > 
> > But what I'd prefer actually is, if you do them like this:
> > 
> > 			... = { 0,  };
> > 
> > because:
> > 
> > 1. It is clear that the memory for the struct is being cleared
> > 2. The following ones - the ones after "," are missing too, on purpose,
> >    because they're being cleared too.
> > 
> > Also pls add that explanation to the commit message.
> > 
> > Thx.
> > 
> > -- 
> > Regards/Gruss,
> >     Boris.
> > 
> > https://people.kernel.org/tglx/notes-about-netiquette
> > 
> Hi Boris,
> 
> Thanks for your reply and suggestion. 
> 
> I am learning patching with sparse trying to solve some problems that the 
> tool complains about.
> 
> Sometime the tool is not always right. If I take your suggestion that I 
> am about to do, sparse will however still complain.
> 
> so I will suggest my change to be discarded.
> 
> I will take another challenge.

This initializer should ether use named members with the appropriate
zeroing type or just use a blank {} so that regardless of type and
member order, the entire structure is zeroed.

	struct cont_desc desc = {};



      reply	other threads:[~2019-11-27 21:18 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-26  0:27 Jules Irenge
2019-11-26 13:53 ` Borislav Petkov
2019-11-26 16:03   ` Jules Irenge
2019-11-27 21:11     ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=074cc723b3874f95b1b1ad89c1d2dcbae982deba.camel@perches.com \
    --to=joe@perches.com \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=jbi.octave@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®