ubox/logd: free regex's on log_shutdown() call
[project/ubox.git] / kmodloader.c
index 2dc795e..5ba75c1 100644 (file)
@@ -450,7 +450,7 @@ static int deps_available(struct module *m, int verbose)
        char *dep;
        int err = 0;
 
-       if (!strcmp(m->depends, "-") || !strcmp(m->depends, ""))
+       if (!m->depends || !strcmp(m->depends, "-") || !strcmp(m->depends, ""))
                return 0;
 
        dep = m->depends;
@@ -609,7 +609,10 @@ static int main_insmod(int argc, char **argv)
                cur += sprintf(cur, "%s", argv[i]);
        }
 
-       init_module_folders();
+       if (init_module_folders()) {
+               fprintf(stderr, "falied to find the folder holding the modules\n");
+               return -1;
+       }
 
        if (get_module_path(argv[1])) {
                name = argv[1];
@@ -658,15 +661,26 @@ static int main_rmmod(int argc, char **argv)
 static int main_lsmod(int argc, char **argv)
 {
        struct module *m;
+       char *dep;
 
        if (scan_loaded_modules())
                return -1;
 
        avl_for_each_element(&modules, m, avl)
-               if (m->state == LOADED)
-                       printf("%-20s%8d%3d %s\n",
-                               m->name, m->size, m->usage,
-                               (*m->depends == '-') ? ("") : (m->depends));
+               if (m->state == LOADED) {
+                       printf("%-20s%8d%3d ",
+                               m->name, m->size, m->usage);
+                       if (m->depends && strcmp(m->depends, "-") && strcmp(m->depends, "")) {
+                               dep = m->depends;
+                               while (*dep) {
+                                       printf("%s", dep);
+                                       dep = dep + strlen(dep) + 1;
+                                       if (*dep)
+                                               printf(",");
+                               }
+                       }
+                       printf("\n");
+               }
 
        free_modules();