gcc 3.3 and coreutils
Stefan Reinauer
stepan at suse.de
Wed Apr 23 18:04:00 CEST 2003
Hi LinuxBIOS hackers,
while working on a port to the freshly released AMD64 Opteron systems
I fixed a couple of warnings that probably occur due to stricter gcc 3.x
syntax checks. This includes type signedness checking and stricter
string concatenation.
Also I noticed that coreutils 5.0 are stricter with their POSIX
compliance in a way that breaks LinuxBIOS scripts. tail -5 has to be
tail -n 5, head accordingly.
I have not explicitly tested older compilers, but the changes are
harmless and unlikely to break anything. Can this be included?
Comments?
Stefan
--
The use of COBOL cripples the mind; its teaching should, therefore, be
regarded as a criminal offense. -- E. W. Dijkstra
-------------- next part --------------
diff -urN freebios/src/arch/i386/boot/linuxbios_table.c freebios.hammer/src/arch/i386/boot/linuxbios_table.c
--- freebios/src/arch/i386/boot/linuxbios_table.c 2003-01-28 21:03:28.000000000 +0100
+++ freebios.hammer/src/arch/i386/boot/linuxbios_table.c 2003-04-11 17:36:04.000000000 +0200
@@ -115,11 +115,11 @@
{ LB_TAG_LINKER, linuxbios_linker, },
{ LB_TAG_ASSEMBLER, linuxbios_assembler, },
};
- int i;
+ unsigned int i;
for(i = 0; i < sizeof(strings)/sizeof(strings[0]); i++) {
struct lb_string *rec;
size_t len;
- rec = lb_new_record(header);
+ rec = (struct lb_string *)lb_new_record(header);
len = strlen(strings[i].string);
rec->tag = strings[i].tag;
rec->size = (sizeof(*rec) + len + 1 + 3) & ~3;
diff -urN freebios/src/arch/i386/lib/c_start.S freebios.hammer/src/arch/i386/lib/c_start.S
--- freebios/src/arch/i386/lib/c_start.S 2002-10-28 08:41:54.000000000 +0100
+++ freebios.hammer/src/arch/i386/lib/c_start.S 2003-04-11 18:13:13.000000000 +0200
@@ -10,7 +10,7 @@
cli
lgdt %cs:gdtaddr
ljmp $0x10, $1f
-1: movl $0x18, %ax
+1: movl $0x18, %eax
movl %eax, %ds
movl %eax, %es
movl %eax, %ss
diff -urN freebios/src/arch/i386/smp/ioapic.c freebios.hammer/src/arch/i386/smp/ioapic.c
--- freebios/src/arch/i386/smp/ioapic.c 2001-11-03 03:11:48.000000000 +0100
+++ freebios.hammer/src/arch/i386/smp/ioapic.c 2003-04-11 18:13:42.000000000 +0200
@@ -54,7 +54,7 @@
void setup_ioapic(void)
{
- int i;
+ unsigned int i;
unsigned long value_low, value_high;
unsigned long nvram = 0xfec00000;
volatile unsigned long *l;
diff -urN freebios/src/config/Config freebios.hammer/src/config/Config
--- freebios/src/config/Config 2003-04-17 04:12:58.000000000 +0200
+++ freebios.hammer/src/config/Config 2003-04-17 04:20:15.000000000 +0200
@@ -20,8 +20,8 @@
option LINUXBIOS_COMPILE_BY = $(shell whoami)
option LINUXBIOS_COMPILE_HOST = $(shell hostname)
option LINUXBIOS_COMPILE_DOMAIN = $(shell dnsdomainname)
-option LINUXBIOS_COMPILER = $(shell $(CC) $(CFLAGS) -v 2>&1 | tail -1)
-option LINUXBIOS_LINKER = $(shell $(CC) -Wl,-v 2>&1 | grep version | tail -1)
+option LINUXBIOS_COMPILER = $(shell $(CC) $(CFLAGS) -v 2>&1 | tail -n 1)
+option LINUXBIOS_LINKER = $(shell $(CC) -Wl,-v 2>&1 | grep version | tail -n 1)
option LINUXBIOS_ASSEMBLER = $(shell touch dummy.s ; $(CC) -c -Wa,-v dummy.s 2>&1; rm -f dummy.s dummy.o )
makerule ldscript.ld : ldoptions $(LDSUBSCRIPTS-1) ; echo "INCLUDE ldoptions" > $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo "INCLUDE $$file" >> $@ ; done
diff -urN freebios/src/cpu/p5/delay_tsc.c freebios.hammer/src/cpu/p5/delay_tsc.c
--- freebios/src/cpu/p5/delay_tsc.c 2002-10-26 02:49:25.000000000 +0200
+++ freebios.hammer/src/cpu/p5/delay_tsc.c 2003-04-11 18:19:17.000000000 +0200
@@ -99,10 +99,10 @@
static unsigned long long calibrate_tsc(void)
{
unsigned long long start, end, delta;
- unsigned long allones = (unsigned long) -1, result;
+ // unsigned long allones = (unsigned long) -1;
unsigned long startlow, starthigh;
unsigned long endlow, endhigh;
- unsigned long count;
+ unsigned long count, result;
rdtsc(startlow,starthigh);
// no udivdi3, dammit.
@@ -129,7 +129,7 @@
endhigh, endlow, starthigh, startlow);
printk_spew("32-bit delta %d\n", (unsigned long) delta);
- printk_spew(__FUNCTION__ " 32-bit result is %d\n", result);
+ printk_spew("%s 32-bit result is %d\n", __FUNCTION__, result);
return delta;
}
diff -urN freebios/src/cpu/p6/mtrr.c freebios.hammer/src/cpu/p6/mtrr.c
--- freebios/src/cpu/p6/mtrr.c 2003-01-28 21:04:18.000000000 +0100
+++ freebios.hammer/src/cpu/p6/mtrr.c 2003-04-11 17:53:35.000000000 +0200
@@ -129,8 +129,6 @@
/* setting variable mtrr, comes from linux kernel source */
void set_var_mtrr(unsigned int reg, unsigned long base, unsigned long size, unsigned char type)
{
- unsigned int tmp;
-
if (reg >= 8)
return;
diff -urN freebios/src/lib/clog2.c freebios.hammer/src/lib/clog2.c
--- freebios/src/lib/clog2.c 2002-07-19 23:06:42.000000000 +0200
+++ freebios.hammer/src/lib/clog2.c 2003-04-11 18:03:06.000000000 +0200
@@ -7,8 +7,7 @@
unsigned long pow = sizeof(x) * 8 - 1;
if (! x) {
- printk_emerg(__FUNCTION__
- " called with invalid parameter of 0\n");
+ printk_emerg("%s called with invalid parameter of 0\n",__FUNCTION__);
return -1;
}
for(; i > x; i >>= 1, pow--)
diff -urN freebios/src/lib/elfboot.c freebios.hammer/src/lib/elfboot.c
--- freebios/src/lib/elfboot.c 2003-01-28 21:04:44.000000000 +0100
+++ freebios.hammer/src/lib/elfboot.c 2003-04-11 18:03:58.000000000 +0200
@@ -109,7 +109,7 @@
unsigned long lb_size;
unsigned long mem_entries;
unsigned long buffer;
- int i;
+ unsigned int i;
lb_size = (unsigned long)(&_eram_seg - &_ram_seg);
/* Double linuxBIOS size so I have somewhere to place a copy to return to */
lb_size = lb_size + lb_size;
@@ -207,7 +207,7 @@
* the segment that was passed in is completely contained
* in RAM.
*/
- int i;
+ unsigned int i;
unsigned long end = start + len;
unsigned long mem_entries = (mem->size - sizeof(*mem))/sizeof(mem->map[0]);
@@ -424,7 +424,7 @@
struct segment *head, struct stream *stream,
unsigned char *header, unsigned long header_size)
{
- unsigned long offset;
+ long offset;
struct segment *ptr;
offset = 0;
@@ -598,8 +598,8 @@
{
Elf_ehdr *ehdr;
static unsigned char header[ELF_HEAD_SIZE];
- int header_offset;
- int i, result;
+ int header_offset, result;
+ unsigned int i;
result = 0;
printk_info("\n");
diff -urN freebios/src/lib/malloc.c freebios.hammer/src/lib/malloc.c
--- freebios/src/lib/malloc.c 2002-02-05 01:06:20.000000000 +0100
+++ freebios.hammer/src/lib/malloc.c 2003-04-11 17:59:52.000000000 +0200
@@ -28,7 +28,7 @@
{
void *p;
- MALLOCDBG((__FUNCTION__ " Enter, size %d, free_mem_ptr %p\n", size, free_mem_ptr));
+ MALLOCDBG(("%s Enter, size %d, free_mem_ptr %p\n", __FUNCTION__, size, free_mem_ptr));
if (size < 0)
error("Error! malloc: Size < 0");
if (free_mem_ptr <= 0)
diff -urN freebios/src/lib/memcpy.c freebios.hammer/src/lib/memcpy.c
--- freebios/src/lib/memcpy.c 2001-03-13 05:22:19.000000000 +0100
+++ freebios.hammer/src/lib/memcpy.c 2003-04-11 17:58:58.000000000 +0200
@@ -1,7 +1,7 @@
#include <string.h>
void *memcpy(void *__dest, __const void *__src, size_t __n)
{
- int i;
+ unsigned int i;
char *d = (char *) __dest, *s = (char *) __src;
for (i = 0; i < __n; i++)
diff -urN freebios/src/lib/memset.c freebios.hammer/src/lib/memset.c
--- freebios/src/lib/memset.c 2001-03-13 05:22:19.000000000 +0100
+++ freebios.hammer/src/lib/memset.c 2003-04-11 17:58:43.000000000 +0200
@@ -2,7 +2,7 @@
void *memset(void *s, int c, size_t n)
{
- int i;
+ unsigned int i;
char *ss = (char *) s;
for (i = 0; i < n; i++)
diff -urN freebios/src/lib/newpci.c freebios.hammer/src/lib/newpci.c
--- freebios/src/lib/newpci.c 2003-04-17 04:13:12.000000000 +0200
+++ freebios.hammer/src/lib/newpci.c 2003-04-17 22:42:50.000000000 +0200
@@ -439,7 +439,7 @@
struct resource *result = 0;
int seen_last = 0;
for(curdev = bus->children; curdev; curdev = curdev->sibling) {
- int i;
+ unsigned int i;
for(i = 0; i < curdev->resources; i++) {
struct resource *resource = &curdev->resource[i];
/* If it isn't the right kind of resource ignore it */
diff -urN freebios/src/pc80/mc146818rtc.c freebios.hammer/src/pc80/mc146818rtc.c
--- freebios/src/pc80/mc146818rtc.c 2003-01-28 21:07:09.000000000 +0100
+++ freebios.hammer/src/pc80/mc146818rtc.c 2003-04-11 18:21:11.000000000 +0200
@@ -136,7 +136,7 @@
PC_CKS_RANGE_END,PC_CKS_LOC);
if (invalid || cmos_invalid || checksum_invalid) {
- int i;
+ unsigned int i;
printk_warning("RTC:%s%s%s zeroing cmos\n",
invalid?" Clear requested":"",
cmos_invalid?" Power Problem":"",
diff -urN freebios/util/nrv2b/nrv2b.c freebios.hammer/util/nrv2b/nrv2b.c
--- freebios/util/nrv2b/nrv2b.c 2002-10-26 01:06:54.000000000 +0200
+++ freebios.hammer/util/nrv2b/nrv2b.c 2003-03-19 16:37:08.000000000 +0100
@@ -783,8 +783,7 @@
break;
if (in != m)
if (memcmp(in,ip,c->m_len+1) == 0)
- printf("%p %p %p
-%5d\n",in,ip,m,c->m_len);
+ printf("%p %p %p\n%5d\n",in,ip,m,c->m_len);
in++;
}
@@ -1445,11 +1444,9 @@
rewind(infile = f);
}
else if (argc != 4) {
- Fprintf((stderr, "'lzhuf e file1 file2' encodes file1 into
-file2.\n"
+ Fprintf((stderr, "'lzhuf e file1 file2' encodes file1 into file2.\n"
- "'lzhuf d file2 file1' decodes file2 into
-file1.\n"));
+ "'lzhuf d file2 file1' decodes file2 into file1.\n"));
return EXIT_FAILURE;
}
diff -urN freebios/util/options/build_opt_tbl.c freebios.hammer/util/options/build_opt_tbl.c
--- freebios/util/options/build_opt_tbl.c 2003-01-28 21:08:09.000000000 +0100
+++ freebios.hammer/util/options/build_opt_tbl.c 2003-04-11 17:52:04.000000000 +0200
@@ -26,7 +26,7 @@
void test_for_entry_overlaps(int entry_start,int entry_end)
{
int ptr;
- int buffer_bit_size;
+ unsigned int buffer_bit_size;
int offset;
int byte;
int byte_length;
@@ -74,7 +74,7 @@
}
} else {
/* test if bits overlap byte boundaries */
- if(ce->length>(8-offset)) {
+ if((int)ce->length>(8-offset)) {
printf("Error - Entry %s length overlaps a byte boundry\n", ce->name);
exit(1);
}
@@ -142,7 +142,7 @@
*/
int main(int argc, char **argv)
{
- int i;
+ unsigned int i;
char *config=0;
char *option=0;
FILE *fp;
@@ -163,7 +163,7 @@
int len;
unsigned char buf[16];
- for(i=1;i<argc;i++) {
+ for(i=1;(int)i<argc;i++) {
if(argv[i][0]!='-') {
display_usage();
}
More information about the coreboot
mailing list