summaryrefslogtreecommitdiff
path: root/src/hostname/hostnamed.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/hostname/hostnamed.c')
-rw-r--r--src/hostname/hostnamed.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index e90ae54156..cb837e9d03 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -64,8 +64,7 @@ static void context_reset(Context *c) {
assert(c);
for (p = 0; p < _PROP_MAX; p++) {
- free(c->data[p]);
- c->data[p] = NULL;
+ c->data[p] = mfree(c->data[p]);
}
}
@@ -114,12 +113,11 @@ static int context_read_data(Context *c) {
"PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
"CPE_NAME", &c->data[PROP_OS_CPE_NAME],
NULL);
- if (r == -ENOENT) {
+ if (r == -ENOENT)
r = parse_env_file("/usr/lib/os-release", NEWLINE,
"PRETTY_NAME", &c->data[PROP_OS_PRETTY_NAME],
"CPE_NAME", &c->data[PROP_OS_CPE_NAME],
NULL);
- }
if (r < 0 && r != -ENOENT)
return r;
@@ -498,8 +496,7 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
if (isempty(name)) {
- free(c->data[PROP_STATIC_HOSTNAME]);
- c->data[PROP_STATIC_HOSTNAME] = NULL;
+ c->data[PROP_STATIC_HOSTNAME] = mfree(c->data[PROP_STATIC_HOSTNAME]);
} else {
char *h;
@@ -570,8 +567,7 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
if (isempty(name)) {
- free(c->data[prop]);
- c->data[prop] = NULL;
+ c->data[prop] = mfree(c->data[prop]);
} else {
char *h;