summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/install.c23
-rw-r--r--src/shared/machine-image.c3
-rw-r--r--src/shared/ptyfwd.c3
3 files changed, 10 insertions, 19 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index f44f80560a..d33a658d0a 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -214,8 +214,8 @@ static int path_is_config(const LookupPaths *p, const char *path) {
assert(p);
assert(path);
- /* Note that we do *not* have generic checks for /etc or /run in place, since with them we couldn't discern
- * configuration from transient or generated units */
+ /* Note that we do *not* have generic checks for /etc or /run in place, since with
+ * them we couldn't discern configuration from transient or generated units */
parent = dirname_malloc(path);
if (!parent)
@@ -232,8 +232,8 @@ static int path_is_runtime(const LookupPaths *p, const char *path) {
assert(p);
assert(path);
- /* Everything in /run is considered runtime. On top of that we also add explicit checks for the various runtime
- * directories, as safety net. */
+ /* Everything in /run is considered runtime. On top of that we also add
+ * explicit checks for the various runtime directories, as safety net. */
rpath = skip_root(p, path);
if (rpath && path_startswith(rpath, "/run"))
@@ -1097,7 +1097,7 @@ static int config_parse_default_instance(
UnitFileInstallInfo *i = data;
const char *name;
- char *printed;
+ _cleanup_free_ char *printed = NULL;
int r;
assert(filename);
@@ -1117,15 +1117,10 @@ static int config_parse_default_instance(
if (r < 0)
return r;
- if (!unit_instance_is_valid(printed)) {
- free(printed);
+ if (!unit_instance_is_valid(printed))
return -EINVAL;
- }
-
- free(i->default_instance);
- i->default_instance = printed;
- return 0;
+ return free_and_replace(i->default_instance, printed);
}
static int unit_file_load(
@@ -1371,9 +1366,7 @@ static int install_info_follow(
if (!streq(basename(i->symlink_target), i->name))
return -EXDEV;
- free(i->path);
- i->path = i->symlink_target;
- i->symlink_target = NULL;
+ free_and_replace(i->path, i->symlink_target);
i->type = _UNIT_FILE_TYPE_INVALID;
return unit_file_load_or_readlink(c, i, i->path, root_dir, flags);
diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c
index 529d89ee2a..060f8d50c7 100644
--- a/src/shared/machine-image.c
+++ b/src/shared/machine-image.c
@@ -62,8 +62,7 @@ Image *image_unref(Image *i) {
free(i->name);
free(i->path);
- free(i);
- return NULL;
+ return mfree(i);
}
static char **image_settings_path(Image *image) {
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 24055e772b..293c6673fc 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -463,8 +463,7 @@ int pty_forward_new(
PTYForward *pty_forward_free(PTYForward *f) {
pty_forward_disconnect(f);
- free(f);
- return NULL;
+ return mfree(f);
}
int pty_forward_get_last_char(PTYForward *f, char *ch) {