2.6.4-rc2: scripts/modpost.c
PATCH 1/1 2.6.4-rc2: scripts/modpost.c
(This is is a repost - now with a patch for 2.6.4-rc2).
Hi,
as I found out, it's impossible to use the build-chain tool scripts/modpost of the 2.6 kernel series to externally build modules from 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.6i/' generates a file called '/home/daniel/cvs.linuxtv.mod.c' since modpost cuts every filename string at the first occurence of '.o', not only the 'trailing .o', as the comment says.
Here's the patch for 2.6.4-rc2:
scripts/modpost.c 2004-03-04 11:23:08.000000000 +0100 renamed from scripts/modpost.c 2004-03-04 11:40:21.000000000 +0100 +4 -4
@@ -63,16 +63,16 @@ new_module(char *modname) { struct module *mod; - char *p; + int len; mod = NOFAIL(malloc(sizeof(*mod))); memset(mod, 0, sizeof(*mod)); mod->name = NOFAIL(strdup(modname)); /* strip trailing .o */ - p = strstr(mod->name, ".o"); - if (p) - *p = 0; + len = strlen(mod->name); + if (len > 2 && mod->name[len-2] == '.' && mod->name[len-1] == 'o') + mod->name[len-2] = 0; /* add to list */ mod->next = modules;
Daniel
Quoted 11 lines · Daniel Mack
as I found out, it's impossible to use the build-chain tool
scripts/modpost
of the 2.6 kernel series to externally build modules from 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.6i/' generates a file called '/home/daniel/cvs.linuxtv.mod.c' since modpost cuts every filename string at the first occurence of '.o', not only the 'trailing .o', as the comment says.
I tried your patch the other day and had weird compilation errors with x86
allyesconfig. Could you check that?
Quoted 2 lines · Andrew Morton
I tried your patch the other day and had weird compilation errors with x86
allyesconfig. Could you check that?
I tried this patch on several hosts. Both the modpost tool and all modules were built fine. What compilation errors did you encounter?
Daniel
Quoted 13 lines · Daniel Mack
scripts/modpost.c 2004-03-04 11:23:08.000000000 +0100 renamed from scripts/modpost.c 2004-03-04 11:40:21.000000000 +0100 +1
-1@@ -63,16 +63,16 @@ new_module(char *modname) { struct module *mod; - char *p; + int len; mod = NOFAIL(malloc(sizeof(*mod))); memset(mod, 0, sizeof(*mod)); mod->name = NOFAIL(strdup(modname));
scripts/modpost.c 2004-03-04 11:23:08.000000000 +0100 line 78
Quoted 10 lines
scripts/modpost.c 2004-03-04 11:23:08.000000000 +0100 renamed from scripts/modpost.c 2004-03-04 11:40:21.000000000 +0100 +3
-3/* strip trailing .o */ - p = strstr(mod->name, ".o"); - if (p) - *p = 0; + len = strlen(mod->name); + if (len > 2 && mod->name[len-2] == '.' && mod->name[len-1] == 'o') + mod->name[len-2] = 0; /* add to list */ mod->next = modules;
Please use strrchr(mod->name, '.'). More readable, simpler, and ever arguably more correct.
Rusty.
Signature · 1 line
Anyone who quotes me in their signature is an idiot -- Rusty Russell
Quoted 23 lines · Rusty Russell
Quoted 21 lines · Daniel Mack
scripts/modpost.c 2004-03-04 11:23:08.000000000 +0100 renamed from scripts/modpost.c 2004-03-04 11:40:21.000000000 +0100 +4
-4@@ -63,16 +63,16 @@ new_module(char *modname) { struct module *mod; - char *p; + int len; mod = NOFAIL(malloc(sizeof(*mod))); memset(mod, 0, sizeof(*mod)); mod->name = NOFAIL(strdup(modname)); /* strip trailing .o */ - p = strstr(mod->name, ".o"); - if (p) - *p = 0; + len = strlen(mod->name); + if (len > 2 && mod->name[len-2] == '.' && mod->name[len-1] == 'o') + mod->name[len-2] = 0;
Quoted 5 lines
scripts/modpost.c 2004-03-04 11:23:08.000000000 +0100 line 78
Quoted 2 lines
scripts/modpost.c 2004-03-04 11:23:08.000000000 +0100 renamed from scripts/modpost.c 2004-03-04 11:40:21.000000000 +0100 +0
-0/* add to list */ mod->next = modules;Please use
strrchr(mod->name, '.'). More readable, simpler, and ever arguably more correct.
OK.
I have some pending modpost changes (to fix MODULE_VERSION with O=), so I will include the fix there.
Sam