assert(u);
assert(path);
- if (!(d = opendir(path))) {
+ d = opendir(path);
+ if (!d) {
if (errno == ENOENT)
return 0;
if (ignore_file(de->d_name))
continue;
- if (asprintf(&f, "%s/%s", path, de->d_name) < 0) {
+ f = join(path, "/", de->d_name, NULL);
+ if (!f) {
r = -ENOMEM;
goto finish;
}
free(f);
if (r < 0)
- goto finish;
+ log_error("Cannot add dependency %s to %s, ignoring: %s", de->d_name, u->meta.id, strerror(-r));
}
r = 0;
assert(name);
assert(suffix);
- if (asprintf(&path, "%s/%s%s", unit_path, name, suffix) < 0)
+ path = join(unit_path, "/", name, suffix, NULL);
+ if (!path)
return -ENOMEM;
if (u->meta.manager->unit_path_cache &&
char *template;
/* Also try the template dir */
- if (!(template = unit_name_template(name)))
+ template = unit_name_template(name);
+ if (!template)
return -ENOMEM;
- r = asprintf(&path, "%s/%s%s", unit_path, template, suffix);
+ path = join(unit_path, "/", template, suffix, NULL);
free(template);
- if (r < 0)
+ if (!path)
return -ENOMEM;
if (u->meta.manager->unit_path_cache &&
STRV_FOREACH(p, u->meta.manager->lookup_paths.unit_path) {
int r;
- if ((r = process_dir(u, *p, t, ".wants", UNIT_WANTS)) < 0)
+ r = process_dir(u, *p, t, ".wants", UNIT_WANTS);
+ if (r < 0)
return r;
- if ((r = process_dir(u, *p, t, ".requires", UNIT_REQUIRES)) < 0)
+ r = process_dir(u, *p, t, ".requires", UNIT_REQUIRES);
+ if (r < 0)
return r;
}
}