diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-11 17:46:56 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-11 17:46:56 +0100 |
commit | 1b6715345f2ad026482c336d2844c2d7fe64a25c (patch) | |
tree | 4cd6f48ed09e66af1f5a346883ee61013c52b4bf | |
parent | 3c75b1c34e56e89aacacc781a97c70eff37bc63d (diff) | |
download | busybox-w32-1b6715345f2ad026482c336d2844c2d7fe64a25c.tar.gz busybox-w32-1b6715345f2ad026482c336d2844c2d7fe64a25c.tar.bz2 busybox-w32-1b6715345f2ad026482c336d2844c2d7fe64a25c.zip |
modprobe-small: code shrink
function old new delta
pathname_matches_modname 80 42 -38
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | 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 cf8a3f0fe..cafbdc0b2 100644 --- a/modutils/modprobe-small.c +++ b/modutils/modprobe-small.c | |||
@@ -163,6 +163,15 @@ static char *filename2modname(const char *filename, char *modname) | |||
163 | return modname; | 163 | return modname; |
164 | } | 164 | } |
165 | 165 | ||
166 | static int pathname_matches_modname(const char *pathname, const char *modname) | ||
167 | { | ||
168 | int r; | ||
169 | char name[MODULE_NAME_LEN]; | ||
170 | filename2modname(bb_get_last_path_component_nostrip(pathname), name); | ||
171 | r = (strcmp(name, modname) == 0); | ||
172 | return r; | ||
173 | } | ||
174 | |||
166 | /* Take "word word", return malloced "word",NUL,"word",NUL,NUL */ | 175 | /* Take "word word", return malloced "word",NUL,"word",NUL,NUL */ |
167 | static char* str_2_list(const char *str) | 176 | static char* str_2_list(const char *str) |
168 | { | 177 | { |
@@ -295,18 +304,6 @@ static void parse_module(module_info *info, const char *pathname) | |||
295 | free(module_image); | 304 | free(module_image); |
296 | } | 305 | } |
297 | 306 | ||
298 | static int pathname_matches_modname(const char *pathname, const char *modname) | ||
299 | { | ||
300 | int r; | ||
301 | char name[MODULE_NAME_LEN]; | ||
302 | const char *fname = bb_get_last_path_component_nostrip(pathname); | ||
303 | const char *suffix = strrstr(fname, ".ko"); | ||
304 | safe_strncpy(name, fname, suffix - fname + 1); | ||
305 | replace(name, '-', '_'); | ||
306 | r = (strcmp(name, modname) == 0); | ||
307 | return r; | ||
308 | } | ||
309 | |||
310 | static FAST_FUNC int fileAction(const char *pathname, | 307 | static FAST_FUNC int fileAction(const char *pathname, |
311 | struct stat *sb UNUSED_PARAM, | 308 | struct stat *sb UNUSED_PARAM, |
312 | void *modname_to_match, | 309 | void *modname_to_match, |