Skip to contentSkip to conversation

kexec, x86: Fix x86 build warnings

PATCH In review WANG Chao 2 participants 3 messages Oct 16, 2013 – Oct 17, 2013

Subsystems (2)
lore
Share & tools
lore

WANG Chao

author
#0 lore raw

PATCH 1/1 kexec, x86: Fix x86 build warnings

Gcc throw out three warnings:

kexec/arch/i386/kexec-elf-x86.c: In function ‘elf_x86_load’:
kexec/arch/i386/kexec-elf-x86.c:97:6: warning: variable ‘modified_cmdline_len’ set but not used [-Wunused-but-set-variable]

  int modified_cmdline_len;
      ^
kexec/arch/i386/kexec-bzImage.c: In function ‘do_bzImage_load’:
kexec/arch/i386/kexec-bzImage.c:110:8: warning: variable ‘kernel_version’ set but not used [-Wunused-but-set-variable]
  char *kernel_version;
        ^
kexec/arch/i386/kexec-x86-common.c: In function ‘efi_map_added’:
kexec/arch/i386/kexec-x86-common.c:400:18: warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
  char buf[512], *res;
                  ^

Fix these warnings by remove the unused variables for good.

---
 kexec/arch/i386/kexec-bzImage.c    | 2 --
 kexec/arch/i386/kexec-elf-x86.c    | 3 ---
 kexec/arch/i386/kexec-x86-common.c | 4 ++--
 3 files changed, 2 insertions(+), 7 deletions(-)
kexec/arch/i386/kexec-bzImage.c +0 -2
index fc1a54f..15c1b34 100644
@@ -107,7 +107,6 @@ int do_bzImage_load(struct kexec_info *info,
 	struct x86_linux_header setup_header;
 	struct x86_linux_param_header *real_mode;
 	int setup_sects;
-	char *kernel_version;
 	size_t size;
 	int kern16_size;
 	unsigned long setup_base, setup_size;
@@ -133,7 +132,6 @@ 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");
 		return -1;
kexec/arch/i386/kexec-elf-x86.c +0 -3
index d0f9838..de00dcb 100644
@@ -94,7 +94,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 	char *error_msg = NULL;
 	int result;
 	int command_line_len;
-	int modified_cmdline_len;
 	const char *ramdisk;
 	unsigned long entry, max_addr;
 	int arg_style;
@@ -123,7 +122,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 	 * Parse the command line arguments
 	 */
 	arg_style = ARG_STYLE_ELF;
-	modified_cmdline_len = 0;
 	ramdisk = 0;
 	result = 0;
 	while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
@@ -180,7 +178,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 						COMMAND_LINE_SIZE);
 			modified_cmdline[COMMAND_LINE_SIZE - 1] = '\0';
 		}
-		modified_cmdline_len = strlen(modified_cmdline);
 	}
 
 	/* Load the ELF executable */
kexec/arch/i386/kexec-x86-common.c +2 -2
index ed6c950..e5aa2a4 100644
@@ -397,10 +397,10 @@ again:
  * @return 1 if parameter is present, 0 if not or if an error occurs.
  */
 int efi_map_added( void ) {
-	char buf[512], *res;
+	char buf[512];
 	FILE *fp = fopen( "/proc/cmdline", "r" );
 	if( fp ) {
-		res = fgets( buf, 512, fp );
+		fgets( buf, 512, fp );
 		fclose( fp );
 		return strstr( buf, "add_efi_memmap" ) != NULL;
 	} else {
Signature · 7 lines
1.8.3.1


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec
author
#1 lore raw
Quoted 14 lines · WANG Chao

Gcc throw out three warnings:

kexec/arch/i386/kexec-elf-x86.c: In function ‘elf_x86_load’:
kexec/arch/i386/kexec-elf-x86.c:97:6: warning: variable ‘modified_cmdline_len’ set but not used [-Wunused-but-set-variable]

  int modified_cmdline_len;
      ^
kexec/arch/i386/kexec-bzImage.c: In function ‘do_bzImage_load’:
kexec/arch/i386/kexec-bzImage.c:110:8: warning: variable ‘kernel_version’ set but not used [-Wunused-but-set-variable]
  char *kernel_version;
        ^
kexec/arch/i386/kexec-x86-common.c: In function ‘efi_map_added’:
kexec/arch/i386/kexec-x86-common.c:400:18: warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
  char buf[512], *res;
                  ^
Quoted 3 lines

Fix these warnings by remove the unused variables for good.

Hi, Simon

This is for kexec-tools, will you pick up this one?

Thanks
WANG Chao

Quoted 74 lines
---
 kexec/arch/i386/kexec-bzImage.c    | 2 --
 kexec/arch/i386/kexec-elf-x86.c    | 3 ---
 kexec/arch/i386/kexec-x86-common.c | 4 ++--
 3 files changed, 2 insertions(+), 7 deletions(-)
kexec/arch/i386/kexec-bzImage.c +0 -2
index fc1a54f..15c1b34 100644
@@ -107,7 +107,6 @@ int do_bzImage_load(struct kexec_info *info,
 	struct x86_linux_header setup_header;
 	struct x86_linux_param_header *real_mode;
 	int setup_sects;
-	char *kernel_version;
 	size_t size;
 	int kern16_size;
 	unsigned long setup_base, setup_size;
@@ -133,7 +132,6 @@ 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");
 		return -1;
kexec/arch/i386/kexec-elf-x86.c +0 -3
index d0f9838..de00dcb 100644
@@ -94,7 +94,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 	char *error_msg = NULL;
 	int result;
 	int command_line_len;
-	int modified_cmdline_len;
 	const char *ramdisk;
 	unsigned long entry, max_addr;
 	int arg_style;
@@ -123,7 +122,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 	 * Parse the command line arguments
 	 */
 	arg_style = ARG_STYLE_ELF;
-	modified_cmdline_len = 0;
 	ramdisk = 0;
 	result = 0;
 	while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
@@ -180,7 +178,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 						COMMAND_LINE_SIZE);
 			modified_cmdline[COMMAND_LINE_SIZE - 1] = '\0';
 		}
-		modified_cmdline_len = strlen(modified_cmdline);
 	}
 
 	/* Load the ELF executable */
kexec/arch/i386/kexec-x86-common.c +2 -2
index ed6c950..e5aa2a4 100644
@@ -397,10 +397,10 @@ again:
  * @return 1 if parameter is present, 0 if not or if an error occurs.
  */
 int efi_map_added( void ) {
-	char buf[512], *res;
+	char buf[512];
 	FILE *fp = fopen( "/proc/cmdline", "r" );
 	if( fp ) {
-		res = fgets( buf, 512, fp );
+		fgets( buf, 512, fp );
 		fclose( fp );
 		return strstr( buf, "add_efi_memmap" ) != NULL;
 	} else {
Signature · 1 line
1.8.3.1

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

#2 lore raw
In reply to WANG Chao
Quoted 48 lines · WANG Chao

Gcc throw out three warnings:

kexec/arch/i386/kexec-elf-x86.c: In function ‘elf_x86_load’:
kexec/arch/i386/kexec-elf-x86.c:97:6: warning: variable ‘modified_cmdline_len’ set but not used [-Wunused-but-set-variable]

  int modified_cmdline_len;
      ^
kexec/arch/i386/kexec-bzImage.c: In function ‘do_bzImage_load’:
kexec/arch/i386/kexec-bzImage.c:110:8: warning: variable ‘kernel_version’ set but not used [-Wunused-but-set-variable]
  char *kernel_version;
        ^
kexec/arch/i386/kexec-x86-common.c: In function ‘efi_map_added’:
kexec/arch/i386/kexec-x86-common.c:400:18: warning: variable ‘res’ set but not used [-Wunused-but-set-variable]
  char buf[512], *res;
                  ^

Fix these warnings by remove the unused variables for good.

---
 kexec/arch/i386/kexec-bzImage.c    | 2 --
 kexec/arch/i386/kexec-elf-x86.c    | 3 ---
 kexec/arch/i386/kexec-x86-common.c | 4 ++--
 3 files changed, 2 insertions(+), 7 deletions(-)
kexec/arch/i386/kexec-bzImage.c +0 -2
index fc1a54f..15c1b34 100644
@@ -107,7 +107,6 @@ int do_bzImage_load(struct kexec_info *info,
 	struct x86_linux_header setup_header;
 	struct x86_linux_param_header *real_mode;
 	int setup_sects;
-	char *kernel_version;
 	size_t size;
 	int kern16_size;
 	unsigned long setup_base, setup_size;
@@ -133,7 +132,6 @@ 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");
 		return -1;
kexec/arch/i386/kexec-elf-x86.c +0 -0
index d0f9838..de00dcb 100644

kexec/arch/i386/kexec-elf-x86.c int elf_x86_load(int argc, char **argv, const char *buf, off_t len, · line 97

Quoted 4 lines
kexec/arch/i386/kexec-elf-x86.c +0 -1
@@ -94,7 +94,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 	char *error_msg = NULL;
 	int result;
 	int command_line_len;
-	int modified_cmdline_len;

I grep this varialbe and found ppc64 ported this code block, then this varialbe isn't used either. Could you please remove it too?

Quoted 44 lines
kexec/arch/i386/kexec-elf-x86.c +0 -2
 	const char *ramdisk;
 	unsigned long entry, max_addr;
 	int arg_style;
@@ -123,7 +122,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 	 * Parse the command line arguments
 	 */
 	arg_style = ARG_STYLE_ELF;
-	modified_cmdline_len = 0;
 	ramdisk = 0;
 	result = 0;
 	while((opt = getopt_long(argc, argv, short_options, options, 0)) != -1) {
@@ -180,7 +178,6 @@ int elf_x86_load(int argc, char **argv, const char *buf, off_t len,
 						COMMAND_LINE_SIZE);
 			modified_cmdline[COMMAND_LINE_SIZE - 1] = '\0';
 		}
-		modified_cmdline_len = strlen(modified_cmdline);
 	}
 
 	/* Load the ELF executable */
kexec/arch/i386/kexec-x86-common.c +2 -2
index ed6c950..e5aa2a4 100644
@@ -397,10 +397,10 @@ again:
  * @return 1 if parameter is present, 0 if not or if an error occurs.
  */
 int efi_map_added( void ) {
-	char buf[512], *res;
+	char buf[512];
 	FILE *fp = fopen( "/proc/cmdline", "r" );
 	if( fp ) {
-		res = fgets( buf, 512, fp );
+		fgets( buf, 512, fp );
 		fclose( fp );
 		return strstr( buf, "add_efi_memmap" ) != NULL;
 	} else {
Signature · 7 lines
1.8.3.1


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

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