[syslinux] [GIT PULL] elflink compiler warning fixes

Matt Fleming matt at console-pimps.org
Wed Mar 16 11:52:21 PDT 2011


Hi,

These patches fix some compiler warnings in ldlinux and elflink. I've
tried to split the patches out so that they only change one file or one
type of problem at once. So, if they do inadvertently introduce any
bugs it should at least be easy to bisect to a smallish commit.


The following changes since commit 9ded45991b4fc83b40af963feb773ddca2589d74:

  ldlinux: Parse and store the "onerror" command line (2011-03-09 14:32:36 +0000)

are available in the git repository at:
  git://git.zytor.com/users/mfleming/syslinux.git for-hpa/elflink/fix-compiler-warnings

Liu Aleaxander (1):
      elflink: Cleanup some warnings

Matt Fleming (9):
      ldlinux: Fix the following warnings
      ldlinux: Fix compiler warnings in cli.c
      ldlinux: Sprinkle const type qualifers
      ldlinux: Delete unused variables and functions
      ldlinux: Fix compiler warning in colors.c
      elflink: Fix compiler warnings in hello.c
      elflink: Fix compiler warnings by including core-elf.h
      elflink: Add draw_message_file() prototype
      elflink: Return zero from draw_background()

 com32/elflink/ldlinux/Makefile     |    2 +-
 com32/elflink/ldlinux/cli.c        |    5 ++---
 com32/elflink/ldlinux/colors.c     |    1 +
 com32/elflink/ldlinux/config.h     |    4 ++--
 com32/elflink/ldlinux/getadv.c     |    2 +-
 com32/elflink/ldlinux/ldlinux.c    |    4 ++--
 com32/elflink/ldlinux/readconfig.c |   22 ++++------------------
 com32/elflink/modules/background.c |    3 +++
 com32/elflink/modules/hello.c      |    3 +--
 com32/elflink/modules/menu.c       |    1 +
 com32/elflink/modules/menu.h       |    3 +++
 com32/elflink/modules/mytest.c     |    1 +
 com32/elflink/modules/passwd.c     |    1 +
 com32/elflink/modules/printmsg.c   |    1 +
 core/elflink/core-elf.h            |    4 ++--
 core/elflink/execute.c             |    2 ++
 core/elflink/kernel.c              |    4 ++--
 17 files changed, 30 insertions(+), 33 deletions(-)

diff --git a/com32/elflink/ldlinux/Makefile b/com32/elflink/ldlinux/Makefile
index 339e13e..f960693 100644
--- a/com32/elflink/ldlinux/Makefile
+++ b/com32/elflink/ldlinux/Makefile
@@ -13,7 +13,7 @@
 topdir = ../../..
 include ../modules/MCONFIG
 
-CFLAGS += -I../modules -I$(topdir)/core/elflink
+CFLAGS += -I../modules -I$(topdir)/core/elflink -I$(topdir)/core/include
 
 all: ldlinux.c32
 
diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index 77d32cd..0e0827d 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -378,7 +378,7 @@ void process_command(const char *cmd, bool history)
 
 	//	dprintf("raw cmd = %s", cmd);
 	strcpy(temp_cmd, cmd);
-	module_name = strtok(cmd, COMMAND_DELIM);
+	module_name = strtok((char *)cmd, COMMAND_DELIM);
 	len_mn = strlen(module_name);
 
 	if (!strcmp(module_name + len_mn - 4, ".c32")) {
@@ -397,7 +397,7 @@ void process_command(const char *cmd, bool history)
 		} while (argc < MAX_COMMAND_ARGS);
 		argv[argc] = NULL;
 		module_load_dependencies(module_name, MODULES_DEP);
-		spawn_load(module_name, argv);
+		spawn_load(module_name, (const char **)argv);
 	} else if (!strcmp(module_name + len_mn - 2, ".0")) {
 		execute(cmd, KT_PXE);
 	} else if (!strcmp(module_name + len_mn - 3, ".bs")) {
@@ -418,7 +418,6 @@ void process_command(const char *cmd, bool history)
 	else
 		execute(temp_cmd, KT_KERNEL);
 
-cleanup:
 	free(argv);
 	free(temp_cmd);
 }
diff --git a/com32/elflink/ldlinux/colors.c b/com32/elflink/ldlinux/colors.c
index 68732bd..c1ef390 100644
--- a/com32/elflink/ldlinux/colors.c
+++ b/com32/elflink/ldlinux/colors.c
@@ -14,6 +14,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <colortbl.h>
+#include <core-elf.h>
 #include "menu.h"
 
 /*
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h
index 7765266..37c57da 100644
--- a/com32/elflink/ldlinux/config.h
+++ b/com32/elflink/ldlinux/config.h
@@ -33,7 +33,7 @@ extern short vkernel;		//have we seen any "label" statements?
 extern short displaycon;	//conio.inc
 extern short nohalt;		//idle.inc
 
-extern char *default_cmd;	//"default" command line
-extern char *onerror;		//"onerror" command line
+extern const char *default_cmd;	//"default" command line
+extern const char *onerror;	//"onerror" command line
 
 #endif /* __CONFIG_H__ */
diff --git a/com32/elflink/ldlinux/getadv.c b/com32/elflink/ldlinux/getadv.c
index 456084b..5578313 100644
--- a/com32/elflink/ldlinux/getadv.c
+++ b/com32/elflink/ldlinux/getadv.c
@@ -39,7 +39,7 @@
 const void *syslinux_getadv(int tag, size_t * size)
 {
     const uint8_t *p;
-    size_t left, len;
+    size_t left;
 
     p = syslinux_adv_ptr();
     left = syslinux_adv_size();
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index b5a4409..31a457f 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -1,6 +1,7 @@
 #include <linux/list.h>
 #include <sys/times.h>
 #include <stdbool.h>
+#include <core.h>
 #include <core-elf.h>
 #include "cli.h"
 #include "console.h"
@@ -12,8 +13,7 @@
 
 static void enter_cmdline(void)
 {
-	struct cli_command  *aux;
-	char *cmdline;
+	const char *cmdline;
 
 	/* Enter endless command line prompt, should support "exit" */
 	while (1) {
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 898ee19..e13d6d4 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -59,8 +59,8 @@ short vkernel = 0;		//have we seen any "label" statements?
 short displaycon = 1;		//conio.inc
 short nohalt = 1;		//idle.inc
 
-char *default_cmd = NULL;	//"default" command line
-char *onerror = NULL;		//"onerror" command line
+const char *default_cmd = NULL;	//"default" command line
+const char *onerror = NULL;	//"onerror" command line
 
 /* Empty refstring */
 const char *empty_string;
@@ -75,7 +75,7 @@ long long totaltimeout = 0;
 
 /* Keep track of global default */
 static int has_ui = 0;		/* DEFAULT only counts if UI is found */
-extern char *globaldefault;
+extern const char *globaldefault;
 static bool menusave = false;	/* True if there is any "menu save" */
 
 /* Linked list of all entires, hidden or not; used by unlabel() */
@@ -568,7 +568,7 @@ uint32_t parse_argb(char **p)
  * same way as if the files had been concatenated together.
  */
 //static const char *append = NULL;
-extern char *append;
+extern const char *append;
 //static unsigned int ipappend = 0;
 unsigned int ipappend = 0;
 static struct labeldata ld;
@@ -1056,7 +1056,6 @@ do_include:
 static int parse_one_config(const char *filename)
 {
 	FILE *f;
-	int i;
 
 	/*
 	if (!strcmp(filename, "~"))
@@ -1107,24 +1106,11 @@ static void resolve_gotos(void)
     }
 }
 
-static void dump_menu(struct menu *menu)
-{
-	dprintf("will dump menu for %s:", menu->label);
-	printf("entries num: %d\n", menu->nentries);
-	printf("defentry: %d, nam = %s\n",
-		menu->defentry, menu->menu_entries[menu->defentry]->label);
-	printf("save: %d\n", menu->save);
-	//printf("", menu->);
-	//printf("", menu->);
-	//printf("", menu->);
-}
-
 void parse_configs(char **argv)
 {
     const char *filename;
     struct menu *m;
     struct menu_entry *me;
-    char *cmdline;
     dprintf("enter");
 
     empty_string = refstrdup("");
diff --git a/com32/elflink/modules/background.c b/com32/elflink/modules/background.c
index 61d8c60..467f6fd 100644
--- a/com32/elflink/modules/background.c
+++ b/com32/elflink/modules/background.c
@@ -12,6 +12,7 @@
 
 #include <consoles.h>
 #include <string.h>
+#include <core-elf.h>
 #include <syslinux/vesacon.h>
 #include <sys/module.h>
 #include "menu.h"
@@ -33,6 +34,8 @@ int draw_background(const char *what)
     else
 	return vesacon_load_background(what);
 #endif
+
+    return 0;
 }
 
 void set_background(const char *new_background)
diff --git a/com32/elflink/modules/hello.c b/com32/elflink/modules/hello.c
index cba63e2..b38f05c 100644
--- a/com32/elflink/modules/hello.c
+++ b/com32/elflink/modules/hello.c
@@ -17,10 +17,9 @@
 static int hello_main(int argc, char **argv)
 {
     int *nums = NULL;
-    int i;
 
     nums = malloc(NUM_COUNT * sizeof(int));
-    printf("Hello, world, from 0x%08X! malloc return %p\n", (unsigned int)&hello_main), nums;
+    printf("Hello, world, from 0x%08X! malloc return %p\n", (unsigned int)&hello_main, nums);
 
     free(nums);
 
diff --git a/com32/elflink/modules/menu.c b/com32/elflink/modules/menu.c
index a4faf89..c0813a8 100644
--- a/com32/elflink/modules/menu.c
+++ b/com32/elflink/modules/menu.c
@@ -4,6 +4,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
+#include <core-elf.h>
 #include <sys/module.h>
 
 #include "menu.h"
diff --git a/com32/elflink/modules/menu.h b/com32/elflink/modules/menu.h
index c7d7079..90b54a5 100644
--- a/com32/elflink/modules/menu.h
+++ b/com32/elflink/modules/menu.h
@@ -208,4 +208,7 @@ void execute(const char *cmdline, enum kernel_type type);
 /* drain.c */
 void drain_keyboard(void);
 
+/* printmsg.c */
+int draw_message_file(const char *filename);
+
 #endif /* MENU_H */
diff --git a/com32/elflink/modules/mytest.c b/com32/elflink/modules/mytest.c
index ddc8a0e..04c59ac 100644
--- a/com32/elflink/modules/mytest.c
+++ b/com32/elflink/modules/mytest.c
@@ -12,6 +12,7 @@
 #include <setjmp.h>
 #include <limits.h>
 #include <com32.h>
+#include <core-elf.h>
 #include <syslinux/adv.h>
 #include <syslinux/config.h>
 #include <sys/module.h>
diff --git a/com32/elflink/modules/passwd.c b/com32/elflink/modules/passwd.c
index a467a81..d190b1c 100644
--- a/com32/elflink/modules/passwd.c
+++ b/com32/elflink/modules/passwd.c
@@ -14,6 +14,7 @@
 #include <xcrypt.h>
 #include <sha1.h>
 #include <base64.h>
+#include <core-elf.h>
 #include <sys/module.h>
 
 #include "menu.h"
diff --git a/com32/elflink/modules/printmsg.c b/com32/elflink/modules/printmsg.c
index da9ec29..e5fc62c 100644
--- a/com32/elflink/modules/printmsg.c
+++ b/com32/elflink/modules/printmsg.c
@@ -26,6 +26,7 @@
 #ifdef __COM32__
 #include <com32.h>
 #endif
+#include <core-elf.h>
 
 #include "menu.h"
 
diff --git a/core/elflink/core-elf.h b/core/elflink/core-elf.h
index d13f506..dcca900 100644
--- a/core/elflink/core-elf.h
+++ b/core/elflink/core-elf.h
@@ -18,9 +18,9 @@ enum kernel_type {
     KT_CONFIG,			/* Configuration file */
 };
 
-extern char *append;
+extern const char *append;
 extern char *ippappend;
-extern char *globaldefault;
+extern const char *globaldefault;
 extern short onerrorlen;
 
 extern int new_linux_kernel(char *okernel, char *ocmdline);
diff --git a/core/elflink/execute.c b/core/elflink/execute.c
index 79dbc55..7e70323 100644
--- a/core/elflink/execute.c
+++ b/core/elflink/execute.c
@@ -16,6 +16,8 @@
 #include <dprintf.h>
 
 #include <com32.h>
+#include <sys/exec.h>
+#include "core.h"
 #include "core-elf.h"
 
 /* Must match enum kernel_type */
diff --git a/core/elflink/kernel.c b/core/elflink/kernel.c
index 6cb3363..3ce2358 100644
--- a/core/elflink/kernel.c
+++ b/core/elflink/kernel.c
@@ -10,8 +10,8 @@
 #include "core.h"
 #include "core-elf.h"
 
-char *globaldefault = NULL;
-char *append = NULL;
+const char *globaldefault = NULL;
+const char *append = NULL;
 
 /* Will be called from readconfig.c */
 int new_linux_kernel(char *okernel, char *ocmdline)




More information about the Syslinux mailing list