mips: vmcore: forced convert 'hdr' in elf_check_arch()
Subsystems (4)
PATCH v2 1/1 mips: vmcore: forced convert 'hdr' in elf_check_arch()
From: Yanjiang Jin <[email protected]>
V1->V2: According to Minfei's suggestion, coverting in the Macro rather than in vmcore.c.
Already verified this patch on a MIPS64 cavium octeon board: CN78XX.
This patch is to eliminate the compile warning only, has no side effect in run-time.
Yanjiang Jin (1):
mips: vmcore: forced convert 'hdr' in elf_check_arch()
arch/mips/include/asm/elf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Signature · 7 lines
1.9.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 1/1 mips: vmcore: forced convert 'hdr' in elf_check_arch()
From: Yanjiang Jin <[email protected]>
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) ||
^--- arch/mips/include/asm/elf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/mips/include/asm/elf.h +2 -2
@@ -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; \
Signature · 7 lines
1.9.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
The new version patch only modifies mips/elf.h, so add Ralf Baechle and cc [email protected]. This is a V2 patch, attach the V1 patch for reference.
Thanks!
Yanjiang
Quoted 50 lines · On 2015年09月18日 15:42, [email protected] wrote:
From: Yanjiang Jin <[email protected]>
elf_check_arch()will be called both inparse_crash_elf64_headers()andparse_crash_elf32_headers(). But in these two functions, the type of the parameter ehdr is different:Elf32_EhdrandElf64_Ehdr.Function
parse_crash_elf_headers()reads e_ident[EI_CLASS] then decides to callparse_crash_elf64_headers()orparse_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 <[email protected]>--- arch/mips/include/asm/elf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/mips/include/asm/elf.h +2
-2@@ -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; \
It seems the last mail has been blocked, resend it.
Quoted 58 lines · yjin
The new version patch only modifies
mips/elf.h, so add Ralf Baechle and cc [email protected]. This is a V2 patch, attach the V1 patch for reference.Thanks!
YanjiangQuoted 50 lines · On 2015年09月18日 15:42, [email protected] wrote:
From: Yanjiang Jin <[email protected]>
elf_check_arch()will be called both inparse_crash_elf64_headers()andparse_crash_elf32_headers(). But in these two functions, the type of the parameter ehdr is different:Elf32_EhdrandElf64_Ehdr.Function
parse_crash_elf_headers()reads e_ident[EI_CLASS] then decides to callparse_crash_elf64_headers()orparse_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 <[email protected]>--- arch/mips/include/asm/elf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)arch/mips/include/asm/elf.h +2
-2@@ -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; \