Skip to contentSkip to conversation

makedumpfile, sadump: fix warning messages in building time

PATCH New HATAYAMA Daisuke 1 participant 1 message Jan 21, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 makedumpfile, sadump: fix warning messages in building time

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.

---
 makedumpfile.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
makedumpfile.h +3 -1
index d2bdc0c..a0c5b7d 100644
@@ -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))
Signature · 7 lines
1.7.7.6


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec