mirror of
https://github.com/systemd/systemd.git
synced 2025-01-27 18:04:05 +03:00
Replace empty ternary with helper method
This commit is contained in:
parent
71050acb68
commit
87e4e28dcf
@ -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:
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user