Skip to contentSkip to conversation

-Wextra cleanups

PATCH New Simon Horman 1 participant 28 messages Feb 1, 2010

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

PATCH 1/27 Mark unused parameters

kexec/kexec.h +2 -1
Index: kexec-tools/kexec/kexec.h
===================================================================
@@ -13,6 +13,7 @@
 #define _GNU_SOURCE
 
 #include "kexec-elf.h"
+#include "unused.h"
 
 #ifndef BYTE_ORDER
 #error BYTE_ORDER not defined
@@ -258,7 +259,7 @@ extern int add_backup_segments(struct ke
 #define dbgprintf(_args...) do {printf(_args);} while(0)
 #else
 static inline int __attribute__ ((format (printf, 1, 2)))
-	dbgprintf(const char *fmt, ...) {return 0;}
+	dbgprintf(const char *UNUSED(fmt), ...) {return 0;}
 #endif
 
 char *concat_cmdline(const char *base, const char *append);
include/unused.h new file +15 -0
Index: kexec-tools/include/unused.h
===================================================================
@@ -0,0 +1,15 @@
+#ifndef UNUSED_H
+#define UNUSED_H
+
+/* http://sourcefrog.net/weblog/software/languages/C/unused.html */
+
+#ifdef UNUSED
+#elif defined(__GNUC__)
+# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
+#elif defined(__LCLINT__)
+# define UNUSED(x) /*@unused@*/ x
+#else
+# define UNUSED(x) x
+#endif
+
+#endif
kexec/arch/i386/kexec-beoboot-x86.c +1 -1
Index: kexec-tools/kexec/arch/i386/kexec-beoboot-x86.c
===================================================================
@@ -75,7 +75,7 @@ void beoboot_usage(void)
 #define KERN32_BASE  0x100000 /* 1MB */
 #define INITRD_BASE 0x1000000 /* 16MB */
 
-int beoboot_load(int argc, char **argv, const char *buf, off_t len,
+int beoboot_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
 	struct kexec_info *info)
 {
 	struct beoboot_header bb_header;
kexec/arch/i386/kexec-nbi.c +1 -1
Index: kexec-tools/kexec/arch/i386/kexec-nbi.c
===================================================================
@@ -150,7 +150,7 @@ void nbi_usage(void)
 		);
 }
 
-int nbi_load(int argc, char **argv, const char *buf, off_t len, 
+int nbi_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
 	struct kexec_info *info)
 {
 	struct imgheader hdr;
kexec/crashdump-xen.c +2 -2
Index: kexec-tools/kexec/crashdump-xen.c
===================================================================
@@ -72,8 +72,8 @@ unsigned long xen_architecture(struct cr
 	return machine;
 }
 
-static int xen_crash_note_callback(void *data, int nr,
-				   char *str,
+static int xen_crash_note_callback(void *UNUSED(data), int nr,
+				   char *UNUSED(str),
 				   unsigned long base,
 				   unsigned long length)
 {
kexec/virt_to_phys.c +1 -1
Index: kexec-tools/kexec/virt_to_phys.c
===================================================================
@@ -1,7 +1,7 @@
 #include "kexec.h"
 #include <stdlib.h>
 
-unsigned long virt_to_phys(unsigned long addr)
+unsigned long virt_to_phys(unsigned long UNUSED(addr))
 {
 	abort();
 }
kexec/arch/i386/kexec-elf-rel-x86.c +1 -1
Index: kexec-tools/kexec/arch/i386/kexec-elf-rel-x86.c
===================================================================
@@ -18,7 +18,7 @@ int machine_verify_elf_rel(struct mem_eh
 	return 1;
 }
 
-void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
+void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type,
 	void *location, unsigned long address, unsigned long value)
 {
 	switch(r_type) {
kexec/lzma.c +2 -3
Index: kexec-tools/kexec/lzma.c
===================================================================
@@ -3,6 +3,7 @@
 
 #include "kexec-lzma.h"
 #include "config.h"
+#include "kexec.h"
 
 #ifdef HAVE_LIBLZMA
 #define _GNU_SOURCE
@@ -16,8 +17,6 @@
 #include <ctype.h>
 #include <lzma.h>
 
-#include "kexec.h"
-
 #define kBufferSize (1 << 15)
 
 typedef struct lzfile {
@@ -197,7 +196,7 @@ char *lzma_decompress_file(const char *f
 	return buf;
 }
 #else
-char *lzma_decompress_file(const char *filename, off_t *r_size)
+char *lzma_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size))
 {
 	return NULL;
 }
kexec/zlib.c +3 -3
Index: kexec-tools/kexec/zlib.c
===================================================================
@@ -1,4 +1,6 @@
 #include "kexec-zlib.h"
+#include "kexec.h"
+
 #ifdef HAVE_LIBZ
 #define _GNU_SOURCE
 #include <stdio.h>
@@ -13,8 +15,6 @@
 #include <ctype.h>
 #include <zlib.h>
 
-#include "kexec.h"
-
 char *zlib_decompress_file(const char *filename, off_t *r_size)
 {
 	gzFile fp;
@@ -71,7 +71,7 @@ char *zlib_decompress_file(const char *f
 	return buf;
 }
 #else
-char *zlib_decompress_file(const char *filename, off_t *r_size)
+char *zlib_decompress_file(const char *UNUSED(filename), off_t *UNUSED(r_size))
 {
 	return NULL;
 }
kexec/arch/x86_64/kexec-x86_64.c +1 -1
Index: kexec-tools/kexec/arch/x86_64/kexec-x86_64.c
===================================================================
@@ -148,7 +148,7 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
kexec/arch/x86_64/kexec-elf-rel-x86_64.c +1 -1
Index: kexec-tools/kexec/arch/x86_64/kexec-elf-rel-x86_64.c
===================================================================
@@ -57,7 +57,7 @@ static const char *reloc_name(unsigned l
 	return name;
 }
 
-void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type, 
+void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type,
 	void *location, unsigned long address, unsigned long value)
 {
 #ifdef DEBUG
kexec/arch/ppc/kexec-ppc.c +4 -4
Index: kexec-tools/kexec/arch/ppc/kexec-ppc.c
===================================================================
@@ -23,8 +23,8 @@
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
 
 /* Return a sorted list of memory ranges. */
-int get_memory_ranges(struct memory_range **range, int *ranges,
-					unsigned long kexec_flags)
+int get_memory_ranges(struct memory_range **UNUSED(range), int *UNUSED(ranges),
+		      unsigned long UNUSED(kexec_flags))
 {
 #ifdef WITH_GAMECUBE
 	int memory_ranges = 0;
@@ -83,12 +83,12 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
 
-void arch_update_purgatory(struct kexec_info *info)
+void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
 
kexec/arch/ppc/kexec-dol-ppc.c +1 -1
Index: kexec-tools/kexec/arch/ppc/kexec-dol-ppc.c
===================================================================
@@ -316,7 +316,7 @@ void dol_ppc_usage(void)
 
 }
 
-int dol_ppc_load(int argc, char **argv, const char *buf, off_t len,
+int dol_ppc_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
 	struct kexec_info *info)
 {
 	dol_header header, *h;
kexec/arch/ppc/kexec-elf-rel-ppc.c +1 -1
Index: kexec-tools/kexec/arch/ppc/kexec-elf-rel-ppc.c
===================================================================
@@ -17,7 +17,7 @@ int machine_verify_elf_rel(struct mem_eh
 	return 1;
 }
 
-void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
+void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type,
 	void *location, unsigned long address, unsigned long value)
 {
 	switch(r_type) {
purgatory/arch/ppc/console-ppc.c +3 -1
Index: kexec-tools/purgatory/arch/ppc/console-ppc.c
===================================================================
@@ -1,5 +1,7 @@
 #include <purgatory.h>
-void putchar(int ch)
+#include "unused.h"
+
+void putchar(int UNUSED(ch))
 {
 	/* Nothing for now */
 }
purgatory/Makefile +1 -0
Index: kexec-tools/purgatory/Makefile
===================================================================
@@ -53,6 +53,7 @@ $(PURGATORY): CPPFLAGS=$($(ARCH)_PURGATO
 			-I$(srcdir)/purgatory/include \
 			-I$(srcdir)/purgatory/arch/$(ARCH)/include \
 			-I$(srcdir)/util_lib/include \
+			-I$(srcdir)/include \
 			-I$(shell $(CC) -print-file-name=include)
 $(PURGATORY): LDFLAGS=$($(ARCH)_PURGATORY_EXTRA_CFLAGS)\
 			--no-undefined -nostartfiles -nostdlib -nodefaultlibs \
kexec/arch/ppc64/kexec-zImage-ppc64.c +3 -2
Index: kexec-tools/kexec/arch/ppc64/kexec-zImage-ppc64.c
===================================================================
@@ -63,8 +63,9 @@ int zImage_ppc64_probe(FILE *file)
 		elf.e_machine         == EM_PPC);
 }
 
-int zImage_ppc64_load(FILE *file, int argc, char **argv, void **ret_entry,
-	struct kexec_segment **ret_segments, int *ret_nr_segments)
+int zImage_ppc64_load(FILE *file, int UNUSED(argc), char **UNUSED(argv),
+		      void **ret_entry, struct kexec_segment **ret_segments,
+		      int *ret_nr_segments)
 {
 	Elf32_Ehdr elf;
 	Elf32_Phdr *p, *ph;
kexec/arch/ppc64/kexec-ppc64.c +2 -2
Index: kexec-tools/kexec/arch/ppc64/kexec-ppc64.c
===================================================================
@@ -804,11 +804,11 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
 
-void arch_update_purgatory(struct kexec_info *info)
+void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
kexec/arch/ia64/kexec-ia64.c +2 -2
Index: kexec-tools/kexec/arch/ia64/kexec-ia64.c
===================================================================
@@ -211,7 +211,7 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
@@ -255,7 +255,7 @@ int update_loaded_segments(struct kexec_
 	return -1;
 }
 
-void arch_update_purgatory(struct kexec_info *info)
+void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
 
kexec/kexec-iomem.c +1 -1
Index: kexec-tools/kexec/kexec-iomem.c
===================================================================
@@ -64,7 +64,7 @@ int kexec_iomem_for_each_line(char *matc
 }
 
 static int kexec_iomem_single_callback(void *data, int nr,
-				       char *str,
+				       char *UNUSED(str),
 				       unsigned long base,
 				       unsigned long length)
 {
kexec/arch/s390/kexec-s390.c +5 -4
Index: kexec-tools/kexec/arch/s390/kexec-s390.c
===================================================================
@@ -36,7 +36,8 @@ static struct memory_range memory_range[
  *  - (-1) if something went wrong.
  */
 
-int get_memory_ranges(struct memory_range **range, int *ranges, unsigned long flags)
+int get_memory_ranges(struct memory_range **range, int *ranges,
+		      unsigned long UNUSED(flags))
 {
 	char sys_ram[] = "System RAM\n";
 	char *iomem = proc_iomem();
@@ -89,7 +90,7 @@ void arch_usage(void)
 {
 }
 
-int arch_process_options(int argc, char **argv)
+int arch_process_options(int UNUSED(argc), char **UNUSED(argv))
 {
 	return 0;
 }
@@ -100,12 +101,12 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
 
-void arch_update_purgatory(struct kexec_info *info)
+void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
 
kexec/arch/s390/kexec-elf-rel-s390.c +6 -3
Index: kexec-tools/kexec/arch/s390/kexec-elf-rel-s390.c
===================================================================
@@ -12,12 +12,15 @@
 #include "../../kexec.h"
 #include "../../kexec-elf.h"
 
-int machine_verify_elf_rel(struct mem_ehdr *ehdr)
+int machine_verify_elf_rel(struct mem_ehdr *UNUSED(ehdr))
 {
 	return 0;
 }
 
-void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
-	void *location, unsigned long address, unsigned long value)
+void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr),
+			   unsigned long UNUSED(r_type),
+			   void *UNUSED(location),
+			   unsigned long UNUSED(address),
+			   unsigned long UNUSED(value))
 {
 }
kexec/arch/sh/kexec-sh.c +4 -4
Index: kexec-tools/kexec/arch/sh/kexec-sh.c
===================================================================
@@ -22,8 +22,8 @@
 #define MAX_MEMORY_RANGES 64
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
 
-static int kexec_sh_memory_range_callback(void *data, int nr,
-					  char *str,
+static int kexec_sh_memory_range_callback(void *UNUSED(data), int nr,
+					  char *UNUSED(str),
 					  unsigned long base,
 					  unsigned long length)
 {
@@ -138,12 +138,12 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
 
-void arch_update_purgatory(struct kexec_info *info)
+void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
 
kexec/arch/sh/kexec-netbsd-sh.c +2 -2
Index: kexec-tools/kexec/arch/sh/kexec-netbsd-sh.c
===================================================================
@@ -33,7 +33,7 @@ const extern unsigned char netbsd_booter
  *
  * Make sure that the file image has a reasonable chance of working.
  */
-int netbsd_sh_probe(const char *buf, off_t len)
+int netbsd_sh_probe(const char *buf, off_t UNUSED(len))
 {
 	Elf32_Ehdr *ehdr;
 
@@ -54,7 +54,7 @@ void netbsd_sh_usage(void)
 		" --miniroot=FILE      NetBSD miniroot ramdisk.\n\n");
 }
 
-int netbsd_sh_load(int argc, char **argv, const char *buf, off_t len,
+int netbsd_sh_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
 	struct kexec_info *info)
 {
 	const char *howto, *miniroot;
kexec/arch/sh/kexec-elf-rel-sh.c +2 -2
Index: kexec-tools/kexec/arch/sh/kexec-elf-rel-sh.c
===================================================================
@@ -28,8 +28,8 @@ int machine_verify_elf_rel(struct mem_eh
 	return 1;
 }
 
-void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
-	void *orig_loc, unsigned long address, unsigned long relocation)
+void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type,
+	void *orig_loc, unsigned long UNUSED(address), unsigned long relocation)
 {
 	uint32_t *location = orig_loc;
 	uint32_t value;
kexec/arch/sh/crashdump-sh.c +1 -1
Index: kexec-tools/kexec/arch/sh/crashdump-sh.c
===================================================================
@@ -34,7 +34,7 @@ static struct memory_range crash_memory_
 uint64_t saved_max_mem;
 
 static int crash_sh_range_nr;
-static int crash_sh_memory_range_callback(void *data, int nr,
+static int crash_sh_memory_range_callback(void *UNUSED(data), int UNUSED(nr),
 					  char *str,
 					  unsigned long base,
 					  unsigned long length)
kexec/arch/s390/kexec-image.c +1 -1
Index: kexec-tools/kexec/arch/s390/kexec-image.c
===================================================================
@@ -119,7 +119,7 @@ image_s390_load(int argc, char **argv, c
 }
 
 int 
-image_s390_probe(const char *kernel_buf, off_t kernel_size)
+image_s390_probe(const char *UNUSED(kernel_buf), off_t UNUSED(kernel_size))
 {
 	/*
 	 * Can't reliably tell if an image is valid,
kexec/arch/arm/kexec-elf-rel-arm.c +1 -1
Index: kexec-tools/kexec/arch/arm/kexec-elf-rel-arm.c
===================================================================
@@ -18,7 +18,7 @@ int machine_verify_elf_rel(struct mem_eh
 	return 1;
 }
 
-void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
+void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type,
 	void *location, unsigned long address, unsigned long value)
 {
 	switch(r_type) {
kexec/arch/arm/kexec-zImage-arm.c +1 -1
Index: kexec-tools/kexec/arch/arm/kexec-zImage-arm.c
===================================================================
@@ -78,7 +78,7 @@ struct tag {
 #define byte_size(t)    ((t)->hdr.size << 2)
 #define tag_size(type)  ((sizeof(struct tag_header) + sizeof(struct type) + 3) >> 2)
 
-int zImage_arm_probe(const char *buf, off_t len)
+int zImage_arm_probe(const char *UNUSED(buf), off_t UNUSED(len))
 {
 	/* 
 	 * Only zImage loading is supported. Do not check if
kexec/arch/arm/kexec-arm.c +3 -3
Index: kexec-tools/kexec/arch/arm/kexec-arm.c
===================================================================
@@ -23,7 +23,7 @@ static struct memory_range memory_range[
 
 /* Return a sorted list of available memory ranges. */
 int get_memory_ranges(struct memory_range **range, int *ranges,
-		unsigned long kexec_flags)
+		unsigned long UNUSED(kexec_flags))
 {
 	const char *iomem = proc_iomem();
 	int memory_ranges = 0;
@@ -116,12 +116,12 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
 
-void arch_update_purgatory(struct kexec_info *info)
+void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
 
kexec/arch/mips/kexec-mips.c +4 -3
Index: kexec-tools/kexec/arch/mips/kexec-mips.c
===================================================================
@@ -26,7 +26,8 @@
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
 
 /* Return a sorted list of memory ranges. */
-int get_memory_ranges(struct memory_range **range, int *ranges, unsigned long kexec_flags)
+int get_memory_ranges(struct memory_range **range, int *ranges,
+		      unsigned long UNUSED(kexec_flags))
 {
 	int memory_ranges = 0;
 
@@ -129,12 +130,12 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
 
-void arch_update_purgatory(struct kexec_info *info)
+void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
 
purgatory/arch/mips/console-mips.c +3 -1
Index: kexec-tools/purgatory/arch/mips/console-mips.c
===================================================================
@@ -1,5 +1,7 @@
 #include <purgatory.h>
-void putchar(int ch)
+#include "unused.h"
+
+void putchar(int UNUSED(ch))
 {
 	/* Nothing for now */
 }
kexec/arch/cris/kexec-cris.c +4 -3
Index: kexec-tools/kexec/arch/cris/kexec-cris.c
===================================================================
@@ -23,7 +23,8 @@
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
 
 /* Return a sorted list of memory ranges. */
-int get_memory_ranges(struct memory_range **range, int *ranges, unsigned long kexec_flags)
+int get_memory_ranges(struct memory_range **range, int *ranges,
+		      unsigned long UNUSED(kexec_flags))
 {
 	int memory_ranges = 0;
 
@@ -79,12 +80,12 @@ const struct arch_map_entry arches[] = {
 	{ 0 },
 };
 
-int arch_compat_trampoline(struct kexec_info *info)
+int arch_compat_trampoline(struct kexec_info *UNUSED(info))
 {
 	return 0;
 }
 
-void arch_update_purgatory(struct kexec_info *info)
+void arch_update_purgatory(struct kexec_info *UNUSED(info))
 {
 }
 
kexec/arch/mips/kexec-elf-rel-mips.c +4 -2
Index: kexec-tools/kexec/arch/mips/kexec-elf-rel-mips.c
===================================================================
@@ -29,8 +29,10 @@ int machine_verify_elf_rel(struct mem_eh
 	return 1;
 }
 
-void machine_apply_elf_rel(struct mem_ehdr *ehdr, unsigned long r_type,
-	void *location, unsigned long address, unsigned long value)
+void machine_apply_elf_rel(struct mem_ehdr *UNUSED(ehdr), unsigned long r_type,
+			   void *UNUSED(location),
+			   unsigned long UNUSED(address),
+			   unsigned long UNUSED(value))
 {
 	switch(r_type) {
 

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

#2 lore raw

PATCH 2/27 Remove unused parameters from build_mem() and related functions

In reply to Simon Horman
kexec/kexec-elf.c +10 -14
Index: kexec-tools/kexec/kexec-elf.c
===================================================================
@@ -302,8 +302,7 @@ static int build_mem_ehdr(const char *bu
 	return 0;
 }
 
-static int build_mem_elf32_phdr(const char *buf, off_t len,
-	struct mem_ehdr *ehdr, int idx)
+static int build_mem_elf32_phdr(const char *buf, struct mem_ehdr *ehdr, int idx)
 {
 	struct mem_phdr *phdr;
 	const char *pbuf;
@@ -335,8 +334,7 @@ static int build_mem_elf32_phdr(const ch
 	return 0;
 }
 
-static int build_mem_elf64_phdr(const char *buf, off_t len,
-	struct mem_ehdr *ehdr, int idx)
+static int build_mem_elf64_phdr(const char *buf, struct mem_ehdr *ehdr, int idx)
 {
 	struct mem_phdr *phdr;
 	const char *pbuf;
@@ -407,11 +405,11 @@ static int build_mem_phdrs(const char *b
 		int result;
 		result = -1;
 		if (ehdr->ei_class == ELFCLASS32) {
-			result = build_mem_elf32_phdr(buf, len, ehdr, i);
+			result = build_mem_elf32_phdr(buf, ehdr, i);
 
 		}
 		else if (ehdr->ei_class == ELFCLASS64) {
-			result = build_mem_elf64_phdr(buf, len, ehdr, i);
+			result = build_mem_elf64_phdr(buf, ehdr, i);
 		}
 		if (result < 0) {
 			return result;
@@ -443,8 +441,7 @@ static int build_mem_phdrs(const char *b
 	return 0;
 }
 
-static int build_mem_elf32_shdr(const char *buf, off_t len,
-	struct mem_ehdr *ehdr, int idx)
+static int build_mem_elf32_shdr(const char *buf, struct mem_ehdr *ehdr, int idx)
 {
 	struct mem_shdr *shdr;
 	const char *sbuf;
@@ -513,8 +510,7 @@ static int build_mem_elf32_shdr(const ch
 	return 0;
 }
 
-static int build_mem_elf64_shdr(const char *buf, off_t len,
-	struct mem_ehdr *ehdr, int idx)
+static int build_mem_elf64_shdr(const char *buf, struct mem_ehdr *ehdr, int idx)
 {
 	struct mem_shdr *shdr;
 	const char *sbuf;
@@ -622,10 +618,10 @@ static int build_mem_shdrs(const char *b
 		int result;
 		result = -1;
 		if (ehdr->ei_class == ELFCLASS32) {
-			result = build_mem_elf32_shdr(buf, len, ehdr, i);
+			result = build_mem_elf32_shdr(buf, ehdr, i);
 		}
 		else if (ehdr->ei_class == ELFCLASS64) {
-			result = build_mem_elf64_shdr(buf, len, ehdr, i);
+			result = build_mem_elf64_shdr(buf, ehdr, i);
 		}
 		if (result < 0) {
 			return result;
@@ -667,7 +663,7 @@ static void read_nhdr(const struct mem_e
 	hdr->n_type   = elf32_to_cpu(ehdr, hdr->n_type);
 
 }
-static int build_mem_notes(const char *buf, off_t len, struct mem_ehdr *ehdr)
+static int build_mem_notes(struct mem_ehdr *ehdr)
 {
 	const unsigned char *note_start, *note_end, *note;
 	size_t note_size;
@@ -769,7 +765,7 @@ int build_elf_info(const char *buf, off_
 			return result;
 		}
 	}
-	result = build_mem_notes(buf, len, ehdr);
+	result = build_mem_notes(ehdr);
 	if (result < 0) {
 		free_elf_info(ehdr);
 		return result;

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

#3 lore raw

PATCH 3/27 sh: make zImage_head32() static

In reply to Simon Horman
kexec/arch/sh/kexec-zImage-sh.c +1 -1
Index: kexec-tools/kexec/arch/sh/kexec-zImage-sh.c
===================================================================
@@ -34,7 +34,7 @@ static const int probe_debug = 0;
 #define HEAD32_INIT_SR 3
 #define HEAD32_INIT_SR_VALUE 0x400000F0
 
-unsigned long zImage_head32(const char *buf, off_t len, int offs)
+static unsigned long zImage_head32(const char *buf, off_t len, int offs)
 {
 	unsigned long *values = (void *)buf;
 	int k;

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

#4 lore raw

PATCH 4/27 sh: Remove unused len parameter from zImage_head32()

In reply to Simon Horman
kexec/arch/sh/kexec-zImage-sh.c +3 -3
Index: kexec-tools/kexec/arch/sh/kexec-zImage-sh.c
===================================================================
@@ -34,7 +34,7 @@ static const int probe_debug = 0;
 #define HEAD32_INIT_SR 3
 #define HEAD32_INIT_SR_VALUE 0x400000F0
 
-static unsigned long zImage_head32(const char *buf, off_t len, int offs)
+static unsigned long zImage_head32(const char *buf, int offs)
 {
 	unsigned long *values = (void *)buf;
 	int k;
@@ -56,7 +56,7 @@ int zImage_sh_probe(const char *buf, off
 	if (memcmp(&buf[0x202], "HdrS", 4) != 0)
 	        return -1;
 
-	if (zImage_head32(buf, len, HEAD32_INIT_SR) != HEAD32_INIT_SR_VALUE)
+	if (zImage_head32(buf, HEAD32_INIT_SR) != HEAD32_INIT_SR_VALUE)
 	        return -1;
 
 	return 0;
@@ -112,7 +112,7 @@ int zImage_sh_load(int argc, char **argv
 	 * all combinations.
 	 */
 
-	empty_zero = zImage_head32(buf, len, HEAD32_KERNEL_START_ADDR);
+	empty_zero = zImage_head32(buf, HEAD32_KERNEL_START_ADDR);
 
 	zero_page_size = 0x10000;
 	zero_page_base = virt_to_phys(empty_zero - zero_page_size);

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

#5 lore raw

PATCH 5/27 i386: Remove unused kexec_flags parameter from setup_edd_info()

In reply to Simon Horman
kexec/arch/i386/x86-linux-setup.c +2 -3
Index: kexec-tools/kexec/arch/i386/x86-linux-setup.c
===================================================================
@@ -353,8 +353,7 @@ static void zero_edd(struct x86_linux_pa
 		EDD_MBR_SIG_MAX * sizeof(uint32_t));
 }
 
-void setup_edd_info(struct x86_linux_param_header *real_mode,
-					unsigned long kexec_flags)
+void setup_edd_info(struct x86_linux_param_header *real_mode)
 {
 	DIR *edd_dir;
 	struct dirent *cursor;
@@ -482,5 +481,5 @@ void setup_linux_system_parameters(struc
 	}
 
 	/* fill the EDD information */
-	setup_edd_info(real_mode, kexec_flags);
+	setup_edd_info(real_mode);
 }

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

#6 lore raw

PATCH 6/27 ia64: Remove unused info parameter from {move, update}_loaded_segments()

In reply to Simon Horman

/bin/bash: 0001-add-kexec-tools-support-for-armv7l-processors.patch: ������������������������������������ ���������������������������������������������������

kexec/arch/ia64/kexec-elf-ia64.c +3 -4
Index: kexec-tools/kexec/arch/ia64/kexec-elf-ia64.c
===================================================================
@@ -96,8 +96,7 @@ void elf_ia64_usage(void)
 
 /* Move the crash kerenl physical offset to reserved region
  */
-void move_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr,
-			  unsigned long addr)
+void move_loaded_segments(struct mem_ehdr *ehdr, unsigned long addr)
 {
 	int i;
 	long offset;
@@ -198,8 +197,8 @@ int elf_ia64_load(int argc, char **argv,
 			free_elf_info(&ehdr);
 			return -1;
 		}
-		move_loaded_segments(info, &ehdr, mem_min);
-	} else if (update_loaded_segments(info, &ehdr) < 0) {
+		move_loaded_segments(&ehdr, mem_min);
+	} else if (update_loaded_segments(&ehdr) < 0) {
 		fprintf(stderr, "Failed to place kernel\n");
 		return -1;
 	}
kexec/arch/ia64/kexec-ia64.c +2 -2
Index: kexec-tools/kexec/arch/ia64/kexec-ia64.c
===================================================================
@@ -216,7 +216,7 @@ int arch_compat_trampoline(struct kexec_
 	return 0;
 }
 
-int update_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr)
+int update_loaded_segments(struct mem_ehdr *ehdr)
 {
 	int i;
 	struct mem_phdr *phdr;
@@ -247,7 +247,7 @@ int update_loaded_segments(struct kexec_
 		start = (memory_range[i].start + align - 1) & ~(align - 1);
 		end = memory_range[i].end;
 		if (end > start && (end - start) > (end_addr - start_addr)) {
-		    move_loaded_segments(info, ehdr, start);
+		    move_loaded_segments(ehdr, start);
 			return 0;
 		}
 	}
kexec/arch/ia64/kexec-ia64.h +2 -3
Index: kexec-tools/kexec/arch/ia64/kexec-ia64.h
===================================================================
@@ -6,9 +6,8 @@ int elf_ia64_probe(const char *buf, off_
 int elf_ia64_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info);
 void elf_ia64_usage(void);
-int update_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr);
-void move_loaded_segments(struct kexec_info *info, struct mem_ehdr *ehdr,
-			  unsigned long addr);
+int update_loaded_segments(struct mem_ehdr *ehdr);
+void move_loaded_segments(struct mem_ehdr *ehdr, unsigned long addr);
 
 #define EFI_PAGE_SIZE	  (1UL<<12)
 #define ELF_PAGE_SIZE	  (1UL<<16)

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

#7 lore raw

PATCH 7/27 ia64: Remove unused info parameter from add_loaded_segments_info()

In reply to Simon Horman
kexec/arch/ia64/crashdump-ia64.c +2 -3
Index: kexec-tools/kexec/arch/ia64/crashdump-ia64.c
===================================================================
@@ -71,8 +71,7 @@ static int seg_comp(const void *a, const
 
 /* purgatory code need this info to patch the EFI memmap
  */
-static void add_loaded_segments_info(struct kexec_info *info,
-	struct mem_ehdr *ehdr, unsigned long max_addr)
+static void add_loaded_segments_info(struct mem_ehdr *ehdr)
 {
 	 int i;
          for(i = 0; i < ehdr->e_phnum; i++) {
@@ -265,7 +264,7 @@ int load_crashdump_segments(struct kexec
 		loaded_segments_num++;
 		cmdline_add_elfcorehdr(cmdline, elfcorehdr);
 	}
-	add_loaded_segments_info(info, ehdr, max_addr);
+	add_loaded_segments_info(ehdr);
 	size = sizeof(struct loaded_segment) * loaded_segments_num;
 	qsort(loaded_segments, loaded_segments_num,
                         sizeof(struct loaded_segment), seg_comp);

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

#8 lore raw

PATCH 8/27 ia64: Remove unused range parameter from get_crash_memory_ranges()

In reply to Simon Horman
kexec/arch/ia64/crashdump-ia64.c +2 -2
Index: kexec-tools/kexec/arch/ia64/crashdump-ia64.c
===================================================================
@@ -152,7 +152,7 @@ static int exclude_crash_reserve_region(
 	return 0;
 }
 
-static int get_crash_memory_ranges(struct memory_range **range, int *ranges)
+static int get_crash_memory_ranges(int *ranges)
 {
 	const char *iomem = proc_iomem();
         char line[MAX_LINE];
@@ -236,7 +236,7 @@ int load_crashdump_segments(struct kexec
 	size_t size;
 	void *tmp;
 	if (info->kexec_flags & KEXEC_ON_CRASH &&
-	    get_crash_memory_ranges(&mem_range, &nr_ranges) == 0) {
+	    get_crash_memory_ranges(&nr_ranges) == 0) {
 		int i;
 
 		info->kern_paddr_start = kernel_code_start;

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

#9 lore raw

PATCH 9/27 Remove some unused variables

In reply to Simon Horman
kexec/arch/ia64/crashdump-ia64.c +0 -1
Index: kexec-tools/kexec/arch/ia64/crashdump-ia64.c
===================================================================
@@ -230,7 +230,6 @@ int load_crashdump_segments(struct kexec
                             unsigned long max_addr, unsigned long min_base,
 			    const char **cmdline)
 {
-	struct memory_range *mem_range;
 	int nr_ranges;
 	unsigned long sz;
 	size_t size;
kexec/arch/arm/kexec-arm.c +0 -3
Index: kexec-tools/kexec/arch/arm/kexec-arm.c
===================================================================
@@ -86,9 +86,6 @@ void arch_usage(void)
 {
 }
 
-static struct {
-} arch_options = {
-};
 int arch_process_options(int argc, char **argv)
 {
 	static const struct option options[] = {

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

#10 lore raw

PATCH 10/27 Use %llx to format mem_max as it is an unsigned long long

In reply to Simon Horman
kexec/arch/i386/crashdump-x86.c +3 -2
Index: kexec-tools/kexec/arch/i386/crashdump-x86.c
===================================================================
@@ -111,7 +111,7 @@ static int get_crash_memory_ranges(struc
 		}
 
 		/* First 640K already registered */
-		if (start >= 0x00000000 && end <= 0x0009ffff)
+		if (start >= 0x00000000ULL && end <= 0x0009ffffULL)
 			continue;
 
 		crash_memory_range[memory_ranges].start = start;
@@ -141,7 +141,8 @@ static int get_crash_memory_ranges(struc
 			}
 		}
 		if (crash_reserved_mem.start >= mem_max) {
-			fprintf(stderr, "Too small mem_max: 0x%lx.\n", mem_max);
+			fprintf(stderr, "Too small mem_max: 0x%llx.\n",
+				mem_max);
 			return -1;
 		}
 		crash_reserved_mem.end = mem_max;

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

#11 lore raw

PATCH 11/27 ppc: memory_range global is only used in conjunction with WITH_GAMECUBE

In reply to Simon Horman
kexec/arch/ppc/kexec-ppc.c +2 -0
Index: kexec-tools/kexec/arch/ppc/kexec-ppc.c
===================================================================
@@ -19,8 +19,10 @@
 
 #include "config.h"
 
+#ifdef WITH_GAMECUBE
 #define MAX_MEMORY_RANGES  64
 static struct memory_range memory_range[MAX_MEMORY_RANGES];
+#endif
 
 /* Return a sorted list of memory ranges. */
 int get_memory_ranges(struct memory_range **UNUSED(range), int *UNUSED(ranges),

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

#12 lore raw

PATCH 12/27 Avoid possible overflows from signed/unsigned comparisons

In reply to Simon Horman
kdump/kdump.c +2 -1
Index: kexec-tools/kdump/kdump.c
===================================================================
@@ -188,7 +188,8 @@ static void *generate_new_headers(
 
 static void write_all(int fd, const void *buf, size_t count)
 {
-	ssize_t result, written = 0;
+	ssize_t result;
+	size_t written = 0;
 	const char *ptr;
 	size_t left;
 	ptr = buf;
purgatory/purgatory.c +1 -1
Index: kexec-tools/purgatory/purgatory.c
===================================================================
@@ -13,7 +13,7 @@ void verify_sha256_digest(void)
 {
 	struct sha256_region *ptr, *end;
 	sha256_digest_t digest;
-	int i;
+	size_t i;
 	sha256_context ctx;
 	sha256_starts(&ctx);
 	end = &sha256_regions[sizeof(sha256_regions)/sizeof(sha256_regions[0])];
kexec/arch/i386/crashdump-x86.c +2 -1
Index: kexec-tools/kexec/arch/i386/crashdump-x86.c
===================================================================
@@ -375,7 +375,8 @@ static void ultoa(unsigned long i, char 
  * memory regions the new kernel can use to boot into. */
 static int cmdline_add_memmap(char *cmdline, struct memory_range *memmap_p)
 {
-	int i, cmdlen, len, min_sizek = 100;
+	int i, cmdlen, len;
+	unsigned long min_sizek = 100;
 	char str_mmap[256], str_tmp[20];
 
 	/* Exact map */
kexec/kexec-elf.c +4 -7
Index: kexec-tools/kexec/kexec-elf.c
===================================================================
@@ -369,8 +369,7 @@ static int build_mem_elf64_phdr(const ch
 static int build_mem_phdrs(const char *buf, off_t len, struct mem_ehdr *ehdr,
 				uint32_t flags)
 {
-	size_t phdr_size, mem_phdr_size;
-	int i;
+	size_t phdr_size, mem_phdr_size, i;
 
 	/* e_phnum is at most 65535 so calculating
 	 * the size of the program header cannot overflow.
@@ -582,8 +581,7 @@ static int build_mem_elf64_shdr(const ch
 static int build_mem_shdrs(const char *buf, off_t len, struct mem_ehdr *ehdr,
 				uint32_t flags)
 {
-	size_t shdr_size, mem_shdr_size;
-	int i;
+	size_t shdr_size, mem_shdr_size, i;
 
 	/* e_shnum is at most 65536 so calculating
 	 * the size of the section header cannot overflow.
@@ -636,7 +634,7 @@ static int build_mem_shdrs(const char *b
 			&& (shdr->sh_offset + shdr->sh_size) > len) {
 			/* The section does not fit in the buffer */
 			if (probe_debug) {
-				fprintf(stderr, "ELF section %d not in file\n",
+				fprintf(stderr, "ELF section %zd not in file\n",
 					i);
 			}
 			return -1;
@@ -666,8 +664,7 @@ static void read_nhdr(const struct mem_e
 static int build_mem_notes(struct mem_ehdr *ehdr)
 {
 	const unsigned char *note_start, *note_end, *note;
-	size_t note_size;
-	int i;
+	size_t note_size, i;
 	/* First find the note segment or section */
 	note_start = note_end = NULL;
 	for(i = 0; !note_start && (i < ehdr->e_phnum); i++) {
kexec/kexec-elf-exec.c +1 -1
Index: kexec-tools/kexec/kexec-elf-exec.c
===================================================================
@@ -53,7 +53,7 @@ int elf_exec_load(struct mem_ehdr *ehdr,
 {
 	unsigned long base;
 	int result;
-	int i;
+	size_t i;
 
 	if (!ehdr->e_phdr) {
 		fprintf(stderr, "No program header?\n");
kexec/lzma.c +1 -1
Index: kexec-tools/kexec/lzma.c
===================================================================
@@ -91,7 +91,7 @@ LZFILE *lzopen(const char *path, const c
 int lzclose(LZFILE *lzfile)
 {
 	lzma_ret ret;
-	int n;
+	size_t n;
 
 	if (!lzfile)
 		return -1;
kexec/arch/i386/kexec-multiboot-x86.c +3 -2
Index: kexec-tools/kexec/arch/i386/kexec-multiboot-x86.c
===================================================================
@@ -154,6 +154,7 @@ int multiboot_x86_load(int argc, char **
 	struct AddrRangeDesc *mmap;
 	int command_line_len;
 	int i;
+	uint32_t u;
 	int opt;
 	int modules, mod_command_line_space;
 #define OPT_CL  		(OPT_ARCH_MAX+0)
@@ -375,8 +376,8 @@ int multiboot_x86_load(int argc, char **
 	/* Relocate offsets in the MBI to absolute addresses */
 	mbi_offset = mbi_base;
 	modp = ((void *)mbi) + mbi->mods_addr;
-	for (i=0; i<mbi->mods_count; i++) {
-		modp[i].cmdline += mbi_offset;
+	for (u = 0; u < mbi->mods_count; u++) {
+		modp[u].cmdline += mbi_offset;
 	}
 	mbi->mods_addr += mbi_offset;
 	mbi->cmdline += mbi_offset;
kexec/arch/x86_64/crashdump-x86_64.c +2 -1
Index: kexec-tools/kexec/arch/x86_64/crashdump-x86_64.c
===================================================================
@@ -487,7 +487,8 @@ static void ultoa(unsigned long i, char 
  * memory regions the new kernel can use to boot into. */
 static int cmdline_add_memmap(char *cmdline, struct memory_range *memmap_p)
 {
-	int i, cmdlen, len, min_sizek = 100;
+	int i, cmdlen, len;
+	unsigned long min_sizek = 100;
 	char str_mmap[256], str_tmp[20];
 
 	/* Exact map */
kexec/arch/ppc64/fs2dt.c +17 -8
Index: kexec-tools/kexec/arch/ppc64/fs2dt.c
===================================================================
@@ -127,8 +127,9 @@ static void add_dyn_reconf_usable_mem_pr
 	uint64_t buf[32];
 	uint64_t ranges[2*MAX_MEMORY_RANGES];
 	uint64_t base, end, loc_base, loc_end;
-	int range, rlen = 0, i;
-	int rngs_cnt, tmp_indx;
+	size_t i, rngs_cnt, range;
+	int rlen = 0;
+	int tmp_indx;
 
 	strcpy(fname, pathname);
 	bname = strrchr(fname, '/');
@@ -189,13 +190,15 @@ static void add_dyn_reconf_usable_mem_pr
 	dt += (rlen + 3)/4;
 }
 
-static void add_usable_mem_property(int fd, int len)
+static void add_usable_mem_property(int fd, size_t len)
 {
 	char fname[MAXPATH], *bname;
 	uint64_t buf[2];
 	uint64_t ranges[2*MAX_MEMORY_RANGES];
 	uint64_t base, end, loc_base, loc_end;
-	int range, rlen = 0;
+	size_t range;
+	int rlen = 0;
+	ssize_t slen;
 
 	strcpy(fname, pathname);
 	bname = strrchr(fname,'/');
@@ -206,12 +209,12 @@ static void add_usable_mem_property(int 
 
 	if (len < 2 * sizeof(uint64_t))
 		die("unrecoverable error: not enough data for mem property\n");
-	len = 2 * sizeof(uint64_t);
+	slen = 2 * sizeof(uint64_t);
 
 	if (lseek(fd, 0, SEEK_SET) < 0)
 		die("unrecoverable error: error seeking in \"%s\": %s\n",
 		    pathname, strerror(errno));
-	if (read(fd, buf, len) != len)
+	if (read(fd, buf, slen) != slen)
 		die("unrecoverable error: error reading \"%s\": %s\n",
 		    pathname, strerror(errno));
 
@@ -263,7 +266,9 @@ static void add_usable_mem_property(int 
 static void putprops(char *fn, struct dirent **nlist, int numlist)
 {
 	struct dirent *dp;
-	int i = 0, fd, len;
+	int i = 0, fd;
+	size_t len;
+	ssize_t slen;
 	struct stat statbuf;
 
 	for (i = 0; i < numlist; i++) {
@@ -324,9 +329,13 @@ static void putprops(char *fn, struct di
 			die("unrecoverable error: could not open \"%s\": %s\n",
 			    pathname, strerror(errno));
 
-		if (read(fd, dt, len) != len)
+		slen = read(fd, dt, len);
+		if (slen < 0)
 			die("unrecoverable error: could not read \"%s\": %s\n",
 			    pathname, strerror(errno));
+		if ((size_t)slen != len)
+			die("unrecoverable error: short read from\"%s\"\n",
+			    pathname);
 
 		checkprop(fn, dt, len);
 
kexec/arch/ppc64/kexec-elf-ppc64.c +1 -1
Index: kexec-tools/kexec/arch/ppc64/kexec-elf-ppc64.c
===================================================================
@@ -84,7 +84,7 @@ int elf_ppc64_load(int argc, char **argv
 	size_t size;
 	uint64_t *rsvmap_ptr;
 	struct bootblock *bb_ptr;
-	unsigned int i;
+	int i;
 	int result, opt;
 	uint64_t my_kernel, my_dt_offset;
 	unsigned int my_panic_kernel;
kexec/arch/ppc64/kexec-ppc64.c +2 -1
Index: kexec-tools/kexec/arch/ppc64/kexec-ppc64.c
===================================================================
@@ -148,7 +148,8 @@ static int get_dyn_reconf_base_ranges(vo
 	uint64_t start, end;
 	char fname[128], buf[32];
 	FILE *file;
-	int i, n;
+	unsigned int i;
+	int n;
 
 	strcpy(fname, "/proc/device-tree/");
 	strcat(fname, "ibm,dynamic-reconfiguration-memory/ibm,lmb-size");
kexec/arch/ppc64/crashdump-ppc64.c +3 -2
Index: kexec-tools/kexec/arch/ppc64/crashdump-ppc64.c
===================================================================
@@ -126,7 +126,8 @@ static int get_dyn_reconf_crash_memory_r
 	uint64_t start, end;
 	char fname[128], buf[32];
 	FILE *file;
-	int i, n;
+	unsigned int i;
+	int n;
 	uint32_t flags;
 
 	strcpy(fname, "/proc/device-tree/");
@@ -450,7 +451,7 @@ int load_crashdump_segments(struct kexec
 
 void add_usable_mem_rgns(unsigned long long base, unsigned long long size)
 {
-	int i;
+	unsigned int i;
 	unsigned long long end = base + size;
 	unsigned long long ustart, uend;
 
kexec/arch/ia64/kexec-ia64.c +4 -3
Index: kexec-tools/kexec/arch/ia64/kexec-ia64.c
===================================================================
@@ -101,7 +101,7 @@ int get_memory_ranges(struct memory_rang
 	while(fgets(line, sizeof(line), fp) != 0) {
 		unsigned long start, end;
 		char *str;
-		int type;
+		unsigned type;
 		int consumed;
 		int count;
 		if (memory_ranges >= max_memory_ranges)
@@ -219,13 +219,14 @@ int arch_compat_trampoline(struct kexec_
 int update_loaded_segments(struct mem_ehdr *ehdr)
 {
 	int i;
+	unsigned u;
 	struct mem_phdr *phdr;
 	unsigned long start_addr = ULONG_MAX, end_addr = 0;
 	unsigned long align = 1UL<<26; /* 64M */
 	unsigned long start, end;
 
-	for (i = 0; i < ehdr->e_phnum; i++) {
-		phdr = &ehdr->e_phdr[i];
+	for (u = 0; u < ehdr->e_phnum; u++) {
+		phdr = &ehdr->e_phdr[u];
 		if (phdr->p_type != PT_LOAD)
 			continue;
 		if (phdr->p_paddr < start_addr)
kexec/arch/ia64/kexec-elf-ia64.c +1 -1
Index: kexec-tools/kexec/arch/ia64/kexec-elf-ia64.c
===================================================================
@@ -98,7 +98,7 @@ void elf_ia64_usage(void)
  */
 void move_loaded_segments(struct mem_ehdr *ehdr, unsigned long addr)
 {
-	int i;
+	unsigned i;
 	long offset;
 	struct mem_phdr *phdr;
 	for(i = 0; i < ehdr->e_phnum; i++) {
kexec/arch/ia64/crashdump-ia64.c +1 -1
Index: kexec-tools/kexec/arch/ia64/crashdump-ia64.c
===================================================================
@@ -73,7 +73,7 @@ static int seg_comp(const void *a, const
  */
 static void add_loaded_segments_info(struct mem_ehdr *ehdr)
 {
-	 int i;
+	 unsigned i;
          for(i = 0; i < ehdr->e_phnum; i++) {
                 struct mem_phdr *phdr;
                 phdr = &ehdr->e_phdr[i];
purgatory/arch/ia64/purgatory-ia64.c +1 -1
Index: kexec-tools/purgatory/arch/ia64/purgatory-ia64.c
===================================================================
@@ -159,7 +159,7 @@ patch_efi_memmap(struct kexec_boot_param
 	uint64_t orig_type;
 	efi_memory_desc_t *src_md, *dst_md;
 	void *src_end = src + boot_param->efi_memmap_size;
-	int i;
+	unsigned long i;
 	for (; src < src_end; src += boot_param->efi_memdesc_size,
 	     dest += boot_param->efi_memdesc_size) {
 		unsigned long mstart, mend;
kexec/arch/sh/kexec-zImage-sh.c +2 -2
Index: kexec-tools/kexec/arch/sh/kexec-zImage-sh.c
===================================================================
@@ -74,8 +74,8 @@ int zImage_sh_load(int argc, char **argv
 	struct kexec_info *info)
 {
         char *command_line;
-	int opt, k;
-	unsigned long empty_zero, zero_page_base, zero_page_size;
+	int opt;
+	unsigned long empty_zero, zero_page_base, zero_page_size, k;
 	unsigned long image_base;
 	char *param;
 

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

#13 lore raw

PATCH 13/27 Use casts to avoid ambiguity when comparing off_t and size_t

In reply to Simon Horman
kexec/arch/i386/kexec-bzImage.c +4 -3
Index: kexec-tools/kexec/arch/i386/kexec-bzImage.c
===================================================================
@@ -44,7 +44,7 @@ static const int probe_debug = 0;
 int bzImage_probe(const char *buf, off_t len)
 {
 	struct x86_linux_header header;
-	if (len < sizeof(header)) {
+	if ((uintmax_t)len < (uintmax_t)sizeof(header)) {
 		return -1;
 	}
 	memcpy(&header, buf, sizeof(header));
@@ -119,7 +119,7 @@ int do_bzImage_load(struct kexec_info *i
 	/*
 	 * Find out about the file I am about to load.
 	 */
-	if (kernel_len < sizeof(setup_header)) {
+	if ((uintmax_t)kernel_len < (uintmax_t)sizeof(setup_header)) {
 		return -1;
 	}
 	memcpy(&setup_header, kernel, sizeof(setup_header));
@@ -136,7 +136,8 @@ int do_bzImage_load(struct kexec_info *i
 	}
 
 	if (setup_header.protocol_version >= 0x0206) {
-		if (command_line_len > setup_header.cmdline_size) {
+		if ((uintmax_t)command_line_len >
+		    (uintmax_t)setup_header.cmdline_size) {
 			dbgprintf("Kernel command line too long for kernel!\n");
 			return -1;
 		}
kexec/arch/i386/kexec-beoboot-x86.c +1 -1
Index: kexec-tools/kexec/arch/i386/kexec-beoboot-x86.c
===================================================================
@@ -43,7 +43,7 @@ int beoboot_probe(const char *buf, off_t
 	struct beoboot_header bb_header;
 	const char *cmdline, *kernel;
 	int result;
-	if (len < sizeof(bb_header)) {
+	if ((uintmax_t)len < (uintmax_t)sizeof(bb_header)) {
 		return -1;
 	}
 	memcpy(&bb_header, buf, sizeof(bb_header));
kexec/kexec-elf.c +9 -7
Index: kexec-tools/kexec/kexec-elf.c
===================================================================
@@ -98,7 +98,7 @@ unsigned long elf_max_addr(const struct 
 static int build_mem_elf32_ehdr(const char *buf, off_t len, struct mem_ehdr *ehdr)
 {
 	Elf32_Ehdr lehdr;
-	if (len < sizeof(lehdr)) {
+	if ((uintmax_t)len < (uintmax_t)sizeof(lehdr)) {
 		/* Buffer is to small to be an elf executable */
 		if (probe_debug) {
 			fprintf(stderr, "Buffer is to small to hold ELF header\n");
@@ -170,7 +170,7 @@ static int build_mem_elf32_ehdr(const ch
 static int build_mem_elf64_ehdr(const char *buf, off_t len, struct mem_ehdr *ehdr)
 {
 	Elf64_Ehdr lehdr;
-	if (len < sizeof(lehdr)) {
+	if ((uintmax_t)len < (uintmax_t)sizeof(lehdr)) {
 		/* Buffer is to small to be an elf executable */
 		if (probe_debug) {
 			fprintf(stderr, "Buffer is to small to hold ELF header\n");
@@ -244,7 +244,7 @@ static int build_mem_ehdr(const char *bu
 	unsigned char e_ident[EI_NIDENT];
 	int result;
 	memset(ehdr, 0, sizeof(*ehdr));
-	if (len < sizeof(e_ident)) {
+	if ((uintmax_t)len < (uintmax_t)sizeof(e_ident)) {
 		/* Buffer is to small to be an elf executable */
 		if (probe_debug) {
 			fprintf(stderr, "Buffer is to small to hold ELF e_ident\n");
@@ -387,7 +387,7 @@ static int build_mem_phdrs(const char *b
 		return -1;
 	}
 	phdr_size *= ehdr->e_phnum;
-	if (ehdr->e_phoff + phdr_size > len) {
+	if ((uintmax_t)(ehdr->e_phoff + phdr_size) > (uintmax_t)len) {
 		/* The program header did not fit in the file buffer */
 		if (probe_debug) {
 			fprintf(stderr, "ELF program segment truncated\n");
@@ -420,7 +420,8 @@ static int build_mem_phdrs(const char *b
 		 */
 		phdr = &ehdr->e_phdr[i];
 		if (!(flags & ELF_SKIP_FILESZ_CHECK)
-			&& (phdr->p_offset + phdr->p_filesz) > len) {
+			&& (uintmax_t)(phdr->p_offset + phdr->p_filesz) >
+			   (uintmax_t)len) {
 			/* The segment does not fit in the buffer */
 			if (probe_debug) {
 				fprintf(stderr, "ELF segment not in file\n");
@@ -599,7 +600,7 @@ static int build_mem_shdrs(const char *b
 		return -1;
 	}
 	shdr_size *= ehdr->e_shnum;
-	if (ehdr->e_shoff + shdr_size > len) {
+	if ((uintmax_t)(ehdr->e_shoff + shdr_size) > (uintmax_t)len) {
 		/* The section header did not fit in the file buffer */
 		if (probe_debug) {
 			fprintf(stderr, "ELF section header does not fit in file\n");
@@ -631,7 +632,8 @@ static int build_mem_shdrs(const char *b
 		shdr = &ehdr->e_shdr[i];
 		if (!(flags & ELF_SKIP_FILESZ_CHECK)
 			&& (shdr->sh_type != SHT_NOBITS)
-			&& (shdr->sh_offset + shdr->sh_size) > len) {
+			&& (uintmax_t)(shdr->sh_offset + shdr->sh_size) >
+			   (uintmax_t)len) {
 			/* The section does not fit in the buffer */
 			if (probe_debug) {
 				fprintf(stderr, "ELF section %zd not in file\n",
kexec/arch/i386/kexec-nbi.c +1 -1
Index: kexec-tools/kexec/arch/i386/kexec-nbi.c
===================================================================
@@ -74,7 +74,7 @@ int nbi_probe(const char *buf, off_t len
 	struct segheader seg;
 	off_t seg_off;
 	/* If we don't have enough data give up */
-	if ((len < sizeof(hdr)) || (len < 512)) {
+	if (((uintmax_t)len < (uintmax_t)sizeof(hdr)) || (len < 512)) {
 		return -1;
 	}
 	memcpy(&hdr, buf, sizeof(hdr));
kexec/arch/ppc/kexec-dol-ppc.c +2 -1
Index: kexec-tools/kexec/arch/ppc/kexec-dol-ppc.c
===================================================================
@@ -265,7 +265,8 @@ int dol_ppc_probe(const char *buf, off_t
 		}
 
 		/* end of physical storage must be within file */
-		if (dol_sect_offset(h, i) + dol_sect_size(h, i) > 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",
kexec/arch/sh/kexec-uImage-sh.c +1 -1
Index: kexec-tools/kexec/arch/sh/kexec-uImage-sh.c
===================================================================
@@ -14,7 +14,7 @@ int uImage_sh_probe(const char *buf, off
 {
 	struct image_header header;
 
-	if (len < sizeof(header))
+	if ((uintmax_t)len < (uintmax_t)sizeof(header))
 		return -1;
 
 	memcpy(&header, buf, sizeof(header));
kexec/arch/arm/kexec-uImage-arm.c +1 -1
Index: kexec-tools/kexec/arch/arm/kexec-uImage-arm.c
===================================================================
@@ -12,7 +12,7 @@ int uImage_arm_probe(const char *buf, of
 {
 	struct image_header header;
 
-	if (len < sizeof(header))
+	if ((uintmax_t)len < (uintmax_t)sizeof(header))
 		return -1;
 
 	memcpy(&header, buf, sizeof(header));

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

#14 lore raw

PATCH 14/27 unsigned values are always at least 0

In reply to Simon Horman
kexec/arch/i386/crashdump-x86.c +1 -1
Index: kexec-tools/kexec/arch/i386/crashdump-x86.c
===================================================================
@@ -111,7 +111,7 @@ static int get_crash_memory_ranges(struc
 		}
 
 		/* First 640K already registered */
-		if (start >= 0x00000000ULL && end <= 0x0009ffffULL)
+		if (end <= 0x0009ffff)
 			continue;
 
 		crash_memory_range[memory_ranges].start = start;
kexec/arch/x86_64/crashdump-x86_64.c +1 -1
Index: kexec-tools/kexec/arch/x86_64/crashdump-x86_64.c
===================================================================
@@ -233,7 +233,7 @@ static int get_crash_memory_ranges(struc
 		}
 
 		/* First 640K already registered */
-		if (start >= 0x00000000 && end <= 0x0009ffff)
+		if (end <= 0x0009ffff)
 			continue;
 
 		crash_memory_range[memory_ranges].start = start;

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

#15 lore raw

PATCH 15/27 Cast when making signed/unsigned comparison in locate_hole()

In reply to Simon Horman
kexec/kexec.c +1 -1
Index: kexec-tools/kexec/kexec.c
===================================================================
@@ -208,7 +208,7 @@ unsigned long locate_hole(struct kexec_i
 		hole_align = 1;
 	}
 	/* Align everything to at least a page size boundary */
-	if (hole_align < getpagesize()) {
+	if (hole_align < (unsigned long)getpagesize()) {
 		hole_align = getpagesize();
 	}
 

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

#16 lore raw

PATCH 16/27 Use C99 initialisers

In reply to Simon Horman
kexec/arch/i386/crashdump-x86.c +1 -1
Index: kexec-tools/kexec/arch/i386/crashdump-x86.c
===================================================================
@@ -171,7 +171,7 @@ static int exclude_crash_reserve_region(
 {
 	int i, j, tidx = -1;
 	unsigned long long cstart, cend;
-	struct memory_range temp_region = { };
+	struct memory_range temp_region = {0, 0, 0};
 
 	/* Crash reserved region. */
 	cstart = crash_reserved_mem.start;
kexec/kexec-elf-rel.c +3 -3
Index: kexec-tools/kexec/kexec-elf-rel.c
===================================================================
@@ -58,7 +58,7 @@ static size_t elf_rela_size(struct mem_e
 
 static struct mem_sym elf_sym(struct mem_ehdr *ehdr, const unsigned char *ptr)
 {
-	struct mem_sym sym = { };
+	struct mem_sym sym = { 0, 0, 0, 0, 0, 0 };
 	if (ehdr->ei_class == ELFCLASS32) {
 		Elf32_Sym lsym;
 		memcpy(&lsym, ptr, sizeof(lsym));
@@ -87,7 +87,7 @@ static struct mem_sym elf_sym(struct mem
 
 static struct mem_rela elf_rel(struct mem_ehdr *ehdr, const unsigned char *ptr)
 {
-	struct mem_rela rela = { };
+	struct mem_rela rela = { 0, 0, 0, 0 };
 	if (ehdr->ei_class == ELFCLASS32) {
 		Elf32_Rel lrel;
 		memcpy(&lrel, ptr, sizeof(lrel));
@@ -112,7 +112,7 @@ static struct mem_rela elf_rel(struct me
 
 static struct mem_rela elf_rela(struct mem_ehdr *ehdr, const unsigned char *ptr)
 {
-	struct mem_rela rela = { };
+	struct mem_rela rela = { 0, 0, 0, 0 };
 	if (ehdr->ei_class == ELFCLASS32) {
 		Elf32_Rela lrela;
 		memcpy(&lrela, ptr, sizeof(lrela));
kexec/arch/x86_64/kexec-x86_64.c +1 -1
Index: kexec-tools/kexec/arch/x86_64/kexec-x86_64.c
===================================================================
@@ -145,7 +145,7 @@ const struct arch_map_entry arches[] = {
 	 * use KEXEC_ARCH_DEFAULT instead of KEXEC_ARCH_X86_64 here.
 	 */
 	{ "x86_64", KEXEC_ARCH_DEFAULT },
-	{ 0 },
+	{ NULL, 0 },
 };
 
 int arch_compat_trampoline(struct kexec_info *UNUSED(info))
kexec/arch/ppc/kexec-ppc.c +1 -1
Index: kexec-tools/kexec/arch/ppc/kexec-ppc.c
===================================================================
@@ -82,7 +82,7 @@ const struct arch_map_entry arches[] = {
 	 * use KEXEC_ARCH_DEFAULT instead of KEXEC_ARCH_PPC here.
 	 */
 	{ "ppc", KEXEC_ARCH_DEFAULT },
-	{ 0 },
+	{ NULL, 0 },
 };
 
 int arch_compat_trampoline(struct kexec_info *UNUSED(info))
kexec/arch/ppc64/kexec-ppc64.c +1 -1
Index: kexec-tools/kexec/arch/ppc64/kexec-ppc64.c
===================================================================
@@ -802,7 +802,7 @@ const struct arch_map_entry arches[] = {
 	 * So pass KEXEC_ARCH_PPC64 here
 	 */
 	{ "ppc64", KEXEC_ARCH_PPC64 },
-	{ 0 },
+	{ NULL, 0 },
 };
 
 int arch_compat_trampoline(struct kexec_info *UNUSED(info))
kexec/arch/ia64/kexec-ia64.c +1 -1
Index: kexec-tools/kexec/arch/ia64/kexec-ia64.c
===================================================================
@@ -208,7 +208,7 @@ int arch_process_options(int argc, char 
 
 const struct arch_map_entry arches[] = {
 	{ "ia64", KEXEC_ARCH_IA_64 },
-	{ 0 },
+	{ NULL, 0 },
 };
 
 int arch_compat_trampoline(struct kexec_info *UNUSED(info))
kexec/arch/s390/kexec-s390.c +1 -1
Index: kexec-tools/kexec/arch/s390/kexec-s390.c
===================================================================
@@ -98,7 +98,7 @@ int arch_process_options(int UNUSED(argc
 const struct arch_map_entry arches[] = {
 	{ "s390", KEXEC_ARCH_S390 },
 	{ "s390x", KEXEC_ARCH_S390 },
-	{ 0 },
+	{ NULL, 0 },
 };
 
 int arch_compat_trampoline(struct kexec_info *UNUSED(info))
kexec/arch/sh/kexec-sh.c +1 -1
Index: kexec-tools/kexec/arch/sh/kexec-sh.c
===================================================================
@@ -135,7 +135,7 @@ const struct arch_map_entry arches[] = {
 	{ "sh4", KEXEC_ARCH_DEFAULT },
 	{ "sh4a", KEXEC_ARCH_DEFAULT },
 	{ "sh4al-dsp", KEXEC_ARCH_DEFAULT },
-	{ 0 },
+	{ NULL, 0 },
 };
 
 int arch_compat_trampoline(struct kexec_info *UNUSED(info))
kexec/arch/arm/kexec-arm.c +1 -1
Index: kexec-tools/kexec/arch/arm/kexec-arm.c
===================================================================
@@ -110,7 +110,7 @@ int arch_process_options(int argc, char 
 
 const struct arch_map_entry arches[] = {
 	{ "arm", KEXEC_ARCH_ARM },
-	{ 0 },
+	{ NULL, 0 },
 };
 
 int arch_compat_trampoline(struct kexec_info *UNUSED(info))
kexec/arch/mips/kexec-mips.c +1 -1
Index: kexec-tools/kexec/arch/mips/kexec-mips.c
===================================================================
@@ -127,7 +127,7 @@ const struct arch_map_entry arches[] = {
 	 * use KEXEC_ARCH_DEFAULT instead of KEXEC_ARCH_MIPS here.
 	 */
 	{ "mips", KEXEC_ARCH_DEFAULT },
-	{ 0 },
+	{ NULL, 0 },
 };
 
 int arch_compat_trampoline(struct kexec_info *UNUSED(info))

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

#17 lore raw

PATCH 17/27 x86_64: initialise temp_region in exclude_region() and delete_memmap()

In reply to Simon Horman
kexec/arch/x86_64/crashdump-x86_64.c +2 -2
Index: kexec-tools/kexec/arch/x86_64/crashdump-x86_64.c
===================================================================
@@ -286,7 +286,7 @@ static int get_crash_memory_ranges(struc
 static int exclude_region(int *nr_ranges, uint64_t start, uint64_t end)
 {
 	int i, j, tidx = -1;
-	struct memory_range temp_region;
+	struct memory_range temp_region = { 0, 0, 0 };
 
 	for (i = 0; i < (*nr_ranges); i++) {
 		unsigned long long mstart, mend;
@@ -385,7 +385,7 @@ static int delete_memmap(struct memory_r
 {
 	int i, j, nr_entries = 0, tidx = -1, operation = 0, align = 1024;
 	unsigned long long mstart, mend;
-	struct memory_range temp_region;
+	struct memory_range temp_region = { 0, 0, 0 };
 
 	/* Do alignment check. */
 	if ((addr%align) || (size%align))

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

#18 lore raw

PATCH 18/27 Make purgatory a signed char buffer

In reply to Simon Horman

The consumer of the purgatory buffer, elf_rel_build_load() expects a signed char buffer.

util/bin-to-hex.c +1 -1
Index: kexec-tools/util/bin-to-hex.c
===================================================================
@@ -6,7 +6,7 @@ int main(int argc, char **argv)
 	int i;
 	const char *name = argv[1];
 	printf("#include <stddef.h>\n");
-	printf("const unsigned char %s[] = {\n", name);
+	printf("const char %s[] = {\n", name);
 	i = 0;
 	while((c = getchar()) != EOF) {
 		if ((i % 16) != 0) {
kexec/arch/i386/kexec-bzImage.c +2 -2
Index: kexec-tools/kexec/arch/i386/kexec-bzImage.c
===================================================================
@@ -200,10 +200,10 @@ int do_bzImage_load(struct kexec_info *i
 	 * overflow takes place while applying relocations.
 	 */
 	if (!real_mode_entry && relocatable_kernel)
-		elf_rel_build_load(info, &info->rhdr, (char *) purgatory, purgatory_size,
+		elf_rel_build_load(info, &info->rhdr, purgatory, purgatory_size,
 					0x3000, 0x7fffffff, -1, 0);
 	else
-		elf_rel_build_load(info, &info->rhdr, (char *) purgatory, purgatory_size,
+		elf_rel_build_load(info, &info->rhdr, purgatory, purgatory_size,
 					0x3000, 640*1024, -1, 0);
 	dbgprintf("Loaded purgatory at addr 0x%lx\n", info->rhdr.rel_addr);
 	/* The argument/parameter segment */
kexec/arch/i386/kexec-elf-x86.c +1 -1
Index: kexec-tools/kexec/arch/i386/kexec-elf-x86.c
===================================================================
@@ -191,7 +191,7 @@ int elf_x86_load(int argc, char **argv, 
 	/* Do we want arguments? */
 	if (arg_style != ARG_STYLE_NONE) {
 		/* Load the setup code */
-		elf_rel_build_load(info, &info->rhdr, (char *) purgatory, purgatory_size,
+		elf_rel_build_load(info, &info->rhdr, purgatory, purgatory_size,
 			0, ULONG_MAX, 1, 0);
 	}
 	if (arg_style == ARG_STYLE_NONE) {
kexec/arch/i386/kexec-multiboot-x86.c +1 -1
Index: kexec-tools/kexec/arch/i386/kexec-multiboot-x86.c
===================================================================
@@ -217,7 +217,7 @@ int multiboot_x86_load(int argc, char **
 	elf_exec_build_load(info, &ehdr, buf, len, 0);
 
 	/* Load the setup code */
-	elf_rel_build_load(info, &info->rhdr, (char *) purgatory, purgatory_size, 0,
+	elf_rel_build_load(info, &info->rhdr, purgatory, purgatory_size, 0,
 				ULONG_MAX, 1, 0);
 	
 	/* The first segment will contain the multiboot headers:
kexec/arch/ppc64/kexec-elf-ppc64.c +1 -1
Index: kexec-tools/kexec/arch/ppc64/kexec-elf-ppc64.c
===================================================================
@@ -207,7 +207,7 @@ int elf_ppc64_load(int argc, char **argv
 	}
 
 	/* Add v2wrap to the current image */
-	elf_rel_build_load(info, &info->rhdr, (const char *)purgatory,
+	elf_rel_build_load(info, &info->rhdr, purgatory,
 				purgatory_size, 0, max_addr, 1, 0);
 
 	/* Add a ram-disk to the current image
kexec/kexec.h +1 -1
Index: kexec-tools/kexec/kexec.h
===================================================================
@@ -226,7 +226,7 @@ extern void arch_reuse_initrd(void);
 
 extern int ifdown(void);
 
-extern unsigned char purgatory[];
+extern char purgatory[];
 extern size_t purgatory_size;
 
 #define BOOTLOADER "kexec"

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

#19 lore raw

PATCH 19/27 Consistently use signed char buffers throughout

In reply to Simon Horman
kexec/arch/x86_64/kexec-elf-x86_64.c +2 -3
Index: kexec-tools/kexec/arch/x86_64/kexec-elf-x86_64.c
===================================================================
@@ -203,8 +203,7 @@ int elf_x86_64_load(int argc, char **arg
 		struct entry64_regs regs;
 
 		/* Setup the ELF boot notes */
-		note_base = elf_boot_notes(info, max_addr,
-			command_line, command_line_len);
+		note_base = elf_boot_notes(info, max_addr, command_line, command_line_len);
 
 		/* Initialize the registers */
 		elf_rel_get_symbol(&info->rhdr, "entry64_regs", &regs, sizeof(regs));
@@ -220,7 +219,7 @@ int elf_x86_64_load(int argc, char **arg
 	else if (arg_style == ARG_STYLE_LINUX) {
 		struct x86_linux_faked_param_header *hdr;
 		unsigned long param_base;
-		const unsigned char *ramdisk_buf;
+		char *ramdisk_buf;
 		off_t ramdisk_length;
 		struct entry64_regs regs;
 		int rc=0;
kexec/kexec-elf-boot.c +1 -1
Index: kexec-tools/kexec/kexec-elf-boot.c
===================================================================
@@ -75,7 +75,7 @@ static inline unsigned long align(unsign
 
 unsigned long elf_boot_notes(
 	struct kexec_info *info, unsigned long max_addr,
-	const unsigned char *cmdline, int cmdline_len)
+	const char *cmdline, int cmdline_len)
 {
 	unsigned long note_bytes;
 	unsigned long note_base;
kexec/kexec-elf-boot.h +1 -1
Index: kexec-tools/kexec/kexec-elf-boot.h
===================================================================
@@ -3,6 +3,6 @@
 
 unsigned long elf_boot_notes(
 	struct kexec_info *info, unsigned long max_addr, 
-	const unsigned char *cmdline, int cmdline_len);
+	const char *cmdline, int cmdline_len);
 
 #endif /* KEXEC_ELF_BOOT_H */
kexec/arch/i386/kexec-elf-x86.c +3 -3
Index: kexec-tools/kexec/arch/i386/kexec-elf-x86.c
===================================================================
@@ -205,7 +205,7 @@ int elf_x86_load(int argc, char **argv, 
 
 		/* Setup the ELF boot notes */
 		note_base = elf_boot_notes(info, max_addr,
-			(unsigned char *) command_line, command_line_len);
+					   command_line, command_line_len);
 
 		/* Initialize the stack arguments */
 		arg2 = 0; /* No return address */
@@ -226,7 +226,7 @@ int elf_x86_load(int argc, char **argv, 
 	else if (arg_style == ARG_STYLE_LINUX) {
 		struct x86_linux_faked_param_header *hdr;
 		unsigned long param_base;
-		const unsigned char *ramdisk_buf;
+		const char *ramdisk_buf;
 		off_t ramdisk_length;
 		struct entry32_regs regs;
 		int rc = 0;
@@ -253,7 +253,7 @@ int elf_x86_load(int argc, char **argv, 
 		ramdisk_buf = NULL;
 		ramdisk_length = 0;
 		if (ramdisk) {
-			ramdisk_buf = (unsigned char *) slurp_file(ramdisk, &ramdisk_length);
+			ramdisk_buf = slurp_file(ramdisk, &ramdisk_length);
 		}
 
 		/* If panic kernel is being loaded, additional segments need
kexec/arch/i386/kexec-bzImage.c +1 -1
Index: kexec-tools/kexec/arch/i386/kexec-bzImage.c
===================================================================
@@ -264,7 +264,7 @@ int do_bzImage_load(struct kexec_info *i
 	/* Tell the kernel what is going on */
 	setup_linux_bootloader_parameters(info, real_mode, setup_base,
 		kern16_size, command_line, command_line_len,
-		(unsigned char *) initrd, initrd_len);
+		initrd, initrd_len);
 
 	/* Get the initial register values */
 	elf_rel_get_symbol(&info->rhdr, "entry16_regs", &regs16, sizeof(regs16));
kexec/arch/i386/x86-linux-setup.c +1 -1
Index: kexec-tools/kexec/arch/i386/x86-linux-setup.c
===================================================================
@@ -49,7 +49,7 @@ void setup_linux_bootloader_parameters(
 	struct kexec_info *info, struct x86_linux_param_header *real_mode,
 	unsigned long real_mode_base, unsigned long cmdline_offset,
 	const char *cmdline, off_t cmdline_len,
-	const unsigned char *initrd_buf, off_t initrd_size)
+	const char *initrd_buf, off_t initrd_size)
 {
 	char *cmdline_ptr;
 	unsigned long initrd_base, initrd_addr_max;
kexec/arch/i386/x86-linux-setup.h +1 -1
Index: kexec-tools/kexec/arch/i386/x86-linux-setup.h
===================================================================
@@ -6,7 +6,7 @@ void setup_linux_bootloader_parameters(
 	struct kexec_info *info, struct x86_linux_param_header *real_mode,
 	unsigned long real_mode_base, unsigned long cmdline_offset,
 	const char *cmdline, off_t cmdline_len,
-	const unsigned char *initrd_buf, off_t initrd_size);
+	const char *initrd_buf, off_t initrd_size);
 void setup_linux_system_parameters(struct x86_linux_param_header *real_mode,
 					unsigned long kexec_flags);
 

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

#20 lore raw

PATCH 20/27 Cast 64bit pointer to a 64bit int then a 32bit int

In reply to Simon Horman

The two-stage cast is because we really do want a 32bit integer value from a 64bit pointer, and gcc assumes that we're making a mistake if there is just one cast.

# powerpc64-unknown-linux-gnu-gcc --version
powerpc64-unknown-linux-gnu-gcc (GCC) 4.1.1
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# make
kexec/arch/ppc64/kexec-elf-rel-ppc64.c: In function 'machine_apply_elf_rel':
kexec/arch/ppc64/kexec-elf-rel-ppc64.c:66: warning: cast from pointer to integer of different size
kexec/arch/ppc64/kexec-elf-rel-ppc64.c +1 -1
Index: kexec-tools/kexec/arch/ppc64/kexec-elf-rel-ppc64.c
===================================================================
@@ -63,7 +63,7 @@ void machine_apply_elf_rel(struct mem_eh
 		break;
 
 	case R_PPC64_REL32:
-		*(uint32_t *)location = value - (uint32_t)location;
+		*(uint32_t *)location = value - (uint32_t)(uint64_t)location;
 		break;
 
 	case R_PPC64_TOC:

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

#21 lore raw

PATCH 21/27 ia64: move_loaded_segments: handle no matching region

In reply to Simon Horman

Apparently this never happens, but the current code seems excessively loose.

1) die if it does happen
2) initialise offset to make gcc happy.

# ia64-unknown-linux-gnu-gcc --version
ia64-unknown-linux-gnu-gcc (GCC) 3.4.5
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# make
kexec/arch/ia64/kexec-elf-ia64.c: In function `move_loaded_segments':
kexec/arch/ia64/kexec-elf-ia64.c:102: warning: 'offset' might be used
uninitialized in this function
kexec/arch/ia64/kexec-elf-ia64.c +5 -1
Index: kexec-tools/kexec/arch/ia64/kexec-elf-ia64.c
===================================================================
@@ -99,15 +99,19 @@ void elf_ia64_usage(void)
 void move_loaded_segments(struct mem_ehdr *ehdr, unsigned long addr)
 {
 	unsigned i;
-	long offset;
+	long offset = 0;
+	int found = 0;
 	struct mem_phdr *phdr;
 	for(i = 0; i < ehdr->e_phnum; i++) {
 		phdr = &ehdr->e_phdr[i];
 		if (phdr->p_type == PT_LOAD) {
 			offset = addr - phdr->p_paddr;
+			found++;
 			break;
 		}
 	}
+	if (!found)
+		die("move_loaded_segments: no PT_LOAD region 0x%016x\n", addr);
 	ehdr->e_entry += offset;
 	for(i = 0; i < ehdr->e_phnum; i++) {
 		phdr = &ehdr->e_phdr[i];

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

#22 lore raw

PATCH 22/27 Dont discard the const qualifier of proc_iomem()

In reply to Simon Horman
kexec/arch/s390/kexec-s390.c +1 -1
Index: kexec-tools/kexec/arch/s390/kexec-s390.c
===================================================================
@@ -40,7 +40,7 @@ int get_memory_ranges(struct memory_rang
 		      unsigned long UNUSED(flags))
 {
 	char sys_ram[] = "System RAM\n";
-	char *iomem = proc_iomem();
+	const char *iomem = proc_iomem();
 	FILE *fp;
 	char line[80];
 	int current_range = 0;

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

#23 lore raw

PATCH 23/27 sh: Use size_t for zero_page_size parameter of kexec_sh_setup_zero_page()

In reply to Simon Horman

This avoids comparisons between signed and unsigned integers.

kexec/arch/sh/kexec-sh.c +2 -2
Index: kexec-tools/kexec/arch/sh/kexec-sh.c
===================================================================
@@ -164,10 +164,10 @@ char *get_append(void)
         return append_buf;
 }
 
-void kexec_sh_setup_zero_page(char *zero_page_buf, int zero_page_size,
+void kexec_sh_setup_zero_page(char *zero_page_buf, size_t zero_page_size,
 			      char *cmd_line)
 {
-	int n = zero_page_size - 0x100;
+	size_t n = zero_page_size - 0x100;
 
 	memset(zero_page_buf, 0, zero_page_size);
 
kexec/arch/sh/kexec-sh.h +1 -1
Index: kexec-tools/kexec/arch/sh/kexec-sh.h
===================================================================
@@ -23,7 +23,7 @@ int netbsd_sh_load(int argc, char **argv
 void netbsd_sh_usage(void);
 
 char *get_append(void);
-void kexec_sh_setup_zero_page(char *zero_page_buf, int zero_page_size,
+void kexec_sh_setup_zero_page(char *zero_page_buf, size_t zero_page_size,
 			      char *cmd_line);
 
 #endif /* KEXEC_SH_H */
kexec/arch/sh/kexec-zImage-sh.c +1 -1
Index: kexec-tools/kexec/arch/sh/kexec-zImage-sh.c
===================================================================
@@ -51,7 +51,7 @@ static unsigned long zImage_head32(const
  *
  * Make sure that the file image has a reasonable chance of working.
  */
-int zImage_sh_probe(const char *buf, off_t len)
+int zImage_sh_probe(const char *buf, off_t UNUSED(len))
 {
 	if (memcmp(&buf[0x202], "HdrS", 4) != 0)
 	        return -1;

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

#24 lore raw

PATCH 24/27 sh: netbsd_booter extern qualifier should come first

In reply to Simon Horman
# sh4-unknown-linux-gnu-gcc --version
sh4-unknown-linux-gnu-gcc (GCC) 4.1.1
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# make
kexec/arch/sh/kexec-netbsd-sh.c:29: warning: 'extern' is not at beginning of declaration
kexec/arch/sh/kexec-netbsd-sh.c +1 -1
Index: kexec-tools/kexec/arch/sh/kexec-netbsd-sh.c
===================================================================
@@ -26,7 +26,7 @@
 #include <arch/options.h>
 
 static const int probe_debug = 0;
-const extern unsigned char netbsd_booter[];
+extern const unsigned char netbsd_booter[];
 
 /*
  * netbsd_sh_probe - sanity check the elf image

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

#25 lore raw

PATCH 25/27 arm: Include unistd.h for getpagesize()

In reply to Simon Horman
kexec/arch/arm/kexec-zImage-arm.c +1 -0
Index: kexec-tools/kexec/arch/arm/kexec-zImage-arm.c
===================================================================
@@ -10,6 +10,7 @@
 #include <errno.h>
 #include <limits.h>
 #include <stdint.h>
+#include <unistd.h>
 #include <getopt.h>
 #include <arch/options.h>
 #include "../../kexec.h"

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

#26 lore raw

PATCH 26/27 arm: Initialise initrd_start in zImage_arm_load()

In reply to Simon Horman

Although the following compiler warning is bogus it seems harmless to initialise initrd_start to NULL.

# arm-unknown-linux-gnu-gcc --version
arm-unknown-linux-gnu-gcc (GCC) 4.1.1
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# make
kexec/arch/arm/kexec-zImage-arm.c: In function 'zImage_arm_load':
kexec/arch/arm/kexec-zImage-arm.c:135: warning: 'initrd_start' may be used
uninitialized in this function
kexec/arch/arm/kexec-zImage-arm.c +1 -1
Index: kexec-tools/kexec/arch/arm/kexec-zImage-arm.c
===================================================================
@@ -132,7 +132,7 @@ int atag_arm_load(struct kexec_info *inf
 	char *buf;
 	off_t len;
 	struct tag *params;
-	uint32_t *initrd_start;
+	uint32_t *initrd_start = NULL;
 	
 	buf = xmalloc(getpagesize());
 	if (!buf) {

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

#27 lore raw

PATCH 27/27 cris: cast trampoline_base

In reply to Simon Horman
# crisv32-axis-linux-gnu-gcc --version
crisv32-axis-linux-gnu-gcc (GCC) 3.2.1 Axis release R64/1.64
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# make
kexec/arch/cris/kexec-elf-cris.c: In function `elf_cris_load':
kexec/arch/cris/kexec-elf-cris.c:134: warning: assignment makes pointer from integer without a cast
kexec/arch/cris/kexec-elf-cris.c +1 -1
Index: kexec-tools/kexec/arch/cris/kexec-elf-cris.c
===================================================================
@@ -131,6 +131,6 @@ int elf_cris_load(int argc, char **argv,
 					  4, 0, elf_max_addr(&ehdr), 1);
 	memcpy(trampoline_buf,
 	       cris_trampoline, cris_trampoline_size);
-	info->entry = trampoline_base;
+	info->entry = (void *)trampoline_base;
 	return 0;
 }

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