Use 'long long' for printf() format string and ELF64 numbers.
Subsystems (2)
PATCH 1/1 Use 'long long' for printf() format string and ELF64 numbers.
Since 'long long' is 64 bit wide on almost any platform, especially on 32 bit platforms (like i386) while 'long long' is only 64 bit on 64 bit platforms but 32 bit on 32 bit platforms, 'long long' is more suited and fixes compiler warnings like
kexec/crashdump-elf.c:160: warning: format '%lx' expects type \
'long unsigned int', but argument 4 has type 'Elf64_Off'
kexec/crashdump-elf.c:160: warning: format '%lx' expects type \
'long unsigned int', but argument 5 has type 'Elf64_Addr'
...
kexec/crashdump-elf.c:248: warning: format '%lx' expects type \
'long unsigned int', but argument 8 has type 'Elf64_Xword'
Tested on i686-pc-linux-gnu.
kexec/crashdump-elf.c +6 -6
@@ -4,12 +4,12 @@#endif #if (ELF_WIDTH ==64 ) -#define dbgprintf_phdr (prefix, phdr) \ -do { \ - dbgprintf("%s: p_type = %u, p_offset = 0x%lx p_paddr = 0x%lx " \ - "p_vaddr = 0x%lx p_filesz = 0x%lx p_memsz = 0x%lx\n", \ - (prefix), (phdr)->p_type, (phdr)->p_offset, (phdr)->p_paddr, \ - (phdr)->p_vaddr, (phdr)->p_filesz, (phdr)->p_memsz); \ +#define dbgprintf_phdr (prefix, phdr) \ +do { \ + dbgprintf("%s: p_type = %u, p_offset = 0x%llx p_paddr = 0x%llx " \ + "p_vaddr = 0x%llx p_filesz = 0x%llx p_memsz = 0x%llx\n", \ + (prefix), (phdr)->p_type, (phdr)->p_offset, (phdr)->p_paddr, \ + (phdr)->p_vaddr, (phdr)->p_filesz, (phdr)->p_memsz); \ } while(0)#else #define dbgprintf_phdr (prefix, phdr) \
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 13 lines · Bernhard Walle
Since 'long long' is 64 bit wide on almost any platform, especially on 32 bit platforms (like i386) while 'long long' is only 64 bit on 64 bit platforms but 32 bit on 32 bit platforms, 'long long' is more suited and fixes compiler warnings like
kexec/crashdump-elf.c:160: warning: format '%lx' expects type \
'long unsigned int', but argument 4 has type 'Elf64_Off'
kexec/crashdump-elf.c:160: warning: format '%lx' expects type \
'long unsigned int', but argument 5 has type 'Elf64_Addr'
...
kexec/crashdump-elf.c:248: warning: format '%lx' expects type \
'long unsigned int', but argument 8 has type 'Elf64_Xword'
Quoted 3 lines
Tested on i686-pc-linux-gnu.
Signed-off-by Bernhard Walle <[email protected]>
Thanks Bernhard, I've had much less elegant ideas on how to solve that problem myself.
Signature · 7 lines
Horms _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Quoted 2 lines · Bernhard Walle
kexec/crashdump-elf.c:160: warning: format '%lx' expects type \
'long unsigned int', but argument 4 has type 'Elf64_Off'
This is what inttypes.h is for, right?
Quoted 1 line
dbgprintf("%s:
p_type= %u,p_offset= 0x%llxp_paddr= 0x%llx " ...
Perhaps (... "p_offset = 0x" PRIx64 " p_paddr = 0x" PRIx64 ...)?
Jamey
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Quoted 10 lines · Jamey Sharp
Quoted 2 lines · Bernhard Walle
kexec/crashdump-elf.c:160: warning: format '%lx' expects type \
'long unsigned int', but argument 4 has type 'Elf64_Off'This is what
inttypes.his for, right?Quoted 1 line
dbgprintf("%s:
p_type= %u,p_offset= 0x%llxp_paddr= 0x%llx " ...Perhaps (... "
p_offset= 0x" PRIx64 "p_paddr= 0x" PRIx64 ...)?
Yes, I know this, but it's really ugly to read IMO. If it's not really necessary I think it's better to avoid it.
Bernhard
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec