[PATCH] mips: vmcore: forced convert 'hdr' in elf_check_arch()

yanjiang.jin at windriver.com yanjiang.jin at windriver.com
Fri Sep 18 00:42:51 PDT 2015


From: Yanjiang Jin <yanjiang.jin at windriver.com>

elf_check_arch() will be called both in parse_crash_elf64_headers()
and parse_crash_elf32_headers(). But in these two functions, the type of
the parameter ehdr is different: Elf32_Ehdr and Elf64_Ehdr.

Function parse_crash_elf_headers() reads e_ident[EI_CLASS] then decides to
call parse_crash_elf64_headers() or parse_crash_elf32_headers().
This happens in run time, not compile time. So compiler will report
the below warning:

In file included from include/linux/elf.h:4:0,
                 from fs/proc/vmcore.c:13:
fs/proc/vmcore.c: In function 'parse_crash_elf32_headers':
arch/mips/include/asm/elf.h:258:23: warning: initializatio
n from incompatible pointer type
  struct elfhdr *__h = (hdr);     \
                       ^
fs/proc/vmcore.c:1071:4: note: in expansion of macro 'elf_
check_arch'
   !elf_check_arch(&ehdr) ||
    ^

Signed-off-by: Yanjiang Jin <yanjiang.jin at windriver.com>
---
 arch/mips/include/asm/elf.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
index f19e890..ece490d 100644
--- a/arch/mips/include/asm/elf.h
+++ b/arch/mips/include/asm/elf.h
@@ -224,7 +224,7 @@ struct mips_elf_abiflags_v0 {
 #define elf_check_arch(hdr)						\
 ({									\
 	int __res = 1;							\
-	struct elfhdr *__h = (hdr);					\
+	struct elfhdr *__h = (struct elfhdr *)(hdr);			\
 									\
 	if (__h->e_machine != EM_MIPS)					\
 		__res = 0;						\
@@ -255,7 +255,7 @@ struct mips_elf_abiflags_v0 {
 #define elf_check_arch(hdr)						\
 ({									\
 	int __res = 1;							\
-	struct elfhdr *__h = (hdr);					\
+	struct elfhdr *__h = (struct elfhdr *)(hdr);			\
 									\
 	if (__h->e_machine != EM_MIPS)					\
 		__res = 0;						\
-- 
1.9.1




More information about the kexec mailing list