]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Replace empty ternary with helper method
authorDaniel Lockyer <thisisdaniellockyer@gmail.com>
Fri, 24 Nov 2017 09:31:08 +0000 (09:31 +0000)
committerDaniel Lockyer <thisisdaniellockyer@gmail.com>
Fri, 24 Nov 2017 09:31:08 +0000 (09:31 +0000)
src/network/networkd-manager.c
src/nspawn/nspawn-mount.c
src/resolve/resolved-dns-rr.c
src/shared/install-printf.c

index 780f17392e4ce70bfebe080d72eeadb8315ed2b5..93a2571ec2d1f3409a297eef8d6bbc5f7109485b 100644 (file)
@@ -606,7 +606,7 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
         case RTM_NEWADDR:
                 if (address)
                         log_link_debug(link, "Updating address: %s/%u (valid %s%s)", buf, prefixlen,
-                                       valid_str ? "for " : "forever", valid_str ?: "");
+                                       valid_str ? "for " : "forever", strempty(valid_str));
                 else {
                         /* An address appeared that we did not request */
                         r = address_add_foreign(link, family, &in_addr, prefixlen, &address);
@@ -615,7 +615,7 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
                                 return 0;
                         } else
                                 log_link_debug(link, "Adding address: %s/%u (valid %s%s)", buf, prefixlen,
-                                               valid_str ? "for " : "forever", valid_str ?: "");
+                                               valid_str ? "for " : "forever", strempty(valid_str));
                 }
 
                 address_update(address, flags, scope, &cinfo);
@@ -626,11 +626,11 @@ int manager_rtnl_process_address(sd_netlink *rtnl, sd_netlink_message *message,
 
                 if (address) {
                         log_link_debug(link, "Removing address: %s/%u (valid %s%s)", buf, prefixlen,
-                                       valid_str ? "for " : "forever", valid_str ?: "");
+                                       valid_str ? "for " : "forever", strempty(valid_str));
                         address_drop(address);
                 } else
                         log_link_warning(link, "Removing non-existent address: %s/%u (valid %s%s)", buf, prefixlen,
-                                         valid_str ? "for " : "forever", valid_str ?: "");
+                                         valid_str ? "for " : "forever", strempty(valid_str));
 
                 break;
         default:
index 9e6f573ae3434770bb66bbc25d66ac3205180797..e6a92411ad9b132153b4555ca355c988f7b38266 100644 (file)
@@ -368,7 +368,7 @@ static int tmpfs_patch_options(
                 assert(uid_shift != UID_INVALID);
 
                 if (asprintf(&buf, "%s%suid=" UID_FMT ",gid=" UID_FMT,
-                             options ?: "", options ? "," : "",
+                             strempty(options), options ? "," : "",
                              uid_shift, uid_shift) < 0)
                         return -ENOMEM;
 
@@ -379,7 +379,7 @@ static int tmpfs_patch_options(
         if (selinux_apifs_context) {
                 char *t;
 
-                t = strjoin(options ?: "", options ? "," : "",
+                t = strjoin(strempty(options), options ? "," : "",
                             "context=\"", selinux_apifs_context, "\"");
                 free(buf);
                 if (!t)
index 019935b58dcb6e64e09ade349703be329ae3c7a3..b44ab00bb5c9f8495a47c49ea230954ba6ba5ed3 100644 (file)
@@ -335,8 +335,8 @@ char* dns_resource_key_to_string(const DnsResourceKey *key, char *buf, size_t bu
 
         snprintf(buf, buf_size, "%s %s%s%.0u %s%s%.0u",
                  dns_resource_key_name(key),
-                 c ?: "", c ? "" : "CLASS", c ? 0 : key->class,
-                 t ?: "", t ? "" : "TYPE", t ? 0 : key->class);
+                 strempty(c), c ? "" : "CLASS", c ? 0 : key->class,
+                 strempty(t), t ? "" : "TYPE", t ? 0 : key->class);
 
         return ans;
 }
index 596f7e46b6cb0838b703ec1bfb341c4ff6852d56..f8d0e53ecadf642ca29095f56147d5cd15f43221 100644 (file)
@@ -94,7 +94,7 @@ static int specifier_instance(char specifier, void *data, void *userdata, char *
                 return r;
 
         if (isempty(instance)) {
-                r = free_and_strdup(&instance, i->default_instance ?: "");
+                r = free_and_strdup(&instance, strempty(i->default_instance));
                 if (r < 0)
                         return r;
         }