[git commit] modprobe-small: code shrink

Denys Vlasenko vda.linux at googlemail.com
Sun Jan 11 16:46:56 UTC 2015


commit: http://git.busybox.net/busybox/commit/?id=1b6715345f2ad026482c336d2844c2d7fe64a25c
branch: http://git.busybox.net/busybox/commit/?id=refs/heads/master

function                                             old     new   delta
pathname_matches_modname                              80      42     -38

Signed-off-by: Denys Vlasenko <vda.linux at googlemail.com>
---
 modutils/modprobe-small.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/modutils/modprobe-small.c b/modutils/modprobe-small.c
index cf8a3f0..cafbdc0 100644
--- a/modutils/modprobe-small.c
+++ b/modutils/modprobe-small.c
@@ -163,6 +163,15 @@ static char *filename2modname(const char *filename, char *modname)
 	return modname;
 }
 
+static int pathname_matches_modname(const char *pathname, const char *modname)
+{
+	int r;
+	char name[MODULE_NAME_LEN];
+	filename2modname(bb_get_last_path_component_nostrip(pathname), name);
+	r = (strcmp(name, modname) == 0);
+	return r;
+}
+
 /* Take "word word", return malloced "word",NUL,"word",NUL,NUL */
 static char* str_2_list(const char *str)
 {
@@ -295,18 +304,6 @@ static void parse_module(module_info *info, const char *pathname)
 	free(module_image);
 }
 
-static int pathname_matches_modname(const char *pathname, const char *modname)
-{
-	int r;
-	char name[MODULE_NAME_LEN];
-	const char *fname = bb_get_last_path_component_nostrip(pathname);
-	const char *suffix = strrstr(fname, ".ko");
-	safe_strncpy(name, fname, suffix - fname + 1);
-	replace(name, '-', '_');
-	r = (strcmp(name, modname) == 0);
-	return r;
-}
-
 static FAST_FUNC int fileAction(const char *pathname,
 		struct stat *sb UNUSED_PARAM,
 		void *modname_to_match,


More information about the busybox-cvs mailing list