[syslinux] [GIT PULL] elflink warning fixes and auto extension support

Matt Fleming matt at console-pimps.org
Tue Apr 17 03:40:46 PDT 2012


Hi,

I just pushed out changes that fix pretty much all the compiler build
warnings on the elflink branch. Also, I've added "auto extension"
support so that if the user doesn't type the file name extension it will
automatically be looked up, e.g. now typing "ls" will execute "ls.c32".

The following changes since commit 81eccba80e68d637197816d15659bd30425b5f13:

  Remove core/ui.inc completely from Syslinux (2012-04-11 21:25:33 -0300)

are available in the git repository at:
  git://git.zytor.com/users/mfleming/syslinux.git elflink

Matt Fleming (43):
      ldlinux: Automatically lookup file extension
      core: Partial revert of commit 9333426b and unify lmalloc()
      getcwd.c: Include core_getcwd() prototype
      sys/open.c: Fix building warnings from missing prototype
      sys/fileread.c: Fix build warning from missing prototype
      sys/fileclose.c: Fix build warning from missing prototype
      syslinux/idle.c: Fix build warnings from missing prototypes
      elflink: Delete dump_elf_module()
      elflink: Fix build warnings
      elflink: Fix module_load() compiler warnings
      elflink: Add _module_unload() prototype to module.h
      ldlinux: Include headers for function prototypes
      ldlinux: parse_kernel_type() parameter should be const
      ldlinux: Tag __syslinux_init() as __constructor
      ldlinux: Match arg types to function prototypes
      ldlinux: Fix check for last command line entry
      ldlinux: Add print_labels() prototype to config.h
      ldlinux: Silence gcc warning about uninitialized variable
      ldlinux: Fix build warnings caused by refstrdup() usage
      core: Add open_config() prototype
      ldlinux: Use '\0' instead of NULL when dealing with characters
      ldlinux: Cast some arguments to avoid compiler warnings
      ldlinux: Fix number of arguments to start_ldlinux()
      ldlinux: Add prototype for new_linux_kernel()
      ldlinux: Fix uninitialized variable warning
      ldlinux: Use signed char consistently
      core: Move write_serial() prototype to core.h
      ldlinux: Include write_serial() prototype
      meminfo: If we allocate with lmalloc() we should free with lfree()
      localboot: Include header files for function prototypes
      init: Fix up compiler warnings
      hello: Delete unused variable 'console_init'
      writestr: Include core.h for writechr() prototype
      font: Cast away compiler warning
      graphics: Fix GXPix* assignment
      conio: Fix up compiler warnings
      elflink: Delete obsolete constructor code
      elflink: Allocate space for 'realname'
      fs: Include header for close() prototype
      fs: Include unistd.h for chdir() prototype
      elflink: Remove unused variables
      Mark unused function parameters as __unused
      Merge branches 'auto-extension' and 'fix-build-warnings' into elflink

 com32/elflink/ldlinux/adv.c           |    2 +-
 com32/elflink/ldlinux/cli.c           |    4 +-
 com32/elflink/ldlinux/config.h        |    4 +
 com32/elflink/ldlinux/eprintf.c       |    1 +
 com32/elflink/ldlinux/execute.c       |   11 +-
 com32/elflink/ldlinux/get_key.c       |    6 +-
 com32/elflink/ldlinux/kernel.c        |    3 +-
 com32/elflink/ldlinux/ldlinux.c       |  173 +++++++++++++++++++++++++++------
 com32/elflink/ldlinux/readconfig.c    |   16 ++--
 com32/hdt/hdt-common.h                |    3 -
 com32/include/com32.h                 |    2 +-
 com32/include/klibc/compiler.h        |    7 ++
 com32/include/sys/module.h            |   32 +++----
 com32/lib/getcwd.c                    |    1 +
 com32/lib/lmalloc.c                   |    9 --
 com32/lib/lstrdup.c                   |    2 +-
 com32/lib/sys/fileclose.c             |    1 +
 com32/lib/sys/fileread.c              |    1 +
 com32/lib/sys/module/common.c         |    9 +-
 com32/lib/sys/module/common.h         |    8 ++
 com32/lib/sys/module/elf_module.c     |   20 ++--
 com32/lib/sys/module/elfutils.c       |    4 +-
 com32/lib/sys/module/elfutils.h       |    2 +-
 com32/lib/sys/module/shallow_module.c |    8 +-
 com32/lib/sys/open.c                  |    1 +
 com32/lib/syslinux/idle.c             |    1 +
 com32/modules/hello.c                 |    2 +-
 com32/modules/meminfo.c               |   10 +-
 com32/modules/vesainfo.c              |    4 +-
 core/conio.c                          |    6 +-
 core/elflink/load_env32.c             |   17 +---
 core/font.c                           |    4 +-
 core/fs/fs.c                          |    1 +
 core/fs/lib/chdir.c                   |    1 +
 core/graphics.c                       |   12 ++-
 core/hello.c                          |    2 -
 core/include/bios.h                   |    6 +-
 core/include/core.h                   |   11 ++
 core/include/fs.h                     |    1 +
 core/init.c                           |   11 +-
 core/localboot.c                      |    7 +-
 core/mem/malloc.c                     |    7 +-
 core/serirq.c                         |   10 +-
 core/writestr.c                       |    1 +
 44 files changed, 283 insertions(+), 161 deletions(-)

diff --git a/com32/elflink/ldlinux/adv.c b/com32/elflink/ldlinux/adv.c
index 7869547..b81361f 100644
--- a/com32/elflink/ldlinux/adv.c
+++ b/com32/elflink/ldlinux/adv.c
@@ -40,7 +40,7 @@ void *__syslinux_adv_ptr;
 size_t __syslinux_adv_size;
 
 extern void adv_init(void);
-void __syslinux_init(void)
+void __constructor __syslinux_init(void)
 {
     static com32sys_t reg;
 
diff --git a/com32/elflink/ldlinux/cli.c b/com32/elflink/ldlinux/cli.c
index fb041ae..498644e 100644
--- a/com32/elflink/ldlinux/cli.c
+++ b/com32/elflink/ldlinux/cli.c
@@ -99,7 +99,7 @@ static const char * cmd_reverse_search(int *cursor)
 	    break;
 	}
 
-	while (last_found != &cli_history_head) {
+	while (!list_is_last(&last_found->list, &cli_history_head)) {
 	    p = strstr(last_found->command, buf);
 	    if (p)
 	        break;
@@ -139,7 +139,7 @@ const char *edit_cmdline(const char *input, int top /*, int width */ ,
     bool done = false;
     const char *ret;
     int width = 0;
-    struct cli_command *comm_counter;
+    struct cli_command *comm_counter = NULL;
 
     if (!width) {
 	int height;
diff --git a/com32/elflink/ldlinux/config.h b/com32/elflink/ldlinux/config.h
index c34b2cc..cab4c70 100644
--- a/com32/elflink/ldlinux/config.h
+++ b/com32/elflink/ldlinux/config.h
@@ -37,7 +37,11 @@ extern const char *default_cmd;	//"default" command line
 extern const char *onerror;	//"onerror" command line
 
 extern void cat_help_file(int key);
+extern struct menu_entry *find_label(const char *str);
+extern void print_labels(const char *prefix, size_t len);
 
 extern void eprintf(const char *filename, ...);
 
+extern int new_linux_kernel(char *okernel, char *ocmdline);
+
 #endif /* __CONFIG_H__ */
diff --git a/com32/elflink/ldlinux/eprintf.c b/com32/elflink/ldlinux/eprintf.c
index d8858ff..f15edc6 100644
--- a/com32/elflink/ldlinux/eprintf.c
+++ b/com32/elflink/ldlinux/eprintf.c
@@ -1,6 +1,7 @@
 #include <stdio.h>
 #include <string.h>
 #include <stdarg.h>
+#include <core.h>
 
 #define BUFFER_SIZE	4096
 
diff --git a/com32/elflink/ldlinux/execute.c b/com32/elflink/ldlinux/execute.c
index 269b74d..afe999e 100644
--- a/com32/elflink/ldlinux/execute.c
+++ b/com32/elflink/ldlinux/execute.c
@@ -20,6 +20,7 @@
 #include "core.h"
 #include "menu.h"
 #include "fs.h"
+#include "config.h"
 
 /* Must match enum kernel_type */
 const char *const kernel_types[] = {
@@ -84,8 +85,8 @@ void execute(const char *cmdline, enum kernel_type type)
 
 	if (type == KT_COM32) {
 		/* new entry for elf format c32 */
-		lfree(kernel);
-		create_args_and_load(cmdline);
+		lfree((void *)kernel);
+		create_args_and_load((char *)cmdline);
 	} else if (type == KT_CONFIG) {
 		char *argv[] = { "ldlinux.c32", NULL };
 
@@ -96,7 +97,7 @@ void execute(const char *cmdline, enum kernel_type type)
 		if (*args)
 			mangle_name(config_cwd, args);
 
-		start_ldlinux("ldlinux.c32", 1, argv);
+		start_ldlinux(argv);
 	} else if (type == KT_LOCALBOOT) {
 		/* process the image need int 22 support */
 		ireg.eax.w[0] = 0x0014;	/* Local boot */
@@ -105,10 +106,10 @@ void execute(const char *cmdline, enum kernel_type type)
 	} else {
 		/* Need add one item for kernel load, as we don't use
 		* the assembly runkernel.inc any more */
-		new_linux_kernel(kernel, cmdline);
+		new_linux_kernel((char *)kernel, (char *)cmdline);
 	}
 
-	lfree(kernel);
+	lfree((void *)kernel);
 
 	/* If this returns, something went bad; return to menu */
 }
diff --git a/com32/elflink/ldlinux/get_key.c b/com32/elflink/ldlinux/get_key.c
index 42ff5c1..5841d02 100644
--- a/com32/elflink/ldlinux/get_key.c
+++ b/com32/elflink/ldlinux/get_key.c
@@ -148,10 +148,10 @@ int get_key_decode(char *buffer, int nc, int *code)
 
 int get_key(FILE * f, clock_t timeout)
 {
-    unsigned char buffer[KEY_MAXLEN];
-    int nc, i, rv;
+    char buffer[KEY_MAXLEN];
+    int nc, rv;
     int another;
-    unsigned char ch;
+    char ch;
     clock_t start;
     int code;
 
diff --git a/com32/elflink/ldlinux/kernel.c b/com32/elflink/ldlinux/kernel.c
index 375dab0..62eec75 100644
--- a/com32/elflink/ldlinux/kernel.c
+++ b/com32/elflink/ldlinux/kernel.c
@@ -15,7 +15,7 @@ const char *append = NULL;
 /* Will be called from readconfig.c */
 int new_linux_kernel(char *okernel, char *ocmdline)
 {
-	const char *kernel_name;
+	const char *kernel_name = NULL;
 	struct initramfs *initramfs = NULL;
 	char *temp;
 	void *kernel_data;
@@ -23,7 +23,6 @@ int new_linux_kernel(char *okernel, char *ocmdline)
 	bool opt_quiet = false;
 	char initrd_name[256];
 	char cmdline_buf[256], *cmdline;
-	int i;
 
 	dprintf("okernel = %s, ocmdline = %s", okernel, ocmdline);
 
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index 6c306ad..da93c54 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -1,7 +1,10 @@
 #include <linux/list.h>
 #include <sys/times.h>
+#include <fcntl.h>
 #include <stdbool.h>
+#include <string.h>
 #include <core.h>
+#include <fs.h>
 #include "cli.h"
 #include "console.h"
 #include "com32.h"
@@ -11,40 +14,119 @@
 
 #include <sys/module.h>
 
-static enum kernel_type parse_kernel_type(char *kernel)
-{
+struct file_ext {
+	const char *name;
 	enum kernel_type type;
+};
+
+static const struct file_ext file_extensions[] = {
+	{ ".com", KT_COMBOOT },
+	{ ".cbt", KT_COMBOOT },
+	{ ".c32", KT_COM32 },
+	{ ".img", KT_FDIMAGE },
+	{ ".bss", KT_BSS },
+	{ ".bin", KT_BOOT },
+	{ ".bs", KT_BOOT },
+	{ ".0", KT_PXE },
+	{ NULL, KT_NONE },
+};
+
+/*
+ * Return a pointer to one byte after the last character of the
+ * command.
+ */
+static inline const char *find_command(const char *str)
+{
 	const char *p;
-	int len;
 
-	/* Find the end of the command */
-	p = kernel;
+	p = str;
 	while (*p && !my_isspace(*p))
 		p++;
+	return p;
+}
 
+static enum kernel_type parse_kernel_type(const char *kernel)
+{
+	const struct file_ext *ext;
+	const char *p;
+	int len;
+
+	/* Find the end of the command */
+	p = find_command(kernel);
 	len = p - kernel;
 
-	if (!strncmp(kernel + len - 4, ".c32", 4)) {
-		type = KT_COM32;
-	} else if (!strncmp(kernel + len - 2, ".0", 2)) {
-		type = KT_PXE;
-	} else if (!strncmp(kernel + len - 3, ".bs", 3)) {
-		type = KT_BOOT;
-	} else if (!strncmp(kernel + len - 4, ".img", 4)) {
-		type = KT_FDIMAGE;
-	} else if (!strncmp(kernel + len - 4, ".bin", 4)) {
-		type = KT_BOOT;
-	} else if (!strncmp(kernel + len - 4, ".bss", 4)) {
-		type = KT_BSS;
-	} else if (!strncmp(kernel + len - 4, ".com", 4) ||
-		   !strncmp(kernel + len - 4, ".cbt", 4)) {
-		type = KT_COMBOOT;
+	for (ext = file_extensions; ext->name; ext++) {
+		int elen = strlen(ext->name);
+
+		if (!strncmp(kernel + len - elen, ext->name, elen))
+			return ext->type;
 	}
+
 	/* use KT_KERNEL as default */
-	else
-		type = KT_KERNEL;
+	return KT_KERNEL;
+}
+
+/*
+ * Returns the kernel name with file extension if one wasn't present.
+ */
+static const char *get_extension(const char *kernel)
+{
+	const struct file_ext *ext;
+	const char *p;
+	int len;
+
+	/* Find the end of the command */
+	p = find_command(kernel);
+	len = p - kernel;
+
+	for (ext = file_extensions; ext->name; ext++) {
+		char *str;
+		int elen = strlen(ext->name);
+		int fd;
+
+		str = malloc(len + elen + 1);
+
+		strncpy(str, kernel, len);
+		strncpy(str + len, ext->name, elen);
+		str[len + elen] = '\0';
 
-	return type;
+		fd = searchdir(str);
+		free(str);
+
+		if (fd >= 0)
+			return ext->name;
+	}
+
+	return NULL;
+}
+
+static const char *apply_extension(const char *kernel, const char *ext)
+{
+	const char *p;
+	char *k;
+	int len = strlen(kernel);
+	int elen = strlen(ext);
+
+	k = malloc(len + elen + 1);
+	if (!k)
+		return NULL;
+
+	p = find_command(kernel);
+
+	len = p - kernel;
+
+	/* Copy just the kernel name */
+	memcpy(k, kernel, len);
+
+	/* Append the extension */
+	memcpy(k + len, ext, elen);
+
+	/* Copy the rest of the command line */
+	strcpy(k + len + elen, p);
+
+	k[len + elen] = '\0';
+
+	return k;
 }
 
 /*
@@ -54,11 +136,16 @@ static enum kernel_type parse_kernel_type(char *kernel)
  * the the kernel. If we return the caller should call enter_cmdline()
  * so that the user can help us out.
  */
-static void load_kernel(const char *kernel)
+static void load_kernel(const char *command_line)
 {
 	struct menu_entry *me;
 	enum kernel_type type;
 	const char *cmdline;
+	const char *kernel;
+
+	kernel = strdup(command_line);
+	if (!kernel)
+		goto bad_kernel;
 
 	/* Virtual kernel? */
 	me = find_label(kernel);
@@ -78,7 +165,30 @@ static void load_kernel(const char *kernel)
 		goto bad_implicit;
 
 	type = parse_kernel_type(kernel);
+	if (type == KT_KERNEL) {
+		const char *ext;
+
+		/*
+		 * Automatically lookup the extension if one wasn't
+		 * supplied by the user.
+		 */
+		ext = get_extension(kernel);
+		if (ext) {
+			const char *k;
+
+			k = apply_extension(kernel, ext);
+			if (!k)
+				goto bad_kernel;
+
+			free((void *)kernel);
+			kernel = k;
+
+			type = parse_kernel_type(kernel);
+		}
+	}
+
 	execute(kernel, type);
+	free((void *)kernel);
 
 bad_implicit:
 bad_kernel:
@@ -113,11 +223,10 @@ static void enter_cmdline(void)
 	}
 }
 
-int main(int argc, char **argv)
+int main(int argc __unused, char **argv __unused)
 {
-	com32sys_t ireg, oreg;
-	uint8_t *adv;
-	int count = 0;
+	const void *adv;
+	size_t count = 0;
 	char *config_argv[2] = { NULL, NULL };
 
 	openconsole(&dev_rawcon_r, &dev_ansiserial_w);
@@ -127,17 +236,17 @@ int main(int argc, char **argv)
 
 	parse_configs(config_argv);
 
-	__syslinux_init();
 	adv = syslinux_getadv(ADV_BOOTONCE, &count);
 	if (adv && count) {
 		/*
 		 * We apparently have a boot-once set; clear it and
 		 * then execute the boot-once.
 		 */
-		uint8_t *src, *dst, *cmdline;
-		int i;
+		const char *cmdline;
+		char *src, *dst;
+		size_t i;
 
-		src = adv;
+		src = (char *)adv;
 		cmdline = dst = malloc(count + 1);
 		if (!dst) {
 			printf("Failed to allocate memory for ADV\n");
diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c
index 4f7a4d2..70fe346 100644
--- a/com32/elflink/ldlinux/readconfig.c
+++ b/com32/elflink/ldlinux/readconfig.c
@@ -1121,7 +1121,8 @@ do_include:
 	 * display/font/kbdmap are rather similar, open a file then do sth
 	 */
 	else if (looking_at(p, "display")) {
-		char *filename, *dst = KernelName;
+		const char *filename;
+		char *dst = KernelName;
 		size_t len = FILENAME_MAX - 1;
 
 		filename = refstrdup(skipspace(p + 7));
@@ -1133,7 +1134,8 @@ do_include:
 		get_msg_file(KernelName);
 		refstr_put(filename);
 	} else if (looking_at(p, "font")) {
-		char *filename, *dst = KernelName;
+		const char *filename;
+		char *dst = KernelName;
 		size_t len = FILENAME_MAX - 1;
 
 		filename = refstrdup(skipspace(p + 4));
@@ -1145,8 +1147,8 @@ do_include:
 		loadfont(KernelName);
 		refstr_put(filename);
 	} else if (looking_at(p, "kbdmap")) {
-		com32sys_t reg;
-		char *filename, *dst = KernelName;
+		const char *filename;
+		char *dst = KernelName;
 		size_t len = FILENAME_MAX - 1;
 
 		filename = refstrdup(skipspace(p + 4));
@@ -1189,7 +1191,6 @@ do_include:
 
 	/* serial setting, bps, flow control */
 	else if (looking_at(p, "serial")) {
-		com32sys_t ireg;
 		uint16_t port, flow;
 		uint32_t baud;
 
@@ -1309,7 +1310,8 @@ do_include:
 		eprintf("%s\n", p+4);
 	} else if (looking_at(p, "path")) {
 		/* PATH-based lookup */
-		char *new_path, *_p;
+		const char *new_path;
+		char *_p;
 		size_t len, new_len;
 
 		new_path = refstrdup(skipspace(p + 4));
@@ -1348,7 +1350,7 @@ static int parse_one_config(const char *filename)
 
 	if (config_cwd[0]) {
 		chdir(config_cwd);
-		config_cwd[0] = NULL;
+		config_cwd[0] = '\0';
 	}
 
 	return 0;
diff --git a/com32/hdt/hdt-common.h b/com32/hdt/hdt-common.h
index d37fcc8..fec213d 100644
--- a/com32/hdt/hdt-common.h
+++ b/com32/hdt/hdt-common.h
@@ -54,9 +54,6 @@
 #include <acpi/acpi.h>
 #include <libupload/upload_backend.h>
 
-/* Declare a variable or data structure as unused. */
-#define __unused __attribute__ (( unused ))
-
 /* This two values are used for switching for the menu to the CLI mode */
 #define HDT_SWITCH_TO_CLI "hdt_switch_to_cli"
 #define HDT_DUMP "hdt_dump"
diff --git a/com32/include/com32.h b/com32/include/com32.h
index f49f9ea..6b14208 100644
--- a/com32/include/com32.h
+++ b/com32/include/com32.h
@@ -120,7 +120,7 @@ extern const com32sys_t __com32_zero_regs;
 /*
  * Lowmem allocation functions
  */
-void *clmalloc(size_t);
+void *lmalloc(size_t);
 void *lzalloc(size_t);
 void lfree(void *);
 char *lstrdup(const char *);
diff --git a/com32/include/klibc/compiler.h b/com32/include/klibc/compiler.h
index b5919d6..210971f 100644
--- a/com32/include/klibc/compiler.h
+++ b/com32/include/klibc/compiler.h
@@ -108,6 +108,13 @@
 # define __unusedfunc
 #endif
 
+/* Declare a variable or data structure as unused. */
+#ifdef __GNUC__
+# define __unused	__attribute__((unused))
+#else
+# define __unused
+#endif
+
 /* Used symbol */
 #define __used				__attribute__((used))
 
diff --git a/com32/include/sys/module.h b/com32/include/sys/module.h
index a9ddb60..fb6a1eb 100644
--- a/com32/include/sys/module.h
+++ b/com32/include/sys/module.h
@@ -120,23 +120,6 @@ struct elf_module {
 
 };
 
-static inline void dump_elf_module(struct elf_module *module)
-{
-	/*
-	dprintf("module name = %s", module->name);
-	printf("base_addr = 0x%p, module_size = %d\n", module->base_addr, module->module_size);
-	printf("hash tlb = 0x%p, ghash tbl = 0x%p\n", module->hash_table, module->ghash_table);
-	printf("str tbl = 0x%p, size = %d\n", module->str_table, module->strtable_size);
-	printf("sym tbl = 0x%p, entry = %d, size = %d\n", module->sym_table, module->syment_size, module->symtable_size);
-	printf("init: %p", module->init_func);
-	printf("main: %p", module->main_func);
-	printf("exit: %p", module->exit_func);
-	printf("", module->base_addr);
-	printf("", module->base_addr);
-	printf("", module->base_addr);
-	*/
-}
-
 /**
  * struct module_dep - structure encapsulating a module dependency need
  *
@@ -263,9 +246,10 @@ extern int module_load_shallow(struct elf_module *module, Elf32_Addr base_addr);
  * module_unload - unloads the module from the system.
  * @module: the module descriptor structure.
  *
- * The function checks to see whether the module can be safely removed, then
- * it releases all the associated memory. This function can be applied both
- * for standard modules and for shallow modules.
+ * The function checks to see whether the module can be safely
+ * removed, then it executes any destructors and releases all the
+ * associated memory. This function can be applied both for standard
+ * modules and for shallow modules.
  *
  * A module can be safely removed from the system when no other modules reference
  * symbols from it.
@@ -273,6 +257,14 @@ extern int module_load_shallow(struct elf_module *module, Elf32_Addr base_addr);
 extern int module_unload(struct elf_module *module);
 
 /**
+ * _module_unload - unloads the module without running destructors
+ *
+ * This function is the same as module_unload(), except that the
+ * module's destructors are not executed.
+ */
+extern int _module_unload(struct elf_module *module);
+
+/**
  * module_unload - unloads the module from the system.
  * @module: the module descriptor structure.
  *
diff --git a/com32/lib/getcwd.c b/com32/lib/getcwd.c
index 2939c07..d5fa9d7 100644
--- a/com32/lib/getcwd.c
+++ b/com32/lib/getcwd.c
@@ -4,6 +4,7 @@
 
 #include <com32.h>
 #include <syslinux/pmapi.h>
+#include <fs.h>
 
 char *getcwd(char *buf, size_t size)
 {
diff --git a/com32/lib/lmalloc.c b/com32/lib/lmalloc.c
index 9d532c8..3e69ac1 100644
--- a/com32/lib/lmalloc.c
+++ b/com32/lib/lmalloc.c
@@ -31,15 +31,6 @@
 #include <string.h>
 #include <syslinux/pmapi.h>
 
-void *clmalloc(size_t size)
-{
-    void *p;
-    p = lmalloc(size);
-    if (!p)
-	errno = ENOMEM;
-    return p;
-}
-
 void *lzalloc(size_t size)
 {
     void *p;
diff --git a/com32/lib/lstrdup.c b/com32/lib/lstrdup.c
index 6747ef3..d11efe7 100644
--- a/com32/lib/lstrdup.c
+++ b/com32/lib/lstrdup.c
@@ -9,7 +9,7 @@
 char *lstrdup(const char *s)
 {
     int l = strlen(s) + 1;
-    char *d = clmalloc(l);
+    char *d = lmalloc(l);
 
     if (d)
 	memcpy(d, s, l);
diff --git a/com32/lib/sys/fileclose.c b/com32/lib/sys/fileclose.c
index 26e1508..699dbe3 100644
--- a/com32/lib/sys/fileclose.c
+++ b/com32/lib/sys/fileclose.c
@@ -34,6 +34,7 @@
 #include <errno.h>
 #include <com32.h>
 #include <string.h>
+#include <fs.h>
 #include "file.h"
 
 int __file_close(struct file_info *fp)
diff --git a/com32/lib/sys/fileread.c b/com32/lib/sys/fileread.c
index 7d9e1b9..26b0ceb 100644
--- a/com32/lib/sys/fileread.c
+++ b/com32/lib/sys/fileread.c
@@ -34,6 +34,7 @@
 #include <errno.h>
 #include <string.h>
 #include <com32.h>
+#include <pmapi.h>
 #include <syslinux/pmapi.h>
 #include <minmax.h>
 #include "file.h"
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index e26163f..eeb2607 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -322,7 +322,7 @@ int check_symbols(struct elf_module *module)
 
 	for(i = 1; i < module->symtable_size; i++)
 	{
-		crt_sym = (Elf32_Sym*)(module->sym_table + i * module->syment_size);
+		crt_sym = symbol_get_entry(module, i);
 		crt_name = module->str_table + crt_sym->st_name;
 
 		strong_count = 0;
@@ -434,7 +434,7 @@ static Elf32_Sym *module_find_symbol_sysv(const char *name, struct elf_module *m
 
 
 	while (crt_index != STN_UNDEF) {
-		crt_sym = (Elf32_Sym*)(module->sym_table + crt_index*module->syment_size);
+		crt_sym = symbol_get_entry(module, crt_index);
 
 		if (strcmp(name, module->str_table + crt_sym->st_name) == 0)
 			return crt_sym;
@@ -489,8 +489,7 @@ static Elf32_Sym *module_find_symbol_gnu(const char *name, struct elf_module *mo
 
 			do {
 				if (((*hasharr ^ h ) >> 1) == 0) {
-					Elf32_Sym *crt_sym = (Elf32_Sym*)(module->sym_table +
-							(hasharr - gnu_chain_zero) * module->syment_size);
+					Elf32_Sym *crt_sym = symbol_get_entry(module, (hasharr - gnu_chain_zero));
 
 					if (strcmp(name, module->str_table + crt_sym->st_name) == 0) {
 						return crt_sym;
@@ -511,7 +510,7 @@ static Elf32_Sym *module_find_symbol_iterate(const char *name,struct elf_module
 
 	for (i=1; i < module->symtable_size; i++)
 	{
-		crt_sym = (Elf32_Sym*)(module->sym_table + i*module->syment_size);
+		crt_sym = symbol_get_entry(module, i);
 		if (strcmp(name, module->str_table + crt_sym->st_name) == 0)
 		{
 			return crt_sym;
diff --git a/com32/lib/sys/module/common.h b/com32/lib/sys/module/common.h
index 6259df5..54f0ec4 100644
--- a/com32/lib/sys/module/common.h
+++ b/com32/lib/sys/module/common.h
@@ -27,6 +27,14 @@
 #define MIN(x,y)	(((x) < (y)) ? (x) : (y))
 #define MAX(x,y)	(((x) > (y)) ? (x) : (y))
 
+static inline Elf32_Sym *symbol_get_entry(struct elf_module *module, int entry)
+{
+	char *sym_table = (char *)module->sym_table;
+	int index = entry * module->syment_size;
+
+	return (Elf32_Sym *)(sym_table + index);
+}
+
 //#define ELF_DEBUG
 
 #ifdef ELF_DEBUG
diff --git a/com32/lib/sys/module/elf_module.c b/com32/lib/sys/module/elf_module.c
index 6b4d548..cc91304 100644
--- a/com32/lib/sys/module/elf_module.c
+++ b/com32/lib/sys/module/elf_module.c
@@ -14,6 +14,7 @@
 
 #include <linux/list.h>
 #include <sys/module.h>
+#include <sys/exec.h>
 
 #include "elfutils.h"
 #include "common.h"
@@ -50,7 +51,7 @@ static int check_header(Elf32_Ehdr *elf_hdr) {
 static int load_segments(struct elf_module *module, Elf32_Ehdr *elf_hdr) {
 	int i;
 	int res = 0;
-	void *pht = NULL;
+	char *pht = NULL;
 	Elf32_Phdr *cr_pht;
 
 	Elf32_Addr min_addr  = 0x00000000; // Min. ELF vaddr
@@ -136,8 +137,8 @@ static int load_segments(struct elf_module *module, Elf32_Ehdr *elf_hdr) {
 				// headers
 				Elf32_Off aux_off = module->u.l._cr_offset - cr_pht->p_offset;
 
-				if (image_read(module_get_absolute(cr_pht->p_vaddr, module) + aux_off,
-						cr_pht->p_filesz - aux_off, module) < 0) {
+				if (image_read((char *)module_get_absolute(cr_pht->p_vaddr, module) + aux_off,
+					       cr_pht->p_filesz - aux_off, module) < 0) {
 					res = -1;
 					goto out;
 				}
@@ -259,8 +260,7 @@ static int perform_relocation(struct elf_module *module, Elf32_Rel *rel) {
 		// Find out details about the symbol
 
 		// The symbol reference
-		Elf32_Sym *sym_ref =
-			(Elf32_Sym*)(module->sym_table + sym * module->syment_size);
+		Elf32_Sym *sym_ref = symbol_get_entry(module, sym);
 
 		// The symbol definition
 		sym_def =
@@ -321,9 +321,9 @@ static int resolve_symbols(struct elf_module *module) {
 	int res;
 
 	Elf32_Word plt_rel_size = 0;
-	void *plt_rel = NULL;
+	char *plt_rel = NULL;
 
-	void *rel = NULL;
+	char *rel = NULL;
 	Elf32_Word rel_size = 0;
 	Elf32_Word rel_entry = 0;
 
@@ -467,7 +467,7 @@ static int extract_operations(struct elf_module *module) {
 
 // Loads the module into the system
 int module_load(struct elf_module *module) {
-	int res, i;
+	int res;
 	Elf32_Sym *main_sym;
 	Elf32_Ehdr elf_hdr;
 	module_ctor_t *ctor;
@@ -504,8 +504,6 @@ int module_load(struct elf_module *module) {
 	nr_needed = 0;
 	CHECKED(res, prepare_dynlinking(module), error);
 	//printf("check... 4\n");
-	//
-	//dump_elf_module(module);
 
 	/* Find modules we need to load as dependencies */
 	if (module->str_table) {
@@ -534,7 +532,7 @@ int module_load(struct elf_module *module) {
 			}
 
 			if (*p++ == '/') {
-				char argv[2] = { p, NULL };
+				char *argv[2] = { p, NULL };
 				spawn_load(p, 1, argv);
 			}
 		}
diff --git a/com32/lib/sys/module/elfutils.c b/com32/lib/sys/module/elfutils.c
index 64be077..b7d760b 100644
--- a/com32/lib/sys/module/elfutils.c
+++ b/com32/lib/sys/module/elfutils.c
@@ -37,7 +37,7 @@ struct memalign_info {
 };
 
 int elf_malloc(void **memptr, size_t alignment, size_t size) {
-	void *start_addr = NULL;
+	char *start_addr = NULL;
 	struct memalign_info *info;
 
 	if ((alignment & (alignment - 1)) != 0)
@@ -63,7 +63,7 @@ int elf_malloc(void **memptr, size_t alignment, size_t size) {
 	return 0;
 }
 
-void elf_free(void *memptr) {
+void elf_free(char *memptr) {
 	struct memalign_info *info = (struct memalign_info*)(memptr -
 			sizeof(struct memalign_info));
 
diff --git a/com32/lib/sys/module/elfutils.h b/com32/lib/sys/module/elfutils.h
index b18968f..a901ff4 100644
--- a/com32/lib/sys/module/elfutils.h
+++ b/com32/lib/sys/module/elfutils.h
@@ -59,6 +59,6 @@ extern int elf_malloc(void **memptr, size_t alignment, size_t size);
  * elf_free - Releases memory previously allocated by elf_malloc.
  * @memptr: the address of the allocated block
  */
-extern void elf_free(void *memptr);
+extern void elf_free(char *memptr);
 
 #endif /*ELF_UTILS_H_*/
diff --git a/com32/lib/sys/module/shallow_module.c b/com32/lib/sys/module/shallow_module.c
index fbcf781..8a88e40 100644
--- a/com32/lib/sys/module/shallow_module.c
+++ b/com32/lib/sys/module/shallow_module.c
@@ -32,8 +32,8 @@ static int check_header_shallow(Elf32_Ehdr *elf_hdr) {
 static int load_shallow_sections(struct elf_module *module, Elf32_Ehdr *elf_hdr) {
 	int i;
 	int res = 0;
-	void *sht = NULL;
-	void *buffer = NULL;
+	char *sht = NULL;
+	char *buffer = NULL;
 	Elf32_Shdr *crt_sht;
 	Elf32_Off buff_offset;
 
@@ -100,8 +100,8 @@ static int load_shallow_sections(struct elf_module *module, Elf32_Ehdr *elf_hdr)
 
 	// Setup module information
 	module->module_size = max_offset - min_offset;
-	module->str_table = (char*)(module->module_addr + (str_offset - min_offset));
-	module->sym_table = module->module_addr + (sym_offset - min_offset);
+	module->str_table = (char *)module->module_addr + (str_offset - min_offset);
+	module->sym_table = (char *)module->module_addr + (sym_offset - min_offset);
 
 out:
 	// Release the SHT
diff --git a/com32/lib/sys/open.c b/com32/lib/sys/open.c
index a0ef159..3221bb6 100644
--- a/com32/lib/sys/open.c
+++ b/com32/lib/sys/open.c
@@ -30,6 +30,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <fs.h>
 #include "file.h"
 
 /*
diff --git a/com32/lib/syslinux/idle.c b/com32/lib/syslinux/idle.c
index 6413d33..33e8035 100644
--- a/com32/lib/syslinux/idle.c
+++ b/com32/lib/syslinux/idle.c
@@ -33,6 +33,7 @@
 
 #include <stddef.h>
 #include <com32.h>
+#include <core.h>
 #include <syslinux/pmapi.h>
 #include <syslinux/idle.h>
 
diff --git a/com32/modules/hello.c b/com32/modules/hello.c
index f28d38d..d3d4d29 100644
--- a/com32/modules/hello.c
+++ b/com32/modules/hello.c
@@ -13,7 +13,7 @@
 #define NUM_COUNT		10
 #define MAX_NUM			100
 
-int main(int argc, char **argv)
+int main(int argc __unused, char **argv __unused)
 {
     int *nums = NULL;
 
diff --git a/com32/modules/meminfo.c b/com32/modules/meminfo.c
index 00d0e14..34b3e91 100644
--- a/com32/modules/meminfo.c
+++ b/com32/modules/meminfo.c
@@ -44,9 +44,9 @@ static void dump_e820(void)
     uint32_t type;
     void *low_ed;
 
-	low_ed = lmalloc(sizeof ed);
-	if (!low_ed)
-		return;
+    low_ed = lmalloc(sizeof ed);
+    if (!low_ed)
+	return;
 
     memset(&ireg, 0, sizeof ireg);
 
@@ -90,7 +90,7 @@ static void dump_e820(void)
 	ireg.ebx.l = oreg.ebx.l;
     } while (ireg.ebx.l);
 
-    free(low_ed);
+    lfree(low_ed);
 }
 
 static void dump_legacy(void)
@@ -122,7 +122,7 @@ static void dump_legacy(void)
 	   oreg.ecx.w[0], oreg.ecx.w[0], oreg.edx.w[0], oreg.edx.w[0] << 6);
 }
 
-int main(int argc, char **argv)
+int main(int argc __unused, char **argv __unused)
 {
     dump_legacy();
     dump_e820();
diff --git a/com32/modules/vesainfo.c b/com32/modules/vesainfo.c
index 86a4365..66b121d 100644
--- a/com32/modules/vesainfo.c
+++ b/com32/modules/vesainfo.c
@@ -79,11 +79,11 @@ static void print_modes(void)
     }
 
 exit:
-	free(vesa);
+	lfree(vesa);
 	return;
 }
 
-int main(int argc, char **argv)
+int main(int argc __unused, char **argv __unused)
 {
     print_modes();
     return 0;
diff --git a/core/conio.c b/core/conio.c
index 70dd3b1..dd18ecf 100644
--- a/core/conio.c
+++ b/core/conio.c
@@ -252,7 +252,7 @@ int pollchar(void)
 	return data;
 }
 
-int pm_pollchar(com32sys_t *regs)
+void pm_pollchar(com32sys_t *regs)
 {
 	if (pollchar())
 		regs->eflags.l &= ~EFLAGS_ZF;
@@ -288,7 +288,7 @@ char getchar(char *hi)
 				sti(); /* We already know we'll consume data */
 				data = *SerialTail++;
 
-				SerialTail = (unsigned char *)((unsigned long)SerialTail & (serial_buf_size - 1));
+				SerialTail = (char *)((unsigned long)SerialTail & (serial_buf_size - 1));
 			} else {
 				/* LSR */
 				data = inb(SerialPort + 5) & 1;
@@ -333,7 +333,7 @@ char getchar(char *hi)
 
 void pm_getchar(com32sys_t *regs)
 {
-	regs->eax.b[0] = getchar(&regs->eax.b[1]);
+	regs->eax.b[0] = getchar((char *)&regs->eax.b[1]);
 }
 
 static void msg_setbg(char data)
diff --git a/core/elflink/load_env32.c b/core/elflink/load_env32.c
index 28bc70c..b15cdbb 100644
--- a/core/elflink/load_env32.c
+++ b/core/elflink/load_env32.c
@@ -24,9 +24,6 @@
 
 #define LDLINUX	"ldlinux.c32"
 
-typedef void (*constructor_t) (void);
-constructor_t __ctors_start[], __ctors_end[];
-
 extern char __dynstr_start[];
 extern char __dynstr_len[], __dynsym_len[];
 extern char __dynsym_start[];
@@ -62,15 +59,6 @@ void init_module_subsystem(struct elf_module *module)
     list_add(&module->list, &modules_head);
 }
 
-/* call_constr: initializes sme things related */
-static void call_constr(void)
-{
-	constructor_t *p;
-
-	for (p = __ctors_start; p < __ctors_end; p++)
-		(*p) ();
-}
-
 int start_ldlinux(char **argv)
 {
 	int rv;
@@ -116,12 +104,12 @@ again:
 }
 
 /* note to self: do _*NOT*_ use static key word on this function */
-void load_env32(com32sys_t * regs)
+void load_env32(com32sys_t * regs __unused)
 {
 	struct file_info *fp;
 	int fd;
 	char *argv[] = { LDLINUX, NULL };
-	char *realname;
+	char realname[FILENAME_MAX];
 
 	static const char *search_directories[] = {
 		"/boot/isolinux",
@@ -138,7 +126,6 @@ void load_env32(com32sys_t * regs)
 	};
 
 	dprintf("Starting 32 bit elf module subsystem...\n");
-	call_constr();
 
 	PATH = malloc(strlen(PATH_DEFAULT) + 1);
 	if (!PATH) {
diff --git a/core/font.c b/core/font.c
index 0eeb90f..1fcbbe8 100644
--- a/core/font.c
+++ b/core/font.c
@@ -164,7 +164,7 @@ void use_font(void)
 void adjust_screen(void)
 {
 	com32sys_t ireg, oreg;
-	volatile uint8_t *vidrows = BIOS_vidrows;
+	volatile uint8_t *vidrows = (volatile uint8_t *)BIOS_vidrows;
 	uint8_t rows, cols;
 
 	rows = *vidrows;
@@ -185,7 +185,7 @@ void adjust_screen(void)
 	VidCols = --cols;	/* Store count-1 (same as rows) */
 }
 
-void pm_adjust_screen(com32sys_t *regs)
+void pm_adjust_screen(com32sys_t *regs __unused)
 {
 	adjust_screen();
 }
diff --git a/core/fs/fs.c b/core/fs/fs.c
index d8f8660..f6b2912 100644
--- a/core/fs/fs.c
+++ b/core/fs/fs.c
@@ -2,6 +2,7 @@
 #include <stdio.h>
 #include <stdbool.h>
 #include <string.h>
+#include <unistd.h>
 #include <dprintf.h>
 #include "core.h"
 #include "dev.h"
diff --git a/core/fs/lib/chdir.c b/core/fs/lib/chdir.c
index 5c7b130..715284b 100644
--- a/core/fs/lib/chdir.c
+++ b/core/fs/lib/chdir.c
@@ -1,3 +1,4 @@
+#include <unistd.h>
 #include <core.h>
 
 int generic_chdir_start(void)
diff --git a/core/graphics.c b/core/graphics.c
index 4a4af55..e85787d 100644
--- a/core/graphics.c
+++ b/core/graphics.c
@@ -92,14 +92,15 @@ static int vgasetmode(void)
 	ireg.eax.w[0] = 0x0012;	/* Set mode = 640x480 VGA 16 colors */
 	__intcall(0x10, &ireg, &oreg);
 
-	ireg.edx.w[0] = (uint16_t)linear_color;
+	ireg.edx.w[0] = (uint32_t)linear_color;
 	ireg.eax.w[0] = 0x1002;	/* Write color registers */
 	__intcall(0x10, &ireg, &oreg);
 
 	UsingVGA = 1;
 
 	/* Set GXPixCols and GXPixRows */
-	GXPixCols = 640+(480 << 16);
+	GXPixCols = 640;
+	GXPixRows = 480;
 
 	use_font();
 	ScrollAttribute = 0;
@@ -219,12 +220,12 @@ static void outputvga(uint32_t *in, uint32_t *out)
 	val = 2;		 /* Sequencer mask */
 
 	/* Select the sequencer mask */
-	outb(val, (uint16_t)addr);
+	outb(val, (uint32_t)addr);
 
 	addr += 1;		/* VGA Sequencer Register data port */
 	for (i = 1; i <= 8; i *= 2) {
 		/* Select the bit plane to write */
-		outb(i, (uint16_t)addr);
+		outb(i, (uint32_t)addr);
 
 		for (j = 0; j < (640 / 32); j++)
 			*(out + j) = *(in + j);
@@ -300,7 +301,8 @@ void vgadisplayfile(FILE *_fd)
 			rledecode(VGARowBuffer, GraphXSize);
 
 			packedpixel2vga(VGARowBuffer, VGAPlaneBuffer, 640);
-			outputvga(VGAPlaneBuffer, MK_PTR(0x0A000, VGAPos));
+			outputvga((uint32_t *)VGAPlaneBuffer,
+				  MK_PTR(0x0A000, VGAPos));
 			VGAPos += 640/8;
 		}
 	}
diff --git a/core/hello.c b/core/hello.c
index 45bdf57..5b22478 100644
--- a/core/hello.c
+++ b/core/hello.c
@@ -7,8 +7,6 @@
 
 #include <console.h>
 
-static int console_init = 0;
-
 void myputchar(int c)
 {
     static com32sys_t ireg;
diff --git a/core/include/bios.h b/core/include/bios.h
index 3c49cf2..2b4b029 100644
--- a/core/include/bios.h
+++ b/core/include/bios.h
@@ -73,8 +73,6 @@ extern union screen _screensize;
 #define VidCols		_screensize.b.col
 #define VidRows		_screensize.b.row
 
-extern void write_serial(char data);
-
 /* font.c */
 extern uint16_t VGAFontSize;
 extern void use_font(void);
@@ -96,8 +94,8 @@ extern void vgaclearmode(void);
 extern void vgadisplayfile(FILE *fd);
 
 /* serirq.c */
-extern unsigned char *SerialHead;
-extern unsigned char *SerialTail;
+extern char *SerialHead;
+extern char *SerialTail;
 
 extern void bios_init(void);
 extern void bios_cleanup_hardware(void);
diff --git a/core/include/core.h b/core/include/core.h
index d2aaf72..7d36e98 100644
--- a/core/include/core.h
+++ b/core/include/core.h
@@ -99,4 +99,15 @@ static inline void set_flags(com32sys_t *regs, uint32_t flags)
     regs->eflags.l = eflags;
 }
 
+extern int start_ldlinux(char **argv);
+
+extern void write_serial(char data);
+extern void writestr(char *str);
+extern void writechr(char data);
+extern void crlf(void);
+
+extern void cleanup_hardware(void);
+extern void sirq_cleanup(void);
+extern void adjust_screen(void);
+
 #endif /* CORE_H */
diff --git a/core/include/fs.h b/core/include/fs.h
index 93eb818..59ec503 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -193,6 +193,7 @@ int open_file(const char *name, struct com32_filedata *filedata);
 void pm_open_file(com32sys_t *);
 void close_file(uint16_t handle);
 void pm_close_file(com32sys_t *);
+int open_config(void);
 
 /* chdir.c */
 void pm_realpath(com32sys_t *regs);
diff --git a/core/init.c b/core/init.c
index c1ba298..19db1e2 100644
--- a/core/init.c
+++ b/core/init.c
@@ -4,7 +4,7 @@
 #include <fs.h>
 #include <bios.h>
 
-static uint16_t min_lowmem_heap = 65536;
+static uint32_t min_lowmem_heap = 65536;
 extern char __lowmem_heap[];
 uint8_t KbdFlags;		/* Check for keyboard escapes */
 
@@ -29,7 +29,7 @@ static inline void check_escapes(void)
 
 		__intcall(0x12, &ireg, &oreg);
 
-		mem = ((uint16_t)__lowmem_heap) + min_lowmem_heap + 1023;
+		mem = ((uint32_t)__lowmem_heap) + min_lowmem_heap + 1023;
 		mem = mem >> 10;
 
 		if (mem < oreg.eax.w[0]) {
@@ -54,14 +54,15 @@ extern uint32_t timer_irq;
 static inline void bios_timer_init(void)
 {
 	unsigned long next;
-	uint32_t *hook = BIOS_timer_hook;
+	uint32_t *hook = (uint32_t *)BIOS_timer_hook;
 
 	next = *hook;
 	BIOS_timer_next = next;
-	*hook = &timer_irq;
+	*hook = (uint32_t)&timer_irq;
 }
 
-void init(com32sys_t *regs)
+extern void printf_init(void);
+void init(com32sys_t *regs __unused)
 {
 	int i;
 
diff --git a/core/localboot.c b/core/localboot.c
index c6993fc..0104047 100644
--- a/core/localboot.c
+++ b/core/localboot.c
@@ -11,7 +11,11 @@
  * -----------------------------------------------------------------------
  */
 #include <sys/cpu.h>
+#include <sys/io.h>
+#include <string.h>
 #include <core.h>
+#include <fs.h>
+#include <bios.h>
 
 /*
  * localboot.c
@@ -32,7 +36,6 @@ extern void local_boot16(void);
 void local_boot(int16_t ax)
 {
 	com32sys_t ireg, oreg;
-	unsigned long data;
 	int i;
 
 	vgaclearmode();
@@ -73,7 +76,7 @@ void local_boot(int16_t ax)
 		kaboom();
 
 	cli();			/* Abandon hope, ye who enter here */
-	memcpy(0x07C00, trackbuf, 512);
+	memcpy((void *)0x07C00, trackbuf, 512);
 
 	ireg.esi.w[0] = OFFS(trackbuf);
 	ireg.edi.w[0] = 0x07C00;
diff --git a/core/mem/malloc.c b/core/mem/malloc.c
index d27fc27..fa1d26a 100644
--- a/core/mem/malloc.c
+++ b/core/mem/malloc.c
@@ -93,7 +93,12 @@ void *malloc(size_t size)
 
 void *lmalloc(size_t size)
 {
-    return _malloc(size, HEAP_LOWMEM, MALLOC_CORE);
+    void *p;
+
+    p = _malloc(size, HEAP_LOWMEM, MALLOC_CORE);
+    if (!p)
+	errno = ENOMEM;
+    return p;
 }
 
 void *pmapi_lmalloc(size_t size)
diff --git a/core/serirq.c b/core/serirq.c
index 767099e..e0675c9 100644
--- a/core/serirq.c
+++ b/core/serirq.c
@@ -26,8 +26,8 @@
 static char serial_buf[serial_buf_size];
 
 static unsigned short SerialIRQPort; /* Serial port w IRQ service */
-unsigned char *SerialHead = serial_buf;    /* Head of serial port rx buffer */
-unsigned char *SerialTail = serial_buf;    /* Tail of serial port rx buffer */
+char *SerialHead = serial_buf;    /* Head of serial port rx buffer */
+char *SerialTail = serial_buf;    /* Tail of serial port rx buffer */
 
 static unsigned char IRQMask[2];	     /* PIC IRQ mask status */
 
@@ -39,11 +39,11 @@ void sirq_cleanup(void);
 
 static void irq_common(unsigned short old_irq)
 {
-	unsigned char *dst;
+	char *dst;
 	irqhandler_t next;
 	char val;
 
-	dst = (unsigned char *)SerialHead;
+	dst = SerialHead;
 	next = (irqhandler_t)oldirq[old_irq];
 
 	/* LSR */
@@ -57,7 +57,7 @@ static void irq_common(unsigned short old_irq)
 		val = inb(SerialPort + 5);
 		if ((val & FlowIgnore) == FlowIgnore) {
 			/* Wrap around if necessary */
-			dst = (unsigned char *)((unsigned long)dst & (serial_buf_size - 1));
+			dst = (char *)((unsigned long)dst & (serial_buf_size - 1));
 
 			/* Would this cause overflow? */
 			if (dst != SerialTail)
diff --git a/core/writestr.c b/core/writestr.c
index 66d126a..fb9de34 100644
--- a/core/writestr.c
+++ b/core/writestr.c
@@ -17,6 +17,7 @@
  * Code to write a simple string.
  */
 #include <com32.h>
+#include <core.h>
 
 /*
  * crlf: Print a newline





More information about the Syslinux mailing list