kexec: Add new interface for printing error messages
Subsystems (2)
PATCH 1/2 kexec: Add new interface for printing error messages
From: Zhang Yanfei <[email protected]>
This patch imports an interface err() for printing error messages.
--- kexec/kexec.h | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
kexec/kexec.h +5 -0
@@ -121,6 +121,11 @@ do { \fprintf (stderr, __VA_ARGS__); \ } while(0) +#define err (...) \ +do { \ + fprintf(stderr, __VA_ARGS__); \ +} while(0); +struct kexec_segment {const void *buf;size_t bufsz;
Signature · 6 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
PATCH 2/2 kexec: Use err() instead of fprintf()
From: Zhang Yanfei <[email protected]>
Since we have the err() interface, so replace the error printing function with err().
--- kexec/arch/arm/kexec-arm.c | 3 +- kexec/arch/arm/kexec-zImage-arm.c | 18 ++++----- kexec/arch/i386/crashdump-x86.c | 37 ++++++++--------- kexec/arch/i386/kexec-bzImage.c | 18 ++++---- kexec/arch/i386/kexec-elf-x86.c | 4 +- kexec/arch/i386/kexec-multiboot-x86.c | 11 ++--- kexec/arch/i386/kexec-nbi.c | 14 +++--- kexec/arch/i386/kexec-x86-common.c | 27 ++++++------- kexec/arch/i386/kexec-x86.c | 9 +--- kexec/arch/i386/x86-linux-setup.c | 19 ++++----- kexec/arch/ia64/crashdump-ia64.c | 5 +- kexec/arch/ia64/kexec-elf-ia64.c | 12 +++--- kexec/arch/ia64/kexec-ia64.c | 3 +- kexec/arch/mips/crashdump-mips.c | 11 ++--- kexec/arch/mips/kexec-elf-mips.c | 2 +- kexec/arch/mips/kexec-mips.c | 4 +- kexec/arch/ppc/crashdump-powerpc.c | 5 +- kexec/arch/ppc/fixup_dtb.c | 3 +- kexec/arch/ppc/kexec-dol-ppc.c | 14 +++---- kexec/arch/ppc/kexec-elf-ppc.c | 4 +- kexec/arch/ppc/kexec-ppc.c | 36 ++++++++-------- kexec/arch/ppc/kexec-uImage-ppc.c | 2 +- kexec/arch/ppc64/crashdump-ppc64.c | 10 ++--- kexec/arch/ppc64/fs2dt.c | 2 +- kexec/arch/ppc64/kexec-elf-ppc64.c | 17 ++++---- kexec/arch/ppc64/kexec-ppc64.c | 6 +- kexec/arch/ppc64/kexec-zImage-ppc64.c | 18 +++----- kexec/arch/s390/kexec-image.c | 4 +- kexec/arch/s390/kexec-s390.c | 2 +- kexec/arch/sh/kexec-sh.c | 2 +- kexec/arch/x86_64/kexec-bzImage64.c | 16 ++++---- kexec/arch/x86_64/kexec-elf-x86_64.c | 6 +- kexec/arch/x86_64/kexec-x86_64.c | 5 +- kexec/crashdump-xen.c | 8 ++-- kexec/firmware_memmap.c | 12 ++--- kexec/fs2dt.c | 2 +- kexec/kernel_version.c | 17 +++----- kexec/kexec-elf-exec.c | 8 ++-- kexec/kexec-elf-rel.c | 10 ++-- kexec/kexec-elf.c | 70 ++++++++++++++++----------------- kexec/kexec.c | 64 ++++++++++++------------------ kexec/phys_arch.c | 6 +-- kexec/zlib.c | 2 +- 43 files changed, 249 insertions(+), 299 deletions(-)
kexec/arch/arm/kexec-arm.c +1 -2
@@ -31,8 +31,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges,FILE *fp; fp =fopen (iomem,"r" );if (!fp) { -fprintf (stderr,"Cannot open %s: %s\n" , - iomem,strerror (errno)); +err ("Cannot open %s: %s\n" , iomem,strerror (errno));return -1 ; }
kexec/arch/arm/kexec-zImage-arm.c +8 -10
@@ -114,8 +114,7 @@ struct tag * atag_read_tags(void)FILE *fp; fp =fopen (fn,"r" );if (!fp) { -fprintf (stderr,"Cannot open %s: %s\n" , - fn,strerror (errno)); +err ("Cannot open %s: %s\n" , fn,strerror (errno));return NULL ; }
@@ -125,8 +124,7 @@ struct tag * atag_read_tags(void) }if (ferror (fp)) { -fprintf (stderr,"Cannot read %s: %s\n" , - fn,strerror (errno)); +err ("Cannot read %s: %s\n" , fn,strerror (errno));fclose (fp);return NULL ; }
@@ -149,7 +147,7 @@ int atag_arm_load(struct kexec_info *info, unsigned long base, buf =xmalloc (getpagesize ());if (!buf) { -fprintf (stderr,"Compiling ATAGs: out of memory\n" ); +err ("Compiling ATAGs: out of memory\n" );return -1 ; }
@@ -282,7 +280,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len, }if (use_atags && dtb_file) { -fprintf (stderr,"You can only use ATAGs if you don't specify a " +err ("You can only use ATAGs if you don't specify a " "dtb file.\n" );return -1 ; }
@@ -361,7 +359,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len, dtb_buf =slurp_file (dtb_file, &dtb_length);if (fdt_check_header (dtb_buf) !=0 ) { -fprintf (stderr,"Invalid FDT buffer.\n" ); +err ("Invalid FDT buffer.\n" );return -1 ; }
@@ -382,13 +380,13 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len, off =fdt_add_subnode (dtb_buf, off, node_name);if (off <0 ) { -fprintf (stderr,"FDT: Error adding %s node.\n" , node_name); +err ("FDT: Error adding %s node.\n" , node_name);return -1 ; }if (fdt_setprop (dtb_buf, off, prop_name, command_line,strlen (command_line) +1 ) !=0 ) { -fprintf (stderr,"FDT: Error setting %s/%s property.\n" , +err ("FDT: Error setting %s/%s property.\n" , node_name, prop_name);return -1 ; }
@@ -401,7 +399,7 @@ int zImage_arm_load(int argc, char **argv, const char *buf, off_t len, }if (base + atag_offset + dtb_length > base + offset) { -fprintf (stderr,"DTB too large!\n" ); +err ("DTB too large!\n" );return -1 ; }
kexec/arch/i386/crashdump-x86.c +17 -20
@@ -101,7 +101,7 @@ static int get_kernel_paddr(struct kexec_info *UNUSED(info),return 0 ; } -fprintf (stderr,"Cannot determine kernel physical load addr\n" ); +err ("Cannot determine kernel physical load addr\n" );return -1 ; }
@@ -134,7 +134,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info), size =KCORE_ELF_HEADERS_SIZE ; buf =slurp_file_len (kcore, size);if (!buf) { -fprintf (stderr,"Cannot read %s: %s\n" , kcore,strerror (errno)); +err ("Cannot read %s: %s\n" , kcore,strerror (errno));return -1 ; }
@@ -147,7 +147,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info), result =build_elf_core_info (buf, size, &ehdr, elf_flags);if (result <0 ) {/* Perhaps KCORE_ELF_HEADERS_SIZE is too small? */ -fprintf (stderr,"ELF core (kcore) parse failed\n" ); +err ("ELF core (kcore) parse failed\n" );return -1 ; }
@@ -175,7 +175,7 @@ static int get_kernel_vaddr_and_size(struct kexec_info *UNUSED(info), } } } -fprintf (stderr,"Can't find kernel text map area from kcore\n" ); +err ("Can't find kernel text map area from kcore\n" );return -1 ; }
@@ -215,8 +215,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, fp =fopen (iomem,"r" );if (!fp) { -fprintf (stderr,"Cannot open %s: %s\n" , - iomem,strerror (errno)); +err ("Cannot open %s: %s\n" , iomem,strerror (errno));return -1 ; }
@@ -277,8 +276,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges, } }if (crash_reserved_mem.start >= mem_max) { -fprintf (stderr,"Too small mem_max: 0x%llx.\n" , - mem_max); +err ("Too small mem_max: 0x%llx.\n" , mem_max);return -1 ; } crash_reserved_mem.end = mem_max;
@@ -320,14 +318,14 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, xc =xc_interface_open (NULL ,NULL ,0 );if (!xc) { -fprintf (stderr,"%s: Failed to open Xen control interface\n" , __func__); +err ("%s: Failed to open Xen control interface\n" , __func__); goto err; }#else xc =xc_interface_open ();if (xc ==-1 ) { -fprintf (stderr,"%s: Failed to open Xen control interface\n" , __func__); +err ("%s: Failed to open Xen control interface\n" , __func__); goto err; }#endif
@@ -335,7 +333,7 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, rc =xc_get_machine_memory_map (xc, e820entries,CRASH_MAX_MEMORY_RANGES );if (rc <0 ) { -fprintf (stderr,"%s: xc_get_machine_memory_map: %s\n" , __func__,strerror (-rc)); +err ("%s: xc_get_machine_memory_map: %s\n" , __func__,strerror (-rc)); goto err; }
@@ -375,7 +373,7 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, fd =open ("/proc/xen/privcmd" ,O_RDWR );if (fd ==-1 ) { -fprintf (stderr,"%s: open(/proc/xen/privcmd): %m\n" , __func__); +err ("%s: open(/proc/xen/privcmd): %m\n" , __func__); goto err; }
@@ -383,7 +381,7 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, sizeof(struct e820entry) * CRASH_MAX_MEMORY_RANGES);if (rc) { -fprintf (stderr,"%s: posix_memalign(e820entries): %s\n" , __func__,strerror (rc)); +err ("%s: posix_memalign(e820entries): %s\n" , __func__,strerror (rc)); e820entries =NULL ; goto err; }
@@ -392,18 +390,18 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, sizeof(struct xen_memory_map));if (rc) { -fprintf (stderr,"%s: posix_memalign(xen_memory_map): %s\n" , __func__,strerror (rc)); +err ("%s: posix_memalign(xen_memory_map): %s\n" , __func__,strerror (rc)); xen_memory_map =NULL ; goto err; }if (mlock (e820entries,sizeof (struct e820entry ) *CRASH_MAX_MEMORY_RANGES ) ==-1 ) { -fprintf (stderr,"%s: mlock(e820entries): %m\n" , __func__); +err ("%s: mlock(e820entries): %m\n" , __func__); goto err; }if (mlock (xen_memory_map,sizeof (struct xen_memory_map )) ==-1 ) { -fprintf (stderr,"%s: mlock(xen_memory_map): %m\n" , __func__); +err ("%s: mlock(xen_memory_map): %m\n" , __func__); goto err; }
@@ -417,7 +415,7 @@ static int get_crash_memory_ranges_xen(struct memory_range **range, rc =ioctl (fd,IOCTL_PRIVCMD_HYPERCALL , &hypercall);if (rc ==-1 ) { -fprintf (stderr,"%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n" , __func__); +err ("%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n" , __func__); goto err; }
@@ -513,7 +511,7 @@ static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end)if (tidx >=0 ) {if (*nr_ranges ==CRASH_MAX_MEMORY_RANGES ) {/* No space to insert another element. */ -fprintf (stderr,"Error: Number of crash memory ranges" +err ("Error: Number of crash memory ranges" " excedeed the max limit\n" );return -1 ; }
@@ -970,8 +968,7 @@ int load_crashdump_segments(struct kexec_info *info, char* mod_cmdline, elf_info.get_note_info = get_crash_notes;break ;default : -fprintf (stderr,"unsupported crashdump architecture: %04x\n" , - kexec_arch); +err ("unsupported crashdump architecture: %04x\n" , kexec_arch);return -1 ; }
kexec/arch/i386/kexec-bzImage.c +9 -9
@@ -46,41 +46,41 @@ int bzImage_probe(const char *buf, off_t len)const struct x86_linux_header *header;if ((uintmax_t )len < (uintmax_t)(2 *512 )) {if (probe_debug) { -fprintf (stderr,"File is too short to be a bzImage!\n" ); +err ("File is too short to be a bzImage!\n" ); }return -1 ; } header = (const struct x86_linux_header *)buf;if (memcmp (header->header_magic,"HdrS" ,4 ) !=0 ) {if (probe_debug) { -fprintf (stderr,"Not a bzImage\n" ); +err ("Not a bzImage\n" ); }return -1 ; }if (header->boot_sector_magic !=0xAA55 ) {if (probe_debug) { -fprintf (stderr,"No x86 boot sector present\n" ); +err ("No x86 boot sector present\n" ); }/* No x86 boot sector present */ return -1 ; }if (header->protocol_version <0x0200 ) {if (probe_debug) { -fprintf (stderr,"Must be at least protocol version 2.00\n" ); +err ("Must be at least protocol version 2.00\n" ); }/* Must be at least protocol version 2.00 */ return -1 ; }if ((header->loadflags &1 ) ==0 ) {if (probe_debug) { -fprintf (stderr,"zImage not a bzImage\n" ); +err ("zImage not a bzImage\n" ); }/* Not a bzImage */ return -1 ; }/* I've got a bzImage */ if (probe_debug) { -fprintf (stderr,"It's a bzImage\n" ); +err ("It's a bzImage\n" ); }return 0 ; }
@@ -135,7 +135,7 @@ int do_bzImage_load(struct kexec_info *info, kern16_size = (setup_sects +1 ) *512 ; kernel_version = ((char *)&setup_header) +512 + setup_header.kver_addr;if (kernel_len < kern16_size) { -fprintf (stderr,"BzImage truncated?\n" ); +err ("BzImage truncated?\n" );return -1 ; }
@@ -158,13 +158,13 @@ int do_bzImage_load(struct kexec_info *info,/* Can't use bzImage for crash dump purposes with real mode entry */ if ((info->kexec_flags &KEXEC_ON_CRASH ) && real_mode_entry) { -fprintf (stderr,"Can't use bzImage for crash dump purposes" +err ("Can't use bzImage for crash dump purposes" " with real mode entry\n" );return -1 ; }if ((info->kexec_flags &KEXEC_ON_CRASH ) && !relocatable_kernel) { -fprintf (stderr,"BzImage is not relocatable. Can't be used" +err ("BzImage is not relocatable. Can't be used" " as capture kernel.\n" );return -1 ; }
kexec/arch/i386/kexec-elf-x86.c +2 -2
@@ -50,7 +50,7 @@ int elf_x86_probe(const char *buf, off_t len) result =build_elf_exec_info (buf, len, &ehdr,0 );if (result <0 ) {if (probe_debug) { -fprintf (stderr,"Not an ELF executable\n" ); +err ("Not an ELF executable\n" ); } goto out; }
@@ -59,7 +59,7 @@ int elf_x86_probe(const char *buf, off_t len)if ((ehdr.e_machine !=EM_386 ) && (ehdr.e_machine !=EM_486 )) {/* for a different architecture */ if (probe_debug) { -fprintf (stderr,"Not i386 ELF executable\n" ); +err ("Not i386 ELF executable\n" ); } result =-1 ; goto out;
kexec/arch/i386/kexec-multiboot-x86.c +4 -7
@@ -93,16 +93,14 @@ int multiboot_x86_probe(const char *buf, off_t buf_len) }if (mbh->flags &MULTIBOOT_AOUT_KLUDGE ) {/* Requires options we don't support */ -fprintf (stderr, -"Found a multiboot header, but it uses " +err ("Found a multiboot header, but it uses " "a non-ELF header layout,\n" "and I can't do that (yet). Sorry.\n" );return -1 ; }if (mbh->flags &MULTIBOOT_UNSUPPORTED ) {/* Requires options we don't support */ -fprintf (stderr, -"Found a multiboot header, but it " +err ("Found a multiboot header, but it " "requires multiboot options that I\n" "don't understand. Sorry.\n" );return -1 ;
@@ -110,8 +108,7 @@ int multiboot_x86_probe(const char *buf, off_t buf_len)if (mbh->flags &MULTIBOOT_VIDEO_MODE ) {/* Asked for screen mode information */ /* XXX carry on regardless */ -fprintf (stderr, -"BEWARE! Found a multiboot header which asks " +err ("BEWARE! Found a multiboot header which asks " "for screen mode information.\n" "BEWARE! I am NOT supplying screen mode " "information, but loading it regardless.\n" );
@@ -171,7 +168,7 @@ int multiboot_x86_load(int argc, char **argv, const char *buf, off_t len,/* Probe for the MB header if it's not already found */ if (mbh ==NULL &&multiboot_x86_probe (buf, len) !=1 ) { -fprintf (stderr,"Cannot find a loadable multiboot header.\n" ); +err ("Cannot find a loadable multiboot header.\n" );return -1 ; }
kexec/arch/i386/kexec-nbi.c +7 -7
@@ -84,7 +84,7 @@ int nbi_probe(const char *buf, off_t len)/* Ensure we have a properly sized header */ if (((hdr.length &0xf )*4 ) !=sizeof (hdr)) {if (probe_debug) { -fprintf (stderr,"NBI: Bad vendor header size\n" ); +err ("NBI: Bad vendor header size\n" ); }return -1 ; }
@@ -93,14 +93,14 @@ int nbi_probe(const char *buf, off_t len)*/ if ((((hdr.length &0xf0 ) >>4 )*4 ) > (512 -sizeof (hdr))) {if (probe_debug) { -fprintf (stderr,"NBI: vendor headr too large\n" ); +err ("NBI: vendor headr too large\n" ); }return -1 ; }/* Reserved bits are set in the image... */ if ((hdr.length &0x7ffffe00 )) {if (probe_debug) { -fprintf (stderr,"NBI: Reserved header bits set\n" ); +err ("NBI: Reserved header bits set\n" ); }return -1 ; }
@@ -117,26 +117,26 @@ int nbi_probe(const char *buf, off_t len)memcpy (&seg, buf + seg_off,sizeof (seg));if ((seg.length &0xf ) !=4 ) {if (probe_debug) { -fprintf (stderr,"NBI: Invalid segment length\n" ); +err ("NBI: Invalid segment length\n" ); }return -1 ; } seg_off += ((seg.length &0xf ) + ((seg.length >>4 ) &0xf )) <<2 ;if (seg.flags &0xf8 ) {if (probe_debug) { -fprintf (stderr,"NBI: segment reserved flags set\n" ); +err ("NBI: segment reserved flags set\n" ); }return -1 ; }if ((seg.flags &NBI_SEG ) ==NBI_SEG_NEGATIVE ) {if (probe_debug) { -fprintf (stderr,"NBI: negative segment addresses not supported\n" ); +err ("NBI: negative segment addresses not supported\n" ); }return -1 ; }if (seg_off >512 ) {if (probe_debug) { -fprintf (stderr,"NBI: segment outside 512 header\n" ); +err ("NBI: segment outside 512 header\n" ); }return -1 ; }
kexec/arch/i386/kexec-x86-common.c +13 -14
@@ -70,8 +70,7 @@ static int get_memory_ranges_proc_iomem(struct memory_range **range, int *rangesFILE *fp; fp =fopen (iomem,"r" );if (!fp) { -fprintf (stderr,"Cannot open %s: %s\n" , - iomem,strerror (errno)); +err ("Cannot open %s: %s\n" , iomem,strerror (errno));return -1 ; }while (fgets (line,sizeof (line), fp) !=0 ) {
@@ -137,7 +136,7 @@ static int get_memory_ranges_sysfs(struct memory_range **range, int *ranges) ret =get_firmware_memmap_ranges (memory_range, &range_number);if (ret !=0 ) { -fprintf (stderr,"Parsing the /sys/firmware memory map failed. " +err ("Parsing the /sys/firmware memory map failed. " "Falling back to /proc/iomem.\n" );return get_memory_ranges_proc_iomem (range, ranges); }
@@ -189,14 +188,14 @@ static int get_memory_ranges_xen(struct memory_range **range, int *ranges) xc =xc_interface_open (NULL ,NULL ,0 );if (!xc) { -fprintf (stderr,"%s: Failed to open Xen control interface\n" , __func__); +err ("%s: Failed to open Xen control interface\n" , __func__); goto err; }#else xc =xc_interface_open ();if (xc ==-1 ) { -fprintf (stderr,"%s: Failed to open Xen control interface\n" , __func__); +err ("%s: Failed to open Xen control interface\n" , __func__); goto err; }#endif
@@ -204,7 +203,7 @@ static int get_memory_ranges_xen(struct memory_range **range, int *ranges) rc =xc_get_machine_memory_map (xc, e820entries,MAX_MEMORY_RANGES );if (rc <0 ) { -fprintf (stderr,"%s: xc_get_machine_memory_map: %s\n" , __func__,strerror (rc)); +err ("%s: xc_get_machine_memory_map: %s\n" , __func__,strerror (rc)); goto err; }
@@ -238,7 +237,7 @@ static int get_memory_ranges_xen(struct memory_range **range, int *ranges) fd =open ("/proc/xen/privcmd" ,O_RDWR );if (fd ==-1 ) { -fprintf (stderr,"%s: open(/proc/xen/privcmd): %m\n" , __func__); +err ("%s: open(/proc/xen/privcmd): %m\n" , __func__); goto err; }
@@ -246,7 +245,7 @@ static int get_memory_ranges_xen(struct memory_range **range, int *ranges) sizeof(struct e820entry) * MAX_MEMORY_RANGES);if (rc) { -fprintf (stderr,"%s: posix_memalign(e820entries): %s\n" , __func__,strerror (rc)); +err ("%s: posix_memalign(e820entries): %s\n" , __func__,strerror (rc)); e820entries =NULL ; goto err; }
@@ -255,18 +254,18 @@ static int get_memory_ranges_xen(struct memory_range **range, int *ranges) sizeof(struct xen_memory_map));if (rc) { -fprintf (stderr,"%s: posix_memalign(xen_memory_map): %s\n" , __func__,strerror (rc)); +err ("%s: posix_memalign(xen_memory_map): %s\n" , __func__,strerror (rc)); xen_memory_map =NULL ; goto err; }if (mlock (e820entries,sizeof (struct e820entry ) *MAX_MEMORY_RANGES ) ==-1 ) { -fprintf (stderr,"%s: mlock(e820entries): %m\n" , __func__); +err ("%s: mlock(e820entries): %m\n" , __func__); goto err; }if (mlock (xen_memory_map,sizeof (struct xen_memory_map )) ==-1 ) { -fprintf (stderr,"%s: mlock(xen_memory_map): %m\n" , __func__); +err ("%s: mlock(xen_memory_map): %m\n" , __func__); goto err; }
@@ -280,7 +279,7 @@ static int get_memory_ranges_xen(struct memory_range **range, int *ranges) rc =ioctl (fd,IOCTL_PRIVCMD_HYPERCALL , &hypercall);if (rc ==-1 ) { -fprintf (stderr,"%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n" , __func__); +err ("%s: ioctl(IOCTL_PRIVCMD_HYPERCALL): %m\n" , __func__); goto err; }
@@ -347,7 +346,7 @@ again:for (i =0 ; i < (nr_ranges-1 ); i++) { j = i+1 ;if (rp[i].start > rp[j].start) { -fprintf (stderr,"memory out of order!!\n" ); +err ("memory out of order!!\n" );return 1 ; }
@@ -467,7 +466,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, ret =parse_iomem_single ("Crash kernel\n" , &start, &end);if (ret !=0 ) { -fprintf (stderr,"parse_iomem_single failed.\n" ); +err ("parse_iomem_single failed.\n" );return -1 ; }
kexec/arch/i386/kexec-x86.c +3 -6
@@ -106,8 +106,7 @@ int arch_process_options(int argc, char **argv) } }if (value >=65536 ) { -fprintf (stderr,"Bad serial port base '%s'\n" , - optarg); +err ("Bad serial port base '%s'\n" , optarg);usage ();return -1 ;
@@ -119,8 +118,7 @@ int arch_process_options(int argc, char **argv)if ((value >115200 ) || ((115200 %value) !=0 ) || (value <9600 ) || (*end)) { -fprintf (stderr,"Bad serial port baud rate '%s'\n" , - optarg); +err ("Bad serial port baud rate '%s'\n" , optarg);usage ();return -1 ;
@@ -158,8 +156,7 @@ int arch_compat_trampoline(struct kexec_info *info)if ((info->kexec_flags &KEXEC_ARCH_MASK ) ==KEXEC_ARCH_X86_64 ) {if (!info->rhdr.e_shdr) { -fprintf (stderr, -"A trampoline is required for cross architecture support\n" ); +err ("A trampoline is required for cross architecture support\n" );return -1 ; } elf_rel_set_symbol(&info->rhdr, "compat_x86_64_entry32",
kexec/arch/i386/x86-linux-setup.c +9 -10
@@ -272,7 +272,7 @@ static int read_edd_raw_data(const char *dir, struct edd_info *edd_info)dbgprintf ("EDD raw data has length %d\n" , len);if (read_chars < len) { -fprintf (stderr,"BIOS reported EDD length of %hd but only " +err ("BIOS reported EDD length of %hd but only " "%d chars read.\n" , len, (int )read_chars);return -1 ; }
@@ -288,7 +288,7 @@ static int add_edd_entry(struct x86_linux_param_header *real_mode,struct edd_info *edd_info;if (!current_mbr || !current_edd) { -fprintf (stderr,"%s: current_edd and current_edd " +err ("%s: current_edd and current_edd " "must not be NULL" , __FUNCTION__);return -1 ; }
@@ -298,7 +298,7 @@ static int add_edd_entry(struct x86_linux_param_header *real_mode,/* extract the device number */ if (sscanf (basename (sysfs_name),"int13_dev%hhx" , &devnum) !=1 ) { -fprintf (stderr,"Invalid format of int13_dev dir " +err ("Invalid format of int13_dev dir " "entry: %s\n" ,basename (sysfs_name));return -1 ; }
@@ -324,33 +324,33 @@ static int add_edd_entry(struct x86_linux_param_header *real_mode,/* legacy_max_cylinder */ if (file_scanf (sysfs_name,"legacy_max_cylinder" ,"%hu" , &edd_info->legacy_max_cylinder) !=1 ) { -fprintf (stderr,"Reading legacy_max_cylinder failed.\n" ); +err ("Reading legacy_max_cylinder failed.\n" );return -1 ; }/* legacy_max_head */ if (file_scanf (sysfs_name,"legacy_max_head" ,"%hhu" , &edd_info->legacy_max_head) !=1 ) { -fprintf (stderr,"Reading legacy_max_head failed.\n" ); +err ("Reading legacy_max_head failed.\n" );return -1 ; }/* legacy_sectors_per_track */ if (file_scanf (sysfs_name,"legacy_sectors_per_track" ,"%hhu" , &edd_info->legacy_sectors_per_track) !=1 ) { -fprintf (stderr,"Reading legacy_sectors_per_track failed.\n" ); +err ("Reading legacy_sectors_per_track failed.\n" );return -1 ; }/* Parse the EDD extensions */ if (parse_edd_extensions (sysfs_name, edd_info) !=0 ) { -fprintf (stderr,"Parsing EDD extensions failed.\n" ); +err ("Parsing EDD extensions failed.\n" );return -1 ; }/* Parse the raw info */ if (read_edd_raw_data (sysfs_name, edd_info) !=0 ) { -fprintf (stderr,"Reading EDD raw data failed.\n" ); +err ("Reading EDD raw data failed.\n" );return -1 ; } }
@@ -513,8 +513,7 @@ void setup_linux_system_parameters(struct kexec_info *info,* this e820 not used for capture kernel, see * do_bzImage_load() */ -fprintf (stderr, -"Too many memory ranges, truncating...\n" ); +err ("Too many memory ranges, truncating...\n" ); ranges =E820MAX ; } real_mode->e820_map_nr = ranges;
kexec/arch/ia64/crashdump-ia64.c +2 -3
@@ -140,7 +140,7 @@ static int exclude_crash_reserve_region(int *nr_ranges)if (tidx >=0 ) {if (*nr_ranges == max_memory_ranges) {/* No space to insert another element. */ -fprintf (stderr,"Error: Number of crash memory ranges" +err ("Error: Number of crash memory ranges" " excedeed the max limit\n" );return -1 ; }
@@ -165,8 +165,7 @@ static int get_crash_memory_ranges(int *ranges) max_memory_ranges); fp =fopen (iomem,"r" );if (!fp) { -fprintf (stderr,"Cannot open %s: %s\n" , - iomem,strerror (errno)); +err ("Cannot open %s: %s\n" , iomem,strerror (errno));return -1 ; }while (fgets (line,sizeof (line), fp) !=0 ) {
kexec/arch/ia64/kexec-elf-ia64.c +6 -6
@@ -60,7 +60,7 @@ int elf_ia64_probe(const char *buf, off_t len) result =build_elf_exec_info (buf, len, &ehdr,0 );if (result <0 ) {if (probe_debug) { -fprintf (stderr,"Not an ELF executable\n" ); +err ("Not an ELF executable\n" ); }return -1 ; }
@@ -68,7 +68,7 @@ int elf_ia64_probe(const char *buf, off_t len)if (ehdr.e_machine !=EM_IA_64 ) {/* for a different architecture */ if (probe_debug) { -fprintf (stderr,"Not for this architecture.\n" ); +err ("Not for this architecture.\n" ); }return -1 ; }
@@ -186,21 +186,21 @@ int elf_ia64_load(int argc, char **argv, const char *buf, off_t len,/* Parse the Elf file */ result =build_elf_exec_info (kernel_buf, kernel_size, &ehdr,0 );if (result <0 ) { -fprintf (stderr,"ELF parse failed\n" ); +err ("ELF parse failed\n" );free_elf_info (&ehdr);return result; }if (info->kexec_flags &KEXEC_ON_CRASH ) {if ((mem_min ==0x00 ) && (mem_max ==ULONG_MAX )) { -fprintf (stderr,"Failed to find crash kernel region " +err ("Failed to find crash kernel region " "in %s\n" ,proc_iomem ());free_elf_info (&ehdr);return -1 ; }move_loaded_segments (&ehdr, mem_min); }else if (update_loaded_segments (&ehdr) <0 ) { -fprintf (stderr,"Failed to place kernel\n" ); +err ("Failed to place kernel\n" );return -1 ; }
@@ -210,7 +210,7 @@ int elf_ia64_load(int argc, char **argv, const char *buf, off_t len,/* Load the Elf data */ result =elf_exec_load (&ehdr, info);if (result <0 ) { -fprintf (stderr,"ELF load failed\n" ); +err ("ELF load failed\n" );free_elf_info (&ehdr);return result; }
kexec/arch/ia64/kexec-ia64.c +1 -2
@@ -84,8 +84,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges,FILE *fp; fp =fopen (iomem,"r" );if (!fp) { -fprintf (stderr,"Cannot open %s: %s\n" , - iomem,strerror (errno)); +err ("Cannot open %s: %s\n" , iomem,strerror (errno));return -1 ; }
kexec/arch/mips/crashdump-mips.c +5 -6
@@ -64,7 +64,7 @@ static int get_kernel_paddr(struct crash_elf_info *elf_info)return 0 ; } -fprintf (stderr,"Cannot determine kernel physical load addr\n" ); +err ("Cannot determine kernel physical load addr\n" );return -1 ; }
@@ -86,7 +86,7 @@ static int get_kernel_vaddr_and_size(struct crash_elf_info *elf_info,dbgprintf ("kernel size = 0x%lx\n" , elf_info->kern_size);return 0 ; } -fprintf (stderr,"Cannot determine kernel virtual load addr and size\n" ); +err ("Cannot determine kernel virtual load addr and size\n" );return -1 ; }
@@ -128,8 +128,8 @@ static int exclude_crash_reserve_region(int *nr_ranges)if (tidx >=0 ) {if (*nr_ranges ==CRASH_MAX_MEMORY_RANGES ) {/* No space to insert another element. */ -fprintf (stderr,"Error: Number of crash memory ranges" -" excedeed the max limit\n" ); +err ("Error: Number of crash memory ranges" +" excedeed the max limit\n" );return -1 ; }for (j = (*nr_ranges -1 ); j >= tidx; j--)
@@ -162,8 +162,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) fp =fopen (iomem,"r" );if (!fp) { -fprintf (stderr,"Cannot open %s: %s\n" , - iomem,strerror (errno)); +err ("Cannot open %s: %s\n" , iomem,strerror (errno));return -1 ; }/* Separate segment for backup region */
kexec/arch/mips/kexec-elf-mips.c +1 -1
@@ -50,7 +50,7 @@ int elf_mips_probe(const char *buf, off_t len)if (ehdr.e_machine !=EM_MIPS ) {/* for a different architecture */ if (probe_debug) { -fprintf (stderr,"Not for this architecture.\n" ); +err ("Not for this architecture.\n" ); } result =-1 ; goto out;
kexec/arch/mips/kexec-mips.c +2 -2
@@ -38,7 +38,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, fp =fopen (iomem,"r" );if (!fp) { -fprintf (stderr,"Cannot open %s: %s\n" , iomem,strerror (errno)); +err ("Cannot open %s: %s\n" , iomem,strerror (errno));return -1 ; }while (fgets (line,sizeof (line), fp) !=0 ) {
@@ -75,7 +75,7 @@ int file_types = sizeof(file_type) / sizeof(file_type[0]);void arch_usage (void ) {#ifdef __mips64 -fprintf (stderr," --elf32-core-headers Prepare core headers in " +err (" --elf32-core-headers Prepare core headers in " "ELF32 format\n" );#endif }
kexec/arch/ppc/crashdump-powerpc.c +2 -3
@@ -90,7 +90,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) crash_memory_range = (struct memory_range *)malloc (crash_rng_len);if (!crash_memory_range) { -fprintf (stderr,"Allocation for crash memory range failed\n" ); +err ("Allocation for crash memory range failed\n" );return -1 ; }memset (crash_memory_range,0 , crash_rng_len);
@@ -141,8 +141,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) }if (memory_ranges >= (max_memory_ranges +1 )) {/* No space to insert another element. */ -fprintf (stderr, -"Error: Number of crash memory ranges" +err ("Error: Number of crash memory ranges" " excedeed the max limit\n" ); goto err; }
kexec/arch/ppc/fixup_dtb.c +1 -2
@@ -58,8 +58,7 @@ static void fixup_nodes(char *nodes[]) content =slurp_file (fname, &content_size);if (!content) { -fprintf (stderr,"Can't open %s: %s\n" , - fname,strerror (errno)); +err ("Can't open %s: %s\n" , fname,strerror (errno));exit (1 ); }
kexec/arch/ppc/kexec-dol-ppc.c +6 -8
@@ -242,7 +242,7 @@ int dol_ppc_probe(const char *buf, off_t dol_length)/* the DOL file should be at least as long as the DOL header */ if (dol_length <DOL_HEADER_SIZE ) {if (debug) { -fprintf (stderr,"Not a DOL file, too short.\n" ); +err ("Not a DOL file, too short.\n" ); }return -1 ; }
@@ -257,8 +257,7 @@ int dol_ppc_probe(const char *buf, off_t dol_length)if ((dol_sect_offset (h, i) !=0 ) && (dol_sect_offset (h, i) <DOL_HEADER_SIZE )) {if (debug) { -fprintf (stderr, -"%s segment offset within DOL header\n" , +err ("%s segment offset within DOL header\n" ,dol_sect_type (i)); }return -1 ;
@@ -268,8 +267,7 @@ int dol_ppc_probe(const char *buf, off_t dol_length)if ((uintmax_t)(dol_sect_offset (h, i) +dol_sect_size (h, i)) > (uintmax_t )dol_length) {if (debug) { -fprintf (stderr, -"%s segment past DOL file size\n" , +err ("%s segment past DOL file size\n" ,dol_sect_type (i)); }return -1 ;
@@ -278,7 +276,7 @@ int dol_ppc_probe(const char *buf, off_t dol_length)/* we only should accept DOLs with segments above 2GB */ if (dol_sect_address (h, i) !=0 && !(dol_sect_address (h, i) &0x80000000 )) { -fprintf (stderr,"warning, %s segment below 2GB\n" , +err ("warning, %s segment below 2GB\n" ,dol_sect_type (i)); }
@@ -293,13 +291,13 @@ int dol_ppc_probe(const char *buf, off_t dol_length)/* if there is a BSS segment it must^H^H^H^Hshould be above 2GB, too */ if (h->address_bss !=0 && !(h->address_bss &0x80000000 )) { -fprintf (stderr,"warning, BSS segment below 2GB\n" ); +err ("warning, BSS segment below 2GB\n" ); }/* if entrypoint is not within a code segment reject this file */ if (!valid) {if (debug) { -fprintf (stderr,"Entry point out of text segment\n" ); +err ("Entry point out of text segment\n" ); }return -1 ; }
kexec/arch/ppc/kexec-elf-ppc.c +2 -2
@@ -88,7 +88,7 @@ int elf_ppc_probe(const char *buf, off_t len)if (ehdr.e_machine !=EM_PPC ) {/* for a different architecture */ if (probe_debug) { -fprintf (stderr,"Not for this architecture.\n" ); +err ("Not for this architecture.\n" ); } result =-1 ; goto out;
@@ -223,7 +223,7 @@ int elf_ppc_load(int argc, char **argv, const char *buf, off_t len,case OPT_NODES :if (cur_fixup >=FIXUP_ENTRYS ) { -fprintf (stderr,"The number of entries for the fixup is too large\n" ); +err ("The number of entries for the fixup is too large\n" );exit (1 ); } fixup_nodes[cur_fixup] = optarg;
kexec/arch/ppc/kexec-ppc.c +18 -18
@@ -50,13 +50,13 @@ int init_memory_region_info() file ="/proc/device-tree/#address-cells" ; fd =open (file,O_RDONLY );if (fd <0 ) { -fprintf (stderr,"Unable to open %s\n" , file); +err ("Unable to open %s\n" , file);return -1 ; } res =read (fd, &dt_address_cells,sizeof (dt_address_cells));if (res !=sizeof (dt_address_cells)) { -fprintf (stderr,"Error reading %s\n" , file); +err ("Error reading %s\n" , file);return -1 ; }close (fd);
@@ -64,13 +64,13 @@ int init_memory_region_info() file ="/proc/device-tree/#size-cells" ; fd =open (file,O_RDONLY );if (fd <0 ) { -fprintf (stderr,"Unable to open %s\n" , file); +err ("Unable to open %s\n" , file);return -1 ; } res =read (fd, &dt_size_cells,sizeof (dt_size_cells));if (res !=sizeof (dt_size_cells)) { -fprintf (stderr,"Error reading %s\n" , file); +err ("Error reading %s\n" , file);return -1 ; }close (fd);
@@ -95,11 +95,11 @@ int read_memory_region_limits(int fd, unsigned long long *start,unsigned long nbytes = dt_address_cells + dt_size_cells;if (lseek (fd,0 ,SEEK_SET ) ==-1 ) { -fprintf (stderr,"Error in file seek\n" ); +err ("Error in file seek\n" );return -1 ; }if (read (fd, buf, nbytes) != nbytes) { -fprintf (stderr,"Error reading the memory region info\n" ); +err ("Error reading the memory region info\n" );return -1 ; }
@@ -111,8 +111,8 @@ int read_memory_region_limits(int fd, unsigned long long *start, *start = ((unsigned long long *)p)[0 ]; p = (unsigned long long *)p +1 ; }else { -fprintf (stderr,"Unsupported value for #address-cells : %ld\n" , - dt_address_cells); +err ("Unsupported value for #address-cells : %ld\n" , + dt_address_cells);return -1 ; }
@@ -121,8 +121,8 @@ int read_memory_region_limits(int fd, unsigned long long *start,else if (dt_size_cells ==sizeof (unsigned long long )) *end = *start + ((unsigned long long *)p)[0 ];else { -fprintf (stderr,"Unsupported value for #size-cells : %ld\n" , - dt_size_cells); +err ("Unsupported value for #size-cells : %ld\n" , + dt_size_cells);return -1 ; }
@@ -228,7 +228,7 @@ static int alloc_memory_ranges(void)return 0 ; err1: -fprintf (stderr,"memory range structure allocation failure\n" ); +err ("memory range structure allocation failure\n" );cleanup_memory_ranges ();return -1 ; }
@@ -308,7 +308,7 @@ static int realloc_memory_ranges(void)return 0 ; err: -fprintf (stderr,"memory range structure re-allocation failure\n" ); +err ("memory range structure re-allocation failure\n" );return -1 ; }
@@ -411,7 +411,7 @@ static int read_kernel_memory_limit(char *fname, char *buf) goto err_out; }if (n !=sizeof (uint64_t )) { -fprintf (stderr,"%s node has invalid size: %d\n" , +err ("%s node has invalid size: %d\n" , fname, n); goto err_out; }
@@ -479,7 +479,7 @@ static int get_devtree_details(unsigned long kexec_flags) }else if (n ==sizeof (uint64_t )) { kernel_end = ((uint64_t *)buf)[0 ]; }else { -fprintf (stderr,"%s node has invalid size: %d\n" , fname, n); +err ("%s node has invalid size: %d\n" , fname, n); goto error_openfile; }fclose (file);
@@ -508,7 +508,7 @@ static int get_devtree_details(unsigned long kexec_flags) }else if (n ==sizeof (uint64_t )) { crash_base = ((uint64_t *)buf)[0 ]; }else { -fprintf (stderr,"%s node has invalid size: %d\n" , fname, n); +err ("%s node has invalid size: %d\n" , fname, n); goto error_openfile; }fclose (file);
@@ -531,7 +531,7 @@ static int get_devtree_details(unsigned long kexec_flags) }else if (n ==sizeof (uint64_t )) { crash_size = ((uint64_t *)buf)[0 ]; }else { -fprintf (stderr,"%s node has invalid size: %d\n" , fname, n); +err ("%s node has invalid size: %d\n" , fname, n); goto error_openfile; }fclose (file);
@@ -581,7 +581,7 @@ static int get_devtree_details(unsigned long kexec_flags) }else if (n ==sizeof (uint64_t )) { initrd_start = ((uint64_t *)buf)[0 ]; }else { -fprintf (stderr,"%s node has invalid size: %d\n" , fname, n); +err ("%s node has invalid size: %d\n" , fname, n); goto error_openfile; }fclose (file);
@@ -605,7 +605,7 @@ static int get_devtree_details(unsigned long kexec_flags) }else if (n ==sizeof (uint64_t )) { initrd_end = ((uint64_t *)buf)[0 ]; }else { -fprintf (stderr,"%s node has invalid size: %d\n" , fname, n); +err ("%s node has invalid size: %d\n" , fname, n); goto error_openfile; }fclose (file);
kexec/arch/ppc/kexec-uImage-ppc.c +1 -1
@@ -127,7 +127,7 @@ static int ppc_load_bare_bits(int argc, char **argv, const char *buf,case OPT_NODES :if (cur_fixup >=FIXUP_ENTRYS ) { -fprintf (stderr,"The number of entries for the fixup is too large\n" ); +err ("The number of entries for the fixup is too large\n" );exit (1 ); } fixup_nodes[cur_fixup] = optarg;
kexec/arch/ppc64/crashdump-ppc64.c +4 -6
@@ -151,9 +151,8 @@ static int get_dyn_reconf_crash_memory_ranges(void) }if (memory_ranges >= (max_memory_ranges +1 )) {/* No space to insert another element. */ -fprintf (stderr, -"Error: Number of crash memory ranges" -" excedeed the max limit\n" ); +err ("Error: Number of crash memory ranges" +" excedeed the max limit\n" );return -1 ; }
@@ -203,7 +202,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) crash_memory_range = (struct memory_range *)malloc (crash_rng_len);if (!crash_memory_range) { -fprintf (stderr,"Allocation for crash memory range failed\n" ); +err ("Allocation for crash memory range failed\n" );return -1 ; }memset (crash_memory_range,0 , crash_rng_len);
@@ -257,8 +256,7 @@ static int get_crash_memory_ranges(struct memory_range **range, int *ranges) }if (memory_ranges >= (max_memory_ranges +1 )) {/* No space to insert another element. */ -fprintf (stderr, -"Error: Number of crash memory ranges" +err ("Error: Number of crash memory ranges" " excedeed the max limit\n" ); goto err; }
kexec/arch/ppc64/fs2dt.c +1 -1
@@ -591,7 +591,7 @@ static void putnode(void)memcpy (dt, local_cmdline,cmd_len); dt += (cmd_len +3 )/4 ; -fprintf (stderr,"Modified cmdline:%s\n" , local_cmdline); +err ("Modified cmdline:%s\n" , local_cmdline);/* * Determine the platform type/stdout type, so that purgatory
kexec/arch/ppc64/kexec-elf-ppc64.c +8 -9
@@ -209,8 +209,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,*/ if (ramdisk) {if (devicetreeblob) { -fprintf (stderr, -"Can't use ramdisk with device tree blob input\n" ); +err ("Can't use ramdisk with device tree blob input\n" );return -1 ; } seg_buf =slurp_file (ramdisk, &seg_size);
@@ -332,7 +331,7 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,dbgprintf ("debug is %d\n" , my_debug);for (i =0 ; i < info->nr_segments; i++) -fprintf (stderr,"segment[%d].mem:%p memsz:%zu\n" , i, +err ("segment[%d].mem:%p memsz:%zu\n" , i, info->segment[i].mem, info->segment[i].memsz);return 0 ;
@@ -340,11 +339,11 @@ int elf_ppc64_load(int argc, char **argv, const char *buf, off_t len,void elf_ppc64_usage (void ) { -fprintf (stderr," --command-line=<Command line> command line to append.\n" ); -fprintf (stderr," --append=<Command line> same as --command-line.\n" ); -fprintf (stderr," --ramdisk=<filename> Initial RAM disk.\n" ); -fprintf (stderr," --initrd=<filename> same as --ramdisk.\n" ); -fprintf (stderr," --devicetreeblob=<filename> Specify device tree blob file.\n" ); +err (" --command-line=<Command line> command line to append.\n" ); +err (" --append=<Command line> same as --command-line.\n" ); +err (" --ramdisk=<filename> Initial RAM disk.\n" ); +err (" --initrd=<filename> same as --ramdisk.\n" ); +err (" --devicetreeblob=<filename> Specify device tree blob file.\n" ); -fprintf (stderr,"elf support is still broken\n" ); +err ("elf support is still broken\n" ); }
kexec/arch/ppc64/kexec-ppc64.c +3 -3
@@ -91,7 +91,7 @@ static int alloc_memory_ranges(void)return 0 ; err1: -fprintf (stderr,"memory range structure allocation failure\n" ); +err ("memory range structure allocation failure\n" );cleanup_memory_ranges ();return -1 ;
@@ -124,7 +124,7 @@ static int realloc_memory_ranges(void)return 0 ; err: -fprintf (stderr,"memory range structure re-allocation failure\n" ); +err ("memory range structure re-allocation failure\n" );return -1 ; }
@@ -759,7 +759,7 @@ int file_types = sizeof(file_type) / sizeof(file_type[0]);void arch_usage (void ) { -fprintf (stderr," --elf64-core-headers Prepare core headers in ELF64 format\n" ); +err (" --elf64-core-headers Prepare core headers in ELF64 format\n" ); }struct arch_options_t arch_options = {
kexec/arch/ppc64/kexec-zImage-ppc64.c +7 -11
@@ -38,18 +38,16 @@ int zImage_ppc64_probe(FILE *file)Elf32_Ehdr elf;if (fseek (file,0 ,SEEK_SET ) <0 ) { -fprintf (stderr,"seek error: %s\n" , -strerror (errno)); +err ("seek error: %s\n" ,strerror (errno));return -1 ; }if (fread (&elf,sizeof (Elf32_Ehdr),1 , file) !=1 ) { -fprintf (stderr,"read error: %s\n" , -strerror (errno)); +err ("read error: %s\n" ,strerror (errno));return -1 ; }if (elf.e_machine ==EM_PPC64 ) { -fprintf (stderr,"Elf64 not supported\n" ); +err ("Elf64 not supported\n" );return -1 ; }
@@ -85,8 +83,7 @@ int zImage_ppc64_load(FILE *file, int UNUSED(argc), char **UNUSED(argv),return -1 ; }if (elf.e_phnum >MAX_HEADERS ) { -fprintf (stderr, -"Only kernels with %i program headers are supported\n" , +err ("Only kernels with %i program headers are supported\n" ,MAX_HEADERS );return -1 ; }
@@ -108,8 +105,7 @@ int zImage_ppc64_load(FILE *file, int UNUSED(argc), char **UNUSED(argv), *ret_segments =malloc (elf.e_phnum *sizeof (struct kexec_segment ));if (*ret_segments ==0 ) { -fprintf (stderr,"malloc failed: %s\n" , -strerror (errno)); +err ("malloc failed: %s\n" ,strerror (errno));return -1 ; } segment = ret_segments[0 ];
@@ -131,7 +127,7 @@ int zImage_ppc64_load(FILE *file, int UNUSED(argc), char **UNUSED(argv), } }if (memsize ==0 ) { -fprintf (stderr,"Can't find a loadable segment.\n" ); +err ("Can't find a loadable segment.\n" );return -1 ; }
@@ -170,5 +166,5 @@ int zImage_ppc64_load(FILE *file, int UNUSED(argc), char **UNUSED(argv),void zImage_ppc64_usage (void ) { -fprintf (stderr,"zImage support is still broken\n" ); +err ("zImage support is still broken\n" ); }
kexec/arch/s390/kexec-image.c +2 -2
@@ -39,7 +39,7 @@ static void add_segment_check(struct kexec_info *info, const void *buf,int command_line_add (const char *str) {if (strlen (command_line) +strlen (str) +1 >COMMAND_LINESIZE ) { -fprintf (stderr,"Command line too long.\n" ); +err ("Command line too long.\n" );return -1 ; }strcat (command_line, str);
@@ -108,7 +108,7 @@ image_s390_load(int argc, char **argv, const char *kernel_buf,if (ramdisk) { rd_buffer =slurp_file (ramdisk, &ramdisk_len);if (rd_buffer ==NULL ) { -fprintf (stderr,"Could not read ramdisk.\n" ); +err ("Could not read ramdisk.\n" );return -1 ; } ramdisk_origin =MAX (RAMDISK_ORIGIN_ADDR , kernel_size);
kexec/arch/s390/kexec-s390.c +1 -1
@@ -157,7 +157,7 @@ int get_memory_ranges_s390(struct memory_range memory_range[], int *ranges, fp =fopen (iomem,"r" );if (fp ==0 ) { -fprintf (stderr,"Unable to open %s: %s\n" ,iomem,strerror (errno)); +err ("Unable to open %s: %s\n" ,iomem,strerror (errno));return -1 ; }
kexec/arch/sh/kexec-sh.c +1 -1
@@ -58,7 +58,7 @@ int get_memory_ranges(struct memory_range **range, int *ranges, ret =parse_iomem_single ("Crash kernel\n" , &start, &end);if (ret !=0 ) { -fprintf (stderr,"parse_iomem_single failed.\n" ); +err ("parse_iomem_single failed.\n" );return -1 ; }
kexec/arch/x86_64/kexec-bzImage64.c +8 -8
@@ -49,42 +49,42 @@ int bzImage64_probe(const char *buf, off_t len)if ((uintmax_t )len < (uintmax_t)(2 *512 )) {if (probe_debug) -fprintf (stderr,"File is too short to be a bzImage!\n" ); +err ("File is too short to be a bzImage!\n" );return -1 ; } header = (const struct x86_linux_header *)buf;if (memcmp (header->header_magic,"HdrS" ,4 ) !=0 ) {if (probe_debug) -fprintf (stderr,"Not a bzImage\n" ); +err ("Not a bzImage\n" );return -1 ; }if (header->boot_sector_magic !=0xAA55 ) {if (probe_debug) -fprintf (stderr,"No x86 boot sector present\n" ); +err ("No x86 boot sector present\n" );/* No x86 boot sector present */ return -1 ; }if (header->protocol_version <0x020C ) {if (probe_debug) -fprintf (stderr,"Must be at least protocol version 2.12\n" ); +err ("Must be at least protocol version 2.12\n" );/* Must be at least protocol version 2.12 */ return -1 ; }if ((header->loadflags &1 ) ==0 ) {if (probe_debug) -fprintf (stderr,"zImage not a bzImage\n" ); +err ("zImage not a bzImage\n" );/* Not a bzImage */ return -1 ; }if ((header->xloadflags &3 ) !=3 ) {if (probe_debug) -fprintf (stderr,"Not a relocatable bzImage64\n" ); +err ("Not a relocatable bzImage64\n" );/* Must be KERNEL_64 and CAN_BE_LOADED_ABOVE_4G */ return -1 ; }/* I've got a relocatable bzImage64 */ if (probe_debug) -fprintf (stderr,"It's a relocatable bzImage64\n" ); +err ("It's a relocatable bzImage64\n" );return 0 ; }
@@ -129,7 +129,7 @@ static int do_bzImage64_load(struct kexec_info *info, setup_sects =4 ; kern16_size = (setup_sects +1 ) *512 ;if (kernel_len < kern16_size) { -fprintf (stderr,"BzImage truncated?\n" ); +err ("BzImage truncated?\n" );return -1 ; }
kexec/arch/x86_64/kexec-elf-x86_64.c +3 -3
@@ -50,7 +50,7 @@ int elf_x86_64_probe(const char *buf, off_t len) result =build_elf_exec_info (buf, len, &ehdr,0 );if (result <0 ) {if (probe_debug) { -fprintf (stderr,"Not an ELF executable\n" ); +err ("Not an ELF executable\n" ); } goto out; }
@@ -59,7 +59,7 @@ int elf_x86_64_probe(const char *buf, off_t len)if (ehdr.e_machine !=EM_X86_64 ) {/* for a different architecture */ if (probe_debug) { -fprintf (stderr,"Not x86_64 ELF executable\n" ); +err ("Not x86_64 ELF executable\n" ); } result =-1 ; goto out;
@@ -127,7 +127,7 @@ int elf_x86_64_load(int argc, char **argv, const char *buf, off_t len,if (opt <OPT_ARCH_MAX ) {break ; } -fprintf (stderr,"Unknown option: opt: %d\n" , opt); +err ("Unknown option: opt: %d\n" , opt);case '?' :usage ();return -1 ;
kexec/arch/x86_64/kexec-x86_64.c +2 -3
@@ -105,7 +105,7 @@ int arch_process_options(int argc, char **argv) } }if (value >=65536 ) { -fprintf (stderr,"Bad serial port base '%s'\n" , +err ("Bad serial port base '%s'\n" , optarg);usage ();return -1 ;
@@ -118,8 +118,7 @@ int arch_process_options(int argc, char **argv)if ((value >115200 ) || ((115200 %value) !=0 ) || (value <9600 ) || (*end)) { -fprintf (stderr,"Bad serial port baud rate '%s'\n" , - optarg); +err ("Bad serial port baud rate '%s'\n" , optarg);usage ();return -1 ;
kexec/crashdump-xen.c +4 -4
@@ -145,20 +145,20 @@ unsigned long xen_architecture(struct crash_elf_info *elf_info)#ifdef XENCTRL_HAS_XC_INTERFACE xc =xc_interface_open (NULL ,NULL ,0 );if ( !xc ) { -fprintf (stderr,"failed to open xen control interface.\n" ); +err ("failed to open xen control interface.\n" ); goto out; }#else xc =xc_interface_open ();if ( xc ==-1 ) { -fprintf (stderr,"failed to open xen control interface.\n" ); +err ("failed to open xen control interface.\n" ); goto out; }#endif rc =xc_version (xc, XENVER_capabilities, &capabilities[0 ]);if ( rc ==-1 ) { -fprintf (stderr,"failed to make Xen version hypercall.\n" ); +err ("failed to make Xen version hypercall.\n" ); goto out_close; }
@@ -200,7 +200,7 @@ int xen_get_nr_phys_cpus(void) n =sizeof (struct crash_note_info ) * cpus; xen_phys_notes =malloc (n);if (!xen_phys_notes) { -fprintf (stderr,"failed to allocate xen_phys_notes.\n" ); +err ("failed to allocate xen_phys_notes.\n" );return -1 ; }memset (xen_phys_notes,0 , n);
kexec/firmware_memmap.c +5 -7
@@ -62,8 +62,7 @@ static unsigned long long parse_numeric_sysfs(const char *filename) fp =fopen (filename,"r" );if (!fp) { -fprintf (stderr,"Opening \"%s\" failed: %s\n" , - filename,strerror (errno)); +err ("Opening \"%s\" failed: %s\n" , filename,strerror (errno));return ULLONG_MAX ; }
@@ -98,8 +97,7 @@ static char *parse_string_sysfs(const char *filename) fp =fopen (filename,"r" );if (!fp) { -fprintf (stderr,"Opening \"%s\" failed: %s\n" , - filename,strerror (errno)); +err ("Opening \"%s\" failed: %s\n" , filename,strerror (errno));return NULL ; }
@@ -170,7 +168,7 @@ static int parse_memmap_entry(const char *entry, struct memory_range *range)else if (strcmp (type,"Uncached RAM" ) ==0 ) range->type =RANGE_UNCACHED ;else { -fprintf (stderr,"Unknown type (%s) while parsing %s. Please " +err ("Unknown type (%s) while parsing %s. Please " "report this as bug. Using RANGE_RESERVED now.\n" , type, filename); range->type =RANGE_RESERVED ;
@@ -219,7 +217,7 @@ int get_firmware_memmap_ranges(struct memory_range *range, size_t *ranges)/* argument checking */ if (!range || !ranges) { -fprintf (stderr,"%s: Invalid arguments.\n" , __FUNCTION__); +err ("%s: Invalid arguments.\n" , __FUNCTION__);return -1 ; }
@@ -237,7 +235,7 @@ int get_firmware_memmap_ranges(struct memory_range *range, size_t *ranges)/* array overflow check */ if ((size_t )i >= *ranges) { -fprintf (stderr,"The firmware provides more entries " +err ("The firmware provides more entries " "allowed (%zd). Please report that as bug.\n" , *ranges); goto error;
kexec/fs2dt.c +1 -1
@@ -607,7 +607,7 @@ static void putnode(void)memcpy (dt, local_cmdline,cmd_len); dt += (cmd_len +3 )/4 ; -fprintf (stderr,"Modified cmdline:%s\n" , local_cmdline); +err ("Modified cmdline:%s\n" , local_cmdline);/* * Determine the platform type/stdout type, so that purgatory
kexec/kernel_version.c +7 -10
@@ -13,44 +13,41 @@ long kernel_version(void)char *p;if (uname (&utsname) <0 ) { -fprintf (stderr,"uname failed: %s\n" ,strerror (errno)); +err ("uname failed: %s\n" ,strerror (errno));return -1 ; } p = utsname.release; major =strtoul (p, &p,10 );if (major ==ULONG_MAX ) { -fprintf (stderr,"strtoul failed: %s\n" ,strerror (errno)); +err ("strtoul failed: %s\n" ,strerror (errno));return -1 ; }if (*p++ !='.' ) { -fprintf (stderr,"Unsupported utsname.release: %s\n" , - utsname.release); +err ("Unsupported utsname.release: %s\n" , utsname.release);return -1 ; } minor =strtoul (p, &p,10 );if (major ==ULONG_MAX ) { -fprintf (stderr,"strtoul failed: %s\n" ,strerror (errno)); +err ("strtoul failed: %s\n" ,strerror (errno));return -1 ; }if (*p++ !='.' ) { -fprintf (stderr,"Unsupported utsname.release: %s\n" , - utsname.release); +err ("Unsupported utsname.release: %s\n" , utsname.release);return -1 ; } patch =strtoul (p, &p,10 );if (major ==ULONG_MAX ) { -fprintf (stderr,"strtoul failed: %s\n" ,strerror (errno)); +err ("strtoul failed: %s\n" ,strerror (errno));return -1 ; }if (major >=256 || minor >=256 || patch >=256 ) { -fprintf (stderr,"Unsupported utsname.release: %s\n" , - utsname.release); +err ("Unsupported utsname.release: %s\n" , utsname.release);return -1 ; }
kexec/kexec-elf-exec.c +4 -4
@@ -24,13 +24,13 @@ int build_elf_exec_info(const char *buf, off_t len, struct mem_ehdr *ehdr, (ehdr->e_type != ET_CORE)) {/* not an ELF executable */ if (probe_debug) { -fprintf (stderr,"Not ELF type ET_EXEC or ET_DYN\n" ); +err ("Not ELF type ET_EXEC or ET_DYN\n" ); }return -1 ; }if (!ehdr->e_phdr) {/* No program header */ -fprintf (stderr,"No ELF program header\n" ); +err ("No ELF program header\n" );return -1 ; } end_phdr = &ehdr->e_phdr[ehdr->e_phnum];
@@ -40,7 +40,7 @@ int build_elf_exec_info(const char *buf, off_t len, struct mem_ehdr *ehdr,* to kexec ordinay executables. */ if (phdr->p_type ==PT_INTERP ) { -fprintf (stderr,"Requires an ELF interpreter\n" ); +err ("Requires an ELF interpreter\n" );return -1 ; } }
@@ -56,7 +56,7 @@ int elf_exec_load(struct mem_ehdr *ehdr, struct kexec_info *info)size_t i;if (!ehdr->e_phdr) { -fprintf (stderr,"No program header?\n" ); +err ("No program header?\n" ); result =-1 ; goto out; }
kexec/kexec-elf-rel.c +5 -5
@@ -146,22 +146,22 @@ int build_elf_rel_info(const char *buf, off_t len, struct mem_ehdr *ehdr,if (ehdr->e_type !=ET_REL ) {/* not an ELF relocate object */ if (probe_debug) { -fprintf (stderr,"Not ELF type ET_REL\n" ); -fprintf (stderr,"ELF Type: %x\n" , ehdr->e_type); +err ("Not ELF type ET_REL\n" ); +err ("ELF Type: %x\n" , ehdr->e_type); }return -1 ; }if (!ehdr->e_shdr) {/* No section headers */ if (probe_debug) { -fprintf (stderr,"No ELF section headers\n" ); +err ("No ELF section headers\n" ); }return -1 ; }if (!machine_verify_elf_rel (ehdr)) {/* It does not meant the native architecture constraints */ if (probe_debug) { -fprintf (stderr,"ELF architecture constraint failure\n" ); +err ("ELF architecture constraint failure\n" ); }return -1 ; }
@@ -183,7 +183,7 @@ int elf_rel_load(struct mem_ehdr *ehdr, struct kexec_info *info, max =elf_max_addr (ehdr); }if (!ehdr->e_shdr) { -fprintf (stderr,"No section header?\n" ); +err ("No section header?\n" ); result =-1 ; goto out; }
kexec/kexec-elf.c +34 -36
274 lines not on this page · raw message
kexec/kexec.c +26 -38
191 lines not on this page · raw message
kexec/phys_arch.c +2 -4
@@ -8,8 +8,7 @@ long physical_arch(void)struct utsname utsname;int i, result =uname (&utsname);if (result <0 ) { -fprintf (stderr,"uname failed: %s\n" , -strerror (errno)); +err ("uname failed: %s\n" ,strerror (errno));return -1 ; }
@@ -22,7 +21,6 @@ long physical_arch(void)return arches[i].arch; } -fprintf (stderr,"Unsupported machine type: %s\n" , - utsname.machine); +err ("Unsupported machine type: %s\n" , utsname.machine);return -1 ; }
kexec/zlib.c +1 -1
@@ -34,7 +34,7 @@ char *zlib_decompress_file(const char *filename, off_t *r_size)if (errnum ==Z_ERRNO ) { msg =strerror (errno); } -fprintf (stderr,"Cannot open `%s': %s\n" , filename, msg); +err ("Cannot open `%s': %s\n" , filename, msg);return NULL ; } size =0 ;
Signature · 7 lines
1.7.1 _______________________________________________ kexec mailing list [email protected] http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 2/2] kexec: Use err() instead of fprintf()
Quoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
Since we have the
err()interface, so replace the error printing function witherr().
This patch introduces a lot of code changes and I'm not entirely sure that I see the benefit.
Quoted 38 lines
Signed-off-by Zhang Yanfei <[email protected]>--- kexec/arch/arm/kexec-arm.c | 3 +- kexec/arch/arm/kexec-zImage-arm.c | 18 ++++----- kexec/arch/i386/crashdump-x86.c | 37 ++++++++--------- kexec/arch/i386/kexec-bzImage.c | 18 ++++---- kexec/arch/i386/kexec-elf-x86.c | 4 +- kexec/arch/i386/kexec-multiboot-x86.c | 11 ++--- kexec/arch/i386/kexec-nbi.c | 14 +++--- kexec/arch/i386/kexec-x86-common.c | 27 ++++++------- kexec/arch/i386/kexec-x86.c | 9 +--- kexec/arch/i386/x86-linux-setup.c | 19 ++++----- kexec/arch/ia64/crashdump-ia64.c | 5 +- kexec/arch/ia64/kexec-elf-ia64.c | 12 +++--- kexec/arch/ia64/kexec-ia64.c | 3 +- kexec/arch/mips/crashdump-mips.c | 11 ++--- kexec/arch/mips/kexec-elf-mips.c | 2 +- kexec/arch/mips/kexec-mips.c | 4 +- kexec/arch/ppc/crashdump-powerpc.c | 5 +- kexec/arch/ppc/fixup_dtb.c | 3 +- kexec/arch/ppc/kexec-dol-ppc.c | 14 +++---- kexec/arch/ppc/kexec-elf-ppc.c | 4 +- kexec/arch/ppc/kexec-ppc.c | 36 ++++++++-------- kexec/arch/ppc/kexec-uImage-ppc.c | 2 +- kexec/arch/ppc64/crashdump-ppc64.c | 10 ++--- kexec/arch/ppc64/fs2dt.c | 2 +- kexec/arch/ppc64/kexec-elf-ppc64.c | 17 ++++---- kexec/arch/ppc64/kexec-ppc64.c | 6 +- kexec/arch/ppc64/kexec-zImage-ppc64.c | 18 +++----- kexec/arch/s390/kexec-image.c | 4 +- kexec/arch/s390/kexec-s390.c | 2 +- kexec/arch/sh/kexec-sh.c | 2 +- kexec/arch/x86_64/kexec-bzImage64.c | 16 ++++---- kexec/arch/x86_64/kexec-elf-x86_64.c | 6 +- kexec/arch/x86_64/kexec-x86_64.c | 5 +- kexec/crashdump-xen.c | 8 ++-- kexec/firmware_memmap.c | 12 ++--- kexec/fs2dt.c | 2 +-
Quoted 8 lines
kexec/kernel_version.c | 17 +++----- kexec/kexec-elf-exec.c | 8 ++-- kexec/kexec-elf-rel.c | 10 ++-- kexec/kexec-elf.c | 70 ++++++++++++++++----------------- kexec/kexec.c | 64 ++++++++++++------------------ kexec/phys_arch.c | 6 +-- kexec/zlib.c | 2 +- 43 files changed, 249 insertions(+), 299 deletions(-)
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 2/2] kexec: Use err() instead of fprintf()
Quoted 8 lines · Simon Horman
Quoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
Since we have the
err()interface, so replace the error printing function witherr().This patch introduces a lot of code changes and I'm not entirely sure that I see the benefit.
Sorry for the long patch.
I just wanted to use a simpler error displaying function instead of fprintf(stderr, ...). Just like we use die() or dbgprintf. If you think this is unnecessary, just ignore the patch please.
Thanks
Zhang
Quoted 39 lines
Quoted 39 lines
Signed-off-by Zhang Yanfei <[email protected]>--- kexec/arch/arm/kexec-arm.c | 3 +- kexec/arch/arm/kexec-zImage-arm.c | 18 ++++----- kexec/arch/i386/crashdump-x86.c | 37 ++++++++--------- kexec/arch/i386/kexec-bzImage.c | 18 ++++---- kexec/arch/i386/kexec-elf-x86.c | 4 +- kexec/arch/i386/kexec-multiboot-x86.c | 11 ++--- kexec/arch/i386/kexec-nbi.c | 14 +++--- kexec/arch/i386/kexec-x86-common.c | 27 ++++++------- kexec/arch/i386/kexec-x86.c | 9 +--- kexec/arch/i386/x86-linux-setup.c | 19 ++++----- kexec/arch/ia64/crashdump-ia64.c | 5 +- kexec/arch/ia64/kexec-elf-ia64.c | 12 +++--- kexec/arch/ia64/kexec-ia64.c | 3 +- kexec/arch/mips/crashdump-mips.c | 11 ++--- kexec/arch/mips/kexec-elf-mips.c | 2 +- kexec/arch/mips/kexec-mips.c | 4 +- kexec/arch/ppc/crashdump-powerpc.c | 5 +- kexec/arch/ppc/fixup_dtb.c | 3 +- kexec/arch/ppc/kexec-dol-ppc.c | 14 +++---- kexec/arch/ppc/kexec-elf-ppc.c | 4 +- kexec/arch/ppc/kexec-ppc.c | 36 ++++++++-------- kexec/arch/ppc/kexec-uImage-ppc.c | 2 +- kexec/arch/ppc64/crashdump-ppc64.c | 10 ++--- kexec/arch/ppc64/fs2dt.c | 2 +- kexec/arch/ppc64/kexec-elf-ppc64.c | 17 ++++---- kexec/arch/ppc64/kexec-ppc64.c | 6 +- kexec/arch/ppc64/kexec-zImage-ppc64.c | 18 +++----- kexec/arch/s390/kexec-image.c | 4 +- kexec/arch/s390/kexec-s390.c | 2 +- kexec/arch/sh/kexec-sh.c | 2 +- kexec/arch/x86_64/kexec-bzImage64.c | 16 ++++---- kexec/arch/x86_64/kexec-elf-x86_64.c | 6 +- kexec/arch/x86_64/kexec-x86_64.c | 5 +- kexec/crashdump-xen.c | 8 ++-- kexec/firmware_memmap.c | 12 ++--- kexec/fs2dt.c | 2 +-
Quoted 8 lines
Quoted 8 lines
kexec/kernel_version.c | 17 +++----- kexec/kexec-elf-exec.c | 8 ++-- kexec/kexec-elf-rel.c | 10 ++-- kexec/kexec-elf.c | 70 ++++++++++++++++----------------- kexec/kexec.c | 64 ++++++++++++------------------ kexec/phys_arch.c | 6 +-- kexec/zlib.c | 2 +- 43 files changed, 249 insertions(+), 299 deletions(-)
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
Re: [PATCH 2/2] kexec: Use err() instead of fprintf()
Quoted 7 lines · Zhang Yanfei
Quoted 6 lines · Simon Horman
Quoted 4 lines · Zhang Yanfei
From: Zhang Yanfei <[email protected]>
Since we have the
err()interface, so replace the error printing function witherr().
Quoted 8 lines
Quoted 2 lines
This patch introduces a lot of code changes and I'm not entirely sure that I see the benefit.
Sorry for the long patch.
I just wanted to use a simpler error displaying function instead of
fprintf(stderr, ...). Just like we usedie()or dbgprintf. If you think this is unnecessary, just ignore the patch please.
I think that I would prefer to not accept this patch at this time. Thanks all the same.
_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec