Reduce warnings/errors in libpayload when using picky compiler options
authorPatrick Georgi <patrick@georgi-clan.de>
Thu, 21 Apr 2011 16:57:16 +0000 (18:57 +0200)
committerUwe Hermann <uwe@hermann-uwe.de>
Thu, 30 Jun 2011 18:41:23 +0000 (20:41 +0200)
The new build system uses quite a few more -W flags for the compiler by
default than the old one. And that's for the better.

Change-Id: Ia8e3d28fb35c56760c2bd0983046c7067e8c5dd6
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/72
Tested-by: build bot (Jenkins)
Reviewed-by: Uwe Hermann <uwe@hermann-uwe.de>
20 files changed:
payloads/libpayload/Config.in
payloads/libpayload/arch/i386/coreboot.c
payloads/libpayload/arch/i386/main.c
payloads/libpayload/arch/i386/multiboot.c
payloads/libpayload/arch/i386/virtual.c
payloads/libpayload/arch/powerpc/coreboot.c
payloads/libpayload/arch/powerpc/main.c
payloads/libpayload/arch/powerpc/virtual.c
payloads/libpayload/curses/keyboard.c
payloads/libpayload/curses/tinycurses.c
payloads/libpayload/drivers/keyboard.c
payloads/libpayload/drivers/serial.c
payloads/libpayload/drivers/usb/uhci.c
payloads/libpayload/drivers/usb/usbhid.c
payloads/libpayload/include/libpayload.h
payloads/libpayload/libc/getopt_long.c
payloads/libpayload/libc/printf.c
payloads/libpayload/libc/strings.c
payloads/libpayload/libc/sysinfo.c
payloads/libpayload/libpci/libpci.c

index 0a9265d73327248b85a71cbbeec24c9e51bfe3b7..fe534001bb40725b557bc917b13750ab412a390c 100644 (file)
@@ -73,6 +73,10 @@ config TARGET_POWERPC
 
 endchoice
 
+config MEMMAP_RAM_ONLY
+       bool "Only consider RAM entries in memory map for further processing"
+       default n
+
 config MULTIBOOT
        bool "Multiboot header support"
        depends on TARGET_I386
index 8441903e7caebeafda8819e72fd1e01d38674064..e3c944d443d85ee8b3c3b823e5c630bc168b68f4 100644 (file)
@@ -57,7 +57,7 @@ static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info)
                struct cb_memory_range *range =
                    (struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
 
-#if MEMMAP_RAM_ONLY
+#ifdef CONFIG_MEMMAP_RAM_ONLY
                if (range->type != CB_MEM_RAM)
                        continue;
 #endif
index 48d6ef54952aa8105ade915b6e36b359c98bc717..378c6f387f237241273a9162c810cfb75c86f827 100644 (file)
@@ -41,6 +41,7 @@ char *main_argv[MAX_ARGC_COUNT];
  * This is our C entry function - set up the system
  * and jump into the payload entry point.
  */
+void start_main(void);
 void start_main(void)
 {
        extern int main(int argc, char **argv);
index 82736b14fea866d2aabe40f259c32924d19cabe0..fa0c576dc91a0719c2ff209180cc82bad2e97234 100644 (file)
@@ -45,7 +45,7 @@ static void mb_parse_mmap(struct multiboot_header *table,
        while(ptr < (start + table->mmap_length)) {
                struct multiboot_mmap *mmap = (struct multiboot_mmap *) ptr;
 
-#if MEMMAP_RAM_ONLY
+#ifdef CONFIG_MEMMAP_RAM_ONLY
                /* 1 == normal RAM.  Ignore everything else for now */
 
                if (mmap->type == 1) {
@@ -56,7 +56,7 @@ static void mb_parse_mmap(struct multiboot_header *table,
 
                        if (++info->n_memranges == SYSINFO_MAX_MEM_RANGES)
                                return;
-#if MEMMAP_RAM_ONLY
+#ifdef CONFIG_MEMMAP_RAM_ONLY
                }
 #endif
 
index 256bfc25f7f9eb89d5dc817452ad1158ee0bb1d6..59768dbd66bb92d2ed2e5582a29b17851d6ef33a 100644 (file)
@@ -27,6 +27,7 @@
  * SUCH DAMAGE.
  */
 
+#include <unistd.h>
 
 unsigned long virtual_offset = 0;
 
index 95d8f16f76cef19dd1700ba53bc383b43bf2460e..ee1842c82f8c15f7c20e15f9c707df8d59e86e48 100644 (file)
@@ -57,7 +57,7 @@ static void cb_parse_memory(unsigned char *ptr, struct sysinfo_t *info)
                struct cb_memory_range *range =
                    (struct cb_memory_range *)MEM_RANGE_PTR(mem, i);
 
-#if MEMMAP_RAM_ONLY
+#ifdef CONFIG_MEMMAP_RAM_ONLY
                if (range->type != CB_MEM_RAM)
                        continue;
 #endif
index 48d6ef54952aa8105ade915b6e36b359c98bc717..378c6f387f237241273a9162c810cfb75c86f827 100644 (file)
@@ -41,6 +41,7 @@ char *main_argv[MAX_ARGC_COUNT];
  * This is our C entry function - set up the system
  * and jump into the payload entry point.
  */
+void start_main(void);
 void start_main(void)
 {
        extern int main(int argc, char **argv);
index 6312ae13cac3c44f31036b3dfc1f5962ec9dd607..6ff588c504e3473feb5986b5ed657729e14044ed 100644 (file)
@@ -27,6 +27,7 @@
  * SUCH DAMAGE.
  */
 
+#include <unistd.h>
 
 unsigned long virtual_offset = 0;
 
index a7506759959ba2a929563fd65daa01036ecbaa18..7ebb04f111f31431039f811f54a3a6bb96d6e0f4 100644 (file)
@@ -71,7 +71,7 @@ static int getkeyseq(char *buffer, int len, int max)
 }
 
 static struct {
-       char *seq;
+       const char *seq;
        int key;
 } escape_codes[] = {
        { "[A", KEY_UP },
@@ -109,7 +109,7 @@ static int handle_escape(void)
                return 27;
 
        for(i = 0; escape_codes[i].seq != NULL; i++) {
-               char *p = escape_codes[i].seq;
+               const char *p = escape_codes[i].seq;
 
                for(t = 0; t < len; t++) {
                        if (!*p || *p != buffer[t])
@@ -144,7 +144,7 @@ static int cook_serial(unsigned char ch)
 
 /* ================ Keyboard ================ */
 
-static int curses_getchar(int delay)
+static int curses_getchar(int _delay)
 {
 #if defined(CONFIG_USB_HID) || defined(CONFIG_PC_KEYBOARD) || defined(CONFIG_SERIAL_CONSOLE)
        unsigned short c;
@@ -175,12 +175,12 @@ static int curses_getchar(int delay)
                }
 #endif
 
-               if (delay == 0)
+               if (_delay == 0)
                        break;
 
-               if (delay > 0) {
+               if (_delay > 0) {
                        mdelay(1);
-                       delay--;
+                       _delay--;
                }
 
 
@@ -193,14 +193,14 @@ static int curses_getchar(int delay)
 
 int wgetch(WINDOW *win)
 {
-       int delay = -1;
+       int _delay = -1;
 
        if (_halfdelay)
-               delay = _halfdelay;
+               _delay = _halfdelay;
        else
-               delay = win->_delay;
+               _delay = win->_delay;
 
-       return curses_getchar(delay);
+       return curses_getchar(_delay);
 }
 
 int nodelay(WINDOW *win, NCURSES_BOOL flag)
index cb1d695933e52d387059a55517cdeecaa5018df8..4d3e8e1be247178874bdd1862617b08170ea70b1 100644 (file)
@@ -971,7 +971,7 @@ int wsetscrreg(WINDOW *win, int top, int bottom)
 }
 // void wsyncdown (WINDOW *) {}
 // void wsyncup (WINDOW *) {}
-/* D */ void wtimeout(WINDOW *win, int delay) { win->_delay = delay; }
+/* D */ void wtimeout(WINDOW *win, int _delay) { win->_delay = _delay; }
 /* D */ int wtouchln(WINDOW *win, int y, int n, int changed)
 {
        int i;
index 2b2ac2685db259bd735ac9a5a2d3c23d659e92cb..0663f47bc636f2e1acd88f0ef2aafceb118555bb 100644 (file)
@@ -37,8 +37,8 @@
 #define I8042_MODE_XLATE     0x40
 
 struct layout_maps {
-       char *country;
-       unsigned short map[4][0x57];
+       const char *country;
+       const unsigned short map[4][0x57];
 };
 
 static struct layout_maps *map;
@@ -261,22 +261,22 @@ int keyboard_getchar(void)
 
 static int keyboard_wait_read(void)
 {
-       int timeout = 10000;
+       int retries = 10000;
 
-       while(timeout-- && !(inb(0x64) & 0x01))
+       while(retries-- && !(inb(0x64) & 0x01))
                udelay(50);
 
-       return (timeout <= 0) ? -1 : 0;
+       return (retries <= 0) ? -1 : 0;
 }
 
 static int keyboard_wait_write(void)
 {
-       int timeout = 10000;
+       int retries = 10000;
 
-       while(timeout-- && (inb(0x64) & 0x02))
+       while(retries-- && (inb(0x64) & 0x02))
                udelay(50);
 
-       return (timeout <= 0) ? -1 : 0;
+       return (retries <= 0) ? -1 : 0;
 }
 
 static unsigned char keyboard_get_mode(void)
index 0674ec8c38804ac226bb558ded3a02753771c199..c6804d2b2ae166f3d6ec91cf11c909580be8d118 100644 (file)
@@ -195,7 +195,7 @@ int serial_getchar(void)
 /* A vt100 doesn't do color, setaf/setab below are from xterm-color. */
 #define VT100_SET_COLOR   "\e[3%d;4%dm"
 
-static void serial_putcmd(char *str)
+static void serial_putcmd(const char *str)
 {
        while(*str)
                serial_putchar(*(str++));
index 721fde00f7fbd6cc525a0694e3ac934f9c27f2a5..1f80c6a3c699486be2f4d562007515eaccced2d7 100644 (file)
@@ -65,7 +65,7 @@ static void
 td_dump (td_t *td)
 {
        char td_value[3];
-       char *td_type;
+       const char *td_type;
        switch (td->pid) {
                case UHCI_SETUP:
                        td_type="SETUP";
index 84de0c8afb7e84009a665cb3dbd5e188d9c1b47e..bf3ec1e4076d9028152cffcb6c866e80130bc0d2 100644 (file)
@@ -62,7 +62,7 @@ static int keycount;
 #define KEYBOARD_BUFFER_SIZE 16
 static short keybuffer[KEYBOARD_BUFFER_SIZE];
 
-char *countries[36][2] = {
+const char *countries[36][2] = {
        { "not supported", "us" },
        { "Arabic", "ae" },
        { "Belgian", "be" },
@@ -105,13 +105,13 @@ char *countries[36][2] = {
 
 
 struct layout_maps {
-       char *country;
-       short map[4][0x80];
+       const char *country;
+       const short map[4][0x80];
 };
 
-static struct layout_maps *map;
+static const struct layout_maps *map;
 
-static struct layout_maps keyboard_layouts[] = {
+static const struct layout_maps keyboard_layouts[] = {
 // #ifdef CONFIG_PC_KEYBOARD_LAYOUT_US
 { .country = "us", .map = {
        { /* No modifier */
@@ -378,7 +378,7 @@ static struct console_input_driver cons = {
 };
 
 
-int usb_hid_set_layout (char *country)
+static int usb_hid_set_layout (const char *country)
 {
        /* FIXME should be per keyboard */
        int i;
index 74fb79a4ae7a23e1417ddb8487a61f608c5d03ff..6ce7548b3d4d1877628e676f395ff05713073cdc 100644 (file)
@@ -272,6 +272,7 @@ typedef struct {
 void SHA1Init(SHA1_CTX *context);
 void SHA1Transform(u32 state[5], const u8 buffer[SHA1_BLOCK_LENGTH]);
 void SHA1Update(SHA1_CTX *context, const u8 *data, size_t len);
+void SHA1Pad(SHA1_CTX *context);
 void SHA1Final(u8 digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context);
 u8 *sha1(const u8 *data, size_t len, u8 *buf);
 /** @} */
index 493df4d3b3233ef9a037b18287c0333428297273..365bc4a85a85b51e57070d7b22d631774774300e 100644 (file)
 #include <libpayload.h>
 #include <getopt.h>
 #define warnx(x...) printf(x)
-/*
 #include <stdlib.h>
 #include <string.h>
-*/
 #define        REPLACE_GETOPT          /* use this getopt as the system getopt(3) */
 
 #ifdef REPLACE_GETOPT
@@ -84,7 +82,7 @@ int posixly_correct = 0;
 #define        BADARG          ((*options == ':') ? (int)':' : (int)'?')
 #define        INORDER         (int)1
 
-#define        EMSG            ""
+#define        EMSG            (char*)""
 
 static int getopt_internal(int, char * const *, const char *,
                           const struct option *, int *, int);
index 389d2277eaf6d22faa34f57d7bb4a40d9bd4ebc0..e3cf8bbb24ca2224879ac96ff3da8add9f0a0548 100644 (file)
@@ -114,7 +114,7 @@ static int printf_putstr(const char *str, struct printf_spec *ps)
        size_t count;
 
        if (str == NULL) {
-               char *nullstr = "(NULL)";
+               const char *nullstr = "(NULL)";
                return printf_putnchars(nullstr, strlen(nullstr), ps);
        }
 
index 9a56ba127c38cf3742f86f1c894bf7e96359896d..465ae4f12d3d3d564de3b74922d8513f3c5763de 100644 (file)
@@ -27,6 +27,8 @@
  * SUCH DAMAGE.
  */
 
+#include <strings.h>
+
 int ffs(int i)
 {
        int count = 1;
index 73a9ab55398da426617a698479c60520149d6edc..b1cad5030258268b411d12d8565635c9a3ae7dfc 100644 (file)
@@ -30,8 +30,6 @@
 #include <libpayload.h>
 #include <sysinfo.h>
 
-extern struct sysinfo_t lib_sysinfo;
-
 int sysinfo_have_multiboot(unsigned long *addr)
 {
        *addr = (unsigned long) lib_sysinfo.mbtable;
index 0b54ba338c5d9a21c7f6fced50bc96f6e8b81d9c..203e770e47216f5c2fe73798f723d2e3cc830ca4 100644 (file)
@@ -96,6 +96,8 @@ void pci_filter_init(struct pci_access* pacc, struct pci_filter* pf)
        pf->device = -1;
 }
 
+static char *invalid_pci_device_string = (char *)"invalid pci device string";
+
 /* parse domain:bus:dev.func (with all components but "dev" optional)
  * into filter.
  * Returns NULL on success, a string pointer to the error message otherwise.
@@ -109,7 +111,7 @@ char *pci_filter_parse_slot(struct pci_filter* filter, const char* id)
        char *funcp = strrchr(id, '.');
        if (funcp) {
                filter->func = strtoul(funcp+1, &endptr, 0);
-               if (endptr[0] != '\0') return "invalid pci device string";
+               if (endptr[0] != '\0') return invalid_pci_device_string;
        }
 
        char *devp = strrchr(id, ':');
@@ -118,7 +120,7 @@ char *pci_filter_parse_slot(struct pci_filter* filter, const char* id)
        } else {
                filter->dev = strtoul(devp+1, &endptr, 0);
        }
-       if (endptr != funcp) return "invalid pci device string";
+       if (endptr != funcp) return invalid_pci_device_string;
        if (!devp) return NULL;
 
        char *busp = strchr(id, ':');
@@ -127,11 +129,11 @@ char *pci_filter_parse_slot(struct pci_filter* filter, const char* id)
        } else {
                filter->bus = strtoul(busp+1, &endptr, 0);
        }
-       if (endptr != funcp) return "invalid pci device string";
+       if (endptr != funcp) return invalid_pci_device_string;
        if (busp == devp) return NULL;
 
        filter->domain = strtoul(id, &endptr, 0);
-       if (endptr != busp) return "invalid pci device string";
+       if (endptr != busp) return invalid_pci_device_string;
 
        return NULL;
 }