]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use strempty() where possible 1412/head
authorDaniel Mack <daniel@zonque.org>
Fri, 25 Sep 2015 11:36:54 +0000 (13:36 +0200)
committerDaniel Mack <daniel@zonque.org>
Wed, 30 Sep 2015 09:41:03 +0000 (11:41 +0200)
Also add a Coccinell patch to detect such locations in the future.

src/libsystemd-network/sd-pppoe.c
src/login/sysfs-show.c
src/systemctl/systemctl.c
src/tty-ask-password-agent/tty-ask-password-agent.c

index 439d4eff38c701cd5f7d79e03ee57909579857d5..f2baafdeb97bc9b5a4bb356a83630ea80306b268 100644 (file)
@@ -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);
 
index 9a9fb7622d1732abb69576101105da5328fd02e4..f38f06baf9dec578b42dbd298f52e7dd91c23f0d 100644 (file)
@@ -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);
index e0a69867d2a3dd898b99ba87778a0e96dabdbef0..9718ef54df1885685bb70161b143767eb81683bd 100644 (file)
@@ -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)
index b50f114a34c02e610e588f52d11a8d54b6ae2870..4630eb94f14fede12ac8550ceb2095ce74a54fbe 100644 (file)
@@ -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)