summaryrefslogtreecommitdiff
path: root/src/hostname/hostnamed.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-07-11 15:31:49 +0200
committerLennart Poettering <lennart@poettering.net>2014-07-11 15:35:22 +0200
commitd77ab3f7e3e56a4fd370caff6347bf4e56e51dec (patch)
tree67522f3713e5c0ec7fc28fa41781bfd7ec56f51f /src/hostname/hostnamed.c
parent46b131574fdd7d77c15a0919ca9010cad7aa6ac7 (diff)
hostnamed: minor modernization
Diffstat (limited to 'src/hostname/hostnamed.c')
-rw-r--r--src/hostname/hostnamed.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index a4849b3673..19ab500533 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -336,7 +336,8 @@ static int context_write_data_machine_info(Context *c) {
return r;
for (p = PROP_PRETTY_HOSTNAME; p <= PROP_DEPLOYMENT; p++) {
- char *t, **u;
+ _cleanup_free_ char *t = NULL;
+ char **u;
assert(name[p]);
@@ -345,12 +346,11 @@ static int context_write_data_machine_info(Context *c) {
continue;
}
- if (asprintf(&t, "%s=%s", name[p], strempty(c->data[p])) < 0)
+ t = strjoin(name[p], "=", c->data[p], NULL);
+ if (!t)
return -ENOMEM;
u = strv_env_set(l, t);
- free(t);
-
if (!u)
return -ENOMEM;
@@ -359,7 +359,6 @@ static int context_write_data_machine_info(Context *c) {
}
if (strv_isempty(l)) {
-
if (unlink("/etc/machine-info") < 0)
return errno == ENOENT ? 0 : -errno;