linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: Fixes to compile 2.4.32 with gcc-4.0.2
@ 2006-01-23  7:54 Mikael Pettersson
  0 siblings, 0 replies; 2+ messages in thread
From: Mikael Pettersson @ 2006-01-23  7:54 UTC (permalink / raw)
  To: linux-kernel, ulrich.windl

On Mon, 23 Jan 2006 08:07:42 +0100, Ulrich Windl wrote:
>I'm no real C guru, neither am I a kernel guru, but I managed to compile Linux-
>2.4.32 with gcc-4.0.2 (I also could boot that kernel, but couldn't load the 
>modules as SuSE 10.0 lacks the old mudutils required to do that).
>
>Please have a look at the attached diffs, as som of my fixes seem to wipe out some 
>real C nonsense, independent of the compiler issues.
>
>Note: gcc still produces a _lot_ of warnings, but at least the kernel compiles.

Well-tested fixes for gcc-4.0.x and recent 2.4 kernels on
i386, x86_64, and ppc(32) are available in
<http://www.csd.uu.se/~mikpe/linux/patches/2.4/>.
Look for the patch-gcc4-fixes-v<N>-<KERNELVERSION> file that
matches your kernel version.

There is also a patch-more-gcc4-fixes-v1-<KERNELVERSION> file
but those changes were only compile-tested once (due to me not
being able to test them at runtime).

I'd be happy to extend these patches if you find that something
important is missing from them.

2.4 is in deep feature freeze and gcc-4 fixes are not being
accepted into the standard 2.4 tree.

>Index: drivers/scsi/aic7xxx/Makefile
>===================================================================
>RCS file: /root/LinuxCVS/Kernel/drivers/scsi/aic7xxx/Makefile,v
>retrieving revision 1.1.1.6
>diff -u -r1.1.1.6 Makefile
>--- drivers/scsi/aic7xxx/Makefile	22 Jan 2005 20:43:25 -0000	1.1.1.6
>+++ drivers/scsi/aic7xxx/Makefile	20 Jan 2006 20:55:44 -0000
>@@ -13,7 +13,7 @@
> obj-$(CONFIG_SCSI_AIC79XX)	+= aic79xx.o
> endif
> 
>-EXTRA_CFLAGS += -I$(TOPDIR)/drivers/scsi -Werror
>+EXTRA_CFLAGS += -I$(TOPDIR)/drivers/scsi #-Werror
> #EXTRA_CFLAGS += -g
> 
> # Platform Specific Files

Better to find and fix the causes of those warnings.

>Index: drivers/sound/sound_firmware.c
>===================================================================
>RCS file: /root/LinuxCVS/Kernel/drivers/sound/sound_firmware.c,v
>retrieving revision 1.1.1.2
>diff -u -r1.1.1.2 sound_firmware.c
>--- drivers/sound/sound_firmware.c	11 Mar 2001 13:55:33 -0000	1.1.1.2
>+++ drivers/sound/sound_firmware.c	21 Jan 2006 22:27:06 -0000
>@@ -7,7 +7,6 @@
> #include <linux/unistd.h>
> #include <asm/uaccess.h>
> 
>-static int errno;
> static int do_mod_firmware_load(const char *fn, char **fp)
> {
> 	int fd;

This changes the semantics of the in-kernel system calls
called here so they now clobber a global errno. My solution
was to force the syscall wrappers to use a local variable
'my_errno'.

/Mikael

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Fixes to compile 2.4.32 with gcc-4.0.2
@ 2006-01-23  7:07 Ulrich Windl
  0 siblings, 0 replies; 2+ messages in thread
From: Ulrich Windl @ 2006-01-23  7:07 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Mail message body --]
[-- Type: text/plain, Size: 465 bytes --]

Hi,

I'm no real C guru, neither am I a kernel guru, but I managed to compile Linux-
2.4.32 with gcc-4.0.2 (I also could boot that kernel, but couldn't load the 
modules as SuSE 10.0 lacks the old mudutils required to do that).

Please have a look at the attached diffs, as som of my fixes seem to wipe out some 
real C nonsense, independent of the compiler issues.

Note: gcc still produces a _lot_ of warnings, but at least the kernel compiles.

Regards,
Ulrich


[-- Attachment #2: gcc-4.0.2-fixes.diff --]
[-- Type: Application/Octet-stream, Size: 11000 bytes --]

Index: drivers/i2c/i2c-core.c
===================================================================
RCS file: /root/LinuxCVS/Kernel/drivers/i2c/i2c-core.c,v
retrieving revision 1.1.1.11
diff -u -r1.1.1.11 i2c-core.c
--- drivers/i2c/i2c-core.c	19 Jan 2006 19:19:34 -0000	1.1.1.11
+++ drivers/i2c/i2c-core.c	21 Jan 2006 22:18:28 -0000
@@ -750,7 +750,7 @@
 		msg.addr   = client->addr;
 		msg.flags = client->flags & I2C_M_TEN;
 		msg.len = count;
-		(const char *)msg.buf = buf;
+		msg.buf = buf;
 	
 		DEB2(printk(KERN_DEBUG "i2c-core.o: master_send: writing %d bytes on %s.\n",
 			count,client->adapter->name));
Index: drivers/i2c/i2c-proc.c
===================================================================
RCS file: /root/LinuxCVS/Kernel/drivers/i2c/i2c-proc.c,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 i2c-proc.c
--- drivers/i2c/i2c-proc.c	22 Jan 2005 21:04:10 -0000	1.1.1.5
+++ drivers/i2c/i2c-proc.c	21 Jan 2006 22:25:23 -0000
@@ -43,9 +43,9 @@
 
 static int i2c_create_name(char **name, const char *prefix,
 			       struct i2c_adapter *adapter, int addr);
-static int i2c_parse_reals(int *nrels, void *buffer, int bufsize,
+static int i2c_parse_reals(int *nrels, char *buffer, int bufsize,
 			       long *results, int magnitude);
-static int i2c_write_reals(int nrels, void *buffer, int *bufsize,
+static int i2c_write_reals(int nrels, char *buffer, int *bufsize,
 			       long *results, int magnitude);
 static int i2c_proc_chips(ctl_table * ctl, int write,
 			      struct file *filp, void *buffer,
@@ -205,7 +205,7 @@
 		table = i2c_entries[id]->ctl_table;
 		unregister_sysctl_table(i2c_entries[id]);
 		/* 2-step kfree needed to keep gcc happy about const points */
-		(const char *) temp = table[4].procname;
+		temp = table[4].procname;
 		kfree(temp);
 		kfree(table);
 		i2c_entries[id] = NULL;
@@ -287,7 +287,7 @@
 			if(copy_to_user(buffer, BUF, buflen))
 				return -EFAULT;
 			curbufsize += buflen;
-			(char *) buffer += buflen;
+			buffer += buflen;
 		}
 	*lenp = curbufsize;
 	filp->f_pos += curbufsize;
@@ -318,8 +318,7 @@
 					     sizeof(struct
 						    i2c_chips_data)))
 					return -EFAULT;
-				(char *) oldval +=
-				    sizeof(struct i2c_chips_data);
+				oldval += sizeof(struct i2c_chips_data);
 				nrels++;
 			}
 		oldlen = nrels * sizeof(struct i2c_chips_data);
@@ -456,7 +455,7 @@
    WARNING! This is tricky code. I have tested it, but there may still be
             hidden bugs in it, even leading to crashes and things!
 */
-int i2c_parse_reals(int *nrels, void *buffer, int bufsize,
+int i2c_parse_reals(int *nrels, char *buffer, int bufsize,
 			 long *results, int magnitude)
 {
 	int maxels, min, mag;
@@ -470,10 +469,10 @@
 
 		/* Skip spaces at the start */
 		while (bufsize && 
-		       !((ret=get_user(nextchar, (char *) buffer))) &&
+		       !((ret=get_user(nextchar, buffer))) &&
 		       isspace((int) nextchar)) {
 			bufsize--;
-			((char *) buffer)++;
+			buffer++;
 		}
 
 		if (ret)
@@ -488,22 +487,22 @@
 		mag = magnitude;
 
 		/* Check for a minus */
-		if (!((ret=get_user(nextchar, (char *) buffer)))
+		if (!((ret=get_user(nextchar, buffer)))
 		    && (nextchar == '-')) {
 			min = 1;
 			bufsize--;
-			((char *) buffer)++;
+			buffer++;
 		}
 		if (ret)
 			return -EFAULT;
 
 		/* Digits before a decimal dot */
 		while (bufsize && 
-		       !((ret=get_user(nextchar, (char *) buffer))) &&
+		       !((ret=get_user(nextchar, buffer))) &&
 		       isdigit((int) nextchar)) {
 			res = res * 10 + nextchar - '0';
 			bufsize--;
-			((char *) buffer)++;
+			buffer++;
 		}
 		if (ret)
 			return -EFAULT;
@@ -517,16 +516,16 @@
 		if (bufsize && (nextchar == '.')) {
 			/* Skip the dot */
 			bufsize--;
-			((char *) buffer)++;
+			buffer++;
 
 			/* Read digits while they are significant */
 			while (bufsize && (mag > 0) &&
-			       !((ret=get_user(nextchar, (char *) buffer))) &&
+			       !((ret=get_user(nextchar, buffer))) &&
 			       isdigit((int) nextchar)) {
 				res = res * 10 + nextchar - '0';
 				mag--;
 				bufsize--;
-				((char *) buffer)++;
+				buffer++;
 			}
 			if (ret)
 				return -EFAULT;
@@ -539,10 +538,10 @@
 
 		/* Skip everything until we hit whitespace */
 		while (bufsize && 
-		       !((ret=get_user(nextchar, (char *) buffer))) &&
+		       !((ret=get_user(nextchar, buffer))) &&
 		       !isspace((int) nextchar)) {
 			bufsize--;
-			((char *) buffer)++;
+			buffer++;
 		}
 		if (ret)
 			return -EFAULT;
@@ -557,7 +556,7 @@
 	return 0;
 }
 
-int i2c_write_reals(int nrels, void *buffer, int *bufsize,
+int i2c_write_reals(int nrels, char *buffer, int *bufsize,
 			 long *results, int magnitude)
 {
 #define BUFLEN 20
@@ -571,10 +570,10 @@
 		mag = magnitude;
 
 		if (nr != 0) {
-			if(put_user(' ', (char *) buffer))
+			if(put_user(' ', buffer))
 				return -EFAULT;
 			curbufsize++;
-			((char *) buffer)++;
+			buffer++;
 		}
 
 		/* Fill BUF with the representation of the next string */
@@ -612,15 +611,15 @@
 		/* Now copy it to the user-space buffer */
 		if (buflen + curbufsize > *bufsize)
 			buflen = *bufsize - curbufsize;
-		if(copy_to_user(buffer, BUF, buflen))
+		if (copy_to_user(buffer, BUF, buflen))
 			return -EFAULT;
 		curbufsize += buflen;
-		(char *) buffer += buflen;
+		buffer += buflen;
 
 		nr++;
 	}
 	if (curbufsize < *bufsize) {
-		if(put_user('\n', (char *) buffer))
+		if(put_user('\n', buffer))
 			return -EFAULT;
 		curbufsize++;
 	}
Index: drivers/scsi/aic7xxx/Makefile
===================================================================
RCS file: /root/LinuxCVS/Kernel/drivers/scsi/aic7xxx/Makefile,v
retrieving revision 1.1.1.6
diff -u -r1.1.1.6 Makefile
--- drivers/scsi/aic7xxx/Makefile	22 Jan 2005 20:43:25 -0000	1.1.1.6
+++ drivers/scsi/aic7xxx/Makefile	20 Jan 2006 20:55:44 -0000
@@ -13,7 +13,7 @@
 obj-$(CONFIG_SCSI_AIC79XX)	+= aic79xx.o
 endif
 
-EXTRA_CFLAGS += -I$(TOPDIR)/drivers/scsi -Werror
+EXTRA_CFLAGS += -I$(TOPDIR)/drivers/scsi #-Werror
 #EXTRA_CFLAGS += -g
 
 # Platform Specific Files
Index: drivers/sound/sound_firmware.c
===================================================================
RCS file: /root/LinuxCVS/Kernel/drivers/sound/sound_firmware.c,v
retrieving revision 1.1.1.2
diff -u -r1.1.1.2 sound_firmware.c
--- drivers/sound/sound_firmware.c	11 Mar 2001 13:55:33 -0000	1.1.1.2
+++ drivers/sound/sound_firmware.c	21 Jan 2006 22:27:06 -0000
@@ -7,7 +7,6 @@
 #include <linux/unistd.h>
 #include <asm/uaccess.h>
 
-static int errno;
 static int do_mod_firmware_load(const char *fn, char **fp)
 {
 	int fd;
Index: drivers/usb/inode.c
===================================================================
RCS file: /root/LinuxCVS/Kernel/drivers/usb/inode.c,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 inode.c
--- drivers/usb/inode.c	22 Jan 2005 20:56:55 -0000	1.1.1.8
+++ drivers/usb/inode.c	21 Jan 2006 22:35:17 -0000
@@ -310,7 +310,7 @@
 	return 1;
 }
 
-static struct dentry_operations usbdevfs_dentry_operations = {
+/*static*/ struct dentry_operations usbdevfs_dentry_operations = {
 	d_revalidate:	usbdevfs_revalidate,
 };
 
@@ -495,11 +495,11 @@
 	lookup: usbdevfs_root_lookup,
 };
 
-static struct file_operations usbdevfs_bus_file_operations = {
+/*static*/ struct file_operations usbdevfs_bus_file_operations = {
 	readdir: usbdevfs_bus_readdir,
 };
 
-static struct inode_operations usbdevfs_bus_inode_operations = {
+/*static*/ struct inode_operations usbdevfs_bus_inode_operations = {
 	lookup: usbdevfs_bus_lookup,
 };
 
Index: include/asm-i386/processor.h
===================================================================
RCS file: /root/LinuxCVS/Kernel/include/asm-i386/processor.h,v
retrieving revision 1.1.1.12
diff -u -r1.1.1.12 processor.h
--- include/asm-i386/processor.h	22 Jan 2005 20:58:03 -0000	1.1.1.12
+++ include/asm-i386/processor.h	20 Jan 2006 20:49:29 -0000
@@ -72,7 +72,6 @@
  */
 
 extern struct cpuinfo_x86 boot_cpu_data;
-extern struct tss_struct init_tss[NR_CPUS];
 
 #ifdef CONFIG_SMP
 extern struct cpuinfo_x86 cpu_data[];
@@ -357,6 +356,8 @@
 	unsigned long __cacheline_filler[5];
 };
 
+extern struct tss_struct init_tss[NR_CPUS];
+
 struct thread_struct {
 	unsigned long	esp0;
 	unsigned long	eip;
Index: include/linux/fs.h
===================================================================
RCS file: /root/LinuxCVS/Kernel/include/linux/fs.h,v
retrieving revision 1.1.1.19
diff -u -r1.1.1.19 fs.h
--- include/linux/fs.h	19 Jan 2006 19:22:03 -0000	1.1.1.19
+++ include/linux/fs.h	20 Jan 2006 20:51:43 -0000
@@ -1559,7 +1559,7 @@
 unsigned long generate_cluster(kdev_t, int b[], int);
 unsigned long generate_cluster_swab32(kdev_t, int b[], int);
 extern kdev_t ROOT_DEV;
-extern char root_device_name[];
+/* extern char root_device_name[]; */
 
 
 extern void show_buffers(void);
Index: include/linux/i2c.h
===================================================================
RCS file: /root/LinuxCVS/Kernel/include/linux/i2c.h,v
retrieving revision 1.1.1.8
diff -u -r1.1.1.8 i2c.h
--- include/linux/i2c.h	19 Jan 2006 19:22:03 -0000	1.1.1.8
+++ include/linux/i2c.h	21 Jan 2006 22:17:41 -0000
@@ -34,9 +34,19 @@
 #include <linux/i2c-id.h>	/* id values of adapters et. al. 	*/
 #include <linux/types.h>
 
-
-struct i2c_msg;
-
+/*
+ * I2C Message - used for pure i2c transaction, also from /dev interface
+ */
+struct i2c_msg {
+	__u16 addr;	/* slave address			*/
+	__u16 flags;		
+#define I2C_M_TEN	0x10	/* we have a ten bit chip address	*/
+#define I2C_M_RD	0x01
+#define I2C_M_NOSTART	0x4000
+#define I2C_M_REV_DIR_ADDR	0x2000
+	__u16 len;		/* msg length				*/
+	__u8 *buf;		/* pointer to msg data			*/
+};
 
 #ifdef __KERNEL__
 
@@ -358,20 +368,6 @@
 
 #endif /* __KERNEL__ */
 
-/*
- * I2C Message - used for pure i2c transaction, also from /dev interface
- */
-struct i2c_msg {
-	__u16 addr;	/* slave address			*/
-	__u16 flags;		
-#define I2C_M_TEN	0x10	/* we have a ten bit chip address	*/
-#define I2C_M_RD	0x01
-#define I2C_M_NOSTART	0x4000
-#define I2C_M_REV_DIR_ADDR	0x2000
-	__u16 len;		/* msg length				*/
-	__u8 *buf;		/* pointer to msg data			*/
-};
-
 /* To determine what functionality is present */
 
 #define I2C_FUNC_I2C			0x00000001
Index: include/net/icmp.h
===================================================================
RCS file: /root/LinuxCVS/Kernel/include/net/icmp.h,v
retrieving revision 1.1.1.3
diff -u -r1.1.1.3 icmp.h
--- include/net/icmp.h	28 Jul 2001 20:54:02 -0000	1.1.1.3
+++ include/net/icmp.h	21 Jan 2006 22:09:48 -0000
@@ -23,6 +23,7 @@
 
 #include <net/sock.h>
 #include <net/protocol.h>
+#include <net/snmp.h>
 
 struct icmp_err {
   int		errno;
Index: include/net/ipv6.h
===================================================================
RCS file: /root/LinuxCVS/Kernel/include/net/ipv6.h,v
retrieving revision 1.1.1.5
diff -u -r1.1.1.5 ipv6.h
--- include/net/ipv6.h	22 Jan 2005 20:59:07 -0000	1.1.1.5
+++ include/net/ipv6.h	21 Jan 2006 22:07:47 -0000
@@ -19,6 +19,7 @@
 #include <asm/hardirq.h>
 #include <net/ndisc.h>
 #include <net/flow.h>
+#include <net/snmp.h>
 
 #define SIN6_LEN_RFC2133	24
 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2006-01-23  7:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-01-23  7:54 Fixes to compile 2.4.32 with gcc-4.0.2 Mikael Pettersson
  -- strict thread matches above, loose matches on Subject: below --
2006-01-23  7:07 Ulrich Windl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).