assert(same_name_link);
fd = open(config_path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW);
- if (fd < 0)
+ if (fd < 0) {
+ if (errno == ENOENT)
+ return 0;
return -errno;
+ }
/* This takes possession of fd and closes it */
return find_symlinks_fd(name, fd, config_path, config_path, same_name_link);
UnitFileState *state) {
int r;
- char *path;
+ char _cleanup_free_ *path = NULL;
bool same_name_link_runtime = false, same_name_link = false;
assert(scope >= 0);
return r;
r = find_symlinks(name, path, &same_name_link_runtime);
- free(path);
-
if (r < 0)
return r;
else if (r > 0) {
return r;
r = find_symlinks(name, path, &same_name_link);
- free(path);
-
if (r < 0)
return r;
else if (r > 0) {
UnitFileChange **changes,
unsigned *n_changes) {
- char **i, *prefix;
+ char **i;
+ char _cleanup_free_ *prefix;
int r;
assert(scope >= 0);
return r;
STRV_FOREACH(i, files) {
- char *path;
+ char _cleanup_free_ *path = NULL;
if (!unit_name_is_valid(*i, true)) {
if (r == 0)
if (symlink("/dev/null", path) >= 0) {
add_file_change(changes, n_changes, UNIT_FILE_SYMLINK, path, "/dev/null");
- free(path);
continue;
}
if (errno == EEXIST) {
- if (null_or_empty_path(path) > 0) {
- free(path);
+ if (null_or_empty_path(path) > 0)
continue;
- }
if (force) {
unlink(path);
add_file_change(changes, n_changes, UNIT_FILE_UNLINK, path, NULL);
add_file_change(changes, n_changes, UNIT_FILE_SYMLINK, path, "/dev/null");
- free(path);
continue;
}
}
if (r == 0)
r = -errno;
}
-
- free(path);
}
- free(prefix);
-
return r;
}