summaryrefslogtreecommitdiff
path: root/src/hostname/hostnamed.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-05-30 17:59:43 +0200
committerLennart Poettering <lennart@poettering.net>2016-05-30 17:59:43 +0200
commit3c6f7c340237262b560586cf7cf06be957d4352f (patch)
tree6eb58f6d2ef4843256139d939dbcbc91da40734c /src/hostname/hostnamed.c
parentc6f8d17de0c36f94213496e2c9fd013f113ebe08 (diff)
util-lib: make localed's nonempty() generic, rename it to empty_to_null() and make use of it everywhere
Diffstat (limited to 'src/hostname/hostnamed.c')
-rw-r--r--src/hostname/hostnamed.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/hostname/hostnamed.c b/src/hostname/hostnamed.c
index d11756e615..fe8bb62752 100644
--- a/src/hostname/hostnamed.c
+++ b/src/hostname/hostnamed.c
@@ -479,8 +479,7 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
if (r < 0)
return r;
- if (isempty(name))
- name = NULL;
+ name = empty_to_null(name);
if (streq_ptr(name, c->data[PROP_STATIC_HOSTNAME]))
return sd_bus_reply_method_return(m, NULL);
@@ -499,9 +498,9 @@ static int method_set_static_hostname(sd_bus_message *m, void *userdata, sd_bus_
if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
- if (isempty(name)) {
+ if (isempty(name))
c->data[PROP_STATIC_HOSTNAME] = mfree(c->data[PROP_STATIC_HOSTNAME]);
- } else {
+ else {
char *h;
if (!hostname_is_valid(name, false))
@@ -546,8 +545,7 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
if (r < 0)
return r;
- if (isempty(name))
- name = NULL;
+ name = empty_to_null(name);
if (streq_ptr(name, c->data[prop]))
return sd_bus_reply_method_return(m, NULL);
@@ -570,9 +568,9 @@ static int set_machine_info(Context *c, sd_bus_message *m, int prop, sd_bus_mess
if (r == 0)
return 1; /* No authorization for now, but the async polkit stuff will call us again when it has it */
- if (isempty(name)) {
+ if (isempty(name))
c->data[prop] = mfree(c->data[prop]);
- } else {
+ else {
char *h;
/* The icon name might ultimately be used as file