summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Mack <daniel@zonque.org>2015-09-25 13:36:54 +0200
committerDaniel Mack <daniel@zonque.org>2015-09-30 11:41:03 +0200
commit5cfee41459d54e13fd61238a0440cd4453421ed6 (patch)
tree1635065a8f9d9c0950aabef6fe37a50b91fb4494
parent2ea69f8d5e4a83397c5050914adf6452cafa9559 (diff)
tree-wide: use strempty() where possible
Also add a Coccinell patch to detect such locations in the future.
-rw-r--r--src/libsystemd-network/sd-pppoe.c6
-rw-r--r--src/login/sysfs-show.c2
-rw-r--r--src/systemctl/systemctl.c4
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/src/libsystemd-network/sd-pppoe.c b/src/libsystemd-network/sd-pppoe.c
index 439d4eff38..f2baafdeb9 100644
--- a/src/libsystemd-network/sd-pppoe.c
+++ b/src/libsystemd-network/sd-pppoe.c
@@ -385,7 +385,7 @@ static int pppoe_send_initiation(sd_pppoe *ppp) {
return r;
log_debug("PPPoE: sent DISCOVER (Service-Name: %s)",
- ppp->service_name ? : "");
+ strempty(ppp->service_name));
pppoe_arm_timeout(ppp);
@@ -625,8 +625,8 @@ static int pppoe_handle_message(sd_pppoe *ppp, struct pppoe_hdr *packet, struct
mac->ether_addr_octet[3],
mac->ether_addr_octet[4],
mac->ether_addr_octet[5],
- ppp->tags.service_name ? : "",
- ppp->tags.ac_name ? : "");
+ strempty(ppp->tags.service_name),
+ strempty(ppp->tags.ac_name));
memcpy(&ppp->peer_mac, mac, ETH_ALEN);
diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c
index 9a9fb7622d..f38f06baf9 100644
--- a/src/login/sysfs-show.c
+++ b/src/login/sysfs-show.c
@@ -114,7 +114,7 @@ static int show_sysfs_one(
"%s%s:%s%s%s%s",
is_master ? "[MASTER] " : "",
subsystem, sysname,
- name ? " \"" : "", name ? name : "", name ? "\"" : "") < 0)
+ name ? " \"" : "", strempty(name), name ? "\"" : "") < 0)
return -ENOMEM;
free(k);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index e0a69867d2..9718ef54df 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -3524,7 +3524,7 @@ static void print_status_info(
printf("Condition: start %scondition failed%s at %s%s%s\n",
ansi_highlight_yellow(), ansi_normal(),
- s2, s1 ? "; " : "", s1 ? s1 : "");
+ s2, s1 ? "; " : "", strempty(s1));
if (i->failed_condition_trigger)
printf(" none of the trigger conditions were met\n");
else if (i->failed_condition)
@@ -3540,7 +3540,7 @@ static void print_status_info(
printf(" Assert: start %sassertion failed%s at %s%s%s\n",
ansi_highlight_red(), ansi_normal(),
- s2, s1 ? "; " : "", s1 ? s1 : "");
+ s2, s1 ? "; " : "", strempty(s1));
if (i->failed_assert_trigger)
printf(" none of the trigger assertions were met\n");
else if (i->failed_assert)
diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c
index b50f114a34..4630eb94f1 100644
--- a/src/tty-ask-password-agent/tty-ask-password-agent.c
+++ b/src/tty-ask-password-agent/tty-ask-password-agent.c
@@ -256,7 +256,7 @@ static int parse_password(const char *filename, char **wall) {
if (asprintf(&_wall,
"%s%sPassword entry required for \'%s\' (PID %u).\r\n"
"Please enter password with the systemd-tty-ask-password-agent tool!",
- *wall ? *wall : "",
+ strempty(*wall),
*wall ? "\r\n\r\n" : "",
message,
pid) < 0)