aboutsummaryrefslogtreecommitdiff
path: root/modutils/depmod.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2015-01-24 22:30:30 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2015-01-24 22:30:30 +0100
commitcc70b6f8b6c6441e1c48690c7885700a2d389946 (patch)
tree4ed5b3b75f89ff88d28f639c0911507c07c09c77 /modutils/depmod.c
parent86031a5ffd106b8128f5763d32c273b96875f707 (diff)
downloadbusybox-w32-cc70b6f8b6c6441e1c48690c7885700a2d389946.tar.gz
busybox-w32-cc70b6f8b6c6441e1c48690c7885700a2d389946.tar.bz2
busybox-w32-cc70b6f8b6c6441e1c48690c7885700a2d389946.zip
depmod: simple memory optimization
function old new delta filename2modname 67 86 +19 parse_module 374 351 -23 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'modutils/depmod.c')
-rw-r--r--modutils/depmod.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/modutils/depmod.c b/modutils/depmod.c
index a41b3e440..37a8482d9 100644
--- a/modutils/depmod.c
+++ b/modutils/depmod.c
@@ -33,7 +33,6 @@ typedef struct module_info {
33static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM, 33static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARAM,
34 void *data, int depth UNUSED_PARAM) 34 void *data, int depth UNUSED_PARAM)
35{ 35{
36 char modname[MODULE_NAME_LEN];
37 module_info **first = (module_info **) data; 36 module_info **first = (module_info **) data;
38 char *image, *ptr; 37 char *image, *ptr;
39 module_info *info; 38 module_info *info;
@@ -51,11 +50,10 @@ static int FAST_FUNC parse_module(const char *fname, struct stat *sb UNUSED_PARA
51 50
52 info->dnext = info->dprev = info; 51 info->dnext = info->dprev = info;
53 info->name = xstrdup(fname + 2); /* skip "./" */ 52 info->name = xstrdup(fname + 2); /* skip "./" */
54 info->modname = xstrdup( 53 info->modname = filename2modname(
55 filename2modname(
56 bb_get_last_path_component_nostrip(fname), 54 bb_get_last_path_component_nostrip(fname),
57 modname 55 NULL
58 )); 56 );
59 for (ptr = image; ptr < image + len - 10; ptr++) { 57 for (ptr = image; ptr < image + len - 10; ptr++) {
60 if (strncmp(ptr, "depends=", 8) == 0) { 58 if (strncmp(ptr, "depends=", 8) == 0) {
61 char *u; 59 char *u;
@@ -250,11 +248,12 @@ int depmod_main(int argc UNUSED_PARAM, char **argv)
250 const char *fname = bb_basename(m->name); 248 const char *fname = bb_basename(m->name);
251 filename2modname(fname, modname); 249 filename2modname(fname, modname);
252 while (m->aliases) { 250 while (m->aliases) {
253 /* Last word can well be m->modname instead, 251 /*
254 * but depmod from module-init-tools 3.4 252 * Last word used to be a basename
255 * uses module basename, i.e., no s/-/_/g. 253 * (filename with path and .ko.* stripped)
256 * (pathname and .ko.* are still stripped) 254 * at the time of module-init-tools 3.4.
257 * Mimicking that... */ 255 * kmod v.12 uses module name, i.e., s/-/_/g.
256 */
258 printf("alias %s %s\n", 257 printf("alias %s %s\n",
259 (char*)llist_pop(&m->aliases), 258 (char*)llist_pop(&m->aliases),
260 modname); 259 modname);