All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] arch/x86: Fix sparse warning
@ 2017-02-12  6:44 Tobin C. Harding
  2017-02-12  6:44 ` [PATCH 1/2] arch/x86: Fix sparse warning symbol not declared Tobin C. Harding
  2017-02-12  6:44 ` [PATCH 2/2] " Tobin C. Harding
  0 siblings, 2 replies; 8+ messages in thread
From: Tobin C. Harding @ 2017-02-12  6:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Tobin C. Harding

This series fixes multiple occurences of sparse warning, 'symbol
is not declared. Should it be static?'. Initial patch adds 'static'
keyword to variable declarations. Second patch declares function in
order to clear same warning. 

Tobin C. Harding (2):
  arch/x86: Fix sparse warning symbol not declared
  arch/x86: Fix sparse warning symbol not declared

 arch/x86/purgatory/purgatory.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

-- 
2.7.4

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

* [PATCH 1/2] arch/x86: Fix sparse warning symbol not declared
  2017-02-12  6:44 [PATCH 0/2] arch/x86: Fix sparse warning Tobin C. Harding
@ 2017-02-12  6:44 ` Tobin C. Harding
  2017-02-12 10:57   ` Thomas Gleixner
  2017-02-12  6:44 ` [PATCH 2/2] " Tobin C. Harding
  1 sibling, 1 reply; 8+ messages in thread
From: Tobin C. Harding @ 2017-02-12  6:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Tobin C. Harding

This patch adds static declaration to a number of variables. Fixes
sparse symbol was not declared warnings.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---
 arch/x86/purgatory/purgatory.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/purgatory/purgatory.c b/arch/x86/purgatory/purgatory.c
index 25e068b..2a2cbe5 100644
--- a/arch/x86/purgatory/purgatory.c
+++ b/arch/x86/purgatory/purgatory.c
@@ -18,11 +18,11 @@ struct sha_region {
 	unsigned long len;
 };
 
-unsigned long backup_dest = 0;
-unsigned long backup_src = 0;
-unsigned long backup_sz = 0;
+static unsigned long backup_dest = 0;
+static unsigned long backup_src = 0;
+static unsigned long backup_sz = 0;
 
-u8 sha256_digest[SHA256_DIGEST_SIZE] = { 0 };
+static u8 sha256_digest[SHA256_DIGEST_SIZE] = { 0 };
 
 struct sha_region sha_regions[16] = {};
 
@@ -39,7 +39,7 @@ static int copy_backup_region(void)
 	return 0;
 }
 
-int verify_sha256_digest(void)
+static int verify_sha256_digest(void)
 {
 	struct sha_region *ptr, *end;
 	u8 digest[SHA256_DIGEST_SIZE];
-- 
2.7.4

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

* [PATCH 2/2] arch/x86: Fix sparse warning symbol not declared
  2017-02-12  6:44 [PATCH 0/2] arch/x86: Fix sparse warning Tobin C. Harding
  2017-02-12  6:44 ` [PATCH 1/2] arch/x86: Fix sparse warning symbol not declared Tobin C. Harding
@ 2017-02-12  6:44 ` Tobin C. Harding
  2017-02-12 11:06   ` Thomas Gleixner
  1 sibling, 1 reply; 8+ messages in thread
From: Tobin C. Harding @ 2017-02-12  6:44 UTC (permalink / raw)
  To: linux-kernel
  Cc: Thomas Gleixner, Ingo Molnar, H. Peter Anvin, x86, Tobin C. Harding

This patch adds function declaration in order to quiet sparse symbol
not declared warning.

Signed-off-by: Tobin C. Harding <me@tobin.cc>
---

Unsure why adding declaration quiets sparse. This may not be the
correct solution. Only testing done is building and booting kernel.
Since 'purgatory' is called from assembler and does not need forward
declaration the only advantage to this patch seems to be to save the
next newbie from investigating the sparse warning.

arch/x86/purgatory/purgatory.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/purgatory/purgatory.c b/arch/x86/purgatory/purgatory.c
index 2a2cbe5..129433c 100644
--- a/arch/x86/purgatory/purgatory.c
+++ b/arch/x86/purgatory/purgatory.c
@@ -18,6 +18,8 @@ struct sha_region {
 	unsigned long len;
 };
 
+void purgatory(void);
+
 static unsigned long backup_dest = 0;
 static unsigned long backup_src = 0;
 static unsigned long backup_sz = 0;
-- 
2.7.4

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

* Re: [PATCH 1/2] arch/x86: Fix sparse warning symbol not declared
  2017-02-12  6:44 ` [PATCH 1/2] arch/x86: Fix sparse warning symbol not declared Tobin C. Harding
@ 2017-02-12 10:57   ` Thomas Gleixner
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Gleixner @ 2017-02-12 10:57 UTC (permalink / raw)
  To: Tobin C. Harding; +Cc: linux-kernel, Ingo Molnar, H. Peter Anvin, x86

On Sun, 12 Feb 2017, Tobin C. Harding wrote:

A few nitpicks.

> Subject: [PATCH 1/2] arch/x86: Fix sparse warning symbol not declared

arch/x86: is not the correct prefix. Run git log on a file to figure out
what the usual prefix is. The file was checked in with 'purgatory', but I'd
prefer 'x86/purgatory' for future changes.

> This patch adds static declaration to a number of variables. Fixes
> sparse symbol was not declared warnings.

Please read 'Documentation...SubmittingPatches' and look for 'This patch'.

I give you an example for a changelog:

  Sparse emits several 'symbol not declared' warnings.

  Make the variables and functions, which have only file scope static.

Now try to map that to the advise in Documentation.

Thanks,

	tglx

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

* Re: [PATCH 2/2] arch/x86: Fix sparse warning symbol not declared
  2017-02-12  6:44 ` [PATCH 2/2] " Tobin C. Harding
@ 2017-02-12 11:06   ` Thomas Gleixner
  2017-02-13 20:26     ` Tobin Harding
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Gleixner @ 2017-02-12 11:06 UTC (permalink / raw)
  To: Tobin C. Harding; +Cc: linux-kernel, Ingo Molnar, H. Peter Anvin, x86

On Sun, 12 Feb 2017, Tobin C. Harding wrote:

> This patch adds function declaration in order to quiet sparse symbol
> not declared warning.

Same comment vs. 'This patch' as before. Hint, we already know that this is
a patch, otherwise it would be mislabeled.

> 
> Signed-off-by: Tobin C. Harding <me@tobin.cc>
> ---
> 
> Unsure why adding declaration quiets sparse.

Because sparse finds a declaration before the definition.

> This may not be the correct solution.

Right, it's not.

> Only testing done is building and booting kernel.  Since 'purgatory' is
> called from assembler and does not need forward declaration the only
> advantage to this patch seems to be to save the next newbie from
> investigating the sparse warning.

Well, yes. But just quietening a checker by slapping a pointless forward
declaration into the code is not pretty either. A smarter checker might
catch that.

The proper solution is to have a local include file 'purgatory.h' and put
the declaration there. Include it in both files even if that's not required
for the ASM file. But that documents, that the function is used outside of
purgatory.c

Thanks,

	tglx

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

* Re: [PATCH 2/2] arch/x86: Fix sparse warning symbol not declared
  2017-02-12 11:06   ` Thomas Gleixner
@ 2017-02-13 20:26     ` Tobin Harding
  2017-02-13 21:24       ` Thomas Gleixner
  0 siblings, 1 reply; 8+ messages in thread
From: Tobin Harding @ 2017-02-13 20:26 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Ingo Molnar, H. Peter Anvin, x86


On Sun, Feb 12, 2017 at 12:06:47PM +0100, Thomas Gleixner wrote:
> On Sun, 12 Feb 2017, Tobin C. Harding wrote:
> 
> > This patch adds function declaration in order to quiet sparse symbol
> > not declared warning.
> 
> Same comment vs. 'This patch' as before. Hint, we already know that this is
> a patch, otherwise it would be mislabeled.
> 
> > 
> > Signed-off-by: Tobin C. Harding <me@tobin.cc>
> > ---
> > 
> > Unsure why adding declaration quiets sparse.
> 
> Because sparse finds a declaration before the definition.
> 
> > This may not be the correct solution.
> 
> Right, it's not.
> 
> > Only testing done is building and booting kernel.  Since 'purgatory' is
> > called from assembler and does not need forward declaration the only
> > advantage to this patch seems to be to save the next newbie from
> > investigating the sparse warning.
> 
> Well, yes. But just quietening a checker by slapping a pointless forward
> declaration into the code is not pretty either. A smarter checker might
> catch that.
> 
> The proper solution is to have a local include file 'purgatory.h' and put
> the declaration there. Include it in both files even if that's not required
> for the ASM file. But that documents, that the function is used outside of
> purgatory.c

Blindly following instructions led to the bone headed patch I
submitted yesterday (without building). Is there some way to include a
C header in an ASM file that I do not know about?

Thanks for patiently pointing out how to write a commit log. May I
please bother you with another small etiquette question. Should I
have replayed to you as I have done so or should I have re-sent another
patch (v3) with the mistakes fixed (and stated in the log that I did
not know how to implement the suggestions).

thanks,
Tobin.

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

* Re: [PATCH 2/2] arch/x86: Fix sparse warning symbol not declared
  2017-02-13 20:26     ` Tobin Harding
@ 2017-02-13 21:24       ` Thomas Gleixner
  2017-02-21  8:19         ` Tobin Harding
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Gleixner @ 2017-02-13 21:24 UTC (permalink / raw)
  To: Tobin Harding; +Cc: linux-kernel, Ingo Molnar, H. Peter Anvin, x86

On Tue, 14 Feb 2017, Tobin Harding wrote:
> On Sun, Feb 12, 2017 at 12:06:47PM +0100, Thomas Gleixner wrote:
> > The proper solution is to have a local include file 'purgatory.h' and put
> > the declaration there. Include it in both files even if that's not required
> > for the ASM file. But that documents, that the function is used outside of
> > purgatory.c
> 
> Blindly following instructions led to the bone headed patch I
> submitted yesterday (without building). Is there some way to include a
> C header in an ASM file that I do not know about?

Yes, you have to guard the function declaration with

#ifndef __ASSEMBLY__

I did not think about that when I suggested this. Brainslip :)

So yes, it's kinda pointless, but it still has documentatory value and
keeps the sparse build clean.

> Thanks for patiently pointing out how to write a commit log. May I
> please bother you with another small etiquette question. Should I
> have replayed to you as I have done so or should I have re-sent another
> patch (v3) with the mistakes fixed (and stated in the log that I did
> not know how to implement the suggestions).

All good. Either way works as long as you notice your own mistakes. It's
also fine to tell me that I suggested nonsense. :)

Thanks,

	tglx

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

* Re: [PATCH 2/2] arch/x86: Fix sparse warning symbol not declared
  2017-02-13 21:24       ` Thomas Gleixner
@ 2017-02-21  8:19         ` Tobin Harding
  0 siblings, 0 replies; 8+ messages in thread
From: Tobin Harding @ 2017-02-21  8:19 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, Ingo Molnar, H. Peter Anvin, x86

On Tue, Feb 14, 2017, at 08:24 AM, Thomas Gleixner wrote:
> On Tue, 14 Feb 2017, Tobin Harding wrote:
> > On Sun, Feb 12, 2017 at 12:06:47PM +0100, Thomas Gleixner wrote:
> > > The proper solution is to have a local include file 'purgatory.h' and put
> > > the declaration there. Include it in both files even if that's not required
> > > for the ASM file. But that documents, that the function is used outside of
> > > purgatory.c
> > 
> > Blindly following instructions led to the bone headed patch I
> > submitted yesterday (without building). Is there some way to include a
> > C header in an ASM file that I do not know about?
> 
> Yes, you have to guard the function declaration with
> 
> #ifndef __ASSEMBLY__
> 
> I did not think about that when I suggested this. Brainslip :)
> 
> So yes, it's kinda pointless, but it still has documentatory value and
> keeps the sparse build clean.
> 
> > Thanks for patiently pointing out how to write a commit log. May I
> > please bother you with another small etiquette question. Should I
> > have replayed to you as I have done so or should I have re-sent another
> > patch (v3) with the mistakes fixed (and stated in the log that I did
> > not know how to implement the suggestions).
> 
> All good. Either way works as long as you notice your own mistakes. It's
> also fine to tell me that I suggested nonsense. :)
> 

It has been pointed out to me that I could have approached the dev
process of this patch better. In the name of learning the correct method
I am now replying to your comments Thomas. Thanks for being patient, if
you could please slap me if I slip I should be able to blossom into a
decent contributor.

After sending an incorrect version (v3) with the __ASSEMBLY__
preprocessor guard in the wrong place, I re-sent v4 with what I believe
is all of your comments implemented and functioning.

Thanks for taking the time to review my annoying multi-version almost
trivial patch series.

thanks,
Tobin.

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

end of thread, other threads:[~2017-02-21  8:19 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-12  6:44 [PATCH 0/2] arch/x86: Fix sparse warning Tobin C. Harding
2017-02-12  6:44 ` [PATCH 1/2] arch/x86: Fix sparse warning symbol not declared Tobin C. Harding
2017-02-12 10:57   ` Thomas Gleixner
2017-02-12  6:44 ` [PATCH 2/2] " Tobin C. Harding
2017-02-12 11:06   ` Thomas Gleixner
2017-02-13 20:26     ` Tobin Harding
2017-02-13 21:24       ` Thomas Gleixner
2017-02-21  8:19         ` Tobin Harding

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.