Skip to contentSkip to conversation

x86/purgatory: Fix sparse warnings

PATCH Superseded Tobin C. Harding 2 participants 4 messages Feb 12, 2017 x86

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover x86/purgatory: Fix sparse warnings

Sparse emits multiple warnings of type 'symbol was not declared'.

Separate fixes into two patches. In first patch add static keyword to functions and variables which have file scope only.

In the second patch add a header file with the function declaration. Include the header file in the C source file defining the function in order to fix the sparse warning. Include the header file in ASM file containing the call site thereby adding documentation of usage.

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

 arch/x86/purgatory/purgatory.c    | 11 ++++++-----
 arch/x86/purgatory/purgatory.h    |  7 +++++++
 arch/x86/purgatory/setup-x86_64.S |  3 ++-
 3 files changed, 15 insertions(+), 6 deletions(-)
 create mode 100644 arch/x86/purgatory/purgatory.h
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 x86/purgatory: Fix sparse warning, symbol not declared

Sparse emits several 'symbol not declared' warnings for various functions and variables.

Add static keyword to functions and variables which have file scope only.

---
 arch/x86/purgatory/purgatory.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
arch/x86/purgatory/purgatory.c +5 -5
index 25e068b..2a5f437 100644
@@ -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;
+static unsigned long backup_src;
+static unsigned long backup_sz;
 
-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];
Signature · 1 line
2.7.4
#2 lore raw

PATCH v2 2/2 x86/purgatory: Fix sparse warning, symbol not declared

In reply to Tobin C. Harding

Sparse emits warning, 'symbol not declared' for a function that has neither file scope nor a forward declaration. The functions only call site is an ASM file.

Add a header file with the function declaration. Include the header file in the C source file defining the function in order to fix the sparse warning. Include the header file in ASM file containing the call site thereby adding documentation of usage.

---
 arch/x86/purgatory/purgatory.c    | 1 +
 arch/x86/purgatory/purgatory.h    | 7 +++++++
 arch/x86/purgatory/setup-x86_64.S | 3 ++-
 3 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 arch/x86/purgatory/purgatory.h
arch/x86/purgatory/purgatory.c +1 -0
index 2a5f437..b6d5c89 100644
@@ -11,6 +11,7 @@
  */
 
 #include "sha256.h"
+#include "purgatory.h"
 #include "../boot/string.h"
 
 struct sha_region {
arch/x86/purgatory/purgatory.h new file +7 -0
new file mode 100644
index 0000000..b2e859f
@@ -0,0 +1,7 @@
+#ifndef PURGATORY_H
+#define PURGATORY_H
+
+extern void purgatory(void);
+
+#endif /* PURGATORY_H */
+
arch/x86/purgatory/setup-x86_64.S +2 -1
index fe3c91b..7ed06e9 100644
@@ -9,7 +9,8 @@
  * This source code is licensed under the GNU General Public License,
  * Version 2.  See the file COPYING for more details.
  */
-
+ #include "purgatory.h"
+        
 	.text
 	.globl purgatory_start
 	.balign 16
Signature · 1 line
2.7.4
#3 lore raw

Re: [PATCH v2 2/2] x86/purgatory: Fix sparse warning, symbol not declared

url: https://github.com/0day-ci/linux/commits/Tobin-C-Harding/x86-purgatory-Fix-sparse-warnings/20170213-051217 config: x86_64-randconfig-x001-201707 (attached as .config) compiler: gcc-6 (Debian…

Hi Tobin,

[auto build test ERROR on tip/x86/core]
[also build test ERROR on v4.10-rc8 next-20170210]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url: https://github.com/0day-ci/linux/commits/Tobin-C-Harding/x86-purgatory-Fix-sparse-warnings/20170213-051217
config: x86_64-randconfig-x001-201707 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901 reproduce:

        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

arch/x86/purgatory/purgatory.h: Assembler messages:

>> arch/x86/purgatory/purgatory.h:4: Error: no such instruction: `extern void purgatory(void)'

make[2]: *** [arch/x86/purgatory/setup-x86_64.o] Error 1
make[2]: Target 'arch/x86/purgatory/kexec-purgatory.c' not remade because of errors. make[1]: *** [archprepare] Error 2
make[1]: Target 'prepare' not remade because of errors.
make: *** [sub-make] Error 2

vim +4 arch/x86/purgatory/purgatory.h

1 #ifndef PURGATORY_H
2 #define PURGATORY_H
3

   > 4	extern void purgatory(void);
     5	
     6	#endif /* PURGATORY_H */
     7	

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation