Replace empty ternary with helper method

This commit is contained in:
Daniel Lockyer 2017-11-24 09:31:08 +00:00
parent 71050acb68
commit 87e4e28dcf
4 changed files with 9 additions and 9 deletions

View 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:

View 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)

View 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;
}

View 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;
}