modprobe: use basename_r()
authorIsaac Dunham <ibid.ag@gmail.com>
Wed, 5 Aug 2015 02:34:00 +0000 (19:34 -0700)
committerRob Landley <rob@landley.net>
Sat, 8 Aug 2015 21:59:20 +0000 (16:59 -0500)
toys/pending/modprobe.c

index 12d2d78..10bd578 100644 (file)
@@ -65,14 +65,12 @@ struct module_s {
 static char *path2mod(char *file, char *mod)
 {
   int i;
-  char *from, *lslash;
+  char *from;
 
   if (!file) return NULL;
   if (!mod) mod = xmalloc(MODNAME_LEN);
        
-  lslash = strrchr(file, '/');
-  if (!lslash || (lslash == file && !lslash[1])) from = file;
-  else from = lslash + 1;
+  from = basename_r(file);
   
   for (i = 0; i < (MODNAME_LEN-1) && from[i] && from[i] != '.'; i++)
     mod[i] = (from[i] == '-') ? '_' : from[i];