Skip to contentSkip to conversation

2.6 series: fixed strange behaviour of scripts/modpost

PATCH New Daniel Mack 1 participant 1 message Mar 2, 2004

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.6 series: fixed strange behaviour of scripts/modpost

Hi,

as I found out this morning, it's impossible to use the build-chain tool modpost of the 2.6 kernel series from within a directory that contains the character sequence '.o'. Weird things happen if you try to do so.

With a directory structure like on my system here, building the current DVB driver in '/home/daniel/cvs.linuxtv.org/dvb-kernel/build-2.6' generates a file called '/home/daniel/cvs.linuxtv.mod.c' since modpost cuts every filename string at the first occurence of '.o'. Funny enough that obviously nobody ever renamed a kernel tree to something like 'linux-2.6.2.orig' and tried to remake it afterwards ;)

Here's the patch that fixes it:

modpost.c 2004-03-02 14:43:42.000000000 +0100 renamed from modpost.orig.c 2004-02-18 04:57:17.000000000 +0100 +4 -4
@@ -63,12 +63,12 @@
 new_module(char *modname)
 {
        struct module *mod;
-       char *p;
+       int len;
 
        /* strip trailing .o */
-       p = strstr(modname, ".o");
-       if (p)
-               *p = 0;
+       len = strlen (modname);
+       if (len > 2 && modname[len-2] == '.' && modname[len-1] == 'o')
+               modname[len-2] = 0;
 
        mod = NOFAIL(malloc(sizeof(*mod)));
        memset(mod, 0, sizeof(*mod));

Daniel