@@ -907,23 +907,35 @@ static void mod_free(struct mod *mod)
free(mod);
}
-static int mod_add_dependency(struct mod *mod, struct symbol *sym)
+static int mod_add_dep_unique(struct mod *mod, struct mod *dep)
{
int err;
- DBG("%s depends on %s %s\n", mod->path, sym->name,
- sym->owner != NULL ? sym->owner->path : "(unknown)");
-
- if (sym->owner == NULL)
+ if (dep == NULL)
return 0;
- err = array_append_unique(&mod->deps, sym->owner);
+ err = array_append_unique(&mod->deps, dep);
if (err == -EEXIST)
return 0;
if (err < 0)
return err;
- sym->owner->users++;
+ dep->users++;
+
+ return 1;
+}
+
+static int mod_add_dependency(struct mod *mod, struct symbol *sym)
+{
+ int err;
+
+ DBG("%s depends on %s %s\n", mod->path, sym->name,
+ sym->owner != NULL ? sym->owner->path : "(unknown)");
+
+ err = mod_add_dep_unique(mod, sym->owner);
+ if (err <= 0)
+ return err;
+
SHOW("%s needs \"%s\": %s\n", mod->path, sym->name, sym->owner->path);
return 0;
}