lkml.org 
[lkml]   [2004]   [Mar]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] 2.6.4-rc2: scripts/modpost.c
From
Date
On Thu, 2004-03-04 at 22:37, Daniel Mack wrote:

> --- linux-2.6.4-rc2.orig/scripts/modpost.c 2004-03-04 11:40:21.000000000 +0100
> +++ linux-2.6.4-rc2/scripts/modpost.c 2004-03-04 11:23:08.000000000 +0100
> @@ -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;

Please use strrchr(mod->name, '.'). More readable, simpler, and ever
arguably more correct.

Rusty.
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 14:01    [W:0.087 / U:0.040 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site