[PATCH] makedumpfile, sadump: fix warning messages in building time

HATAYAMA Daisuke d.hatayama at jp.fujitsu.com
Mon Jan 21 02:30:46 EST 2013


Recent gcc outputs the following warning messages when compiles
sadump_info.c because a given pointer is compared as conditional but
they are static string objects and are alreays converted into true.

./sadump_info.c: In function 'sadump_virt_phys_base':
./sadump_info.c:926: warning: the address of 'buf' will always evaluate as 'true'
./sadump_info.c:933: warning: the address of 'buf' will always evaluate as 'true'

But this is within our intension so enclose the occurence of static
strings by static inline function to surpress the compiler's checking.

I borrowed this code from crash utility.

Signed-off-by: HATAYAMA Daisuke <d.hatayama at jp.fujitsu.com>
---
 makedumpfile.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/makedumpfile.h b/makedumpfile.h
index d2bdc0c..a0c5b7d 100644
--- a/makedumpfile.h
+++ b/makedumpfile.h
@@ -213,7 +213,9 @@ isAnon(unsigned long mapping)
 	sizeof(Elf64_Ehdr)+sizeof(Elf64_Phdr)+sizeof(Elf64_Phdr)
 #define MIN_ELF_HEADER_SIZE \
 	MAX(MIN_ELF32_HEADER_SIZE, MIN_ELF64_HEADER_SIZE)
-#define STRNEQ(A, B)	(A && B && \
+static inline int string_exists(char *s) { return (s ? TRUE : FALSE); }
+#define STRNEQ(A, B)	(string_exists((char *)(A)) &&			\
+			string_exists((char *)(B)) &&			\
 	(strncmp((char *)(A), (char *)(B), strlen((char *)(B))) == 0))
 
 #define USHORT(ADDR)	*((unsigned short *)(ADDR))
-- 
1.7.7.6




More information about the kexec mailing list