summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2023-03-18 13:58:27 +0100
committerFrantisek Sumsal <frantisek@sumsal.cz>2023-03-18 14:23:11 +0100
commit1da3cb81411e7c3d698fe20f95cc1c8145f2941c (patch)
tree520f0df7135e25623ec9c28830333aaa062c3442
parent64254629f7e062a39156ee95428d46f2a1e82e06 (diff)
downloadsystemd-1da3cb81411e7c3d698fe20f95cc1c8145f2941c.tar.gz
tree-wide: simplify x ? x : y to x ?: y where applicable
-rw-r--r--src/analyze/analyze-plot.c2
-rw-r--r--src/basic/strv.h2
-rw-r--r--src/core/execute.c2
-rw-r--r--src/core/service.c2
-rw-r--r--src/core/transaction.c2
-rw-r--r--src/coredump/coredump.c2
-rw-r--r--src/fundamental/bootspec-fundamental.c2
-rw-r--r--src/journal-remote/journal-gatewayd.c2
-rw-r--r--src/journal-remote/journal-upload.c2
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c2
-rw-r--r--src/libsystemd/sd-device/device-enumerator.c2
-rw-r--r--src/libsystemd/sd-event/event-util.c2
-rw-r--r--src/nspawn/nspawn.c2
-rw-r--r--src/shared/bus-wait-for-jobs.c4
14 files changed, 15 insertions, 15 deletions
diff --git a/src/analyze/analyze-plot.c b/src/analyze/analyze-plot.c
index 0f39484f92..e44b9c11f6 100644
--- a/src/analyze/analyze-plot.c
+++ b/src/analyze/analyze-plot.c
@@ -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,
diff --git a/src/basic/strv.h b/src/basic/strv.h
index 71ff3a4edf..49e1c3d8b1 100644
--- a/src/basic/strv.h
+++ b/src/basic/strv.h
@@ -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) {
diff --git a/src/core/execute.c b/src/core/execute.c
index 39c46857b3..093d1ad5b4 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -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;
}
diff --git a/src/core/service.c b/src/core/service.c
index 0481416f22..addd4e66a7 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -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);
}
diff --git a/src/core/transaction.c b/src/core/transaction.c
index a6fd184e33..7d0e1ecc5e 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -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
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index e715fd232b..266471a9c8 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -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(
diff --git a/src/fundamental/bootspec-fundamental.c b/src/fundamental/bootspec-fundamental.c
index 4ba7c4c28d..b2841e3342 100644
--- a/src/fundamental/bootspec-fundamental.c
+++ b/src/fundamental/bootspec-fundamental.c
@@ -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)
diff --git a/src/journal-remote/journal-gatewayd.c b/src/journal-remote/journal-gatewayd.c
index a792c75cca..b6e8469922 100644
--- a/src/journal-remote/journal-gatewayd.c
+++ b/src/journal-remote/journal-gatewayd.c
@@ -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)
diff --git a/src/journal-remote/journal-upload.c b/src/journal-remote/journal-upload.c
index e42516c799..b9b310b664 100644
--- a/src/journal-remote/journal-upload.c
+++ b/src/journal-remote/journal-upload.c
@@ -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;
}
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index e482450cd4..cffe7ba917 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -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
diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c
index a583a37dab..0bd2c89eb6 100644
--- a/src/libsystemd/sd-device/device-enumerator.c
+++ b/src/libsystemd/sd-device/device-enumerator.c
@@ -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);
diff --git a/src/libsystemd/sd-event/event-util.c b/src/libsystemd/sd-event/event-util.c
index 9863b07653..d93d8865ec 100644
--- a/src/libsystemd/sd-event/event-util.c
+++ b/src/libsystemd/sd-event/event-util.c
@@ -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);
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 13d744870d..7122902aa0 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -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));
diff --git a/src/shared/bus-wait-for-jobs.c b/src/shared/bus-wait-for-jobs.c
index 10e3a8e269..969c62979f 100644
--- a/src/shared/bus-wait-for-jobs.c
+++ b/src/shared/bus-wait-for-jobs.c
@@ -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)) {