]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: simplify x ? x : y to x ?: y where applicable 26879/head
authorFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 18 Mar 2023 12:58:27 +0000 (13:58 +0100)
committerFrantisek Sumsal <frantisek@sumsal.cz>
Sat, 18 Mar 2023 13:23:11 +0000 (14:23 +0100)
14 files changed:
src/analyze/analyze-plot.c
src/basic/strv.h
src/core/execute.c
src/core/service.c
src/core/transaction.c
src/coredump/coredump.c
src/fundamental/bootspec-fundamental.c
src/journal-remote/journal-gatewayd.c
src/journal-remote/journal-upload.c
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd/sd-device/device-enumerator.c
src/libsystemd/sd-event/event-util.c
src/nspawn/nspawn.c
src/shared/bus-wait-for-jobs.c

index 0f39484f92b5c6fb3f9e89356c77340621dcefca..e44b9c11f62affded0ce27177e0204ece9853451 100644 (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,
index 71ff3a4edf279418168a19c351dde5448cc2f07d..49e1c3d8b1317218aa2059502b7d0749d14f1ef2 100644 (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) {
index 39c46857b383dc56a7a2fbba038a1d73195862db..093d1ad5b474514cd96d69b180138ab3acf5e3b3 100644 (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;
         }
index 0481416f2282c080d015bb1a9c9627db236c5c04..addd4e66a730eb9a9945eed3f0c5adeda38e1d58 100644 (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);
 }
index a6fd184e33e78d1b7a0207422dc8e91309faf626..7d0e1ecc5e2ad454dee9b515a6fee30bf7dbba20 100644 (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
index e715fd232b777908302be5b9ca50640d2b374b62..266471a9c8282291f1672fc3f92c8cec514aa364 100644 (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(
index 4ba7c4c28d32bd79d34c971321ff53487b07e1e6..b2841e3342406ad2ae0359fe1b7e3a94be0831e6 100644 (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)
index a792c75ccaf4ab4e8976c1f8c4497a2c3c87c7dc..b6e8469922f9bd75129439dcd7676df301b37d3e 100644 (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)
index e42516c7990edc08c0b6fb96596ae5fa5fcf3f94..b9b310b6644aa2af2b51eb87a8d9e61ae3612840 100644 (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;
 }
 
index e482450cd4d7a28fbf2b0afe34b8dc5731d387dc..cffe7ba917dfdcdb0231d601c62d2a1368c5bb75 100644 (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
index a583a37dab22d02d8d98a221a8eb157aa9da981c..0bd2c89eb6e4e247d4e518427509a0f20f299ec2 100644 (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);
index 9863b07653f71a005cb6669a753e5d2d88a044d4..d93d8865ecf3017b9cfc8bdb7992d08276d94f5e 100644 (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);
index 13d744870db49b98f6b2ace786079130f9a05e78..7122902aa0291235e806ad0482bc73a40a8ac41a 100644 (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));
index 10e3a8e269ee59316f3effe9fc5238d39952cc23..969c62979f046b32eae51b3408384f3822917733 100644 (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)) {