Patchwork No warnings for qemu build

login
register
about
Submitter Myles Watson
Date 2009-11-12 16:09:37
Message ID <2831fecf0911120809o5ec1790ble1773bf47dc75c1f@mail.gmail.com>
Download mbox | patch
Permalink /patch/558/
State Accepted
Headers show

Comments

Myles Watson - 2009-11-12 16:09:37
I think we should be pushing down the number of warnings in our code
with the goal of being able to use -Werror for all of our boards.
It's possible that we should add -Wno-unused-function, since there are
lots of those warnings that would be hard to avoid, but it would help
us keep our size down if we don't ignore that warning.

The attached patch adds a Kconfig variable WARNINGS_ARE_ERRORS and
sets it for qemu.

I think the changes all make sense except for casting a
cbmem_entry.base to u32 before void* in cbmem.c.  The problem is that
it is a very large can of worms to do it right and still allow 64-bit
pointers in a cbmem entry.

Stefan:
- Do we need cbmem entries above 4GB?
- Can we use void* for base instead of u64?  I like the idea of using
pointers for pointers.
- What's the "right" way?

Other changes:
- include delay.h and make the prototype match in emulation/northbridge.c
- remove unused cbmem_base and cbmem_size variables
- cast 0x400 to a (void*) before passing it to memset
- conditionally define lb_forward since it is only used with high_tables
- add a DECLARE_SPIN_LOCK macro to avoid unused spin locks
- remove unneeded gcc workaround once there are no unused spin locks

Abuild tested.

Signed-off-by: Myles Watson <mylesgw@gmail.com>

Thanks,
Myles













Removed warnings:
src/lib/cbmem.c: In function 'cbmem_add':
src/lib/cbmem.c:154: warning: cast to pointer from integer of different size
src/lib/cbmem.c: At top level:
src/lib/cbmem.c:38: warning: 'cbmem_base' defined but not used
src/lib/cbmem.c:39: warning: 'cbmem_size' defined but not used
src/console/printk.c:26: warning: 'console_lock' defined but not used
src/console/vsprintf.c:27: warning: 'vsprintf_lock' defined but not used
src/devices/device.c:61: warning: 'dev_lock' defined but not used
util/x86emu/x86.c: In function 'run_bios':
util/x86emu/x86.c:129: warning: passing argument 1 of 'memset' makes
pointer from integer without a cast
/home/myles/try/buildrom-devel/work/coreboot/svn/src/include/string.h:9:
note: expected 'void *' but argument is of type 'int'
src/arch/i386/boot/coreboot_table.c:68: warning: 'lb_next_record'
defined but not used
src/arch/i386/boot/coreboot_table.c:221: warning: 'lb_forward' defined
but not used
src/cpu/emulation/qemu-x86/northbridge.c:160: warning: no previous
prototype for 'udelay'
ron minnich - 2009-11-12 16:16:02
Acked-by: Ronald G. Minnich <rminnich@gmail.com>

Good plans on getting rid of warnings ...

ron
Myles Watson - 2009-11-12 16:35:18
On Thu, Nov 12, 2009 at 9:16 AM, ron minnich <rminnich@gmail.com> wrote:
> Acked-by: Ronald G. Minnich <rminnich@gmail.com>
Rev 4939.

> Good plans on getting rid of warnings ...
Thanks,
Myles

Patch

Index: svn/Makefile
===================================================================
--- svn.orig/Makefile
+++ svn/Makefile
@@ -247,6 +247,9 @@  CFLAGS = $(STACKPROTECT) $(INCLUDES) -Os
 CFLAGS += -nostdlib -Wall -Wundef -Wstrict-prototypes -Wmissing-prototypes
 CFLAGS += -Wwrite-strings -Wredundant-decls -Wno-trigraphs 
 CFLAGS += -Wstrict-aliasing -Wshadow 
+ifeq ($(CONFIG_WARNINGS_ARE_ERRORS),y)
+CFLAGS += -Werror
+endif
 CFLAGS += -fno-common -ffreestanding -fno-builtin -fomit-frame-pointer
 
 CBFS_COMPRESS_FLAG:=l
Index: svn/src/cpu/emulation/qemu-x86/northbridge.c
===================================================================
--- svn.orig/src/cpu/emulation/qemu-x86/northbridge.c
+++ svn/src/cpu/emulation/qemu-x86/northbridge.c
@@ -8,6 +8,7 @@ 
 #include <bitops.h>
 #include "chip.h"
 #include "northbridge.h"
+#include <delay.h>
 
 static void ram_resource(device_t dev, unsigned long index,
 	unsigned long basek, unsigned long sizek)
@@ -157,9 +158,9 @@  struct chip_operations cpu_emulation_qem
 	.enable_dev = enable_dev,
 };
 
-void udelay(int usecs)
+void udelay(unsigned usecs)
 {
-	int i;
+	unsigned i;
 	for(i = 0; i < usecs; i++)
 		inb(0x80);
 }
Index: svn/src/lib/cbmem.c
===================================================================
--- svn.orig/src/lib/cbmem.c
+++ svn/src/lib/cbmem.c
@@ -35,9 +35,6 @@ 
 #define MAX_CBMEM_ENTRIES	16
 #define CBMEM_MAGIC		0x434f5245
 
-static void *cbmem_base;
-static int cbmem_size;
-
 struct cbmem_entry {
 	u32 magic;
 	u32 id;
@@ -151,7 +148,7 @@  void *cbmem_add(u32 id, u64 size)
 	cbmem_toc[0].base += size;
 	cbmem_toc[0].size -= size;
 
-	return (void *)cbmem_toc[i].base;
+	return (void *)(u32)cbmem_toc[i].base;
 }
 
 void *cbmem_find(u32 id)
Index: svn/util/x86emu/x86.c
===================================================================
--- svn.orig/util/x86emu/x86.c
+++ svn/util/x86emu/x86.c
@@ -126,7 +126,7 @@  static void setup_realmode_idt(void)
 void run_bios(struct device *dev, unsigned long addr)
 {
 	/* clear vga bios data area */
-	memset(0x400, 0, 0x200);
+	memset((void *)0x400, 0, 0x200);
 	
 	/* Set up C interrupt handlers */
 	setup_interrupt_handlers();
Index: svn/src/arch/i386/boot/coreboot_table.c
===================================================================
--- svn.orig/src/arch/i386/boot/coreboot_table.c
+++ svn/src/arch/i386/boot/coreboot_table.c
@@ -65,11 +65,13 @@  static struct lb_record *lb_last_record(
 	return rec;
 }
 
+#if 0
 static struct lb_record *lb_next_record(struct lb_record *rec)
 {
 	rec = (void *)(((char *)rec) + rec->size);	
 	return rec;
 }
+#endif
 
 static struct lb_record *lb_new_record(struct lb_header *header)
 {
@@ -218,6 +220,7 @@  static void lb_strings(struct lb_header 
 
 }
 
+#if CONFIG_WRITE_HIGH_TABLES == 1
 static struct lb_forward *lb_forward(struct lb_header *header, struct lb_header *next_header)
 {
 	struct lb_record *rec;
@@ -229,6 +232,7 @@  static struct lb_forward *lb_forward(str
 	forward->forward = (uint64_t)(unsigned long)next_header;
 	return forward;
 }
+#endif
 
 void lb_memory_range(struct lb_memory *mem,
 	uint32_t type, uint64_t start, uint64_t size)
Index: svn/src/arch/i386/include/arch/smp/spinlock.h
===================================================================
--- svn.orig/src/arch/i386/include/arch/smp/spinlock.h
+++ svn/src/arch/i386/include/arch/smp/spinlock.h
@@ -11,6 +11,7 @@  typedef struct {
 
 
 #define SPIN_LOCK_UNLOCKED (spinlock_t) { 1 }
+#define DECLARE_SPIN_LOCK(x) static spinlock_t x = SPIN_LOCK_UNLOCKED;
 
 /*
  * Simple spin lock operations.  There are two variants, one clears IRQ's
Index: svn/src/console/printk.c
===================================================================
--- svn.orig/src/console/printk.c
+++ svn/src/console/printk.c
@@ -23,7 +23,7 @@  int default_message_loglevel = DEFAULT_M
 int minimum_console_loglevel = MINIMUM_CONSOLE_LOGLEVEL;
 int default_console_loglevel = CONFIG_DEFAULT_CONSOLE_LOGLEVEL;
 
-static spinlock_t console_lock = SPIN_LOCK_UNLOCKED;
+DECLARE_SPIN_LOCK(console_lock)
 
 int do_printk(int msg_level, const char *fmt, ...)
 {
Index: svn/src/console/vsprintf.c
===================================================================
--- svn.orig/src/console/vsprintf.c
+++ svn/src/console/vsprintf.c
@@ -24,7 +24,7 @@ 
 #include <smp/spinlock.h>
 #include <console/vtxprintf.h>
 
-static spinlock_t vsprintf_lock = SPIN_LOCK_UNLOCKED;
+DECLARE_SPIN_LOCK(vsprintf_lock)
 
 static char *str_buf;
 
Index: svn/src/devices/device.c
===================================================================
--- svn.orig/src/devices/device.c
+++ svn/src/devices/device.c
@@ -58,7 +58,9 @@  extern struct device **last_dev_p;
  *
  * @see device_path
  */
-static spinlock_t dev_lock = SPIN_LOCK_UNLOCKED;
+
+DECLARE_SPIN_LOCK(dev_lock)
+
 device_t alloc_dev(struct bus *parent, struct device_path *path)
 {
 	device_t dev, child;
Index: svn/src/include/smp/spinlock.h
===================================================================
--- svn.orig/src/include/smp/spinlock.h
+++ svn/src/include/smp/spinlock.h
@@ -5,15 +5,7 @@ 
 #include <arch/smp/spinlock.h>
 #else /* !CONFIG_SMP */
 
-/* Most GCC versions have a nasty bug with empty initializers */
-#if (__GNUC__ > 2) 
-typedef struct { } spinlock_t;
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { }
-#else
-typedef struct { int gcc_is_buggy; } spinlock_t;
-#define SPIN_LOCK_UNLOCKED (spinlock_t) { 0 }
-#endif
-
+#define DECLARE_SPIN_LOCK(x)
 #define barrier()		do {} while(0)
 #define spin_is_locked(lock)	0
 #define spin_unlock_wait(lock)	do {} while(0)
Index: svn/src/Kconfig
===================================================================
--- svn.orig/src/Kconfig
+++ svn/src/Kconfig
@@ -463,3 +463,7 @@  config USE_INIT
 config ENABLE_APIC_EXT_ID
 	bool
 	default n
+
+config WARNINGS_ARE_ERRORS
+	bool
+	default n
Index: svn/src/mainboard/emulation/qemu-x86/Kconfig
===================================================================
--- svn.orig/src/mainboard/emulation/qemu-x86/Kconfig
+++ svn/src/mainboard/emulation/qemu-x86/Kconfig
@@ -5,6 +5,7 @@  config BOARD_EMULATION_QEMU_X86
 	select CPU_EMULATION_QEMU_X86
 	select HAVE_PIRQ_TABLE
 	select BOARD_ROMSIZE_KB_256
+	select WARNINGS_ARE_ERRORS
 
 config MAINBOARD_DIR
 	string