# --- SDE-COPYRIGHT-NOTE-BEGIN ---
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
#
# Filename: package/.../modutils/gcc-4.0.patch
# Copyright (C) 2004 - 2006 The T2 SDE Project
#
# More information can be found in the files COPYING and README.
#
# This patch file is dual-licensed. It is available under the license the
# patched project is licensed under, as long as it is an OpenSource license
# as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
# of the GNU General Public License as published by the Free Software
# Foundation; either version 2 of the License, or (at your option) any later
# version.
# --- SDE-COPYRIGHT-NOTE-END ---
--- modutils-2.4.27/obj/obj_kallsyms.c.vanilla	2005-08-29 07:31:59.000000000 +0200
+++ modutils-2.4.27/obj/obj_kallsyms.c	2005-08-29 07:42:14.000000000 +0200
@@ -200,8 +200,8 @@
 
     /* Initial contents, header + one entry per input section.  No strings. */
     osec->header.sh_size = sizeof(*a_hdr) + loaded*sizeof(*a_sec);
-    a_hdr = (struct kallsyms_header *) osec->contents =
-    	xmalloc(osec->header.sh_size);
+    osec->contents = xmalloc(osec->header.sh_size);
+    a_hdr = (struct kallsyms_header *) osec->contents;
     memset(osec->contents, 0, osec->header.sh_size);
     a_hdr->size = sizeof(*a_hdr);
     a_hdr->sections = loaded;
@@ -275,8 +275,8 @@
 	a_hdr->symbol_off +
 	a_hdr->symbols*a_hdr->symbol_size +
 	strings_size - strings_left;
-    a_hdr = (struct kallsyms_header *) osec->contents =
-	xrealloc(a_hdr, a_hdr->total_size);
+    osec->contents = xrealloc(a_hdr, a_hdr->total_size);
+    a_hdr = (struct kallsyms_header *) osec->contents;
     p = (char *)a_hdr + a_hdr->symbol_off;
     memcpy(p, symbols, a_hdr->symbols*a_hdr->symbol_size);
     free(symbols);
--- modutils-2.4.27/example/kallsyms.c.vanilla	2005-08-29 07:42:33.000000000 +0200
+++ modutils-2.4.27/example/kallsyms.c	2005-08-29 07:42:53.000000000 +0200
@@ -48,6 +48,8 @@
 
 static struct module *local_module_list;
 
+static int errors;
+
 static void get_module_list(void)
 {
 	const struct kallsyms_header	*ka_hdr;
--- modutils-2.4.27/depmod/depmod.c.vanilla	2005-08-29 07:45:03.000000000 +0200
+++ modutils-2.4.27/depmod/depmod.c	2005-08-29 07:46:24.000000000 +0200
@@ -60,6 +60,8 @@
 #define __u8 u_int8_t
 #endif
 
+static int errors;
+
 typedef struct SYMBOL{
 	struct SYMBOL *next;	/* List connected via hashing */
 	struct MODULE *module;	/* Module declaring this symbol */
@@ -1132,8 +1134,10 @@
 			return -1;
 
 		for (ksym = ksyms; so_far < nksyms; ++so_far, ksym++) {
-			if (strncmp((char *)ksym->name, "GPLONLY_", 8) == 0)
-				((char *)ksym->name) += 8;
+			if (strncmp((char *)ksym->name, "GPLONLY_", 8) == 0) {
+				char* n = ksym->name; n += 8;
+				ksym->name = n;
+			}
 			assert(n_syms < MAX_MAP_SYM);
 			symtab[n_syms++] = addsym((char *)ksym->name, mod, SYM_DEFINED, 0);
 		}
--- modutils-2.4.27/insmod/rmmod.c.vanilla	2005-08-29 07:40:57.000000000 +0200
+++ modutils-2.4.27/insmod/rmmod.c	2005-08-29 07:41:32.000000000 +0200
@@ -51,6 +51,8 @@
 #define main rmmod_main
 #endif
 
+static int errors;
+
 struct module_parm {
 	struct obj_symbol *sym;
 	int max;
--- modutils-2.4.27/insmod/kallsyms.c.vanilla	2005-08-29 07:43:40.000000000 +0200
+++ modutils-2.4.27/insmod/kallsyms.c	2005-08-29 07:43:51.000000000 +0200
@@ -37,6 +37,8 @@
 extern int kallsyms_main_32(int argc, char **argv);
 extern int kallsyms_main_64(int argc, char **argv);
 
+int errors;
+
 /*======================================================================*/
 
 /* For common 3264 code, only compile the usage message once, in the 64 bit version */
--- modutils-2.4.27/insmod/insmod.c.vanilla	2005-08-29 07:34:20.000000000 +0200
+++ modutils-2.4.27/insmod/insmod.c	2005-08-29 07:40:32.000000000 +0200
@@ -100,6 +100,7 @@
 static int n_ext_modules_used;
 static int m_has_modinfo;
 static int gplonly_seen;
+static int errors;
 static int warnings;
 
 extern int insmod_main(int argc, char **argv);
@@ -274,8 +275,11 @@
 		 */
 		if (strncmp((char *)s->name, "GPLONLY_", 8) == 0) {
 			gplonly_seen = 1;
-			if (gpl)
-				((char *)s->name) += 8;
+			if (gpl) {
+				char* n = (char*) s->name;
+				n += 8;
+				s->name = n;
+			}
 			else
 				continue;
 		}
--- modutils-2.4.27/include/util.h.vanilla	2005-08-29 07:38:19.000000000 +0200
+++ modutils-2.4.27/include/util.h	2005-08-29 07:38:30.000000000 +0200
@@ -40,7 +40,7 @@
 
 /* Error logging */
 extern int log;
-extern int errors;
+//extern int errors;
 extern const char *error_file;
 
 extern int flag_verbose;
--- ./obj/obj_ppc.c.vanilla	2005-10-27 01:18:59.247661544 +0300
+++ ./obj/obj_ppc.c	2005-10-27 01:19:35.521739000 +0300
@@ -255,7 +255,7 @@
   archdata_sec->header.sh_size = 0;
   sec = obj_find_section(f, "__ftr_fixup");
   if (sec) {
-    ad = (struct archdata *) (archdata_sec->contents) = xmalloc(sizeof(*ad));
+    ad = (archdata_sec->contents) = xmalloc(sizeof(*ad));
     memset(ad, 0, sizeof(*ad));
     archdata_sec->header.sh_size = sizeof(*ad);
     ad->__start___ftr_fixup = sec->header.sh_addr;
--- modutils-2.4.27/obj/obj_mips.c.vanilla	2005-11-13 17:55:36.000000000 +0100
+++ modutils-2.4.27/obj/obj_mips.c	2005-11-13 17:55:52.000000000 +0100
@@ -244,7 +244,7 @@
   archdata_sec->header.sh_size = 0;
   sec = obj_find_section(f, "__dbe_table");
   if (sec) {
-    ad = (struct archdata *) (archdata_sec->contents) = xmalloc(sizeof(*ad));
+    ad = /* (struct archdata *)*/ (archdata_sec->contents) = xmalloc(sizeof(*ad));
     memset(ad, 0, sizeof(*ad));
     archdata_sec->header.sh_size = sizeof(*ad);
     ad->__start___dbe_table = sec->header.sh_addr;