tree-wide: simplify x ? x : y to x ?: y where applicable

This commit is contained in:
Frantisek Sumsal 2023-03-18 13:58:27 +01:00
parent 64254629f7
commit 1da3cb8141
14 changed files with 15 additions and 15 deletions

View file

@ -89,7 +89,7 @@ static int acquire_host_info(sd_bus *bus, HostInfo **hi) {
}
r = bus_map_all_properties(
system_bus ? : bus,
system_bus ?: bus,
"org.freedesktop.hostname1",
"/org/freedesktop/hostname1",
hostname_map,

View file

@ -87,7 +87,7 @@ char** strv_new_ap(const char *x, va_list ap);
#define STRV_IGNORE ((const char *) POINTER_MAX)
static inline const char* STRV_IFNOTNULL(const char *x) {
return x ? x : STRV_IGNORE;
return x ?: STRV_IGNORE;
}
static inline bool strv_isempty(char * const *l) {

View file

@ -3334,7 +3334,7 @@ static int setup_smack(
if (r < 0 && !ERRNO_IS_XATTR_ABSENT(r))
return r;
r = mac_smack_apply_pid(0, exec_label ? : manager->default_smack_process_label);
r = mac_smack_apply_pid(0, exec_label ?: manager->default_smack_process_label);
if (r < 0)
return r;
}

View file

@ -4173,7 +4173,7 @@ static void service_force_watchdog(Service *s) {
return;
log_unit_error(UNIT(s), "Watchdog request (last status: %s)!",
s->status_text ? s->status_text : "<unset>");
s->status_text ?: "<unset>");
service_enter_signal(s, SERVICE_STOP_WATCHDOG, SERVICE_FAILURE_WATCHDOG);
}

View file

@ -433,7 +433,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
* find our way backwards if we want to break a cycle. We use
* a special marker for the beginning: we point to
* ourselves. */
j->marker = from ? from : j;
j->marker = from ?: j;
j->generation = generation;
/* Actual ordering of jobs depends on the unit ordering dependency and job types. We need to traverse

View file

@ -246,7 +246,7 @@ static int fix_xattr(int fd, const Context *context) {
#define filename_escape(s) xescape((s), "./ ")
static const char *coredump_tmpfile_name(const char *s) {
return s ? s : "(unnamed temporary file)";
return s ?: "(unnamed temporary file)";
}
static int fix_permissions(

View file

@ -43,7 +43,7 @@ bool bootspec_pick_name_version_sort_key(
* defined) or entry "id" string (i.e. entry file name) otherwise. */
good_name = os_pretty_name ?: (os_image_id ?: (os_name ?: os_id));
good_version = os_image_version ?: (os_version ?: (os_version_id ? : os_build_id));
good_version = os_image_version ?: (os_version ?: (os_version_id ?: os_build_id));
good_sort_key = os_image_id ?: os_id;
if (!good_name)

View file

@ -329,7 +329,7 @@ static int request_parse_range(
return r;
}
p = (colon2 ? colon2 : colon) + 1;
p = (colon2 ?: colon) + 1;
if (*p) {
r = safe_atou64(p, &m->n_entries);
if (r < 0)

View file

@ -801,7 +801,7 @@ static int open_journal(sd_journal **j) {
r = sd_journal_open(j, (arg_merge ? 0 : SD_JOURNAL_LOCAL_ONLY) | arg_journal_type);
if (r < 0)
log_error_errno(r, "Failed to open %s: %m",
arg_directory ? arg_directory : arg_file ? "files" : "journal");
arg_directory ?: (arg_file ? "files" : "journal"));
return r;
}

View file

@ -790,7 +790,7 @@ static int client_message_init(
/* seconds between sending first and last DISCOVER
* must always be strictly positive to deal with broken servers */
secs = ((time_now - client->start_time) / USEC_PER_SEC) ? : 1;
secs = ((time_now - client->start_time) / USEC_PER_SEC) ?: 1;
packet->dhcp.secs = htobe16(secs);
/* RFC2131 section 4.1

View file

@ -769,7 +769,7 @@ static int enumerator_scan_dir(
if (!relevant_sysfs_subdir(de))
continue;
if (!match_subsystem(enumerator, subsystem ? : de->d_name))
if (!match_subsystem(enumerator, subsystem ?: de->d_name))
continue;
k = enumerator_scan_dir_and_add_devices(enumerator, basedir, de->d_name, subdir);

View file

@ -46,7 +46,7 @@ int event_reset_time(
return log_debug_errno(SYNTHETIC_ERRNO(EINVAL),
"sd-event: Current clock id %i of event source \"%s\" is different from specified one %i.",
(int)c,
strna((*s)->description ? : description),
strna((*s)->description ?: description),
(int)clock);
r = sd_event_source_set_time(*s, usec);

View file

@ -3483,7 +3483,7 @@ static int inner_child(
if (arg_user || !uid_is_valid(arg_uid) || arg_uid == 0)
if (asprintf(envp + n_env++, "USER=%s", arg_user ?: "root") < 0 ||
asprintf(envp + n_env++, "LOGNAME=%s", arg_user ? arg_user : "root") < 0)
asprintf(envp + n_env++, "LOGNAME=%s", arg_user ?: "root") < 0)
return log_oom();
assert(!sd_id128_is_null(arg_uuid));

View file

@ -186,8 +186,8 @@ static void log_job_error_with_service_result(const char* service, const char *r
_cleanup_free_ char *t = NULL;
t = strv_join((char**) extra_args, " ");
systemctl = strjoina("systemctl ", t ? : "<args>");
journalctl = strjoina("journalctl ", t ? : "<args>");
systemctl = strjoina("systemctl ", t ?: "<args>");
journalctl = strjoina("journalctl ", t ?: "<args>");
}
if (!isempty(result)) {