]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: use UINT64_MAX or friends
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 3 Mar 2021 04:07:10 +0000 (13:07 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 4 Mar 2021 22:10:13 +0000 (07:10 +0900)
150 files changed:
src/analyze/analyze.c
src/basic/audit-util.h
src/basic/btrfs-util.c
src/basic/capability-util.c
src/basic/capability-util.h
src/basic/cgroup-util.c
src/basic/cgroup-util.h
src/basic/copy.c
src/basic/device-nodes.c
src/basic/env-file.c
src/basic/escape.c
src/basic/extract-word.c
src/basic/format-util.c
src/basic/hexdecoct.c
src/basic/io-util.h
src/basic/prioq.h
src/basic/string-util.c
src/basic/terminal-util.c
src/basic/user-util.c
src/basic/utf8.c
src/basic/utf8.h
src/basic/xattr-util.c
src/boot/bootctl.c
src/busctl/busctl.c
src/cgtop/cgtop.c
src/core/dbus-execute.c
src/core/dbus-unit.c
src/core/execute.c
src/core/load-fragment.c
src/core/main.c
src/core/manager.c
src/core/socket.c
src/coredump/coredump-vacuum.c
src/coredump/coredump.c
src/coredump/test-coredump-vacuum.c
src/cryptenroll/cryptenroll-tpm2.c
src/cryptsetup/cryptsetup-fido2.c
src/cryptsetup/cryptsetup-pkcs11.c
src/cryptsetup/cryptsetup-tpm2.c
src/cryptsetup/cryptsetup.c
src/dissect/dissect.c
src/firstboot/firstboot.c
src/import/export-raw.c
src/import/export-tar.c
src/import/import-raw.c
src/import/import-tar.c
src/import/importd.c
src/import/pull-job.c
src/import/pull-raw.c
src/journal-remote/journal-remote-main.c
src/journal-remote/journal-remote-write.c
src/journal-remote/journal-remote.c
src/journal-remote/journal-upload-journal.c
src/journal/fuzz-journald-stream.c
src/journal/journald-context.c
src/journal/journald-native.c
src/journal/journald-server.c
src/journal/test-journal-config.c
src/libsystemd-network/fuzz-dhcp6-client.c
src/libsystemd-network/fuzz-ndisc-rs.c
src/libsystemd-network/lldp-network.c
src/libsystemd-network/sd-dhcp-client.c
src/libsystemd-network/sd-dhcp-lease.c
src/libsystemd-network/sd-lldp.c
src/libsystemd-network/test-dhcp-client.c
src/libsystemd-network/test-ipv4ll.c
src/libsystemd/sd-bus/bus-control.c
src/libsystemd/sd-bus/bus-dump.c
src/libsystemd/sd-bus/bus-message.c
src/libsystemd/sd-bus/bus-socket.c
src/libsystemd/sd-bus/sd-bus.c
src/libsystemd/sd-bus/test-bus-chat.c
src/libsystemd/sd-bus/test-bus-objects.c
src/libsystemd/sd-bus/test-bus-server.c
src/libsystemd/sd-device/device-private.c
src/libsystemd/sd-device/sd-device.c
src/libsystemd/sd-event/sd-event.c
src/libsystemd/sd-event/test-event.c
src/libsystemd/sd-journal/compress.c
src/libsystemd/sd-journal/journal-file.c
src/libsystemd/sd-journal/sd-journal.c
src/libsystemd/sd-journal/test-journal-interleaving.c
src/libsystemd/sd-journal/test-journal-stream.c
src/libsystemd/sd-journal/test-journal-verify.c
src/libsystemd/sd-journal/test-journal.c
src/libsystemd/sd-login/sd-login.c
src/libsystemd/sd-login/test-login.c
src/libsystemd/sd-netlink/sd-netlink.c
src/libsystemd/sd-network/sd-network.c
src/libsystemd/sd-resolve/sd-resolve.c
src/login/logind-dbus.c
src/login/logind.c
src/login/pam_systemd.c
src/login/sysfs-show.c
src/machine/machine-dbus.c
src/machine/machinectl.c
src/machine/machined-dbus.c
src/network/networkd-dhcp4.c
src/network/networkd-link-bus.c
src/network/networkd-link.c
src/network/networkd-sriov.c
src/network/networkd-state-file.c
src/notify/notify.c
src/nspawn/nspawn-oci.c
src/nspawn/nspawn-settings.c
src/nspawn/nspawn.c
src/oom/oomctl.c
src/partition/repart.c
src/portable/portablectl.c
src/portable/portabled-bus.c
src/resolve/resolved-dns-cache.c
src/resolve/resolved-dns-dnssec.c
src/resolve/resolved-dns-packet.c
src/resolve/resolved-dns-rr.c
src/resolve/resolved-dns-rr.h
src/resolve/resolved-dns-transaction.c
src/resolve/resolved-mdns.c
src/shared/ask-password-api.c
src/shared/bitmap.c
src/shared/bus-get-properties.c
src/shared/bus-print-properties.c
src/shared/bus-unit-util.c
src/shared/bus-util.c
src/shared/bus-wait-for-jobs.c
src/shared/bus-wait-for-units.c
src/shared/dissect-image.c
src/shared/format-table.c
src/shared/format-table.h
src/shared/json.c
src/shared/json.h
src/shared/logs-show.c
src/shared/nsflags.h
src/shared/pager.c
src/shared/ptyfwd.c
src/shared/udev-util.c
src/shared/user-record.c
src/shared/verbs.h
src/systemctl/systemctl-show.c
src/systemd/sd-lldp.h
src/systemd/sd-resolve.h
src/sysusers/sysusers.c
src/test/test-bitmap.c
src/test/test-calendarspec.c
src/test/test-copy.c
src/test/test-fileio.c
src/test/test-format-table.c
src/test/test-fs-util.c
src/test/test-hexdecoct.c
src/test/test-prioq.c
src/test/test-utf8.c

index f41eb6682808c4b8ad7e20615072a7b8a0abab43..1a38d878a36a0defc0cc2531905f56316a13f116 100644 (file)
@@ -1357,7 +1357,7 @@ static int dump(int argc, char *argv[], void *userdata) {
                 return bus_log_parse_error(r);
 
         fflush(stdout);
-        return copy_bytes(fd, STDOUT_FILENO, (uint64_t) -1, 0);
+        return copy_bytes(fd, STDOUT_FILENO, UINT64_MAX, 0);
 }
 
 static int cat_config(int argc, char *argv[], void *userdata) {
index aa2177113b1abca2499585bd403d57ee7d6ae6b5..765f3f4f635253b857bf93a8f4890a180d882f48 100644 (file)
@@ -5,7 +5,7 @@
 #include <stdint.h>
 #include <sys/types.h>
 
-#define AUDIT_SESSION_INVALID ((uint32_t) -1)
+#define AUDIT_SESSION_INVALID (UINT32_MAX)
 
 int audit_session_from_pid(pid_t pid, uint32_t *id);
 int audit_loginuid_from_pid(pid_t pid, uid_t *uid);
index 0fb8dfedebd878033fdc76630323f62a7ae71aa9..51aaee71fd7c10a57909902d79edd3915ef18706 100644 (file)
@@ -396,18 +396,18 @@ static bool btrfs_ioctl_search_args_inc(struct btrfs_ioctl_search_args *args) {
          * comparing. This call increases the counter by one, dealing
          * with the overflow between the overflows */
 
-        if (args->key.min_offset < (uint64_t) -1) {
+        if (args->key.min_offset < UINT64_MAX) {
                 args->key.min_offset++;
                 return true;
         }
 
-        if (args->key.min_type < (uint8_t) -1) {
+        if (args->key.min_type < UINT8_MAX) {
                 args->key.min_type++;
                 args->key.min_offset = 0;
                 return true;
         }
 
-        if (args->key.min_objectid < (uint64_t) -1) {
+        if (args->key.min_objectid < UINT64_MAX) {
                 args->key.min_objectid++;
                 args->key.min_offset = 0;
                 args->key.min_type = 0;
@@ -464,11 +464,11 @@ int btrfs_subvol_get_info_fd(int fd, uint64_t subvol_id, BtrfsSubvolInfo *ret) {
                 .key.max_type = BTRFS_ROOT_ITEM_KEY,
 
                 .key.min_offset = 0,
-                .key.max_offset = (uint64_t) -1,
+                .key.max_offset = UINT64_MAX,
 
                 /* No restrictions on the other components */
                 .key.min_transid = 0,
-                .key.max_transid = (uint64_t) -1,
+                .key.max_transid = UINT64_MAX,
         };
 
         bool found = false;
@@ -562,7 +562,7 @@ int btrfs_qgroup_get_quota_fd(int fd, uint64_t qgroupid, BtrfsQuotaInfo *ret) {
 
                 /* No restrictions on the other components */
                 .key.min_transid = 0,
-                .key.max_transid = (uint64_t) -1,
+                .key.max_transid = UINT64_MAX,
         };
 
         bool found_info = false, found_limit = false;
@@ -624,12 +624,12 @@ int btrfs_qgroup_get_quota_fd(int fd, uint64_t qgroupid, BtrfsQuotaInfo *ret) {
                                 if (le64toh(qli->flags) & BTRFS_QGROUP_LIMIT_MAX_RFER)
                                         ret->referenced_max = le64toh(qli->max_rfer);
                                 else
-                                        ret->referenced_max = (uint64_t) -1;
+                                        ret->referenced_max = UINT64_MAX;
 
                                 if (le64toh(qli->flags) & BTRFS_QGROUP_LIMIT_MAX_EXCL)
                                         ret->exclusive_max = le64toh(qli->max_excl);
                                 else
-                                        ret->exclusive_max = (uint64_t) -1;
+                                        ret->exclusive_max = UINT64_MAX;
 
                                 found_limit = true;
                         }
@@ -648,13 +648,13 @@ finish:
                 return -ENODATA;
 
         if (!found_info) {
-                ret->referenced = (uint64_t) -1;
-                ret->exclusive = (uint64_t) -1;
+                ret->referenced = UINT64_MAX;
+                ret->exclusive = UINT64_MAX;
         }
 
         if (!found_limit) {
-                ret->referenced_max = (uint64_t) -1;
-                ret->exclusive_max = (uint64_t) -1;
+                ret->referenced_max = UINT64_MAX;
+                ret->exclusive_max = UINT64_MAX;
         }
 
         return 0;
@@ -671,7 +671,7 @@ int btrfs_qgroup_get_quota(const char *path, uint64_t qgroupid, BtrfsQuotaInfo *
 }
 
 int btrfs_subvol_find_subtree_qgroup(int fd, uint64_t subvol_id, uint64_t *ret) {
-        uint64_t level, lowest = (uint64_t) -1, lowest_qgroupid = 0;
+        uint64_t level, lowest = UINT64_MAX, lowest_qgroupid = 0;
         _cleanup_free_ uint64_t *qgroups = NULL;
         int r, n;
 
@@ -713,13 +713,13 @@ int btrfs_subvol_find_subtree_qgroup(int fd, uint64_t subvol_id, uint64_t *ret)
                 if (id != subvol_id)
                         continue;
 
-                if (lowest == (uint64_t) -1 || level < lowest) {
+                if (lowest == UINT64_MAX || level < lowest) {
                         lowest_qgroupid = qgroups[i];
                         lowest = level;
                 }
         }
 
-        if (lowest == (uint64_t) -1) {
+        if (lowest == UINT64_MAX) {
                 /* No suitable higher-level qgroup found, let's return
                  * the leaf qgroup instead, and indicate that with the
                  * return value. */
@@ -1089,7 +1089,7 @@ static int subvol_remove_children(int fd, const char *subvolume, uint64_t subvol
                 .key.max_type = BTRFS_ROOT_BACKREF_KEY,
 
                 .key.min_transid = 0,
-                .key.max_transid = (uint64_t) -1,
+                .key.max_transid = UINT64_MAX,
         };
 
         struct btrfs_ioctl_vol_args vol_args = {};
@@ -1265,7 +1265,7 @@ int btrfs_qgroup_copy_limits(int fd, uint64_t old_qgroupid, uint64_t new_qgroupi
 
                 /* No restrictions on the other components */
                 .key.min_transid = 0,
-                .key.max_transid = (uint64_t) -1,
+                .key.max_transid = UINT64_MAX,
         };
 
         int r;
@@ -1451,7 +1451,7 @@ static int subvol_snapshot_children(
                 .key.max_type = BTRFS_ROOT_BACKREF_KEY,
 
                 .key.min_transid = 0,
-                .key.max_transid = (uint64_t) -1,
+                .key.max_transid = UINT64_MAX,
         };
 
         struct btrfs_ioctl_vol_args_v2 vol_args = {
@@ -1721,10 +1721,10 @@ int btrfs_qgroup_find_parents(int fd, uint64_t qgroupid, uint64_t **ret) {
 
                 /* No restrictions on the other components */
                 .key.min_offset = 0,
-                .key.max_offset = (uint64_t) -1,
+                .key.max_offset = UINT64_MAX,
 
                 .key.min_transid = 0,
-                .key.max_transid = (uint64_t) -1,
+                .key.max_transid = UINT64_MAX,
         };
 
         _cleanup_free_ uint64_t *items = NULL;
@@ -1965,10 +1965,10 @@ int btrfs_subvol_get_parent(int fd, uint64_t subvol_id, uint64_t *ret) {
 
                 /* No restrictions on the other components */
                 .key.min_offset = 0,
-                .key.max_offset = (uint64_t) -1,
+                .key.max_offset = UINT64_MAX,
 
                 .key.min_transid = 0,
-                .key.max_transid = (uint64_t) -1,
+                .key.max_transid = UINT64_MAX,
         };
         int r;
 
index 43eb23cb05c41a0733f3679d58b7305cf25a877d..b31a9cb2113c0ab9d2ba5eeccadabfda1728e164 100644 (file)
@@ -405,7 +405,7 @@ bool capability_quintet_mangle(CapabilityQuintet *q) {
 
         combined = q->effective | q->bounding | q->inheritable | q->permitted;
 
-        ambient_supported = q->ambient != (uint64_t) -1;
+        ambient_supported = q->ambient != UINT64_MAX;
         if (ambient_supported)
                 combined |= q->ambient;
 
@@ -437,7 +437,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
         _cleanup_cap_free_ cap_t c = NULL, modified = NULL;
         int r;
 
-        if (q->ambient != (uint64_t) -1) {
+        if (q->ambient != UINT64_MAX) {
                 bool changed = false;
 
                 c = cap_get_proc();
@@ -479,7 +479,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
                         return r;
         }
 
-        if (q->inheritable != (uint64_t) -1 || q->permitted != (uint64_t) -1 || q->effective != (uint64_t) -1) {
+        if (q->inheritable != UINT64_MAX || q->permitted != UINT64_MAX || q->effective != UINT64_MAX) {
                 bool changed = false;
 
                 if (!c) {
@@ -492,7 +492,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
                         uint64_t m = UINT64_C(1) << i;
                         cap_value_t cv = (cap_value_t) i;
 
-                        if (q->inheritable != (uint64_t) -1) {
+                        if (q->inheritable != UINT64_MAX) {
                                 cap_flag_value_t old_value, new_value;
 
                                 if (cap_get_flag(c, cv, CAP_INHERITABLE, &old_value) < 0) {
@@ -515,7 +515,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
                                 }
                         }
 
-                        if (q->permitted != (uint64_t) -1) {
+                        if (q->permitted != UINT64_MAX) {
                                 cap_flag_value_t old_value, new_value;
 
                                 if (cap_get_flag(c, cv, CAP_PERMITTED, &old_value) < 0) {
@@ -535,7 +535,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
                                 }
                         }
 
-                        if (q->effective != (uint64_t) -1) {
+                        if (q->effective != UINT64_MAX) {
                                 cap_flag_value_t old_value, new_value;
 
                                 if (cap_get_flag(c, cv, CAP_EFFECTIVE, &old_value) < 0) {
@@ -559,7 +559,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
                 if (changed) {
                         /* In order to change the bounding caps, we need to keep CAP_SETPCAP for a bit
                          * longer. Let's add it to our list hence for now. */
-                        if (q->bounding != (uint64_t) -1) {
+                        if (q->bounding != UINT64_MAX) {
                                 cap_value_t cv = CAP_SETPCAP;
 
                                 modified = cap_dup(c);
@@ -587,7 +587,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
                 }
         }
 
-        if (q->bounding != (uint64_t) -1) {
+        if (q->bounding != UINT64_MAX) {
                 r = capability_bounding_set_drop(q->bounding, false);
                 if (r < 0)
                         return r;
index d9489d7883cae7d5f5591d91cf2885d539c77953..dbce54531d1e2c120960a2d8a0edebcb2c96c8af 100644 (file)
@@ -10,7 +10,7 @@
 #include "missing_capability.h"
 #include "util.h"
 
-#define CAP_ALL (uint64_t) -1
+#define CAP_ALL UINT64_MAX
 
 unsigned cap_last_cap(void);
 int have_effective_cap(int value);
@@ -49,7 +49,7 @@ bool ambient_capabilities_supported(void);
 #define CAP_TO_MASK_CORRECTED(x) (1U << ((x) & 31U))
 
 typedef struct CapabilityQuintet {
-        /* Stores all five types of capabilities in one go. Note that we use (uint64_t) -1 for unset here. This hence
+        /* Stores all five types of capabilities in one go. Note that we use UINT64_MAX for unset here. This hence
          * needs to be updated as soon as Linux learns more than 63 caps. */
         uint64_t effective;
         uint64_t bounding;
@@ -60,14 +60,14 @@ typedef struct CapabilityQuintet {
 
 assert_cc(CAP_LAST_CAP < 64);
 
-#define CAPABILITY_QUINTET_NULL { (uint64_t) -1, (uint64_t) -1, (uint64_t) -1, (uint64_t) -1, (uint64_t) -1 }
+#define CAPABILITY_QUINTET_NULL { UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX }
 
 static inline bool capability_quintet_is_set(const CapabilityQuintet *q) {
-        return q->effective != (uint64_t) -1 ||
-                q->bounding != (uint64_t) -1 ||
-                q->inheritable != (uint64_t) -1 ||
-                q->permitted != (uint64_t) -1 ||
-                q->ambient != (uint64_t) -1;
+        return q->effective != UINT64_MAX ||
+                q->bounding != UINT64_MAX ||
+                q->inheritable != UINT64_MAX ||
+                q->permitted != UINT64_MAX ||
+                q->ambient != UINT64_MAX;
 }
 
 /* Mangles the specified caps quintet taking the current bounding set into account:
index 3c59ca5e10607be3b0886cd247941dcab4b5d1ad..0ecb8d944e98ea133dd25cb47cce5a17ab6efda0 100644 (file)
@@ -1975,7 +1975,7 @@ int cg_kernel_controllers(Set **ret) {
                 return r;
 
         /* Ignore the header line */
-        (void) read_line(f, (size_t) -1, NULL);
+        (void) read_line(f, SIZE_MAX, NULL);
 
         for (;;) {
                 char *controller;
index 30b4819eb3d3658555c2d67ca49e0823010a1f9f..11deae2d20d07c0b2ac5f4d5897019c9a85c5228 100644 (file)
@@ -75,13 +75,13 @@ CGroupMask get_cpu_accounting_mask(void);
 bool cpu_accounting_is_cheap(void);
 
 /* Special values for all weight knobs on unified hierarchy */
-#define CGROUP_WEIGHT_INVALID ((uint64_t) -1)
+#define CGROUP_WEIGHT_INVALID (UINT64_MAX)
 #define CGROUP_WEIGHT_MIN UINT64_C(1)
 #define CGROUP_WEIGHT_MAX UINT64_C(10000)
 #define CGROUP_WEIGHT_DEFAULT UINT64_C(100)
 
 #define CGROUP_LIMIT_MIN UINT64_C(0)
-#define CGROUP_LIMIT_MAX ((uint64_t) -1)
+#define CGROUP_LIMIT_MAX (UINT64_MAX)
 
 static inline bool CGROUP_WEIGHT_IS_OK(uint64_t x) {
         return
@@ -106,7 +106,7 @@ const char* cgroup_io_limit_type_to_string(CGroupIOLimitType t) _const_;
 CGroupIOLimitType cgroup_io_limit_type_from_string(const char *s) _pure_;
 
 /* Special values for the cpu.shares attribute */
-#define CGROUP_CPU_SHARES_INVALID ((uint64_t) -1)
+#define CGROUP_CPU_SHARES_INVALID (UINT64_MAX)
 #define CGROUP_CPU_SHARES_MIN UINT64_C(2)
 #define CGROUP_CPU_SHARES_MAX UINT64_C(262144)
 #define CGROUP_CPU_SHARES_DEFAULT UINT64_C(1024)
@@ -118,7 +118,7 @@ static inline bool CGROUP_CPU_SHARES_IS_OK(uint64_t x) {
 }
 
 /* Special values for the blkio.weight attribute */
-#define CGROUP_BLKIO_WEIGHT_INVALID ((uint64_t) -1)
+#define CGROUP_BLKIO_WEIGHT_INVALID (UINT64_MAX)
 #define CGROUP_BLKIO_WEIGHT_MIN UINT64_C(10)
 #define CGROUP_BLKIO_WEIGHT_MAX UINT64_C(1000)
 #define CGROUP_BLKIO_WEIGHT_DEFAULT UINT64_C(500)
index 6bb02c03a6638fad8fd13abbca593e35b8a3429e..6391e34ed63c82e7067d722e1c0ebabca06e2a17 100644 (file)
@@ -361,7 +361,7 @@ int copy_bytes_full(
                                 return r;
                 }
 
-                if (max_bytes != (uint64_t) -1) {
+                if (max_bytes != UINT64_MAX) {
                         assert(max_bytes >= (uint64_t) n);
                         max_bytes -= n;
                 }
@@ -642,7 +642,7 @@ static int fd_copy_regular(
         if (fdt < 0)
                 return -errno;
 
-        r = copy_bytes_full(fdf, fdt, (uint64_t) -1, copy_flags, NULL, NULL, progress, userdata);
+        r = copy_bytes_full(fdf, fdt, UINT64_MAX, copy_flags, NULL, NULL, progress, userdata);
         if (r < 0) {
                 (void) unlinkat(dt, to, 0);
                 return r;
@@ -1051,7 +1051,7 @@ int copy_file_fd_full(
         if (fdf < 0)
                 return -errno;
 
-        r = copy_bytes_full(fdf, fdt, (uint64_t) -1, copy_flags, NULL, NULL, progress_bytes, userdata);
+        r = copy_bytes_full(fdf, fdt, UINT64_MAX, copy_flags, NULL, NULL, progress_bytes, userdata);
 
         (void) copy_times(fdf, fdt, copy_flags);
         (void) copy_xattr(fdf, fdt);
@@ -1081,7 +1081,7 @@ int copy_file_full(
         if (fdf < 0)
                 return -errno;
 
-        if (mode == (mode_t) -1)
+        if (mode == MODE_INVALID)
                 if (fstat(fdf, &st) < 0)
                         return -errno;
 
@@ -1092,7 +1092,7 @@ int copy_file_full(
                                 return r;
                 }
                 fdt = open(to, flags|O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY,
-                           mode != (mode_t) -1 ? mode : st.st_mode);
+                           mode != MODE_INVALID ? mode : st.st_mode);
                 if (copy_flags & COPY_MAC_CREATE)
                         mac_selinux_create_file_clear();
                 if (fdt < 0)
@@ -1102,7 +1102,7 @@ int copy_file_full(
         if (chattr_mask != 0)
                 (void) chattr_fd(fdt, chattr_flags, chattr_mask & CHATTR_EARLY_FL, NULL);
 
-        r = copy_bytes_full(fdf, fdt, (uint64_t) -1, copy_flags, NULL, NULL, progress_bytes, userdata);
+        r = copy_bytes_full(fdf, fdt, UINT64_MAX, copy_flags, NULL, NULL, progress_bytes, userdata);
         if (r < 0) {
                 close(fdt);
                 (void) unlink(to);
index 7eb9c351b6d4b4d0692ea2be464a15917d0e6dd5..158ab738e839c0a14a0b0705c5f5f5866d9398cb 100644 (file)
@@ -28,7 +28,7 @@ int encode_devnode_name(const char *str, char *str_enc, size_t len) {
         for (i = 0, j = 0; str[i] != '\0'; i++) {
                 int seqlen;
 
-                seqlen = utf8_encoded_valid_unichar(str + i, (size_t) -1);
+                seqlen = utf8_encoded_valid_unichar(str + i, SIZE_MAX);
                 if (seqlen > 1) {
 
                         if (len-j < (size_t)seqlen)
index 11362d8556b88da20cc9718ce4844faf04043202..a3009093607523b9cd22a78c835d0efb9e677030 100644 (file)
@@ -20,7 +20,7 @@ static int parse_env_file_internal(
                 void *userdata,
                 int *n_pushed) {
 
-        size_t key_alloc = 0, n_key = 0, value_alloc = 0, n_value = 0, last_value_whitespace = (size_t) -1, last_key_whitespace = (size_t) -1;
+        size_t key_alloc = 0, n_key = 0, value_alloc = 0, n_value = 0, last_value_whitespace = SIZE_MAX, last_key_whitespace = SIZE_MAX;
         _cleanup_free_ char *contents = NULL, *key = NULL, *value = NULL;
         unsigned line = 1;
         char *p;
@@ -56,7 +56,7 @@ static int parse_env_file_internal(
                                 state = COMMENT;
                         else if (!strchr(WHITESPACE, c)) {
                                 state = KEY;
-                                last_key_whitespace = (size_t) -1;
+                                last_key_whitespace = SIZE_MAX;
 
                                 if (!GREEDY_REALLOC(key, key_alloc, n_key+2))
                                         return -ENOMEM;
@@ -72,11 +72,11 @@ static int parse_env_file_internal(
                                 n_key = 0;
                         } else if (c == '=') {
                                 state = PRE_VALUE;
-                                last_value_whitespace = (size_t) -1;
+                                last_value_whitespace = SIZE_MAX;
                         } else {
                                 if (!strchr(WHITESPACE, c))
-                                        last_key_whitespace = (size_t) -1;
-                                else if (last_key_whitespace == (size_t) -1)
+                                        last_key_whitespace = SIZE_MAX;
+                                else if (last_key_whitespace == SIZE_MAX)
                                          last_key_whitespace = n_key;
 
                                 if (!GREEDY_REALLOC(key, key_alloc, n_key+2))
@@ -97,7 +97,7 @@ static int parse_env_file_internal(
                                         value[n_value] = 0;
 
                                 /* strip trailing whitespace from key */
-                                if (last_key_whitespace != (size_t) -1)
+                                if (last_key_whitespace != SIZE_MAX)
                                         key[last_key_whitespace] = 0;
 
                                 r = push(fname, line, key, value, userdata, n_pushed);
@@ -136,11 +136,11 @@ static int parse_env_file_internal(
                                         value[n_value] = 0;
 
                                 /* Chomp off trailing whitespace from value */
-                                if (last_value_whitespace != (size_t) -1)
+                                if (last_value_whitespace != SIZE_MAX)
                                         value[last_value_whitespace] = 0;
 
                                 /* strip trailing whitespace from key */
-                                if (last_key_whitespace != (size_t) -1)
+                                if (last_key_whitespace != SIZE_MAX)
                                         key[last_key_whitespace] = 0;
 
                                 r = push(fname, line, key, value, userdata, n_pushed);
@@ -153,11 +153,11 @@ static int parse_env_file_internal(
 
                         } else if (c == '\\') {
                                 state = VALUE_ESCAPE;
-                                last_value_whitespace = (size_t) -1;
+                                last_value_whitespace = SIZE_MAX;
                         } else {
                                 if (!strchr(WHITESPACE, c))
-                                        last_value_whitespace = (size_t) -1;
-                                else if (last_value_whitespace == (size_t) -1)
+                                        last_value_whitespace = SIZE_MAX;
+                                else if (last_value_whitespace == SIZE_MAX)
                                         last_value_whitespace = n_value;
 
                                 if (!GREEDY_REALLOC(value, value_alloc, n_value+2))
@@ -255,11 +255,11 @@ static int parse_env_file_internal(
                         value[n_value] = 0;
 
                 if (state == VALUE)
-                        if (last_value_whitespace != (size_t) -1)
+                        if (last_value_whitespace != SIZE_MAX)
                                 value[last_value_whitespace] = 0;
 
                 /* strip trailing whitespace from key */
-                if (last_key_whitespace != (size_t) -1)
+                if (last_key_whitespace != SIZE_MAX)
                         key[last_key_whitespace] = 0;
 
                 r = push(fname, line, key, value, userdata, n_pushed);
index 31f3cda472e60668dfd1084d6198d6e4ec42a8bf..af785ecfa457752879845f65e7ae6fa2f8fc2029 100644 (file)
@@ -114,7 +114,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
          * instead be copied directly.
          */
 
-        if (length != (size_t) -1 && length < 1)
+        if (length != SIZE_MAX && length < 1)
                 return -EINVAL;
 
         switch (p[0]) {
@@ -159,7 +159,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
                 /* hexadecimal encoding */
                 int a, b;
 
-                if (length != (size_t) -1 && length < 3)
+                if (length != SIZE_MAX && length < 3)
                         return -EINVAL;
 
                 a = unhexchar(p[1]);
@@ -187,7 +187,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
                 size_t i;
                 uint32_t c;
 
-                if (length != (size_t) -1 && length < 5)
+                if (length != SIZE_MAX && length < 5)
                         return -EINVAL;
 
                 for (i = 0; i < 4; i++) {
@@ -214,7 +214,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
                 size_t i;
                 char32_t c;
 
-                if (length != (size_t) -1 && length < 9)
+                if (length != SIZE_MAX && length < 9)
                         return -EINVAL;
 
                 for (i = 0; i < 8; i++) {
@@ -251,7 +251,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
                 int a, b, c;
                 char32_t m;
 
-                if (length != (size_t) -1 && length < 3)
+                if (length != SIZE_MAX && length < 3)
                         return -EINVAL;
 
                 a = unoctchar(p[0]);
index 4104dac9a74eba854c2c06abe9c3be3855157c11..4e4e7e8ce931b6545e49dc7320accb89208e5626 100644 (file)
@@ -91,7 +91,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
                                 char32_t u;
 
                                 if ((flags & EXTRACT_CUNESCAPE) &&
-                                    (r = cunescape_one(*p, (size_t) -1, &u, &eight_bit, false)) >= 0) {
+                                    (r = cunescape_one(*p, SIZE_MAX, &u, &eight_bit, false)) >= 0) {
                                         /* A valid escaped sequence */
                                         assert(r >= 1);
 
index 04ed4be9418b770b126eb8149beff5a22a2f8c47..9920604f3abe8b7c346289a4293f883958d97e56 100644 (file)
@@ -47,7 +47,7 @@ char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) {
 
         assert_cc(ELEMENTSOF(table_iec) == ELEMENTSOF(table_si));
 
-        if (t == (uint64_t) -1)
+        if (t == UINT64_MAX)
                 return NULL;
 
         table = flag & FORMAT_BYTES_USE_IEC ? table_iec : table_si;
index da60202e57c53cf7cfab94962836c3cb64a9c0af..cb0104670f0770344005309c422f19559d198257 100644 (file)
@@ -119,7 +119,7 @@ int unhexmem_full(const char *p, size_t l, bool secure, void **ret, size_t *ret_
         assert(ret_len);
         assert(p || l == 0);
 
-        if (l == (size_t) -1)
+        if (l == SIZE_MAX)
                 l = strlen(p);
 
         /* Note that the calculation of memory size is an upper boundary, as we ignore whitespace while decoding */
@@ -309,7 +309,7 @@ int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *_l
         assert(mem);
         assert(_len);
 
-        if (l == (size_t) -1)
+        if (l == SIZE_MAX)
                 l = strlen(p);
 
         /* padding ensures any base32hex input has input divisible by 8 */
@@ -708,7 +708,7 @@ int unbase64mem_full(const char *p, size_t l, bool secure, void **ret, size_t *r
         assert(ret);
         assert(ret_size);
 
-        if (l == (size_t) -1)
+        if (l == SIZE_MAX)
                 l = strlen(p);
 
         /* A group of four input bytes needs three output bytes, in case of padding we need to add two or three extra
index 0cd26d4c2c1b5ec66577c226b576f268e9a7d1a1..d98817f760955104a6b655a27d79de05d31b9051 100644 (file)
@@ -62,7 +62,7 @@ static inline bool FILE_SIZE_VALID_OR_INFINITY(uint64_t l) {
 
         /* Same as above, but allows one extra value: -1 as indication for infinity. */
 
-        if (l == (uint64_t) -1)
+        if (l == UINT64_MAX)
                 return true;
 
         return FILE_SIZE_VALID(l);
index 951576c021773cadb6143e0beb9c59b6a050da51..7c7664761135a761e194458fe931433a63991d81 100644 (file)
@@ -8,7 +8,7 @@
 
 typedef struct Prioq Prioq;
 
-#define PRIOQ_IDX_NULL ((unsigned) -1)
+#define PRIOQ_IDX_NULL (UINT_MAX)
 
 Prioq *prioq_new(compare_func_t compare);
 Prioq *prioq_free(Prioq *q);
index 7f7122c1f12ed7300b0960836e55f7283098b4e9..c369f59ee1c0ea826d94f035cd988ad9df36a83d 100644 (file)
@@ -71,7 +71,7 @@ char *strnappend(const char *s, const char *suffix, size_t b) {
         assert(suffix);
 
         a = strlen(s);
-        if (b > ((size_t) -1) - a)
+        if (b > (SIZE_MAX) - a)
                 return NULL;
 
         r = new(char, a+b+1);
@@ -307,7 +307,7 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
 
         assert(s);
         assert(percent <= 100);
-        assert(new_length != (size_t) -1);
+        assert(new_length != SIZE_MAX);
 
         if (old_length <= new_length)
                 return strndup(s, old_length);
@@ -378,7 +378,7 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
         assert(s);
         assert(percent <= 100);
 
-        if (new_length == (size_t) -1)
+        if (new_length == SIZE_MAX)
                 return strndup(s, old_length);
 
         if (new_length == 0)
index 3617a04d3b7409a274786a1070371274ed4105c9..1a3f9ccb33cd782ac773ca404b4c234580c13a7a 100644 (file)
@@ -41,6 +41,7 @@
 #include "strv.h"
 #include "terminal-util.h"
 #include "time-util.h"
+#include "user-util.h"
 #include "util.h"
 
 static volatile unsigned cached_columns = 0;
@@ -1341,7 +1342,7 @@ int vt_restore(int fd) {
                         q = -errno;
         }
 
-        r = fchmod_and_chown(fd, TTY_MODE, 0, (gid_t) -1);
+        r = fchmod_and_chown(fd, TTY_MODE, 0, GID_INVALID);
         if (r < 0) {
                 log_debug_errno(r, "Failed to chmod()/chown() VT, ignoring: %m");
                 if (q >= 0)
index 933a398e7313ff59da6f526357cc9e93c5274725..1fad342cef3c7f9f4485bc38d970edb3e36f8e8c 100644 (file)
@@ -882,7 +882,7 @@ char *mangle_gecos(const char *d) {
                         continue;
                 }
 
-                len = utf8_encoded_valid_unichar(i, (size_t) -1);
+                len = utf8_encoded_valid_unichar(i, SIZE_MAX);
                 if (len < 0) {
                         *i = ' ';
                         continue;
index d61692d07f191790045b1edf30209a6fc5e370ae..46c3a463b95ccd48fcd03a2a3e72e1c6f41130f9 100644 (file)
@@ -156,14 +156,14 @@ char *utf8_is_valid_n(const char *str, size_t len_bytes) {
 
         assert(str);
 
-        for (const char *p = str; len_bytes != (size_t) -1 ? (size_t) (p - str) < len_bytes : *p != '\0'; ) {
+        for (const char *p = str; len_bytes != SIZE_MAX ? (size_t) (p - str) < len_bytes : *p != '\0'; ) {
                 int len;
 
-                if (_unlikely_(*p == '\0') && len_bytes != (size_t) -1)
+                if (_unlikely_(*p == '\0') && len_bytes != SIZE_MAX)
                         return NULL; /* embedded NUL */
 
                 len = utf8_encoded_valid_unichar(p,
-                                                 len_bytes != (size_t) -1 ? len_bytes - (p - str) : (size_t) -1);
+                                                 len_bytes != SIZE_MAX ? len_bytes - (p - str) : SIZE_MAX);
                 if (_unlikely_(len < 0))
                         return NULL; /* invalid character */
 
@@ -185,7 +185,7 @@ char *utf8_escape_invalid(const char *str) {
         while (*str) {
                 int len;
 
-                len = utf8_encoded_valid_unichar(str, (size_t) -1);
+                len = utf8_encoded_valid_unichar(str, SIZE_MAX);
                 if (len > 0) {
                         s = mempcpy(s, str, len);
                         str += len;
@@ -233,7 +233,7 @@ char *utf8_escape_non_printable_full(const char *str, size_t console_width) {
                 if (!*str) /* done! */
                         goto finish;
 
-                len = utf8_encoded_valid_unichar(str, (size_t) -1);
+                len = utf8_encoded_valid_unichar(str, SIZE_MAX);
                 if (len > 0) {
                         if (utf8_is_printable(str, len)) {
                                 int w;
@@ -508,7 +508,7 @@ int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
         assert(str);
         assert(length > 0);
 
-        /* We read until NUL, at most length bytes. (size_t) -1 may be used to disable the length check. */
+        /* We read until NUL, at most length bytes. SIZE_MAX may be used to disable the length check. */
 
         len = utf8_encoded_expected_len(str[0]);
         if (len == 0)
@@ -545,14 +545,14 @@ int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
 size_t utf8_n_codepoints(const char *str) {
         size_t n = 0;
 
-        /* Returns the number of UTF-8 codepoints in this string, or (size_t) -1 if the string is not valid UTF-8. */
+        /* Returns the number of UTF-8 codepoints in this string, or SIZE_MAX if the string is not valid UTF-8. */
 
         while (*str != 0) {
                 int k;
 
-                k = utf8_encoded_valid_unichar(str, (size_t) -1);
+                k = utf8_encoded_valid_unichar(str, SIZE_MAX);
                 if (k < 0)
-                        return (size_t) -1;
+                        return SIZE_MAX;
 
                 str += k;
                 n++;
@@ -572,7 +572,7 @@ size_t utf8_console_width(const char *str) {
 
                 w = utf8_char_console_width(str);
                 if (w < 0)
-                        return (size_t) -1;
+                        return SIZE_MAX;
 
                 n += w;
                 str = utf8_next_char(str);
index a6ea942c6240f49ea482d564eb9581c22dd7a129..219ca89184b6046010606e5cbf8df51f1790a8c1 100644 (file)
@@ -16,7 +16,7 @@ bool unichar_is_valid(char32_t c);
 
 char *utf8_is_valid_n(const char *str, size_t len_bytes) _pure_;
 static inline char *utf8_is_valid(const char *s) {
-        return utf8_is_valid_n(s, (size_t) -1);
+        return utf8_is_valid_n(s, SIZE_MAX);
 }
 char *ascii_is_valid(const char *s) _pure_;
 char *ascii_is_valid_n(const char *str, size_t len);
@@ -27,7 +27,7 @@ bool utf8_is_printable_newline(const char* str, size_t length, bool allow_newlin
 char *utf8_escape_invalid(const char *s);
 char *utf8_escape_non_printable_full(const char *str, size_t console_width);
 static inline char *utf8_escape_non_printable(const char *str) {
-        return utf8_escape_non_printable_full(str, (size_t) -1);
+        return utf8_escape_non_printable_full(str, SIZE_MAX);
 }
 
 size_t utf8_encode_unichar(char *out_utf8, char32_t g);
index b9a0dc54c5329bad9fd1638d62983efc7decc768..c175ce1fbcc79c91aef0dab7aa9c1af917880996 100644 (file)
@@ -147,7 +147,7 @@ static int parse_crtime(le64_t le, usec_t *usec) {
         assert(usec);
 
         u = le64toh(le);
-        if (IN_SET(u, 0, (uint64_t) -1))
+        if (IN_SET(u, 0, UINT64_MAX))
                 return -EIO;
 
         *usec = (usec_t) u;
index 9964dda1fcc61d98698a7a693386b5e0125266c6..04cc7664e512bc2657f0e1a1cb1cf98724ba8f7d 100644 (file)
@@ -541,7 +541,7 @@ static int copy_file_with_version_check(const char *from, const char *to, bool f
                         return log_error_errno(errno, "Failed to open \"%s\" for writing: %m", t);
         }
 
-        r = copy_bytes(fd_from, fd_to, (uint64_t) -1, COPY_REFLINK);
+        r = copy_bytes(fd_from, fd_to, UINT64_MAX, COPY_REFLINK);
         if (r < 0) {
                 (void) unlink(t);
                 return log_error_errno(r, "Failed to copy data from \"%s\" to \"%s\": %m", from, t);
index c8421e1ee7aa40e7f1c8a1e931d512f16869266f..cbc24bc2517f32300916551fc5f7e6b1a9a244ab 100644 (file)
@@ -1328,7 +1328,7 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f
                 if (r > 0)
                         continue;
 
-                r = sd_bus_wait(bus, (uint64_t) -1);
+                r = sd_bus_wait(bus, UINT64_MAX);
                 if (r < 0)
                         return log_error_errno(r, "Failed to wait for bus: %m");
         }
index 29817224ad8e6cd5cbc426caf54490303110d8b0..5424f2c90f78cee45f545eff639a9ce650092031 100644 (file)
@@ -56,7 +56,7 @@ typedef struct Group {
 } Group;
 
 static unsigned arg_depth = 3;
-static unsigned arg_iterations = (unsigned) -1;
+static unsigned arg_iterations = UINT_MAX;
 static bool arg_batch = false;
 static bool arg_raw = false;
 static usec_t arg_delay = 1*USEC_PER_SEC;
@@ -943,7 +943,7 @@ static int run(int argc, char *argv[]) {
 
         signal(SIGWINCH, columns_lines_cache_reset);
 
-        if (arg_iterations == (unsigned) -1)
+        if (arg_iterations == UINT_MAX)
                 arg_iterations = on_tty() ? 0 : 1;
 
         while (!quit) {
index f474a02b0e27040e8e47726637385c44f2e2bf20..b664bbffa674e3db63e072c4fd5e575d1c3e40ea 100644 (file)
@@ -3309,7 +3309,7 @@ int bus_exec_context_set_transient_property(
                         if (r < 0)
                                 return r;
 
-                        if (rl == (uint64_t) -1)
+                        if (rl == UINT64_MAX)
                                 x = RLIM_INFINITY;
                         else {
                                 x = (rlim_t) rl;
index 859e35eee4244516aaf6a165d78587dd956a8ff6..39d6799b59a7f91818bbb19b226c4543ce1ace02 100644 (file)
@@ -1069,7 +1069,7 @@ static int property_get_current_memory(
                 void *userdata,
                 sd_bus_error *error) {
 
-        uint64_t sz = (uint64_t) -1;
+        uint64_t sz = UINT64_MAX;
         Unit *u = userdata;
         int r;
 
@@ -1093,7 +1093,7 @@ static int property_get_current_tasks(
                 void *userdata,
                 sd_bus_error *error) {
 
-        uint64_t cn = (uint64_t) -1;
+        uint64_t cn = UINT64_MAX;
         Unit *u = userdata;
         int r;
 
@@ -1117,7 +1117,7 @@ static int property_get_cpu_usage(
                 void *userdata,
                 sd_bus_error *error) {
 
-        nsec_t ns = (nsec_t) -1;
+        nsec_t ns = NSEC_INFINITY;
         Unit *u = userdata;
         int r;
 
index 0214cee65e3809e60e7706456aeb5e3c3360c724..158172bd263e916efa2dbf1d95adf72c47e007eb 100644 (file)
@@ -2508,7 +2508,7 @@ static int write_credential(
                                             * user can no longer chmod() the file to gain write access. */
                                 return r;
 
-                        if (fchown(fd, uid, (gid_t) -1) < 0)
+                        if (fchown(fd, uid, GID_INVALID) < 0)
                                 return -errno;
                 }
         }
@@ -2626,7 +2626,7 @@ static int acquire_credentials(
                         if (!ownership_ok)
                                 return r;
 
-                        if (fchown(dfd, uid, (gid_t) -1) < 0)
+                        if (fchown(dfd, uid, GID_INVALID) < 0)
                                 return -errno;
                 }
         }
index c27814ad387f07e7797e575056efe9dac818eae3..f9c334cc65ed2a178db05db165188c04290c1767 100644 (file)
@@ -1094,7 +1094,7 @@ int config_parse_exec_input_data(
                 return 0;
         }
 
-        r = unbase64mem(rvalue, (size_t) -1, &p, &sz);
+        r = unbase64mem(rvalue, SIZE_MAX, &p, &sz);
         if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r,
                            "Failed to decode base64 data, ignoring: %s", rvalue);
index af5a1f426d1fb6cb63103b193d3a3a7e58386254..0ddd6298513cba22f08be59d99ed3c85b5e9a550 100644 (file)
@@ -544,7 +544,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
                 if (proc_cmdline_value_missing(key, value))
                         return 0;
 
-                r = unbase64mem(value, (size_t) -1, &p, &sz);
+                r = unbase64mem(value, SIZE_MAX, &p, &sz);
                 if (r < 0)
                         log_warning_errno(r, "Failed to parse systemd.random_seed= argument, ignoring: %s", value);
 
index d8f80a55362cfe231420828fdfa9f9a64920fe5f..629966ea60edef121b4afb36b6448c123293996b 100644 (file)
@@ -2200,7 +2200,7 @@ static unsigned manager_dispatch_dbus_queue(Manager *m) {
         /* When we are reloading, let's not wait with generating signals, since we need to exit the manager as quickly
          * as we can. There's no point in throttling generation of signals in that case. */
         if (MANAGER_IS_RELOADING(m) || m->send_reloading_done || m->pending_reload_message)
-                budget = (unsigned) -1; /* infinite budget in this case */
+                budget = UINT_MAX; /* infinite budget in this case */
         else {
                 /* Anything to do at all? */
                 if (!m->dbus_unit_queue && !m->dbus_job_queue)
@@ -2232,7 +2232,7 @@ static unsigned manager_dispatch_dbus_queue(Manager *m) {
                 bus_unit_send_change_signal(u);
                 n++;
 
-                if (budget != (unsigned) -1)
+                if (budget != UINT_MAX)
                         budget--;
         }
 
@@ -2242,7 +2242,7 @@ static unsigned manager_dispatch_dbus_queue(Manager *m) {
                 bus_job_send_change_signal(j);
                 n++;
 
-                if (budget != (unsigned) -1)
+                if (budget != UINT_MAX)
                         budget--;
         }
 
index 6255e704ced0f1a6a464d99ddeee509672fcc7db..2aba8bff1c6302ac35c635e03227b210da798416 100644 (file)
@@ -99,7 +99,7 @@ static void socket_init(Unit *u) {
         s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID;
 
         s->trigger_limit.interval = USEC_INFINITY;
-        s->trigger_limit.burst = (unsigned) -1;
+        s->trigger_limit.burst = UINT_MAX;
 }
 
 static void socket_unwatch_control_pid(Socket *s) {
@@ -313,7 +313,7 @@ static int socket_add_extras(Socket *s) {
         if (s->trigger_limit.interval == USEC_INFINITY)
                 s->trigger_limit.interval = 2 * USEC_PER_SEC;
 
-        if (s->trigger_limit.burst == (unsigned) -1) {
+        if (s->trigger_limit.burst == UINT_MAX) {
                 if (s->accept)
                         s->trigger_limit.burst = 200;
                 else
index d20df847e8edd9af84e133c0ec46c4bfeb85aa5d..95c3fca66186e5f5a1852e6ba59cbcfc9bc2f8c4 100644 (file)
@@ -66,7 +66,7 @@ static int uid_from_file_name(const char *filename, uid_t *uid) {
 }
 
 static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t max_use) {
-        uint64_t fs_size = 0, fs_free = (uint64_t) -1;
+        uint64_t fs_size = 0, fs_free = UINT64_MAX;
         struct statvfs sv;
 
         assert(fd >= 0);
@@ -76,7 +76,7 @@ static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t
                 fs_free = sv.f_frsize * sv.f_bfree;
         }
 
-        if (max_use == (uint64_t) -1) {
+        if (max_use == UINT64_MAX) {
 
                 if (fs_size > 0) {
                         max_use = PAGE_ALIGN(fs_size / 10); /* 10% */
@@ -94,7 +94,7 @@ static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t
         if (max_use > 0 && sum > max_use)
                 return true;
 
-        if (keep_free == (uint64_t) -1) {
+        if (keep_free == UINT64_MAX) {
 
                 if (fs_size > 0) {
                         keep_free = PAGE_ALIGN((fs_size * 3) / 20); /* 15% */
index c727cddba42c0c8935114f8ac205eb4b0129231d..72e859a565dafb7a1e7429f1aa921aae82ea7d78 100644 (file)
@@ -141,8 +141,8 @@ static bool arg_compress = true;
 static uint64_t arg_process_size_max = PROCESS_SIZE_MAX;
 static uint64_t arg_external_size_max = EXTERNAL_SIZE_MAX;
 static uint64_t arg_journal_size_max = JOURNAL_SIZE_MAX;
-static uint64_t arg_keep_free = (uint64_t) -1;
-static uint64_t arg_max_use = (uint64_t) -1;
+static uint64_t arg_keep_free = UINT64_MAX;
+static uint64_t arg_max_use = UINT64_MAX;
 
 static int parse_config(void) {
         static const ConfigTableItem items[] = {
index ac212ea23b885085d79094b6bcb8ba2717edd4ea..840884d961220a631f5c142e8f663221802eb2cc 100644 (file)
@@ -6,7 +6,7 @@
 
 int main(int argc, char *argv[]) {
 
-        if (coredump_vacuum(-1, (uint64_t) -1, 70 * 1024) < 0)
+        if (coredump_vacuum(-1, UINT64_MAX, 70 * 1024) < 0)
                 return EXIT_FAILURE;
 
         return EXIT_SUCCESS;
index b58f3a2e7fc024028c821fb7f2ebfeceb233f0f7..9c1478c474e34a1476c1112277a5caf0d89b27f0 100644 (file)
@@ -42,7 +42,7 @@ static int search_policy_hash(
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "TPM2 token data lacks 'tpm2-policy-hash' field.");
 
-                r = unhexmem(json_variant_string(w), (size_t) -1, &thash, &thash_size);
+                r = unhexmem(json_variant_string(w), SIZE_MAX, &thash, &thash_size);
                 if (r < 0)
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "Invalid base64 data in 'tpm2-policy-hash' field.");
index 623a52fa0b005900aaab631a53807e1d1fafd178..dfdb964360a7998e9cecfc527726641dc3c35b6e 100644 (file)
@@ -138,7 +138,7 @@ int find_fido2_auto_data(
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "FIDO2 token data lacks 'fido2-credential' field.");
 
-                r = unbase64mem(json_variant_string(w), (size_t) -1, &cid, &cid_size);
+                r = unbase64mem(json_variant_string(w), SIZE_MAX, &cid, &cid_size);
                 if (r < 0)
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "Invalid base64 data in 'fido2-credential' field.");
@@ -150,7 +150,7 @@ int find_fido2_auto_data(
 
                 assert(!salt);
                 assert(salt_size == 0);
-                r = unbase64mem(json_variant_string(w), (size_t) -1, &salt, &salt_size);
+                r = unbase64mem(json_variant_string(w), SIZE_MAX, &salt, &salt_size);
                 if (r < 0)
                         return log_error_errno(r, "Failed to decode base64 encoded salt.");
 
index a005b62cafb9c04fca8c0c8d03525dfa3e72b2ad..8d7d74fb75b1294725db55248dfaa8be9d88bc57 100644 (file)
@@ -214,7 +214,7 @@ int find_pkcs11_auto_data(
 
                 assert(!key);
                 assert(key_size == 0);
-                r = unbase64mem(json_variant_string(w), (size_t) -1, &key, &key_size);
+                r = unbase64mem(json_variant_string(w), SIZE_MAX, &key, &key_size);
                 if (r < 0)
                         return log_error_errno(r, "Failed to decode base64 encoded key.");
 
index c22f63d973e5074f1010a03fbccd6b3704dee93e..4757c5882d0e3becbfe14e36e04738809062dc9a 100644 (file)
@@ -125,7 +125,7 @@ int find_tpm2_auto_data(
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "TPM2 token data lacks 'tpm2-blob' field.");
 
-                r = unbase64mem(json_variant_string(w), (size_t) -1, &blob, &blob_size);
+                r = unbase64mem(json_variant_string(w), SIZE_MAX, &blob, &blob_size);
                 if (r < 0)
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "Invalid base64 data in 'tpm2-blob' field.");
@@ -136,7 +136,7 @@ int find_tpm2_auto_data(
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "TPM2 token data lacks 'tpm2-policy-hash' field.");
 
-                r = unhexmem(json_variant_string(w), (size_t) -1, &policy_hash, &policy_hash_size);
+                r = unhexmem(json_variant_string(w), SIZE_MAX, &policy_hash, &policy_hash_size);
                 if (r < 0)
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                                "Invalid base64 data in 'tpm2-policy-hash' field.");
index 00de920d091f9c300555e43d7b1f8f58f72f9726..dba26a54a3f15faa45c1d82e557bb31f5e52088b 100644 (file)
@@ -320,7 +320,7 @@ static int parse_one_option(const char *option) {
                         _cleanup_free_ void *cid = NULL;
                         size_t cid_size;
 
-                        r = unbase64mem(val, (size_t) -1, &cid, &cid_size);
+                        r = unbase64mem(val, SIZE_MAX, &cid, &cid_size);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to decode FIDO2 CID data: %m");
 
index 85102d3efa4ce28d7b9182956d3411848a93fe8a..b9adbb6f7f2bea831d2b112d978fc9227f0abbe9 100644 (file)
@@ -627,7 +627,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
 
                 /* Copying to stdout? */
                 if (streq(arg_target, "-")) {
-                        r = copy_bytes(source_fd, STDOUT_FILENO, (uint64_t) -1, COPY_REFLINK);
+                        r = copy_bytes(source_fd, STDOUT_FILENO, UINT64_MAX, COPY_REFLINK);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to copy bytes from %s in mage '%s' to stdout: %m", arg_source, arg_image);
 
@@ -653,7 +653,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
                 if (target_fd < 0)
                         return log_error_errno(errno, "Failed to create regular file at target path '%s': %m", arg_target);
 
-                r = copy_bytes(source_fd, target_fd, (uint64_t) -1, COPY_REFLINK);
+                r = copy_bytes(source_fd, target_fd, UINT64_MAX, COPY_REFLINK);
                 if (r < 0)
                         return log_error_errno(r, "Failed to copy bytes from %s in mage '%s' to '%s': %m", arg_source, arg_image, arg_target);
 
@@ -684,7 +684,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
                         if (target_fd < 0)
                                 return log_error_errno(errno, "Failed to open target file '%s': %m", arg_target);
 
-                        r = copy_bytes(STDIN_FILENO, target_fd, (uint64_t) -1, COPY_REFLINK);
+                        r = copy_bytes(STDIN_FILENO, target_fd, UINT64_MAX, COPY_REFLINK);
                         if (r < 0)
                                 return log_error_errno(r, "Failed to copy bytes from stdin to '%s' in image '%s': %m", arg_target, arg_image);
 
@@ -722,7 +722,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
                 if (target_fd < 0)
                         return log_error_errno(errno, "Failed to open target file '%s': %m", arg_target);
 
-                r = copy_bytes(source_fd, target_fd, (uint64_t) -1, COPY_REFLINK);
+                r = copy_bytes(source_fd, target_fd, UINT64_MAX, COPY_REFLINK);
                 if (r < 0)
                         return log_error_errno(r, "Failed to copy bytes from '%s' to '%s' in image '%s': %m", arg_source, arg_target, arg_image);
 
index c0e88e7915d5d96b72636d2291769b3e2477470f..feb682792d7b36dde1876df42222f823cb4f00fd 100644 (file)
@@ -771,7 +771,7 @@ static int write_root_shadow(const char *shadow_path, const char *hashed_passwor
                         .sp_warn = -1,
                         .sp_inact = -1,
                         .sp_expire = -1,
-                        .sp_flag = (unsigned long) -1, /* this appears to be what everybody does ... */
+                        .sp_flag = ULONG_MAX, /* this appears to be what everybody does ... */
                 };
 
                 if (errno != ENOENT)
index 3e0348f4c160f074cc9328e4ee70378863438228..d42c56172fdde8d9a12645bc37c08401f36900a3 100644 (file)
@@ -95,7 +95,7 @@ int raw_export_new(
                 .input_fd = -1,
                 .on_finished = on_finished,
                 .userdata = userdata,
-                .last_percent = (unsigned) -1,
+                .last_percent = UINT_MAX,
                 .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
         };
 
index 1e6b2c12683f594de9a24e7e76a109d556a4f0a3..b734c3004a7158deca8ea529c4cf5c3efc6ffb9f 100644 (file)
@@ -97,8 +97,8 @@ int tar_export_new(
                 .tar_fd = -1,
                 .on_finished = on_finished,
                 .userdata = userdata,
-                .quota_referenced = (uint64_t) -1,
-                .last_percent = (unsigned) -1,
+                .quota_referenced = UINT64_MAX,
+                .last_percent = UINT_MAX,
                 .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
         };
 
@@ -120,7 +120,7 @@ static void tar_export_report_progress(TarExport *e) {
         assert(e);
 
         /* Do we have any quota info? If not, we don't know anything about the progress */
-        if (e->quota_referenced == (uint64_t) -1)
+        if (e->quota_referenced == UINT64_MAX)
                 return;
 
         if (e->written_uncompressed >= e->quota_referenced)
@@ -281,7 +281,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
         if (r < 0)
                 return r;
 
-        e->quota_referenced = (uint64_t) -1;
+        e->quota_referenced = UINT64_MAX;
 
         if (btrfs_might_be_subvol(&e->st)) {
                 BtrfsQuotaInfo q;
index 4eb59fbb25c09126a72f5ba83103e0c4fd2eccf0..0e7757b6f0c114e1cf95d79876086510f1d70cc3 100644 (file)
@@ -104,7 +104,7 @@ int raw_import_new(
                 .output_fd = -1,
                 .on_finished = on_finished,
                 .userdata = userdata,
-                .last_percent = (unsigned) -1,
+                .last_percent = UINT_MAX,
                 .image_root = TAKE_PTR(root),
                 .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
         };
index e94474389d5c57bc3c548f33ffdf4286de3e4d2e..7c4e5127a9fb495e475910dab7464ebedfb3ffdc 100644 (file)
@@ -113,7 +113,7 @@ int tar_import_new(
                 .tar_fd = -1,
                 .on_finished = on_finished,
                 .userdata = userdata,
-                .last_percent = (unsigned) -1,
+                .last_percent = UINT_MAX,
                 .image_root = TAKE_PTR(root),
                 .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
         };
index f9e8481a6d73b7ca882efe271370fd674c308e35..fa8ff68a461bd2c8994d4dbc23dfdf18f873df8e 100644 (file)
@@ -161,7 +161,7 @@ static int transfer_new(Manager *m, Transfer **ret) {
                 .stdin_fd = -1,
                 .stdout_fd = -1,
                 .verify = _IMPORT_VERIFY_INVALID,
-                .progress_percent= (unsigned) -1,
+                .progress_percent= UINT_MAX,
         };
 
         id = m->current_transfer_id + 1;
@@ -186,7 +186,7 @@ static int transfer_new(Manager *m, Transfer **ret) {
 static double transfer_percent_as_double(Transfer *t) {
         assert(t);
 
-        if (t->progress_percent == (unsigned) -1)
+        if (t->progress_percent == UINT_MAX)
                 return -DBL_MAX;
 
         return (double) t->progress_percent / 100.0;
index 908546b96839af76e449a2c58ee38b5f4ec2e7b1..33512cd77a8adfb1d1fef0a9622a53e27208e666 100644 (file)
@@ -176,7 +176,7 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
                 goto finish;
         }
 
-        if (j->content_length != (uint64_t) -1 &&
+        if (j->content_length != UINT64_MAX &&
             j->content_length != j->written_compressed) {
                 log_error("Download truncated.");
                 r = -EIO;
@@ -293,7 +293,7 @@ static int pull_job_write_compressed(PullJob *j, void *p, size_t sz) {
         if (j->written_compressed + sz > j->compressed_max)
                 return log_error_errno(SYNTHETIC_ERRNO(EFBIG), "File overly large, refusing.");
 
-        if (j->content_length != (uint64_t) -1 &&
+        if (j->content_length != UINT64_MAX &&
             j->written_compressed + sz > j->content_length)
                 return log_error_errno(SYNTHETIC_ERRNO(EFBIG),
                                        "Content length incorrect.");
@@ -502,7 +502,7 @@ static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb
         if (r > 0) {
                 (void) safe_atou64(length, &j->content_length);
 
-                if (j->content_length != (uint64_t) -1) {
+                if (j->content_length != UINT64_MAX) {
                         char bytes[FORMAT_BYTES_MAX];
 
                         if (j->content_length > j->compressed_max) {
@@ -604,7 +604,7 @@ int pull_job_new(PullJob **ret, const char *url, CurlGlue *glue, void *userdata)
                 .disk_fd = -1,
                 .userdata = userdata,
                 .glue = glue,
-                .content_length = (uint64_t) -1,
+                .content_length = UINT64_MAX,
                 .start_usec = now(CLOCK_MONOTONIC),
                 .compressed_max = 64LLU * 1024LLU * 1024LLU * 1024LLU, /* 64GB safety limit */
                 .uncompressed_max = 64LLU * 1024LLU * 1024LLU * 1024LLU, /* 64GB safety limit */
index c9bda3c3b48cfbb72023547f2a8bf7c3845dcc2f..9b5d8ef9e30c009e96b40f9273f5ec30a0a0612f 100644 (file)
@@ -364,7 +364,7 @@ static int raw_pull_make_local_copy(RawPull *i) {
          * since it reduces fragmentation caused by not allowing in-place writes. */
         (void) import_set_nocow_and_log(dfd, tp);
 
-        r = copy_bytes(i->raw_job->disk_fd, dfd, (uint64_t) -1, COPY_REFLINK);
+        r = copy_bytes(i->raw_job->disk_fd, dfd, UINT64_MAX, COPY_REFLINK);
         if (r < 0) {
                 (void) unlink(tp);
                 return log_error_errno(r, "Failed to make writable copy of image: %m");
index 3e84c3dd7b91cb7f7e0b32bbfc01a0587488d571..ae1d43756a143ede25b95ad2b2d000681e6f034a 100644 (file)
@@ -471,7 +471,7 @@ static int setup_microhttpd_server(RemoteServer *s,
         }
 
         r = sd_event_add_time(s->events, &d->timer_event,
-                              CLOCK_MONOTONIC, (uint64_t) -1, 0,
+                              CLOCK_MONOTONIC, UINT64_MAX, 0,
                               null_timer_event_handler, d);
         if (r < 0) {
                 log_error_errno(r, "Failed to add timer_event: %m");
index 764a3ec70bf6506a3ec417173380b2249ee0755d..ea7162318ed243ce4fa01a6ca8cc6880683ad2f9 100644 (file)
@@ -4,7 +4,7 @@
 #include "journal-remote.h"
 
 static int do_rotate(JournalFile **f, bool compress, bool seal) {
-        int r = journal_file_rotate(f, compress, (uint64_t) -1, seal, NULL);
+        int r = journal_file_rotate(f, compress, UINT64_MAX, seal, NULL);
         if (r < 0) {
                 if (*f)
                         log_error_errno(r, "Failed to rotate %s: %m", (*f)->path);
index 0cee84445270112ca8763ed101093916283917e6..6f71248aaf31cf754652aa04d05d31b5c0fa73ab 100644 (file)
@@ -62,7 +62,7 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) {
 
         r = journal_file_open_reliably(filename,
                                        O_RDWR|O_CREAT, 0640,
-                                       s->compress, (uint64_t) -1, s->seal,
+                                       s->compress, UINT64_MAX, s->seal,
                                        &w->metrics,
                                        w->mmap, NULL,
                                        NULL, &w->journal);
index 3296c2268eac2bc163e34d8ca52b433adf2f6318..f23d5cf8b9ca6d9a2edc2fe85393e1d0f569b220 100644 (file)
@@ -399,7 +399,7 @@ int open_journal_for_upload(Uploader *u,
                         return log_error_errno(r, "Failed to register input event: %m");
 
                 log_debug("Listening for journal events on fd:%d, timeout %d",
-                          fd, u->timeout == (uint64_t) -1 ? -1 : (int) u->timeout);
+                          fd, u->timeout == UINT64_MAX ? -1 : (int) u->timeout);
         } else
                 log_debug("Not listening for journal events.");
 
index 038b335cb32bcdf25028273b0c961d00132e2b21..8a979df3ced408094695d86838772e48e6a4013f 100644 (file)
@@ -27,7 +27,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         assert_se(stdout_stream_install(&s, stream_fds[0], &stream) >= 0);
         assert_se(write(stream_fds[1], data, size) == (ssize_t) size);
         while (ioctl(stream_fds[0], SIOCINQ, &v) == 0 && v)
-                sd_event_run(s.event, (uint64_t) -1);
+                sd_event_run(s.event, UINT64_MAX);
         if (s.n_stdout_streams)
                 stdout_stream_destroy(stream);
         server_done(&s);
index 58151aa03db97a01be0540226c1f7bde2db99699..add0a5480d54a17d4d394302f38006cd16fb4905 100644 (file)
@@ -69,7 +69,7 @@
 static size_t cache_max(void) {
         static size_t cached = -1;
 
-        if (cached == (size_t) -1) {
+        if (cached == SIZE_MAX) {
                 uint64_t mem_total;
                 int r;
 
index 1c5849ed5535e6d636634f1387048e3a5edb2f6d..102814a403da8057654207b46a6f4038d0fc7ab1 100644 (file)
@@ -105,7 +105,7 @@ static int server_process_entry(
          *
          * Note that *remaining is altered on both success and failure. */
 
-        size_t n = 0, j, tn = (size_t) -1, m = 0, entry_size = 0;
+        size_t n = 0, j, tn = SIZE_MAX, m = 0, entry_size = 0;
         char *identifier = NULL, *message = NULL;
         struct iovec *iovec = NULL;
         int priority = LOG_INFO;
index 4234ab2e611aba6930f93aadcb2e5070575287c6..e76c13a3b65195ac818823fb5112df4e7ca1a341 100644 (file)
@@ -2185,7 +2185,7 @@ int server_init(Server *s, const char *namespace) {
                 .notify_fd = -1,
 
                 .compress.enabled = true,
-                .compress.threshold_bytes = (uint64_t) -1,
+                .compress.threshold_bytes = UINT64_MAX,
                 .seal = true,
 
                 .set_audit = true,
@@ -2593,7 +2593,7 @@ int config_parse_compress(
 
         if (isempty(rvalue)) {
                 compress->enabled = true;
-                compress->threshold_bytes = (uint64_t) -1;
+                compress->threshold_bytes = UINT64_MAX;
         } else if (streq(rvalue, "1")) {
                 log_syntax(unit, LOG_WARNING, filename, line, 0,
                            "Compress= ambiguously specified as 1, enabling compression with default threshold");
index 4f29e1b310fbf073967b8ab43ed159924adab276..bd0de9600a91fde39399611a666417c96b582958 100644 (file)
@@ -43,7 +43,7 @@ static void test_config_compress(void) {
         /* Invalid Case */
         COMPRESS_PARSE_CHECK("-1", true, 111);
         COMPRESS_PARSE_CHECK("blah blah", true, 111);
-        COMPRESS_PARSE_CHECK("", true, (uint64_t)-1);
+        COMPRESS_PARSE_CHECK("", true, UINT64_MAX);
 }
 
 int main(int argc, char *argv[]) {
index e5e70dd606ef9b1bf2df455125bb3927579b0222..acb8d9b98ca0d5eeabced8f0f233b765b5edf4d5 100644 (file)
@@ -41,7 +41,7 @@ static void fuzz_client(const uint8_t *data, size_t size, bool is_information_re
 
         assert_se(write(test_dhcp_fd[1], data, size) == (ssize_t) size);
 
-        sd_event_run(e, (uint64_t) -1);
+        sd_event_run(e, UINT64_MAX);
 
         assert_se(sd_dhcp6_client_stop(client) >= 0);
 
index d74cd2fffc7f50fffc1adf576a76e64ae52170e8..20350d449cf398d39b5eb683c8eb2087ce61f41b 100644 (file)
@@ -53,7 +53,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
         assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
         assert_se(sd_ndisc_start(nd) >= 0);
         assert_se(write(test_fd[1], data, size) == (ssize_t) size);
-        (void) sd_event_run(e, (uint64_t) -1);
+        (void) sd_event_run(e, UINT64_MAX);
         assert_se(sd_ndisc_stop(nd) >= 0);
         close(test_fd[1]);
 
index 9616cb6250bba70d9f51f8d30b974fd6191178e5..43141b2d7956e3bff1bca89d5d0712d65c2ec7c2 100644 (file)
@@ -22,7 +22,7 @@ int lldp_network_bind_raw_socket(int ifindex) {
                 BPF_STMT(BPF_LD + BPF_H + BPF_ABS, offsetof(struct ethhdr, h_proto)),     /* A <- protocol */
                 BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_LLDP, 1, 0),                /* A != ETHERTYPE_LLDP */
                 BPF_STMT(BPF_RET + BPF_K, 0),                                             /* drop packet */
-                BPF_STMT(BPF_RET + BPF_K, (uint32_t) -1),                                 /* accept packet */
+                BPF_STMT(BPF_RET + BPF_K, UINT32_MAX),                                    /* accept packet */
         };
 
         static const struct sock_fprog fprog = {
index dd9cbf6ea5f1716f49cd7762caea7a403872f797..fb94fdc88289ace602f0f5e552498245de141175 100644 (file)
@@ -2229,7 +2229,7 @@ int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize) {
                 .mtu = DHCP_DEFAULT_MIN_SIZE,
                 .port = DHCP_PORT_CLIENT,
                 .anonymize = !!anonymize,
-                .max_attempts = (uint64_t) -1,
+                .max_attempts = UINT64_MAX,
                 .ip_service_type = -1,
         };
         /* NOTE: this could be moved to a function. */
index 9fcbe17006a13d762e48f030a9e4381488edcdf6..6d88c88e6bb794c6ac3e9360c80f4b0bdec65653 100644 (file)
@@ -1257,13 +1257,13 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
         }
 
         if (client_id_hex) {
-                r = unhexmem(client_id_hex, (size_t) -1, &lease->client_id, &lease->client_id_len);
+                r = unhexmem(client_id_hex, SIZE_MAX, &lease->client_id, &lease->client_id_len);
                 if (r < 0)
                         log_debug_errno(r, "Failed to parse client ID %s, ignoring: %m", client_id_hex);
         }
 
         if (vendor_specific_hex) {
-                r = unhexmem(vendor_specific_hex, (size_t) -1, &lease->vendor_specific, &lease->vendor_specific_len);
+                r = unhexmem(vendor_specific_hex, SIZE_MAX, &lease->vendor_specific, &lease->vendor_specific_len);
                 if (r < 0)
                         log_debug_errno(r, "Failed to parse vendor specific data %s, ignoring: %m", vendor_specific_hex);
         }
@@ -1275,7 +1275,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
                 if (!options[i])
                         continue;
 
-                r = unhexmem(options[i], (size_t) -1, &data, &len);
+                r = unhexmem(options[i], SIZE_MAX, &data, &len);
                 if (r < 0) {
                         log_debug_errno(r, "Failed to parse private DHCP option %s, ignoring: %m", options[i]);
                         continue;
index d3848ebf91cdddfbc733303065b1f929d0136b1a..3c0285df4e92308856af3294e111210ffeacad1a 100644 (file)
@@ -373,7 +373,7 @@ _public_ int sd_lldp_new(sd_lldp **ret) {
                 .n_ref = 1,
                 .fd = -1,
                 .neighbors_max = LLDP_DEFAULT_NEIGHBORS_MAX,
-                .capability_mask = (uint16_t) -1,
+                .capability_mask = UINT16_MAX,
         };
 
         lldp->neighbor_by_id = hashmap_new(&lldp_neighbor_hash_ops);
index d39d1f57a07ef1d53195b7fa00a01cba64e44f31..b464d3d700a3e6eeab07fb4c3c76995b7ac5a9b0 100644 (file)
@@ -308,7 +308,7 @@ static void test_discover_message(sd_event *e) {
 
         assert_se(IN_SET(res, 0, -EINPROGRESS));
 
-        sd_event_run(e, (uint64_t) -1);
+        sd_event_run(e, UINT64_MAX);
 
         sd_dhcp_client_stop(client);
         sd_dhcp_client_unref(client);
index 49e1d590be3e0bdd97b23f1f15958c2f62665347..768595969b7f94ad67afc4f49303d7a9189251c8 100644 (file)
@@ -160,25 +160,25 @@ static void test_basic_request(sd_event *e) {
         assert_se(sd_ipv4ll_set_ifindex(ll, 1) == 0);
         assert_se(sd_ipv4ll_start(ll) == 1);
 
-        sd_event_run(e, (uint64_t) -1);
+        sd_event_run(e, UINT64_MAX);
         assert_se(sd_ipv4ll_start(ll) == 0);
 
         assert_se(sd_ipv4ll_is_running(ll));
 
         /* PROBE */
-        sd_event_run(e, (uint64_t) -1);
+        sd_event_run(e, UINT64_MAX);
         assert_se(recv(test_fd[1], &arp, sizeof(struct ether_arp), 0) == sizeof(struct ether_arp));
 
         if (extended) {
                 /* PROBE */
-                sd_event_run(e, (uint64_t) -1);
+                sd_event_run(e, UINT64_MAX);
                 assert_se(recv(test_fd[1], &arp, sizeof(struct ether_arp), 0) == sizeof(struct ether_arp));
 
                 /* PROBE */
-                sd_event_run(e, (uint64_t) -1);
+                sd_event_run(e, UINT64_MAX);
                 assert_se(recv(test_fd[1], &arp, sizeof(struct ether_arp), 0) == sizeof(struct ether_arp));
 
-                sd_event_run(e, (uint64_t) -1);
+                sd_event_run(e, UINT64_MAX);
                 assert_se(basic_request_handler_bind == 1);
         }
 
index 943877f0ea0b95f2033b23660f0ecdb31cd1e98f..d96b7256a1b162d173a60f223f43a50803be1c11 100644 (file)
@@ -741,7 +741,7 @@ _public_ int sd_bus_get_owner_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **r
                 mask &= ~SD_BUS_CREDS_AUGMENT;
 
         do_label = bus->label && (mask & SD_BUS_CREDS_SELINUX_CONTEXT);
-        do_groups = bus->n_groups != (size_t) -1 && (mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS);
+        do_groups = bus->n_groups != SIZE_MAX && (mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS);
 
         /* Avoid allocating anything if we have no chance of returning useful data */
         if (!bus->ucred_valid && !do_label && !do_groups)
index 7ee6e7012f29c864fadd5a1527eb0fb8b47540ff..d5d22b0d8c64f086cd97dd28ecc7dfcde02e1103 100644 (file)
@@ -81,7 +81,7 @@ _public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
                         m->header->version);
 
                 /* Display synthetic message serial number in a more readable
-                 * format than (uint32_t) -1 */
+                 * format than UINT32_MAX */
                 if (BUS_MESSAGE_COOKIE(m) == 0xFFFFFFFFULL)
                         fprintf(f, " Cookie=-1");
                 else
index 894d681260f3c233d011577cff02353191f20f5e..fba1dbbd7d56dfc47e821db0b623b3d63812b8f3 100644 (file)
@@ -162,7 +162,7 @@ static void *message_extend_fields(sd_bus_message *m, size_t align, size_t sz, b
         new_size = start + sz;
 
         if (new_size < start ||
-            new_size > (size_t) ((uint32_t) -1))
+            new_size > (size_t) (UINT32_MAX))
                 goto poison;
 
         if (old_size == new_size)
@@ -1337,7 +1337,7 @@ static void *message_extend_body(
         added = padding + sz;
 
         /* Check for 32bit overflows */
-        if (end_body > (size_t) ((uint32_t) -1) ||
+        if (end_body > (size_t) (UINT32_MAX) ||
             end_body < start_body) {
                 m->poisoned = true;
                 return NULL;
@@ -2340,13 +2340,13 @@ _public_ int sd_bus_message_appendv(
         assert_return(!m->sealed, -EPERM);
         assert_return(!m->poisoned, -ESTALE);
 
-        n_array = (unsigned) -1;
+        n_array = UINT_MAX;
         n_struct = strlen(types);
 
         for (;;) {
                 const char *t;
 
-                if (n_array == 0 || (n_array == (unsigned) -1 && n_struct == 0)) {
+                if (n_array == 0 || (n_array == UINT_MAX && n_struct == 0)) {
                         r = type_stack_pop(stack, ELEMENTSOF(stack), &stack_ptr, &types, &n_struct, &n_array);
                         if (r < 0)
                                 return r;
@@ -2361,7 +2361,7 @@ _public_ int sd_bus_message_appendv(
                 }
 
                 t = types;
-                if (n_array != (unsigned) -1)
+                if (n_array != UINT_MAX)
                         n_array--;
                 else {
                         types++;
@@ -2445,7 +2445,7 @@ _public_ int sd_bus_message_appendv(
                                         return r;
                         }
 
-                        if (n_array == (unsigned) -1) {
+                        if (n_array == UINT_MAX) {
                                 types += k;
                                 n_struct -= k;
                         }
@@ -2478,7 +2478,7 @@ _public_ int sd_bus_message_appendv(
 
                         types = s;
                         n_struct = strlen(s);
-                        n_array = (unsigned) -1;
+                        n_array = UINT_MAX;
 
                         break;
                 }
@@ -2502,7 +2502,7 @@ _public_ int sd_bus_message_appendv(
                                         return r;
                         }
 
-                        if (n_array == (unsigned) -1) {
+                        if (n_array == UINT_MAX) {
                                 types += k - 1;
                                 n_struct -= k - 1;
                         }
@@ -2513,7 +2513,7 @@ _public_ int sd_bus_message_appendv(
 
                         types = t + 1;
                         n_struct = k - 2;
-                        n_array = (unsigned) -1;
+                        n_array = UINT_MAX;
 
                         break;
                 }
@@ -2675,7 +2675,7 @@ _public_ int sd_bus_message_append_array_memfd(
         if (r < 0)
                 return r;
 
-        if (offset == 0 && size == (uint64_t) -1)
+        if (offset == 0 && size == UINT64_MAX)
                 size = real_size;
         else if (offset + size > real_size)
                 return -EMSGSIZE;
@@ -2692,7 +2692,7 @@ _public_ int sd_bus_message_append_array_memfd(
         if (size % sz != 0)
                 return -EINVAL;
 
-        if (size > (uint64_t) (uint32_t) -1)
+        if (size > (uint64_t) UINT32_MAX)
                 return -EINVAL;
 
         r = sd_bus_message_open_container(m, SD_BUS_TYPE_ARRAY, CHAR_TO_STR(type));
@@ -2750,7 +2750,7 @@ _public_ int sd_bus_message_append_string_memfd(
         if (r < 0)
                 return r;
 
-        if (offset == 0 && size == (uint64_t) -1)
+        if (offset == 0 && size == UINT64_MAX)
                 size = real_size;
         else if (offset + size > real_size)
                 return -EMSGSIZE;
@@ -2759,7 +2759,7 @@ _public_ int sd_bus_message_append_string_memfd(
         if (size == 0)
                 return -EINVAL;
 
-        if (size > (uint64_t) (uint32_t) -1)
+        if (size > (uint64_t) UINT32_MAX)
                 return -EINVAL;
 
         c = message_get_last_container(m);
@@ -4430,7 +4430,7 @@ _public_ int sd_bus_message_readv(
          * in a single stackframe. We hence implement our own
          * home-grown stack in an array. */
 
-        n_array = (unsigned) -1; /* length of current array entries */
+        n_array = UINT_MAX; /* length of current array entries */
         n_struct = strlen(types); /* length of current struct contents signature */
 
         for (;;) {
@@ -4438,7 +4438,7 @@ _public_ int sd_bus_message_readv(
 
                 n_loop++;
 
-                if (n_array == 0 || (n_array == (unsigned) -1 && n_struct == 0)) {
+                if (n_array == 0 || (n_array == UINT_MAX && n_struct == 0)) {
                         r = type_stack_pop(stack, ELEMENTSOF(stack), &stack_ptr, &types, &n_struct, &n_array);
                         if (r < 0)
                                 return r;
@@ -4453,7 +4453,7 @@ _public_ int sd_bus_message_readv(
                 }
 
                 t = types;
-                if (n_array != (unsigned) -1)
+                if (n_array != UINT_MAX)
                         n_array--;
                 else {
                         types++;
@@ -4514,7 +4514,7 @@ _public_ int sd_bus_message_readv(
                                 }
                         }
 
-                        if (n_array == (unsigned) -1) {
+                        if (n_array == UINT_MAX) {
                                 types += k;
                                 n_struct -= k;
                         }
@@ -4553,7 +4553,7 @@ _public_ int sd_bus_message_readv(
 
                         types = s;
                         n_struct = strlen(s);
-                        n_array = (unsigned) -1;
+                        n_array = UINT_MAX;
 
                         break;
                 }
@@ -4581,7 +4581,7 @@ _public_ int sd_bus_message_readv(
                                 }
                         }
 
-                        if (n_array == (unsigned) -1) {
+                        if (n_array == UINT_MAX) {
                                 types += k - 1;
                                 n_struct -= k - 1;
                         }
@@ -4592,7 +4592,7 @@ _public_ int sd_bus_message_readv(
 
                         types = t + 1;
                         n_struct = k - 2;
-                        n_array = (unsigned) -1;
+                        n_array = UINT_MAX;
 
                         break;
                 }
@@ -5034,7 +5034,7 @@ static int message_skip_fields(
                 char t;
                 size_t l;
 
-                if (array_size != (uint32_t) -1 &&
+                if (array_size != UINT32_MAX &&
                     array_size <= *ri - original_index)
                         return 0;
 
@@ -5122,7 +5122,7 @@ static int message_skip_fields(
                         if (r < 0)
                                 return r;
 
-                        r = message_skip_fields(m, ri, (uint32_t) -1, (const char**) &s);
+                        r = message_skip_fields(m, ri, UINT32_MAX, (const char**) &s);
                         if (r < 0)
                                 return r;
 
@@ -5140,7 +5140,7 @@ static int message_skip_fields(
                                 strncpy(sig, *signature + 1, l);
                                 sig[l] = '\0';
 
-                                r = message_skip_fields(m, ri, (uint32_t) -1, (const char**) &s);
+                                r = message_skip_fields(m, ri, UINT32_MAX, (const char**) &s);
                                 if (r < 0)
                                         return r;
                         }
@@ -5247,7 +5247,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
                 _cleanup_free_ char *sig = NULL;
                 const char *signature;
                 uint64_t field_type;
-                size_t item_size = (size_t) -1;
+                size_t item_size = SIZE_MAX;
 
                 if (BUS_MESSAGE_IS_GVARIANT(m)) {
                         uint64_t *u64;
@@ -5461,7 +5461,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
 
                 default:
                         if (!BUS_MESSAGE_IS_GVARIANT(m))
-                                r = message_skip_fields(m, &ri, (uint32_t) -1, (const char **) &signature);
+                                r = message_skip_fields(m, &ri, UINT32_MAX, (const char **) &signature);
                 }
 
                 if (r < 0)
index 4881fd0d321a9b21c8f6d2d53d42162936f03bfa..832526cc1b7124969640ad827359e0b80b8cb58a 100644 (file)
@@ -620,7 +620,7 @@ static void bus_get_peercred(sd_bus *b) {
         assert(b);
         assert(!b->ucred_valid);
         assert(!b->label);
-        assert(b->n_groups == (size_t) -1);
+        assert(b->n_groups == SIZE_MAX);
 
         /* Get the peer for socketpair() sockets */
         b->ucred_valid = getpeercred(b->input_fd, &b->ucred) >= 0;
index 9d1ef937167748ee29f243521a901a1db5f4f360..e719c74370f3f081e54f9acb9eca48c6a43b5f06 100644 (file)
@@ -247,7 +247,7 @@ _public_ int sd_bus_new(sd_bus **ret) {
                 .creds_mask = SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME,
                 .accept_fd = true,
                 .original_pid = getpid_cached(),
-                .n_groups = (size_t) -1,
+                .n_groups = SIZE_MAX,
                 .close_on_exit = true,
         };
 
@@ -1964,8 +1964,8 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) {
          * hence let's fill something in for synthetic messages. Since
          * synthetic messages might have a fake sender and we don't
          * want to interfere with the real sender's serial numbers we
-         * pick a fixed, artificial one. We use (uint32_t) -1 rather
-         * than (uint64_t) -1 since dbus1 only had 32bit identifiers,
+         * pick a fixed, artificial one. We use UINT32_MAX rather
+         * than UINT64_MAX since dbus1 only had 32bit identifiers,
          * even though kdbus can do 64bit. */
         return sd_bus_message_seal(m, 0xFFFFFFFFULL, 0);
 }
@@ -2332,7 +2332,7 @@ int bus_ensure_running(sd_bus *bus) {
                 if (r > 0)
                         continue;
 
-                r = sd_bus_wait(bus, (uint64_t) -1);
+                r = sd_bus_wait(bus, UINT64_MAX);
                 if (r < 0)
                         return r;
         }
@@ -2460,7 +2460,7 @@ _public_ int sd_bus_call(
 
                         left = timeout - n;
                 } else
-                        left = (uint64_t) -1;
+                        left = UINT64_MAX;
 
                 r = bus_poll(bus, true, left);
                 if (r < 0)
@@ -2580,12 +2580,12 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
 
                 c = prioq_peek(bus->reply_callbacks_prioq);
                 if (!c) {
-                        *timeout_usec = (uint64_t) -1;
+                        *timeout_usec = UINT64_MAX;
                         return 0;
                 }
 
                 if (c->timeout_usec == 0) {
-                        *timeout_usec = (uint64_t) -1;
+                        *timeout_usec = UINT64_MAX;
                         return 0;
                 }
 
@@ -2598,7 +2598,7 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
 
         case BUS_WATCH_BIND:
         case BUS_OPENING:
-                *timeout_usec = (uint64_t) -1;
+                *timeout_usec = UINT64_MAX;
                 return 0;
 
         default:
@@ -3310,7 +3310,7 @@ static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
                 }
         }
 
-        if (timeout_usec != (uint64_t) -1 && (m == USEC_INFINITY || timeout_usec < m))
+        if (timeout_usec != UINT64_MAX && (m == USEC_INFINITY || timeout_usec < m))
                 m = timeout_usec;
 
         r = ppoll_usec(p, n, m);
@@ -3376,7 +3376,7 @@ _public_ int sd_bus_flush(sd_bus *bus) {
                 if (bus->wqueue_size <= 0)
                         return 0;
 
-                r = bus_poll(bus, false, (uint64_t) -1);
+                r = bus_poll(bus, false, UINT64_MAX);
                 if (r < 0)
                         return r;
         }
index a1d7ba173f8e24d9df66583c73668f547ec61495..ba367677cf8d65819755f4e122bd4b1067d413b7 100644 (file)
@@ -127,7 +127,7 @@ static int server(sd_bus *bus) {
                 }
 
                 if (r == 0) {
-                        r = sd_bus_wait(bus, (uint64_t) -1);
+                        r = sd_bus_wait(bus, UINT64_MAX);
                         if (r < 0) {
                                 log_error_errno(r, "Failed to wait: %m");
                                 goto fail;
@@ -472,7 +472,7 @@ static void* client2(void *p) {
                         goto finish;
                 }
                 if (r == 0) {
-                        r = sd_bus_wait(bus, (uint64_t) -1);
+                        r = sd_bus_wait(bus, UINT64_MAX);
                         if (r < 0) {
                                 log_error_errno(r, "Failed to wait: %m");
                                 goto finish;
index 5ef3f30c70dced1e0165f2b22b3b75637c076684..a71add4342e6ec67845113fc6d3ea07199450936 100644 (file)
@@ -255,7 +255,7 @@ static void *server(void *p) {
                 }
 
                 if (r == 0) {
-                        r = sd_bus_wait(bus, (uint64_t) -1);
+                        r = sd_bus_wait(bus, UINT64_MAX);
                         if (r < 0) {
                                 log_error_errno(r, "Failed to wait: %m");
                                 goto fail;
index e7a14716bcc50ce6269c93768eed5f1989d37b7b..ab4045ee15b189751e0ee0bdfdfab7a67f37328a 100644 (file)
@@ -47,7 +47,7 @@ static void *server(void *p) {
                 }
 
                 if (r == 0) {
-                        r = sd_bus_wait(bus, (uint64_t) -1);
+                        r = sd_bus_wait(bus, UINT64_MAX);
                         if (r < 0) {
                                 log_error_errno(r, "Failed to wait: %m");
                                 goto fail;
index b14f43aae53444913e792c15e8f6b6d56f6de20d..7a7204b145b4397a47ce3fdf48be00baeffe7c50 100644 (file)
@@ -98,7 +98,7 @@ int device_get_devnode_mode(sd_device *device, mode_t *mode) {
         if (r < 0)
                 return r;
 
-        if (device->devmode == (mode_t) -1)
+        if (device->devmode == MODE_INVALID)
                 return -ENOENT;
 
         if (mode)
@@ -116,7 +116,7 @@ int device_get_devnode_uid(sd_device *device, uid_t *uid) {
         if (r < 0)
                 return r;
 
-        if (device->devuid == (uid_t) -1)
+        if (device->devuid == UID_INVALID)
                 return -ENOENT;
 
         if (uid)
@@ -154,7 +154,7 @@ int device_get_devnode_gid(sd_device *device, gid_t *gid) {
         if (r < 0)
                 return r;
 
-        if (device->devgid == (gid_t) -1)
+        if (device->devgid == GID_INVALID)
                 return -ENOENT;
 
         if (gid)
index 1ef7f4d69c540d80af6d09c0e944da70dfec6f97..964ef1318edfeaf2efb75d07567e0a659bfe8f45 100644 (file)
@@ -26,6 +26,7 @@
 #include "string-util.h"
 #include "strv.h"
 #include "strxcpyx.h"
+#include "user-util.h"
 #include "util.h"
 
 int device_new_aux(sd_device **ret) {
@@ -40,9 +41,9 @@ int device_new_aux(sd_device **ret) {
         *device = (sd_device) {
                 .n_ref = 1,
                 .watch_handle = -1,
-                .devmode = (mode_t) -1,
-                .devuid = (uid_t) -1,
-                .devgid = (gid_t) -1,
+                .devmode = MODE_INVALID,
+                .devuid = UID_INVALID,
+                .devgid = GID_INVALID,
                 .action = _SD_DEVICE_ACTION_INVALID,
         };
 
index 17ac659ec5637f0a97484308dd8f230efcdb6890..8ab9d419af5cdab7c084fba029a3d9c3bded949d 100644 (file)
@@ -1236,7 +1236,7 @@ _public_ int sd_event_add_time(
 
         assert_return(e, -EINVAL);
         assert_return(e = event_resolve(e), -ENOPKG);
-        assert_return(accuracy != (uint64_t) -1, -EINVAL);
+        assert_return(accuracy != UINT64_MAX, -EINVAL);
         assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
         assert_return(!event_pid_changed(e), -ECHILD);
 
@@ -2615,7 +2615,7 @@ _public_ int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec
         int r;
 
         assert_return(s, -EINVAL);
-        assert_return(usec != (uint64_t) -1, -EINVAL);
+        assert_return(usec != UINT64_MAX, -EINVAL);
         assert_return(EVENT_SOURCE_IS_TIME(s->type), -EDOM);
         assert_return(s->event->state != SD_EVENT_FINISHED, -ESTALE);
         assert_return(!event_pid_changed(s->event), -ECHILD);
@@ -4083,7 +4083,7 @@ _public_ int sd_event_loop(sd_event *e) {
         _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = NULL;
 
         while (e->state != SD_EVENT_FINISHED) {
-                r = sd_event_run(e, (uint64_t) -1);
+                r = sd_event_run(e, UINT64_MAX);
                 if (r < 0)
                         return r;
         }
index 851418c96042ac2ef041383538267ecc2933ca5f..082b23af70c88bfd7ee8ca5bf8e27201466c0b7a 100644 (file)
@@ -217,7 +217,7 @@ static void test_basic(bool with_pidfd) {
         got_unref = false;
         assert_se(sd_event_add_io(e, &t, k[0], EPOLLIN, unref_handler, NULL) >= 0);
         assert_se(write(k[1], &ch, 1) == 1);
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
         assert_se(got_unref);
 
         got_a = false, got_b = false, got_c = false, got_d = 0;
@@ -227,10 +227,10 @@ static void test_basic(bool with_pidfd) {
         assert_se(sd_event_add_io(e, &w, d[0], EPOLLIN, io_handler, INT_TO_PTR('d')) >= 0);
         assert_se(sd_event_source_set_enabled(w, SD_EVENT_ONESHOT) >= 0);
         assert_se(write(d[1], &ch, 1) >= 0);
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
         assert_se(got_d == 1);
         assert_se(write(d[1], &ch, 1) >= 0);
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
         assert_se(got_d == 2);
 
         assert_se(sd_event_add_io(e, &x, a[0], EPOLLIN, io_handler, INT_TO_PTR('a')) >= 0);
@@ -258,15 +258,15 @@ static void test_basic(bool with_pidfd) {
 
         assert_se(!got_a && !got_b && !got_c);
 
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
 
         assert_se(!got_a && got_b && !got_c);
 
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
 
         assert_se(!got_a && got_b && got_c);
 
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
 
         assert_se(got_a && got_b && got_c);
 
@@ -357,19 +357,19 @@ static void test_rtqueue(void) {
         assert_se(n_rtqueue == 0);
         assert_se(last_rtqueue_sigval == 0);
 
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
         assert_se(n_rtqueue == 1);
         assert_se(last_rtqueue_sigval == 2); /* first SIGRTMIN+3 */
 
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
         assert_se(n_rtqueue == 2);
         assert_se(last_rtqueue_sigval == 4); /* second SIGRTMIN+3 */
 
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
         assert_se(n_rtqueue == 3);
         assert_se(last_rtqueue_sigval == 3); /* first SIGUSR2 */
 
-        assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
+        assert_se(sd_event_run(e, UINT64_MAX) >= 1);
         assert_se(n_rtqueue == 4);
         assert_se(last_rtqueue_sigval == 1); /* SIGRTMIN+2 */
 
index 3ea3328c1e4320a85af1f9b5f91180fbadd95362..bdcf47a25bf4b87abf8e174eeccaf6c52f2563a7 100644 (file)
@@ -176,7 +176,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
         if (ret != LZMA_OK)
                 return -ENOMEM;
 
-        space = MIN(src_size * 2, dst_max ?: (size_t) -1);
+        space = MIN(src_size * 2, dst_max ?: SIZE_MAX);
         if (!greedy_realloc(dst, dst_alloc_size, space, 1))
                 return -ENOMEM;
 
@@ -202,7 +202,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
                         return -ENOBUFS;
 
                 used = space - s.avail_out;
-                space = MIN(2 * space, dst_max ?: (size_t) -1);
+                space = MIN(2 * space, dst_max ?: SIZE_MAX);
                 if (!greedy_realloc(dst, dst_alloc_size, space, 1))
                         return -ENOMEM;
 
@@ -554,7 +554,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
                         size_t m = sizeof(buf);
                         ssize_t n;
 
-                        if (max_bytes != (uint64_t) -1 && (uint64_t) m > max_bytes)
+                        if (max_bytes != UINT64_MAX && (uint64_t) m > max_bytes)
                                 m = (size_t) max_bytes;
 
                         n = read(fdf, buf, m);
@@ -566,7 +566,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
                                 s.next_in = buf;
                                 s.avail_in = n;
 
-                                if (max_bytes != (uint64_t) -1) {
+                                if (max_bytes != UINT64_MAX) {
                                         assert(max_bytes >= (uint64_t) n);
                                         max_bytes -= n;
                                 }
@@ -664,7 +664,7 @@ int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes) {
                 offset += n;
                 total_out += n;
 
-                if (max_bytes != (uint64_t) -1 && total_out > (size_t) max_bytes) {
+                if (max_bytes != UINT64_MAX && total_out > (size_t) max_bytes) {
                         r = log_debug_errno(SYNTHETIC_ERRNO(EFBIG),
                                             "Compressed stream longer than %" PRIu64 " bytes", max_bytes);
                         goto cleanup;
@@ -752,7 +752,7 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
 
                         n = sizeof(out) - s.avail_out;
 
-                        if (max_bytes != (uint64_t) -1) {
+                        if (max_bytes != UINT64_MAX) {
                                 if (max_bytes < (uint64_t) n)
                                         return -EFBIG;
 
@@ -816,7 +816,7 @@ int decompress_stream_lz4(int in, int out, uint64_t max_bytes) {
                 total_in += used;
                 total_out += produced;
 
-                if (max_bytes != (uint64_t) -1 && total_out > (size_t) max_bytes) {
+                if (max_bytes != UINT64_MAX && total_out > (size_t) max_bytes) {
                         log_debug("Decompressed stream longer than %"PRIu64" bytes", max_bytes);
                         r = -EFBIG;
                         goto cleanup;
index 0bb9133e0cc50c60e19350551278dae97eb1302a..f8bb708e582bbbfb5e4bac582708b65b099e02d3 100644 (file)
@@ -1561,7 +1561,7 @@ bool journal_field_valid(const char *p, size_t l, bool allow_protected) {
 
            http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html */
 
-        if (l == (size_t) -1)
+        if (l == SIZE_MAX)
                 l = strlen(p);
 
         /* No empty field names */
@@ -2352,7 +2352,7 @@ static int generic_array_bisect(
                 uint64_t *ret_offset,
                 uint64_t *ret_idx) {
 
-        uint64_t a, p, t = 0, i = 0, last_p = 0, last_index = (uint64_t) -1;
+        uint64_t a, p, t = 0, i = 0, last_p = 0, last_index = UINT64_MAX;
         bool subtract_one = false;
         Object *o, *array = NULL;
         int r;
@@ -2422,7 +2422,7 @@ static int generic_array_bisect(
                         left = 0;
                         right -= 1;
 
-                        if (last_index != (uint64_t) -1) {
+                        if (last_index != UINT64_MAX) {
                                 assert(last_index <= right);
 
                                 /* If we cached the last index we
@@ -2522,7 +2522,7 @@ static int generic_array_bisect(
 
                 n -= k;
                 t += k;
-                last_index = (uint64_t) -1;
+                last_index = UINT64_MAX;
                 a = le64toh(array->entry_array.next_entry_array_offset);
         }
 
@@ -2533,7 +2533,7 @@ found:
                 return 0;
 
         /* Let's cache this item for the next invocation */
-        chain_cache_put(f->chain_cache, ci, first, a, le64toh(array->entry_array.items[0]), t, subtract_one ? (i > 0 ? i-1 : (uint64_t) -1) : i);
+        chain_cache_put(f->chain_cache, ci, first, a, le64toh(array->entry_array.items[0]), t, subtract_one ? (i > 0 ? i-1 : UINT64_MAX) : i);
 
         if (subtract_one && i == 0)
                 p = last_p;
@@ -3447,7 +3447,7 @@ int journal_file_open(
 #elif HAVE_XZ
                 .compress_xz = compress,
 #endif
-                .compress_threshold_bytes = compress_threshold_bytes == (uint64_t) -1 ?
+                .compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ?
                                             DEFAULT_COMPRESS_THRESHOLD :
                                             MAX(MIN_COMPRESS_THRESHOLD, compress_threshold_bytes),
 #if HAVE_GCRYPT
@@ -3964,12 +3964,12 @@ void journal_reset_metrics(JournalMetrics *m) {
         /* Set everything to "pick automatic values". */
 
         *m = (JournalMetrics) {
-                .min_use = (uint64_t) -1,
-                .max_use = (uint64_t) -1,
-                .min_size = (uint64_t) -1,
-                .max_size = (uint64_t) -1,
-                .keep_free = (uint64_t) -1,
-                .n_max_files = (uint64_t) -1,
+                .min_use = UINT64_MAX,
+                .max_use = UINT64_MAX,
+                .min_size = UINT64_MAX,
+                .max_size = UINT64_MAX,
+                .keep_free = UINT64_MAX,
+                .n_max_files = UINT64_MAX,
         };
 }
 
@@ -3986,7 +3986,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
         else
                 log_debug_errno(errno, "Failed to determine disk size: %m");
 
-        if (m->max_use == (uint64_t) -1) {
+        if (m->max_use == UINT64_MAX) {
 
                 if (fs_size > 0)
                         m->max_use = CLAMP(PAGE_ALIGN(fs_size / 10), /* 10% of file system size */
@@ -4000,7 +4000,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
                         m->max_use = JOURNAL_FILE_SIZE_MIN*2;
         }
 
-        if (m->min_use == (uint64_t) -1) {
+        if (m->min_use == UINT64_MAX) {
                 if (fs_size > 0)
                         m->min_use = CLAMP(PAGE_ALIGN(fs_size / 50), /* 2% of file system size */
                                            MIN_USE_LOW, MIN_USE_HIGH);
@@ -4011,7 +4011,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
         if (m->min_use > m->max_use)
                 m->min_use = m->max_use;
 
-        if (m->max_size == (uint64_t) -1)
+        if (m->max_size == UINT64_MAX)
                 m->max_size = MIN(PAGE_ALIGN(m->max_use / 8), /* 8 chunks */
                                   MAX_SIZE_UPPER);
         else
@@ -4025,14 +4025,14 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
                         m->max_use = m->max_size*2;
         }
 
-        if (m->min_size == (uint64_t) -1)
+        if (m->min_size == UINT64_MAX)
                 m->min_size = JOURNAL_FILE_SIZE_MIN;
         else
                 m->min_size = CLAMP(PAGE_ALIGN(m->min_size),
                                     JOURNAL_FILE_SIZE_MIN,
                                     m->max_size ?: UINT64_MAX);
 
-        if (m->keep_free == (uint64_t) -1) {
+        if (m->keep_free == UINT64_MAX) {
                 if (fs_size > 0)
                         m->keep_free = MIN(PAGE_ALIGN(fs_size / 20), /* 5% of file system size */
                                            KEEP_FREE_UPPER);
@@ -4040,7 +4040,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
                         m->keep_free = DEFAULT_KEEP_FREE;
         }
 
-        if (m->n_max_files == (uint64_t) -1)
+        if (m->n_max_files == UINT64_MAX)
                 m->n_max_files = DEFAULT_N_MAX_FILES;
 
         log_debug("Fixed min_use=%s max_use=%s max_size=%s min_size=%s keep_free=%s n_max_files=%" PRIu64,
index aabbfd90e576521387e9147d3c31167399f6925d..be92f803c95fd33d641b161b93f995ff0e6c0efd 100644 (file)
@@ -2542,7 +2542,7 @@ _public_ int sd_journal_get_timeout(sd_journal *j, uint64_t *timeout_usec) {
                 return fd;
 
         if (!j->on_network) {
-                *timeout_usec = (uint64_t) -1;
+                *timeout_usec = UINT64_MAX;
                 return 0;
         }
 
@@ -2724,10 +2724,10 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
         if (r < 0)
                 return r;
 
-        if (t != (uint64_t) -1) {
+        if (t != UINT64_MAX) {
                 t = usec_sub_unsigned(t, now(CLOCK_MONOTONIC));
 
-                if (timeout_usec == (uint64_t) -1 || timeout_usec > t)
+                if (timeout_usec == UINT64_MAX || timeout_usec > t)
                         timeout_usec = t;
         }
 
index 8c78c3bbf03030c48ceb6fb55f9a8a1b22edee63..62db2266c7ba96fb4cbae5be20f7264d564d7047 100644 (file)
@@ -35,7 +35,7 @@ _noreturn_ static void log_assert_errno(const char *text, int error, const char
 
 static JournalFile *test_open(const char *name) {
         JournalFile *f;
-        assert_ret(journal_file_open(-1, name, O_RDWR|O_CREAT, 0644, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f));
+        assert_ret(journal_file_open(-1, name, O_RDWR|O_CREAT, 0644, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f));
         return f;
 }
 
@@ -206,7 +206,7 @@ static void test_sequence_numbers(void) {
         mkdtemp_chdir_chattr(t);
 
         assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0644,
-                                    true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0);
+                                    true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &one) == 0);
 
         append_number(one, 1, &seqnum);
         printf("seqnum=%"PRIu64"\n", seqnum);
@@ -223,7 +223,7 @@ static void test_sequence_numbers(void) {
         memcpy(&seqnum_id, &one->header->seqnum_id, sizeof(sd_id128_t));
 
         assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0644,
-                                    true, (uint64_t) -1, false, NULL, NULL, NULL, one, &two) == 0);
+                                    true, UINT64_MAX, false, NULL, NULL, NULL, one, &two) == 0);
 
         assert_se(two->header->state == STATE_ONLINE);
         assert_se(!sd_id128_equal(two->header->file_id, one->header->file_id));
@@ -254,7 +254,7 @@ static void test_sequence_numbers(void) {
         seqnum = 0;
 
         assert_se(journal_file_open(-1, "two.journal", O_RDWR, 0,
-                                    true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &two) == 0);
+                                    true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &two) == 0);
 
         assert_se(sd_id128_equal(two->header->seqnum_id, seqnum_id));
 
index a121859e08feb3d56db359e5e279675aa8fa31b4..ca1eaaebfc4a58220e355d8dcea52658e4398f9b 100644 (file)
@@ -73,9 +73,9 @@ static void run_test(void) {
         assert_se(chdir(t) >= 0);
         (void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
 
-        assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0);
-        assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &two) == 0);
-        assert_se(journal_file_open(-1, "three.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &three) == 0);
+        assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &one) == 0);
+        assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &two) == 0);
+        assert_se(journal_file_open(-1, "three.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &three) == 0);
 
         for (i = 0; i < N_ENTRIES; i++) {
                 char *p, *q;
index d208e4650c209a8ec70ca29566f357f30a52e0b3..e9abfef0fc9376b2cbc00e87d0bb92076ba42318 100644 (file)
@@ -41,7 +41,7 @@ static int raw_verify(const char *fn, const char *verification_key) {
         JournalFile *f;
         int r;
 
-        r = journal_file_open(-1, fn, O_RDONLY, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f);
+        r = journal_file_open(-1, fn, O_RDONLY, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f);
         if (r < 0)
                 return r;
 
@@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
 
         log_info("Generating...");
 
-        assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
+        assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
 
         for (n = 0; n < N_ENTRIES; n++) {
                 struct iovec iovec;
@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
 
         log_info("Verifying...");
 
-        assert_se(journal_file_open(-1, "test.journal", O_RDONLY, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
+        assert_se(journal_file_open(-1, "test.journal", O_RDONLY, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
         /* journal_file_print_header(f); */
         journal_file_dump(f);
 
index f8f08b5afc8b09c8915e2c451fdeefd746840564..fd3c4d99501d29d62a57405c7c7c6bfe75cb8a74 100644 (file)
@@ -37,7 +37,7 @@ static void test_non_empty(void) {
 
         mkdtemp_chdir_chattr(t);
 
-        assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f) == 0);
+        assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f) == 0);
 
         assert_se(dual_timestamp_get(&ts));
         assert_se(sd_id128_randomize(&fake_boot_id) == 0);
@@ -98,8 +98,8 @@ static void test_non_empty(void) {
 
         assert_se(journal_file_move_to_entry_by_seqnum(f, 10, DIRECTION_DOWN, &o, NULL) == 0);
 
-        journal_file_rotate(&f, true, (uint64_t) -1, true, NULL);
-        journal_file_rotate(&f, true, (uint64_t) -1, true, NULL);
+        journal_file_rotate(&f, true, UINT64_MAX, true, NULL);
+        journal_file_rotate(&f, true, UINT64_MAX, true, NULL);
 
         (void) journal_file_close(f);
 
@@ -124,13 +124,13 @@ static void test_empty(void) {
 
         mkdtemp_chdir_chattr(t);
 
-        assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, false, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f1) == 0);
+        assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, false, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f1) == 0);
 
-        assert_se(journal_file_open(-1, "test-compress.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f2) == 0);
+        assert_se(journal_file_open(-1, "test-compress.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f2) == 0);
 
-        assert_se(journal_file_open(-1, "test-seal.journal", O_RDWR|O_CREAT, 0666, false, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f3) == 0);
+        assert_se(journal_file_open(-1, "test-seal.journal", O_RDWR|O_CREAT, 0666, false, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f3) == 0);
 
-        assert_se(journal_file_open(-1, "test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f4) == 0);
+        assert_se(journal_file_open(-1, "test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f4) == 0);
 
         journal_file_print_header(f1);
         puts("");
@@ -224,8 +224,8 @@ static void test_min_compress_size(void) {
          * carefully */
 
         /* DEFAULT_MIN_COMPRESS_SIZE is 512 */
-        assert_se(!check_compressed((uint64_t) -1, 255));
-        assert_se(check_compressed((uint64_t) -1, 513));
+        assert_se(!check_compressed(UINT64_MAX, 255));
+        assert_se(check_compressed(UINT64_MAX, 513));
 
         /* compress everything */
         assert_se(check_compressed(0, 96));
index d15dafbd95641b16c6a72fa9cc92961a895c232b..a3da2e3f24dbc43e129b09e3ce7bb383231e754e 100644 (file)
@@ -1043,9 +1043,9 @@ _public_ int sd_login_monitor_get_timeout(sd_login_monitor *m, uint64_t *timeout
         assert_return(m, -EINVAL);
         assert_return(timeout_usec, -EINVAL);
 
-        /* For now we will only return (uint64_t) -1, since we don't
+        /* For now we will only return UINT64_MAX, since we don't
          * need any timeout. However, let's have this API to keep our
          * options open should we later on need it. */
-        *timeout_usec = (uint64_t) -1;
+        *timeout_usec = UINT64_MAX;
         return 0;
 }
index d850323ba39b9ce58eddfebd54dbe0ba424c6a81..3fc394d5ee4dc937ae5b4d7d968d33b5c716ddca 100644 (file)
@@ -277,7 +277,7 @@ static void test_monitor(void) {
                 nw = now(CLOCK_MONOTONIC);
 
                 r = poll(&pollfd, 1,
-                         timeout == (uint64_t) -1 ? -1 :
+                         timeout == UINT64_MAX ? -1 :
                          timeout > nw ? (int) ((timeout - nw) / 1000) :
                          0);
 
index 4ceb64cb23119a3f193dfc80961a9d07279271bd..f862d48253ef27d359b3628725b7966b3dfaf897 100644 (file)
@@ -512,7 +512,7 @@ int sd_netlink_process(sd_netlink *rtnl, sd_netlink_message **ret) {
 }
 
 static usec_t calc_elapse(uint64_t usec) {
-        if (usec == (uint64_t) -1)
+        if (usec == UINT64_MAX)
                 return 0;
 
         if (usec == 0)
@@ -550,7 +550,7 @@ static int rtnl_poll(sd_netlink *rtnl, bool need_more, uint64_t timeout_usec) {
                 }
         }
 
-        if (timeout_usec != (uint64_t) -1 && (m == USEC_INFINITY || timeout_usec < m))
+        if (timeout_usec != UINT64_MAX && (m == USEC_INFINITY || timeout_usec < m))
                 m = timeout_usec;
 
         r = fd_wait_for_event(rtnl->fd, e, m);
@@ -606,7 +606,7 @@ int sd_netlink_call_async(
         if (r < 0)
                 return r;
 
-        if (usec != (uint64_t) -1) {
+        if (usec != UINT64_MAX) {
                 r = prioq_ensure_allocated(&nl->reply_callbacks_prioq, timeout_compare);
                 if (r < 0)
                         return r;
@@ -714,7 +714,7 @@ int sd_netlink_read(sd_netlink *rtnl,
 
                         left = timeout - n;
                 } else
-                        left = (uint64_t) -1;
+                        left = UINT64_MAX;
 
                 r = rtnl_poll(rtnl, true, left);
                 if (r < 0)
@@ -766,7 +766,7 @@ int sd_netlink_get_timeout(const sd_netlink *rtnl, uint64_t *timeout_usec) {
 
         c = prioq_peek(rtnl->reply_callbacks_prioq);
         if (!c) {
-                *timeout_usec = (uint64_t) -1;
+                *timeout_usec = UINT64_MAX;
                 return 0;
         }
 
index 060d84ae96627e0a8bfb6598c95b4e32cc5e6eb0..ccdfde9137e7b1a3072e894d9852f957e1231cb0 100644 (file)
@@ -461,9 +461,9 @@ _public_ int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *tim
         assert_return(m, -EINVAL);
         assert_return(timeout_usec, -EINVAL);
 
-        /* For now we will only return (uint64_t) -1, since we don't
+        /* For now we will only return UINT64_MAX, since we don't
          * need any timeout. However, let's have this API to keep our
          * options open should we later on need it. */
-        *timeout_usec = (uint64_t) -1;
+        *timeout_usec = UINT64_MAX;
         return 0;
 }
index 6dae398acbc414d8d41e0a6df6cd4672d7183d06..ee973c0692278444cfb45b868819ed659da879f4 100644 (file)
@@ -621,7 +621,7 @@ _public_ int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *usec) {
         assert_return(usec, -EINVAL);
         assert_return(!resolve_pid_changed(resolve), -ECHILD);
 
-        *usec = (uint64_t) -1;
+        *usec = UINT64_MAX;
         return 0;
 }
 
index d32ff8aa3bd40b644bde684e2c48bfadaf02cfcd..a539a2e9797d2e2a78336d32dbc52fa489a09434 100644 (file)
@@ -4084,7 +4084,7 @@ int manager_start_scope(
                 return r;
 
         /* disable TasksMax= for the session scope, rely on the slice setting for it */
-        r = sd_bus_message_append(m, "(sv)", "TasksMax", "t", (uint64_t)-1);
+        r = sd_bus_message_append(m, "(sv)", "TasksMax", "t", UINT64_MAX);
         if (r < 0)
                 return bus_log_create_error(r);
 
index 56235230cf7d5d34083feb460b9ceead76c50632..4887889facb482d61f3f36b8ad39d624428c486c 100644 (file)
@@ -1148,7 +1148,7 @@ static int manager_run(Manager *m) {
                 if (r > 0)
                         continue;
 
-                r = sd_event_run(m->event, (uint64_t) -1);
+                r = sd_event_run(m->event, UINT64_MAX);
                 if (r < 0)
                         return r;
         }
index a23200b3b579b17dbd3d7c8d3a1109aa546a295c..2021c31bd5227e3ce28c86daf057f2253e89f45a 100644 (file)
@@ -328,7 +328,7 @@ static int append_session_memory_max(pam_handle_t *handle, sd_bus_message *m, co
                 return PAM_SUCCESS;
 
         if (streq(limit, "infinity")) {
-                r = sd_bus_message_append(m, "(sv)", "MemoryMax", "t", (uint64_t)-1);
+                r = sd_bus_message_append(m, "(sv)", "MemoryMax", "t", UINT64_MAX);
                 if (r < 0)
                         return pam_bus_log_create_error(handle, r);
 
index 5a19dbfeff951d4ee5992da9208f730a0b037491..5c3af06cac6e74497d95311b276ae314d946ed46 100644 (file)
@@ -32,7 +32,7 @@ static int show_sysfs_one(
         assert(prefix);
 
         if (flags & OUTPUT_FULL_WIDTH)
-                max_width = (size_t) -1;
+                max_width = SIZE_MAX;
         else if (n_columns < 10)
                 max_width = 10;
         else
@@ -113,7 +113,7 @@ static int show_sysfs_one(
                                 return -ENOMEM;
 
                         r = show_sysfs_one(seat, dev_list, i_dev, n_dev, sysfs, p,
-                                           n_columns == (unsigned) -1 || n_columns < 2 ? n_columns : n_columns - 2,
+                                           n_columns == UINT_MAX || n_columns < 2 ? n_columns : n_columns - 2,
                                            flags);
                         if (r < 0)
                                 return r;
index 7d6e1c716341fedde629cf25b9d639795b4a2f9a..e7c4ed3c7c17cdfef73b28e4edf482bd4ac1fd76 100644 (file)
@@ -394,7 +394,7 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
                         if (r < 0)
                                 _exit(EXIT_FAILURE);
 
-                        r = copy_bytes(fd, pair[1], (uint64_t) -1, 0);
+                        r = copy_bytes(fd, pair[1], UINT64_MAX, 0);
                         if (r < 0)
                                 _exit(EXIT_FAILURE);
 
index 68d2a59e95f986ef5567265897f613a1b747ed0a..d7849973b855c44291f49cb2db28516100d687ee 100644 (file)
@@ -964,8 +964,8 @@ static int show_pool_info(sd_bus *bus) {
         };
 
         PoolStatusInfo info = {
-                .usage = (uint64_t) -1,
-                .limit = (uint64_t) -1,
+                .usage = UINT64_MAX,
+                .limit = UINT64_MAX,
         };
 
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
@@ -2384,7 +2384,7 @@ static int set_limit(int argc, char *argv[], void *userdata) {
         polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
 
         if (STR_IN_SET(argv[argc-1], "-", "none", "infinity"))
-                limit = (uint64_t) -1;
+                limit = UINT64_MAX;
         else {
                 r = parse_size(argv[argc-1], 1024, &limit);
                 if (r < 0)
index bb6a2bc5761ba09779046104ce98e12c18539692..0a6ae96bc6eeee50176195476b755808d558761a 100644 (file)
@@ -45,7 +45,7 @@ static int property_get_pool_usage(
                 sd_bus_error *error) {
 
         _cleanup_close_ int fd = -1;
-        uint64_t usage = (uint64_t) -1;
+        uint64_t usage = UINT64_MAX;
 
         assert(bus);
         assert(reply);
@@ -71,7 +71,7 @@ static int property_get_pool_limit(
                 sd_bus_error *error) {
 
         _cleanup_close_ int fd = -1;
-        uint64_t size = (uint64_t) -1;
+        uint64_t size = UINT64_MAX;
 
         assert(bus);
         assert(reply);
index 242b977f602759f7f794a5e87eae168f0013e8b9..6f06e2218d348897461b8b66984da1fc4351d998 100644 (file)
@@ -1507,7 +1507,7 @@ int config_parse_dhcp_max_attempts(
         }
 
         if (streq(rvalue, "infinity")) {
-                network->dhcp_max_attempts = (uint64_t) -1;
+                network->dhcp_max_attempts = UINT64_MAX;
                 return 0;
         }
 
index a23c98110e6facfd759248808912652f72404401..f57828b57da4e5f77649628ad2fef8a257aaf920 100644 (file)
@@ -147,7 +147,7 @@ static int bus_link_method_set_dns_servers_internal(sd_bus_message *message, voi
                 goto finalize;
         }
 
-        if (l->n_dns != (unsigned) -1)
+        if (l->n_dns != UINT_MAX)
                 for (unsigned i = 0; i < l->n_dns; i++)
                         in_addr_full_free(l->dns[i]);
 
index 9693e73351a0e986f493332b28ecd78f425ef269..6868a7ccb2c227c6ff3700fd17c66e71f39713ae 100644 (file)
@@ -403,7 +403,7 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
                 .ifindex = ifindex,
                 .iftype = iftype,
 
-                .n_dns = (unsigned) -1,
+                .n_dns = UINT_MAX,
                 .dns_default_route = -1,
                 .llmnr = _RESOLVE_SUPPORT_INVALID,
                 .mdns = _RESOLVE_SUPPORT_INVALID,
@@ -472,11 +472,11 @@ void link_ntp_settings_clear(Link *link) {
 }
 
 void link_dns_settings_clear(Link *link) {
-        if (link->n_dns != (unsigned) -1)
+        if (link->n_dns != UINT_MAX)
                 for (unsigned i = 0; i < link->n_dns; i++)
                         in_addr_full_free(link->dns[i]);
         link->dns = mfree(link->dns);
-        link->n_dns = (unsigned) -1;
+        link->n_dns = UINT_MAX;
 
         link->search_domains = ordered_set_free_free(link->search_domains);
         link->route_domains = ordered_set_free_free(link->route_domains);
index d86de6799e04a6987ede03bfe666d985a0407dfc..7a76b61c4aefec0384bb1b92500564b0717eb4df 100644 (file)
@@ -17,7 +17,7 @@ static int sr_iov_new(SRIOV **ret) {
                 return -ENOMEM;
 
         *sr_iov = (SRIOV) {
-                  .vf = (uint32_t) -1,
+                  .vf = UINT32_MAX,
                   .vlan_proto = ETH_P_8021Q,
                   .vf_spoof_check_setting = -1,
                   .trust = -1,
@@ -256,7 +256,7 @@ static int sr_iov_section_verify(SRIOV *sr_iov) {
         if (section_is_invalid(sr_iov->section))
                 return -EINVAL;
 
-        if (sr_iov->vf == (uint32_t) -1)
+        if (sr_iov->vf == UINT32_MAX)
                 return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
                                          "%s: [SRIOV] section without VirtualFunction= field configured. "
                                          "Ignoring [SRIOV] section from line %u.",
@@ -303,7 +303,7 @@ int config_parse_sr_iov_uint32(
 
         if (isempty(rvalue)) {
                 if (streq(lvalue, "VirtualFunction"))
-                        sr_iov->vf = (uint32_t) -1;
+                        sr_iov->vf = UINT32_MAX;
                 else if (streq(lvalue, "VLANId"))
                         sr_iov->vlan = 0;
                 else if (streq(lvalue, "QualityOfService"))
index 06670a7b8b69db04bb515bd6df2d1831a01d8986..9c5c5047b34a23cfa03c6ff7189e69f81605dbc6 100644 (file)
@@ -154,7 +154,7 @@ int manager_save(Manager *m) {
                         continue;
 
                 /* First add the static configured entries */
-                if (link->n_dns != (unsigned) -1)
+                if (link->n_dns != UINT_MAX)
                         r = ordered_set_put_dns_servers(dns, link->ifindex, link->dns, link->n_dns);
                 else
                         r = ordered_set_put_dns_servers(dns, link->ifindex, link->network->dns, link->network->n_dns);
@@ -456,7 +456,7 @@ int link_save(Link *link) {
 
                 fputs("DNS=", f);
                 space = false;
-                if (link->n_dns != (unsigned) -1)
+                if (link->n_dns != UINT_MAX)
                         link_save_dns(link, f, link->dns, link->n_dns, &space);
                 else
                         link_save_dns(link, f, link->network->dns, link->network->n_dns, &space);
index 1309d8f4e07551e29b79f20dd408021711542882..40cbc296bd516d05f47743d9eb261eabced4da2d 100644 (file)
@@ -241,11 +241,11 @@ static int run(int argc, char* argv[]) {
            ucred data, and sd_pid_notify() uses the real UID for filling in ucred. */
 
         if (arg_gid != GID_INVALID &&
-            setregid(arg_gid, (gid_t) -1) < 0)
+            setregid(arg_gid, GID_INVALID) < 0)
                 return log_error_errno(errno, "Failed to change GID: %m");
 
         if (arg_uid != UID_INVALID &&
-            setreuid(arg_uid, (uid_t) -1) < 0)
+            setreuid(arg_uid, UID_INVALID) < 0)
                 return log_error_errno(errno, "Failed to change UID: %m");
 
         if (arg_pid > 0)
index 826981c3f78ae00a9110eb4f5ffa1b0311863137..1db69b45128414ebf1dfdd52ba4973cdc06bc232 100644 (file)
@@ -308,7 +308,7 @@ static int oci_capability_array(const char *name, JsonVariant *v, JsonDispatchFl
                 m |= UINT64_C(1) << cap;
         }
 
-        if (*mask == (uint64_t) -1)
+        if (*mask == UINT64_MAX)
                 *mask = m;
         else
                 *mask |= m;
@@ -336,7 +336,7 @@ static int oci_capabilities(const char *name, JsonVariant *v, JsonDispatchFlags
         if (r < 0)
                 return r;
 
-        if (s->full_capabilities.bounding != (uint64_t) -1) {
+        if (s->full_capabilities.bounding != UINT64_MAX) {
                 s->capability = s->full_capabilities.bounding;
                 s->drop_capability = ~s->full_capabilities.bounding;
         }
@@ -704,7 +704,7 @@ static int oci_uid_gid_range(const char *name, JsonVariant *v, JsonDispatchFlags
         assert_cc(sizeof(uid_t) == sizeof(gid_t));
 
         /* This is very much like oci_uid_gid(), except the checks are a bit different, as this is a UID range rather
-         * than a specific UID, and hence (uid_t) -1 has no special significance. OTOH a range of zero makes no
+         * than a specific UID, and hence UID_INVALID has no special significance. OTOH a range of zero makes no
          * sense. */
 
         k = json_variant_unsigned(v);
@@ -880,8 +880,8 @@ static int oci_devices(const char *name, JsonVariant *v, JsonDispatchFlags flags
                 *node = (DeviceNode) {
                         .uid = UID_INVALID,
                         .gid = GID_INVALID,
-                        .major = (unsigned) -1,
-                        .minor = (unsigned) -1,
+                        .major = UINT_MAX,
+                        .minor = UINT_MAX,
                         .mode = 0644,
                 };
 
@@ -892,7 +892,7 @@ static int oci_devices(const char *name, JsonVariant *v, JsonDispatchFlags flags
                 if (S_ISCHR(node->mode) || S_ISBLK(node->mode)) {
                         _cleanup_free_ char *path = NULL;
 
-                        if (node->major == (unsigned) -1 || node->minor == (unsigned) -1) {
+                        if (node->major == UINT_MAX || node->minor == UINT_MAX) {
                                 r = json_log(e, flags, SYNTHETIC_ERRNO(EINVAL),
                                              "Major/minor required when device node is device node");
                                 goto fail_element;
@@ -1026,8 +1026,8 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
         JSON_VARIANT_ARRAY_FOREACH(e, v) {
 
                 struct device_data data = {
-                        .major = (unsigned) -1,
-                        .minor = (unsigned) -1,
+                        .major = UINT_MAX,
+                        .minor = UINT_MAX,
                 }, *a;
 
                 static const JsonDispatch table[] = {
@@ -1052,7 +1052,7 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
                          * is really borked in the spec, with one exception: the entry that's supposed to
                          * drop the kernel's default we ignore silently */
 
-                        if (!data.r || !data.w || !data.m || data.type != 0 || data.major != (unsigned) -1 || data.minor != (unsigned) -1)
+                        if (!data.r || !data.w || !data.m || data.type != 0 || data.major != UINT_MAX || data.minor != UINT_MAX)
                                 json_log(v, flags|JSON_WARNING, 0, "Devices cgroup allow list with arbitrary 'allow' entries not supported, ignoring.");
 
                         /* We ignore the 'deny' entry as for us that's implied */
@@ -1064,11 +1064,11 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
                         continue;
                 }
 
-                if (data.minor != (unsigned) -1 && data.major == (unsigned) -1)
+                if (data.minor != UINT_MAX && data.major == UINT_MAX)
                         return json_log(v, flags, SYNTHETIC_ERRNO(EOPNOTSUPP),
                                         "Device cgroup allow list entries with minors but no majors not supported.");
 
-                if (data.major != (unsigned) -1 && data.type == 0)
+                if (data.major != UINT_MAX && data.type == 0)
                         return json_log(v, flags, SYNTHETIC_ERRNO(EOPNOTSUPP),
                                         "Device cgroup allow list entries with majors but no device node type not supported.");
 
@@ -1116,7 +1116,7 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
                 char access[4];
                 size_t n = 0;
 
-                if (list[i].minor == (unsigned) -1) {
+                if (list[i].minor == UINT_MAX) {
                         const char *t;
 
                         if (list[i].type == S_IFBLK)
@@ -1126,7 +1126,7 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
                                 t = "char";
                         }
 
-                        if (list[i].major == (unsigned) -1) {
+                        if (list[i].major == UINT_MAX) {
                                 pattern = strjoin(t, "-*");
                                 if (!pattern)
                                         return log_oom();
@@ -1136,7 +1136,7 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
                         }
 
                 } else {
-                        assert(list[i].major != (unsigned) -1); /* If a minor is specified, then a major also needs to be specified */
+                        assert(list[i].major != UINT_MAX); /* If a minor is specified, then a major also needs to be specified */
 
                         r = device_path_make_major_minor(list[i].type, makedev(list[i].major, list[i].minor), &pattern);
                         if (r < 0)
@@ -1416,8 +1416,8 @@ static int oci_cgroup_block_io_weight_device(const char *name, JsonVariant *v, J
                         unsigned minor;
                         uintmax_t weight;
                 } data = {
-                        .major = (unsigned) -1,
-                        .minor = (unsigned) -1,
+                        .major = UINT_MAX,
+                        .minor = UINT_MAX,
                         .weight = UINTMAX_MAX,
                 };
 
@@ -1477,8 +1477,8 @@ static int oci_cgroup_block_io_throttle(const char *name, JsonVariant *v, JsonDi
                         unsigned minor;
                         uintmax_t rate;
                 } data = {
-                        .major = (unsigned) -1,
-                        .minor = (unsigned) -1,
+                        .major = UINT_MAX,
+                        .minor = UINT_MAX,
                 };
 
                 static const JsonDispatch table[] = {
@@ -1890,7 +1890,7 @@ static int oci_seccomp_syscalls(const char *name, JsonVariant *v, JsonDispatchFl
                         { "args",   JSON_VARIANT_ARRAY,  oci_seccomp_args,   0,                                     0              },
                 };
                 struct syscall_rule rule = {
-                        .action = (uint32_t) -1,
+                        .action = UINT32_MAX,
                 };
                 char **i;
 
index 74a00c52754da587925e2463668468b7c0d35b9b..d4619bead53ce5275c4800903bc747b5d958c324 100644 (file)
@@ -51,10 +51,10 @@ Settings *settings_new(void) {
                 .gid = GID_INVALID,
 
                 .console_mode = _CONSOLE_MODE_INVALID,
-                .console_width = (unsigned) -1,
-                .console_height = (unsigned) -1,
+                .console_width = UINT_MAX,
+                .console_height = UINT_MAX,
 
-                .clone_ns_flags = (unsigned long) -1,
+                .clone_ns_flags = ULONG_MAX,
                 .use_cgns = -1,
         };
 
@@ -274,7 +274,7 @@ int config_parse_capability(
                         break;
 
                 if (streq(word, "all"))
-                        u = (uint64_t) -1;
+                        u = UINT64_MAX;
                 else {
                         r = capability_from_name(word);
                         if (r < 0) {
index 1d9f1ddc5568a61281913716da01675629fc3bc6..a4ac8ed2bb752e6b478b8281d82aa6cd6e56191e 100644 (file)
@@ -217,7 +217,7 @@ static bool arg_oom_score_adjust_set = false;
 static CPUSet arg_cpu_set = {};
 static ResolvConfMode arg_resolv_conf = RESOLV_CONF_AUTO;
 static TimezoneMode arg_timezone = TIMEZONE_AUTO;
-static unsigned arg_console_width = (unsigned) -1, arg_console_height = (unsigned) -1;
+static unsigned arg_console_width = UINT_MAX, arg_console_height = UINT_MAX;
 static DeviceNode* arg_extra_nodes = NULL;
 static size_t arg_n_extra_nodes = 0;
 static char **arg_sysctl = NULL;
@@ -549,7 +549,7 @@ static int parse_capability_spec(const char *spec, uint64_t *ret_mask) {
                 }
 
                 if (streq(t, "all"))
-                        mask = (uint64_t) -1;
+                        mask = UINT64_MAX;
                 else {
                         r = capability_from_name(t);
                         if (r < 0)
@@ -1768,7 +1768,7 @@ static int verify_arguments(void) {
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Cannot use --port= without private networking.");
 
         if (arg_caps_ambient) {
-                if (arg_caps_ambient == (uint64_t)-1)
+                if (arg_caps_ambient == UINT64_MAX)
                         return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "AmbientCapability= does not support the value all.");
 
                 if ((arg_caps_ambient & arg_caps_retain) != arg_caps_ambient)
@@ -2640,19 +2640,19 @@ static int drop_capabilities(uid_t uid) {
         if (capability_quintet_is_set(&arg_full_capabilities)) {
                 q = arg_full_capabilities;
 
-                if (q.bounding == (uint64_t) -1)
+                if (q.bounding == UINT64_MAX)
                         q.bounding = uid == 0 ? arg_caps_retain : 0;
 
-                if (q.effective == (uint64_t) -1)
+                if (q.effective == UINT64_MAX)
                         q.effective = uid == 0 ? q.bounding : 0;
 
-                if (q.inheritable == (uint64_t) -1)
+                if (q.inheritable == UINT64_MAX)
                         q.inheritable = uid == 0 ? q.bounding : arg_caps_ambient;
 
-                if (q.permitted == (uint64_t) -1)
+                if (q.permitted == UINT64_MAX)
                         q.permitted = uid == 0 ? q.bounding : arg_caps_ambient;
 
-                if (q.ambient == (uint64_t) -1 && ambient_capabilities_supported())
+                if (q.ambient == UINT64_MAX && ambient_capabilities_supported())
                         q.ambient = arg_caps_ambient;
 
                 if (capability_quintet_mangle(&q))
@@ -2664,7 +2664,7 @@ static int drop_capabilities(uid_t uid) {
                         .effective = uid == 0 ? arg_caps_retain : 0,
                         .inheritable = uid == 0 ? arg_caps_retain : arg_caps_ambient,
                         .permitted = uid == 0 ? arg_caps_retain : arg_caps_ambient,
-                        .ambient = ambient_capabilities_supported() ? arg_caps_ambient : (uint64_t) -1,
+                        .ambient = ambient_capabilities_supported() ? arg_caps_ambient : UINT64_MAX,
                 };
 
                 /* If we're not using OCI, proceed with mangled capabilities (so we don't error out)
@@ -3045,7 +3045,7 @@ static int determine_uid_shift(const char *directory) {
                 arg_uid_range = UINT32_C(0x10000);
         }
 
-        if (arg_uid_shift > (uid_t) -1 - arg_uid_range)
+        if (arg_uid_shift > UID_INVALID - arg_uid_range)
                 return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
                                        "UID base too high for UID range.");
 
@@ -4336,7 +4336,7 @@ static int merge_settings(Settings *settings, const char *path) {
         }
 
         if ((arg_settings_mask & SETTING_CLONE_NS_FLAGS) == 0 &&
-            settings->clone_ns_flags != (unsigned long) -1) {
+            settings->clone_ns_flags != ULONG_MAX) {
 
                 if (!arg_settings_trusted)
                         log_warning("Ignoring namespace setting, file '%s' is not trusted.", path);
@@ -4931,7 +4931,7 @@ static int run_container(
                         if (r < 0)
                                 return log_error_errno(r, "Failed to create PTY forwarder: %m");
 
-                        if (arg_console_width != (unsigned) -1 || arg_console_height != (unsigned) -1)
+                        if (arg_console_width != UINT_MAX || arg_console_height != UINT_MAX)
                                 (void) pty_forward_set_width_height(forward,
                                                                     arg_console_width,
                                                                     arg_console_height);
@@ -5552,7 +5552,7 @@ finish:
 
         /* Try to flush whatever is still queued in the pty */
         if (master >= 0) {
-                (void) copy_bytes(master, STDOUT_FILENO, (uint64_t) -1, 0);
+                (void) copy_bytes(master, STDOUT_FILENO, UINT64_MAX, 0);
                 master = safe_close(master);
         }
 
index 7fcb4b82cc65f618abdf71773a3b12cc64bef068..0d215cf6e977c083670e8fc2fb32da9145368bc9 100644 (file)
@@ -71,7 +71,7 @@ static int dump_state(int argc, char *argv[], void *userdata) {
                 return bus_log_parse_error(r);
 
         fflush(stdout);
-        return copy_bytes(fd, STDOUT_FILENO, (uint64_t) -1, 0);
+        return copy_bytes(fd, STDOUT_FILENO, UINT64_MAX, 0);
 }
 
 static int parse_argv(int argc, char *argv[]) {
index 22ad337e63e362906bc234a03697a23c2ed716b1..be16f5a067b5ceaab463bf7a7239aa2c1d3363df 100644 (file)
@@ -3849,7 +3849,7 @@ static int remove_efi_variable_factory_reset(void) {
 static int acquire_root_devno(const char *p, int mode, char **ret, int *ret_fd) {
         _cleanup_close_ int fd = -1;
         struct stat st;
-        dev_t devno, fd_devno = (mode_t) -1;
+        dev_t devno, fd_devno = MODE_INVALID;
         int r;
 
         assert(p);
@@ -3907,7 +3907,7 @@ static int acquire_root_devno(const char *p, int mode, char **ret, int *ret_fd)
 
         /* Only if we still lock at the same block device we can reuse the fd. Otherwise return an
          * invalidated fd. */
-        *ret_fd = fd_devno != (mode_t) -1 && fd_devno == devno ? TAKE_FD(fd) : -1;
+        *ret_fd = fd_devno != MODE_INVALID && fd_devno == devno ? TAKE_FD(fd) : -1;
         return 0;
 }
 
index 7c8e08e332c2761f64fd7e6caad7496d89afdd37..77fcd4fe6fcbc374b4cff8055103448163cb3d25 100644 (file)
@@ -923,7 +923,7 @@ static int set_limit(int argc, char *argv[], void *userdata) {
         (void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
 
         if (STR_IN_SET(argv[argc-1], "-", "none", "infinity"))
-                limit = (uint64_t) -1;
+                limit = UINT64_MAX;
         else {
                 r = parse_size(argv[argc-1], 1024, &limit);
                 if (r < 0)
index 8de8bfc247c4ef673dc1c2fc10780110bf883e5b..6d0dee99c3f703494329f3cfa65c9d6c821d027a 100644 (file)
@@ -42,7 +42,7 @@ static int property_get_pool_usage(
                 sd_bus_error *error) {
 
         _cleanup_close_ int fd = -1;
-        uint64_t usage = (uint64_t) -1;
+        uint64_t usage = UINT64_MAX;
 
         assert(bus);
         assert(reply);
@@ -68,7 +68,7 @@ static int property_get_pool_limit(
                 sd_bus_error *error) {
 
         _cleanup_close_ int fd = -1;
-        uint64_t size = (uint64_t) -1;
+        uint64_t size = UINT64_MAX;
 
         assert(bus);
         assert(reply);
index 395f983deb7065f0bb4bbf4487a39de4792e2eaa..0bf320df8808fba9addef2a93592381e44e89d38 100644 (file)
@@ -476,7 +476,7 @@ static int dns_cache_put_positive(
                 .rr = dns_resource_record_ref(rr),
                 .answer = dns_answer_ref(answer),
                 .full_packet = dns_packet_ref(full_packet),
-                .until = calculate_until(rr, (uint32_t) -1, timestamp, false),
+                .until = calculate_until(rr, UINT32_MAX, timestamp, false),
                 .query_flags = query_flags & CACHEABLE_QUERY_FLAGS,
                 .shared_owner = shared_owner,
                 .dnssec_result = dnssec_result,
index 2f5776b5edae2749e767232490271c5fb33832b4..4b12e483523d3723c47069aa46e1cd0d77ce5671 100644 (file)
@@ -490,7 +490,7 @@ static int dnssec_rrsig_prepare(DnsResourceRecord *rrsig) {
         assert(rrsig->key->type == DNS_TYPE_RRSIG);
 
         /* Check if this RRSIG RR is already prepared */
-        if (rrsig->n_skip_labels_source != (unsigned) -1)
+        if (rrsig->n_skip_labels_source != UINT_MAX)
                 return 0;
 
         if (rrsig->rrsig.inception > rrsig->rrsig.expiration)
@@ -1297,10 +1297,10 @@ static int nsec3_is_good(DnsResourceRecord *rr, DnsResourceRecord *nsec3) {
 
         /* Ignore NSEC3 RRs generated from wildcards. If these NSEC3 RRs weren't correctly signed we can't make this
          * check (since rr->n_skip_labels_source is -1), but that's OK, as we won't trust them anyway in that case. */
-        if (!IN_SET(rr->n_skip_labels_source, 0, (unsigned) -1))
+        if (!IN_SET(rr->n_skip_labels_source, 0, UINT_MAX))
                 return 0;
         /* Ignore NSEC3 RRs that are located anywhere else than one label below the zone */
-        if (!IN_SET(rr->n_skip_labels_signer, 1, (unsigned) -1))
+        if (!IN_SET(rr->n_skip_labels_signer, 1, UINT_MAX))
                 return 0;
 
         if (!nsec3)
index 9778f5ee6b5645b248eb388149b3ed73a86c8a20..abc978ab833c6eeaa81a93d489dcb5b290ed3c1e 100644 (file)
@@ -82,8 +82,8 @@ int dns_packet_new(
                 .rindex = DNS_PACKET_HEADER_SIZE,
                 .allocated = a,
                 .max_size = max_size,
-                .opt_start = (size_t) -1,
-                .opt_size = (size_t) -1,
+                .opt_start = SIZE_MAX,
+                .opt_size = SIZE_MAX,
         };
 
         *ret = p;
@@ -182,8 +182,8 @@ int dns_packet_dup(DnsPacket **ret, DnsPacket *p) {
                 .rindex = DNS_PACKET_HEADER_SIZE,
                 .allocated = p->size,
                 .max_size = p->max_size,
-                .opt_start = (size_t) -1,
-                .opt_size = (size_t) -1,
+                .opt_start = SIZE_MAX,
+                .opt_size = SIZE_MAX,
         };
 
         memcpy(DNS_PACKET_DATA(c), DNS_PACKET_DATA(p), p->size);
@@ -736,10 +736,10 @@ int dns_packet_append_opt(
         assert(rcode >= 0);
         assert(rcode <= _DNS_RCODE_MAX);
 
-        if (p->opt_start != (size_t) -1)
+        if (p->opt_start != SIZE_MAX)
                 return -EBUSY;
 
-        assert(p->opt_size == (size_t) -1);
+        assert(p->opt_size == SIZE_MAX);
 
         saved_size = p->size;
 
@@ -851,12 +851,12 @@ fail:
 int dns_packet_truncate_opt(DnsPacket *p) {
         assert(p);
 
-        if (p->opt_start == (size_t) -1) {
-                assert(p->opt_size == (size_t) -1);
+        if (p->opt_start == SIZE_MAX) {
+                assert(p->opt_size == SIZE_MAX);
                 return 0;
         }
 
-        assert(p->opt_size != (size_t) -1);
+        assert(p->opt_size != SIZE_MAX);
         assert(DNS_PACKET_ARCOUNT(p) > 0);
 
         if (p->opt_start + p->opt_size != p->size)
@@ -864,7 +864,7 @@ int dns_packet_truncate_opt(DnsPacket *p) {
 
         dns_packet_truncate(p, p->opt_start);
         DNS_PACKET_HEADER(p)->arcount = htobe16(DNS_PACKET_ARCOUNT(p) - 1);
-        p->opt_start = p->opt_size = (size_t) -1;
+        p->opt_start = p->opt_size = SIZE_MAX;
 
         return 1;
 }
@@ -2458,10 +2458,10 @@ int dns_packet_patch_max_udp_size(DnsPacket *p, uint16_t max_udp_size) {
         assert(p);
         assert(max_udp_size >= DNS_PACKET_UNICAST_SIZE_MAX);
 
-        if (p->opt_start == (size_t) -1) /* No OPT section, nothing to patch */
+        if (p->opt_start == SIZE_MAX) /* No OPT section, nothing to patch */
                 return 0;
 
-        assert(p->opt_size != (size_t) -1);
+        assert(p->opt_size != SIZE_MAX);
         assert(p->opt_size >= 5);
 
         unaligned_write_be16(DNS_PACKET_DATA(p) + p->opt_start + 3, max_udp_size);
index 9b94ab59eabbae6b32bd9a497d4e4d336b403c9b..823117e5c92d3e0d752e89dc5b6cf2df1db2344e 100644 (file)
@@ -118,7 +118,7 @@ DnsResourceKey* dns_resource_key_ref(DnsResourceKey *k) {
 
         /* Static/const keys created with DNS_RESOURCE_KEY_CONST will
          * set this to -1, they should not be reffed/unreffed */
-        assert(k->n_ref != (unsigned) -1);
+        assert(k->n_ref != UINT_MAX);
 
         assert(k->n_ref > 0);
         k->n_ref++;
@@ -130,7 +130,7 @@ DnsResourceKey* dns_resource_key_unref(DnsResourceKey *k) {
         if (!k)
                 return NULL;
 
-        assert(k->n_ref != (unsigned) -1);
+        assert(k->n_ref != UINT_MAX);
         assert(k->n_ref > 0);
 
         if (k->n_ref == 1) {
@@ -342,9 +342,9 @@ bool dns_resource_key_reduce(DnsResourceKey **a, DnsResourceKey **b) {
                 return false;
 
         /* We refuse merging const keys */
-        if ((*a)->n_ref == (unsigned) -1)
+        if ((*a)->n_ref == UINT_MAX)
                 return false;
-        if ((*b)->n_ref == (unsigned) -1)
+        if ((*b)->n_ref == UINT_MAX)
                 return false;
 
         /* Already the same? */
@@ -378,8 +378,8 @@ DnsResourceRecord* dns_resource_record_new(DnsResourceKey *key) {
                 .n_ref = 1,
                 .key = dns_resource_key_ref(key),
                 .expiry = USEC_INFINITY,
-                .n_skip_labels_signer = (unsigned) -1,
-                .n_skip_labels_source = (unsigned) -1,
+                .n_skip_labels_signer = UINT_MAX,
+                .n_skip_labels_source = UINT_MAX,
         };
 
         return rr;
@@ -1265,7 +1265,7 @@ int dns_resource_record_signer(DnsResourceRecord *rr, const char **ret) {
 
         /* Returns the RRset's signer, if it is known. */
 
-        if (rr->n_skip_labels_signer == (unsigned) -1)
+        if (rr->n_skip_labels_signer == UINT_MAX)
                 return -ENODATA;
 
         n = dns_resource_key_name(rr->key);
@@ -1288,7 +1288,7 @@ int dns_resource_record_source(DnsResourceRecord *rr, const char **ret) {
 
         /* Returns the RRset's synthesizing source, if it is known. */
 
-        if (rr->n_skip_labels_source == (unsigned) -1)
+        if (rr->n_skip_labels_source == UINT_MAX)
                 return -ENODATA;
 
         n = dns_resource_key_name(rr->key);
@@ -1322,7 +1322,7 @@ int dns_resource_record_is_synthetic(DnsResourceRecord *rr) {
 
         /* Returns > 0 if the RR is generated from a wildcard, and is not the asterisk name itself */
 
-        if (rr->n_skip_labels_source == (unsigned) -1)
+        if (rr->n_skip_labels_source == UINT_MAX)
                 return -ENODATA;
 
         if (rr->n_skip_labels_source == 0)
index d3edcadf675384f8ed5fdf349f0ecbe00d772648..ab48ea5f2a091297168491c236adad1b68f9404b 100644 (file)
@@ -76,7 +76,7 @@ struct DnsResourceKey {
  * resource key object. */
 #define DNS_RESOURCE_KEY_CONST(c, t, n)                 \
         ((DnsResourceKey) {                             \
-                .n_ref = (unsigned) -1,                 \
+                .n_ref = UINT_MAX,                      \
                 .class = c,                             \
                 .type = t,                              \
                 ._name = (char*) n,                     \
index 07c6eca3ba4ff2293a6a52a94cd899025adf5418..6eac7e9c579f7d046ad5ba10335d57e881ca5131 100644 (file)
@@ -30,7 +30,7 @@ static void dns_transaction_reset_answer(DnsTransaction *t) {
         t->answer_dnssec_result = _DNSSEC_RESULT_INVALID;
         t->answer_source = _DNS_TRANSACTION_SOURCE_INVALID;
         t->answer_query_flags = 0;
-        t->answer_nsec_ttl = (uint32_t) -1;
+        t->answer_nsec_ttl = UINT32_MAX;
         t->answer_errno = 0;
 }
 
@@ -275,7 +275,7 @@ int dns_transaction_new(
                 .dns_udp_fd = -1,
                 .answer_source = _DNS_TRANSACTION_SOURCE_INVALID,
                 .answer_dnssec_result = _DNSSEC_RESULT_INVALID,
-                .answer_nsec_ttl = (uint32_t) -1,
+                .answer_nsec_ttl = UINT32_MAX,
                 .key = dns_resource_key_ref(key),
                 .query_flags = query_flags,
                 .bypass = dns_packet_ref(bypass),
index e3a46f4ca1672701762332fd8a4642f7bfdb5ad1..bfd71575d63e810c8d7215872b10bbf5fccab9ff 100644 (file)
@@ -321,7 +321,7 @@ static int on_mdns_packet(sd_event_source *s, int fd, uint32_t revents, void *us
                                 dns_transaction_process_reply(t, p, false);
                 }
 
-                dns_cache_put(&scope->cache, scope->manager->enable_cache, NULL, DNS_PACKET_RCODE(p), p->answer, NULL, false, _DNSSEC_RESULT_INVALID, (uint32_t) -1, p->family, &p->sender);
+                dns_cache_put(&scope->cache, scope->manager->enable_cache, NULL, DNS_PACKET_RCODE(p), p->answer, NULL, false, _DNSSEC_RESULT_INVALID, UINT32_MAX, p->family, &p->sender);
 
         } else if (dns_packet_validate_query(p) > 0)  {
                 log_debug("Got mDNS query packet for id %u", DNS_PACKET_ID(p));
index 7137eb31306bfb9705ff3ab4205323570ed7f5a1..9aad834ee28ab5e72bd1b1b6ffdb77519009cc54 100644 (file)
@@ -204,7 +204,7 @@ static int backspace_string(int ttyfd, const char *str) {
                 return 0;
 
         size_t m = utf8_n_codepoints(str);
-        if (m == (size_t) -1)
+        if (m == SIZE_MAX)
                 m = strlen(str); /* Not a valid UTF-8 string? If so, let's backspace the number of bytes
                                   * output. Most likely this happened because we are not in an UTF-8 locale,
                                   * and in that case that is the correct thing to do. And even if it's not,
@@ -583,9 +583,9 @@ int ask_password_tty(
                                 for (;;) {
                                         size_t z;
 
-                                        z = utf8_encoded_valid_unichar(passphrase + q, (size_t) -1);
+                                        z = utf8_encoded_valid_unichar(passphrase + q, SIZE_MAX);
                                         if (z == 0) {
-                                                q = (size_t) -1; /* Invalid UTF8! */
+                                                q = SIZE_MAX; /* Invalid UTF8! */
                                                 break;
                                         }
 
@@ -595,7 +595,7 @@ int ask_password_tty(
                                         q += z;
                                 }
 
-                                p = codepoint = q == (size_t) -1 ? p - 1 : q;
+                                p = codepoint = q == SIZE_MAX ? p - 1 : q;
                                 explicit_bzero_safe(passphrase + p, sizeof(passphrase) - p);
 
                         } else if (!dirty && !(flags & ASK_PASSWORD_SILENT)) {
@@ -632,7 +632,7 @@ int ask_password_tty(
 
                         if (!(flags & ASK_PASSWORD_SILENT) && ttyfd >= 0) {
                                 /* Check if we got a complete UTF-8 character now. If so, let's output one '*'. */
-                                n = utf8_encoded_valid_unichar(passphrase + codepoint, (size_t) -1);
+                                n = utf8_encoded_valid_unichar(passphrase + codepoint, SIZE_MAX);
                                 if (n >= 0) {
                                         if (flags & ASK_PASSWORD_ECHO)
                                                 (void) loop_write(ttyfd, passphrase + codepoint, n, false);
index 33528388f036e91cbb1fab65958bfe6cc6193332..dcf67fbbd80c4d0f70541c26fbe8bc3e10e40f0e 100644 (file)
@@ -18,7 +18,7 @@
 #define BITMAPS_MAX_ENTRY 0xffff
 
 /* This indicates that we reached the end of the bitmap */
-#define BITMAP_END ((unsigned) -1)
+#define BITMAP_END (UINT_MAX)
 
 #define BITMAP_NUM_TO_OFFSET(n)           ((n) / (sizeof(uint64_t) * 8))
 #define BITMAP_NUM_TO_REM(n)              ((n) % (sizeof(uint64_t) * 8))
index a5ce7ef17f0185b3803b6f3ebed30b702a72608c..feb6d3807f77c88ef86ee8f1964fa162b1c349ea 100644 (file)
@@ -142,9 +142,9 @@ int bus_property_get_rlimit(
                 x = is_soft ? buf.rlim_cur : buf.rlim_max;
         }
 
-        /* rlim_t might have different sizes, let's map RLIMIT_INFINITY to (uint64_t) -1, so that it is the same on all
+        /* rlim_t might have different sizes, let's map RLIMIT_INFINITY to UINT64_MAX, so that it is the same on all
          * archs */
-        u = x == RLIM_INFINITY ? (uint64_t) -1 : (uint64_t) x;
+        u = x == RLIM_INFINITY ? UINT64_MAX : (uint64_t) x;
 
         return sd_bus_message_append(reply, "t", u);
 }
index 4cea25073d1a78741e60547007921e1edb8c3b78..2a712be7339fc936a4d1926f9b9badce55ccc9eb 100644 (file)
@@ -180,18 +180,18 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
                 } else if ((STR_IN_SET(name, "CPUWeight", "StartupCPUWeight", "IOWeight", "StartupIOWeight") && u == CGROUP_WEIGHT_INVALID) ||
                            (STR_IN_SET(name, "CPUShares", "StartupCPUShares") && u == CGROUP_CPU_SHARES_INVALID) ||
                            (STR_IN_SET(name, "BlockIOWeight", "StartupBlockIOWeight") && u == CGROUP_BLKIO_WEIGHT_INVALID) ||
-                           (STR_IN_SET(name, "MemoryCurrent", "TasksCurrent") && u == (uint64_t) -1) ||
-                           (endswith(name, "NSec") && u == (uint64_t) -1))
+                           (STR_IN_SET(name, "MemoryCurrent", "TasksCurrent") && u == UINT64_MAX) ||
+                           (endswith(name, "NSec") && u == UINT64_MAX))
 
                         bus_print_property_value(name, expected_value, value, "[not set]");
 
                 else if ((STR_IN_SET(name, "DefaultMemoryLow", "DefaultMemoryMin", "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryLimit") && u == CGROUP_LIMIT_MAX) ||
-                         (STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == (uint64_t) -1) ||
-                         (startswith(name, "Limit") && u == (uint64_t) -1) ||
-                         (startswith(name, "DefaultLimit") && u == (uint64_t) -1))
+                         (STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == UINT64_MAX) ||
+                         (startswith(name, "Limit") && u == UINT64_MAX) ||
+                         (startswith(name, "DefaultLimit") && u == UINT64_MAX))
 
                         bus_print_property_value(name, expected_value, value, "infinity");
-                else if (STR_IN_SET(name, "IPIngressBytes", "IPIngressPackets", "IPEgressBytes", "IPEgressPackets") && u == (uint64_t) -1)
+                else if (STR_IN_SET(name, "IPIngressBytes", "IPIngressPackets", "IPEgressBytes", "IPEgressPackets") && u == UINT64_MAX)
                         bus_print_property_value(name, expected_value, value, "[no data]");
                 else
                         bus_print_property_valuef(name, expected_value, value, "%"PRIu64, u);
index 9ed537879159e089e9c9ccdaa057ec1ac2276965..a75178068b507f661985eaa77f4e6b43792f0545 100644 (file)
@@ -1193,7 +1193,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
                 _cleanup_free_ void *decoded = NULL;
                 size_t sz;
 
-                r = unbase64mem(eq, (size_t) -1, &decoded, &sz);
+                r = unbase64mem(eq, SIZE_MAX, &decoded, &sz);
                 if (r < 0)
                         return log_error_errno(r, "Failed to decode base64 data '%s': %m", eq);
 
index 58211ebd0316e2445e2032f20884ee5bed348d16..64ca67993c00e714305b63fb3e32fba3bccea02e 100644 (file)
@@ -101,7 +101,7 @@ int bus_event_loop_with_idle(
                 else
                         idle = true;
 
-                r = sd_event_run(e, exiting || !idle ? (uint64_t) -1 : timeout);
+                r = sd_event_run(e, exiting || !idle ? UINT64_MAX : timeout);
                 if (r < 0)
                         return r;
 
index 80f7785323b7f1018f8f082ba78610bd32fcc429..51b71ecc2c18a6758ac2b956896d4c109c2d0a91 100644 (file)
@@ -133,7 +133,7 @@ static int bus_process_wait(sd_bus *bus) {
                 if (r > 0)
                         return 0;
 
-                r = sd_bus_wait(bus, (uint64_t) -1);
+                r = sd_bus_wait(bus, UINT64_MAX);
                 if (r < 0)
                         return r;
         }
index 4f1c505bd3f1bae01b165d45c03f01b7f080fcd6..29620e0d1b37c1cbb582be047a4e0440a0838339 100644 (file)
@@ -414,7 +414,7 @@ int bus_wait_for_units_run(BusWaitForUnits *d) {
                 if (r > 0)
                         continue;
 
-                r = sd_bus_wait(d->bus, (uint64_t) -1);
+                r = sd_bus_wait(d->bus, UINT64_MAX);
                 if (r < 0)
                         return r;
         }
index a47009c3c1a3ea23fd364fe790bc5fdc28c7657d..997b265259bde7a1c5584499569322c3038ac7e8 100644 (file)
@@ -2331,7 +2331,7 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
                                 continue;
                         }
 
-                        r = copy_bytes(fd, fds[2*k+1], (uint64_t) -1, 0);
+                        r = copy_bytes(fd, fds[2*k+1], UINT64_MAX, 0);
                         if (r < 0) {
                                 (void) write(error_pipe[1], &r, sizeof(r));
                                 _exit(EXIT_FAILURE);
index c4a1b0f48f3bd67c19659e01c5eea465956e60c0..fdb5887a1aaea8ba716fb969cfb5b231a418b921 100644 (file)
@@ -122,7 +122,7 @@ static size_t TABLE_CELL_TO_INDEX(TableCell *cell) {
 }
 
 static TableCell* TABLE_INDEX_TO_CELL(size_t index) {
-        assert(index != (size_t) -1);
+        assert(index != SIZE_MAX);
         return SIZE_TO_PTR(index + 1);
 }
 
@@ -131,9 +131,9 @@ struct Table {
         size_t n_cells;
 
         bool header;   /* Whether to show the header row? */
-        size_t width;  /* If == 0 format this as wide as necessary. If (size_t) -1 format this to console
+        size_t width;  /* If == 0 format this as wide as necessary. If SIZE_MAX format this to console
                         * width or less wide, but not wider. Otherwise the width to format this table in. */
-        size_t cell_height_max; /* Maximum number of lines per cell. (If there are more, ellipsis is shown. If (size_t) -1 then no limit is set, the default. == 0 is not allowed.) */
+        size_t cell_height_max; /* Maximum number of lines per cell. (If there are more, ellipsis is shown. If SIZE_MAX then no limit is set, the default. == 0 is not allowed.) */
 
         TableData **data;
         size_t n_allocated;
@@ -161,8 +161,8 @@ Table *table_new_raw(size_t n_columns) {
         *t = (struct Table) {
                 .n_columns = n_columns,
                 .header = true,
-                .width = (size_t) -1,
-                .cell_height_max = (size_t) -1,
+                .width = SIZE_MAX,
+                .cell_height_max = SIZE_MAX,
         };
 
         return TAKE_PTR(t);
@@ -427,16 +427,16 @@ int table_add_cell_full(
                 p = NULL;
 
         /* If formatting parameters are left unspecified, copy from the previous row */
-        if (minimum_width == (size_t) -1)
+        if (minimum_width == SIZE_MAX)
                 minimum_width = p ? p->minimum_width : 1;
 
-        if (weight == (unsigned) -1)
+        if (weight == UINT_MAX)
                 weight = p ? p->weight : DEFAULT_WEIGHT;
 
-        if (align_percent == (unsigned) -1)
+        if (align_percent == UINT_MAX)
                 align_percent = p ? p->align_percent : 0;
 
-        if (ellipsize_percent == (unsigned) -1)
+        if (ellipsize_percent == UINT_MAX)
                 ellipsize_percent = p ? p->ellipsize_percent : 100;
 
         assert(align_percent <= 100);
@@ -591,7 +591,7 @@ int table_set_minimum_width(Table *t, TableCell *cell, size_t minimum_width) {
         assert(t);
         assert(cell);
 
-        if (minimum_width == (size_t) -1)
+        if (minimum_width == SIZE_MAX)
                 minimum_width = 1;
 
         r = table_dedup_cell(t, cell);
@@ -622,7 +622,7 @@ int table_set_weight(Table *t, TableCell *cell, unsigned weight) {
         assert(t);
         assert(cell);
 
-        if (weight == (unsigned) -1)
+        if (weight == UINT_MAX)
                 weight = DEFAULT_WEIGHT;
 
         r = table_dedup_cell(t, cell);
@@ -639,7 +639,7 @@ int table_set_align_percent(Table *t, TableCell *cell, unsigned percent) {
         assert(t);
         assert(cell);
 
-        if (percent == (unsigned) -1)
+        if (percent == UINT_MAX)
                 percent = 0;
 
         assert(percent <= 100);
@@ -658,7 +658,7 @@ int table_set_ellipsize_percent(Table *t, TableCell *cell, unsigned percent) {
         assert(t);
         assert(cell);
 
-        if (percent == (unsigned) -1)
+        if (percent == UINT_MAX)
                 percent = 100;
 
         assert(percent <= 100);
@@ -1067,7 +1067,7 @@ void table_set_width(Table *t, size_t width) {
 
 void table_set_cell_height_max(Table *t, size_t height) {
         assert(t);
-        assert(height >= 1 || height == (size_t) -1);
+        assert(height >= 1 || height == SIZE_MAX);
 
         t->cell_height_max = height;
 }
@@ -1115,7 +1115,7 @@ int table_set_display_internal(Table *t, size_t first_column, ...) {
                 t->display_map[t->n_display_map++] = column;
 
                 column = va_arg(ap, size_t);
-                if (column == (size_t) -1)
+                if (column == SIZE_MAX)
                         break;
 
         }
@@ -1145,7 +1145,7 @@ int table_set_sort_internal(Table *t, size_t first_column, ...) {
                 t->sort_map[t->n_sort_map++] = column;
 
                 column = va_arg(ap, size_t);
-                if (column == (size_t) -1)
+                if (column == SIZE_MAX)
                         break;
         }
         va_end(ap);
@@ -1758,7 +1758,7 @@ static int console_width_height(
                         k = utf8_console_width(s);
                         s = NULL;
                 }
-                if (k == (size_t) -1)
+                if (k == SIZE_MAX)
                         return -EINVAL;
                 if (k > max_width)
                         max_width = k;
@@ -1794,7 +1794,7 @@ static int table_data_requested_width_height(
         if (!t)
                 return -ENOMEM;
 
-        if (table->cell_height_max != (size_t) -1) {
+        if (table->cell_height_max != SIZE_MAX) {
                 r = string_truncate_lines(t, table->cell_height_max, &truncated);
                 if (r < 0)
                         return r;
@@ -1808,7 +1808,7 @@ static int table_data_requested_width_height(
         if (r < 0)
                 return r;
 
-        if (d->maximum_width != (size_t) -1 && width > d->maximum_width)
+        if (d->maximum_width != SIZE_MAX && width > d->maximum_width)
                 width = d->maximum_width;
 
         if (width < d->minimum_width)
@@ -1965,14 +1965,14 @@ int table_print(Table *t, FILE *f) {
 
         for (size_t j = 0; j < display_columns; j++) {
                 minimum_width[j] = 1;
-                maximum_width[j] = (size_t) -1;
+                maximum_width[j] = SIZE_MAX;
         }
 
         for (unsigned pass = 0; pass < 2; pass++) {
                 /* First pass: determine column sizes */
 
                 for (size_t j = 0; j < display_columns; j++)
-                        requested_width[j] = (size_t) -1;
+                        requested_width[j] = SIZE_MAX;
 
                 bool any_soft = false;
 
@@ -2020,7 +2020,7 @@ int table_print(Table *t, FILE *f) {
                                 }
 
                                 /* Determine the biggest width that any cell in this column would like to have */
-                                if (requested_width[j] == (size_t) -1 ||
+                                if (requested_width[j] == SIZE_MAX ||
                                     requested_width[j] < req_width)
                                         requested_width[j] = req_width;
 
@@ -2029,8 +2029,8 @@ int table_print(Table *t, FILE *f) {
                                         minimum_width[j] = d->minimum_width;
 
                                 /* Determine the maximum width any cell in this column needs */
-                                if (d->maximum_width != (size_t) -1 &&
-                                    (maximum_width[j] == (size_t) -1 ||
+                                if (d->maximum_width != SIZE_MAX &&
+                                    (maximum_width[j] == SIZE_MAX ||
                                      maximum_width[j] > d->maximum_width))
                                         maximum_width[j] = d->maximum_width;
 
@@ -2049,8 +2049,8 @@ int table_print(Table *t, FILE *f) {
 
                         table_minimum_width += minimum_width[j];
 
-                        if (maximum_width[j] == (size_t) -1)
-                                table_maximum_width = (size_t) -1;
+                        if (maximum_width[j] == SIZE_MAX)
+                                table_maximum_width = SIZE_MAX;
                         else
                                 table_maximum_width += maximum_width[j];
 
@@ -2058,7 +2058,7 @@ int table_print(Table *t, FILE *f) {
                 }
 
                 /* Calculate effective table width */
-                if (t->width != 0 && t->width != (size_t) -1)
+                if (t->width != 0 && t->width != SIZE_MAX)
                         table_effective_width = t->width;
                 else if (t->width == 0 ||
                          ((pass > 0 || !any_soft) && (pager_have() || !isatty(STDOUT_FILENO))))
@@ -2066,7 +2066,7 @@ int table_print(Table *t, FILE *f) {
                 else
                         table_effective_width = MIN(table_requested_width, columns());
 
-                if (table_maximum_width != (size_t) -1 && table_effective_width > table_maximum_width)
+                if (table_maximum_width != SIZE_MAX && table_effective_width > table_maximum_width)
                         table_effective_width = table_maximum_width;
 
                 if (table_effective_width < table_minimum_width)
@@ -2091,7 +2091,7 @@ int table_print(Table *t, FILE *f) {
                                 else
                                         width[j] = requested_width[j] + (extra * column_weight[j]) / weight_sum;
 
-                                if (maximum_width[j] != (size_t) -1 && width[j] > maximum_width[j])
+                                if (maximum_width[j] != SIZE_MAX && width[j] > maximum_width[j])
                                         width[j] = maximum_width[j];
 
                                 if (width[j] < minimum_width[j])
@@ -2119,7 +2119,7 @@ int table_print(Table *t, FILE *f) {
                         extra = table_effective_width - table_minimum_width;
 
                         for (size_t j = 0; j < display_columns; j++)
-                                width[j] = (size_t) -1;
+                                width[j] = SIZE_MAX;
 
                         for (;;) {
                                 bool restart = false;
@@ -2128,7 +2128,7 @@ int table_print(Table *t, FILE *f) {
                                         size_t delta, w;
 
                                         /* Did this column already get something assigned? If so, let's skip to the next */
-                                        if (width[j] != (size_t) -1)
+                                        if (width[j] != SIZE_MAX)
                                                 continue;
 
                                         if (weight_sum == 0)
@@ -2210,7 +2210,7 @@ int table_print(Table *t, FILE *f) {
                                         return r;
                                 if (r > 0) {
                                         /* There are more lines to come */
-                                        if ((t->cell_height_max == (size_t) -1 || n_subline + 1 < t->cell_height_max))
+                                        if ((t->cell_height_max == SIZE_MAX || n_subline + 1 < t->cell_height_max))
                                                 more_sublines = true; /* There are more lines to come */
                                         else
                                                 lines_truncated = true;
@@ -2445,7 +2445,7 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
 
         case TABLE_SIZE:
         case TABLE_BPS:
-                if (d->size == (uint64_t) -1)
+                if (d->size == UINT64_MAX)
                         return json_variant_new_null(ret);
 
                 return json_variant_new_unsigned(ret, d->size);
index 1a486bf5bef429a05ca16c16c9adf7ab4269eddd..02a85ee94bdb0f0c18a522dffde9d20f5fb9a289 100644 (file)
@@ -73,7 +73,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Table*, table_unref);
 
 int table_add_cell_full(Table *t, TableCell **ret_cell, TableDataType type, const void *data, size_t minimum_width, size_t maximum_width, unsigned weight, unsigned align_percent, unsigned ellipsize_percent);
 static inline int table_add_cell(Table *t, TableCell **ret_cell, TableDataType type, const void *data) {
-        return table_add_cell_full(t, ret_cell, type, data, (size_t) -1, (size_t) -1, (unsigned) -1, (unsigned) -1, (unsigned) -1);
+        return table_add_cell_full(t, ret_cell, type, data, SIZE_MAX, SIZE_MAX, UINT_MAX, UINT_MAX, UINT_MAX);
 }
 int table_add_cell_stringf(Table *t, TableCell **ret_cell, const char *format, ...) _printf_(3, 4);
 
index d391eb01cc1a7ba49f4adb665d64b777828f766d..ef1e937645914ee714153b8e11f636ce3c4732ef 100644 (file)
@@ -393,10 +393,10 @@ int json_variant_new_stringn(JsonVariant **ret, const char *s, size_t n) {
 
         assert_return(ret, -EINVAL);
         if (!s) {
-                assert_return(IN_SET(n, 0, (size_t) -1), -EINVAL);
+                assert_return(IN_SET(n, 0, SIZE_MAX), -EINVAL);
                 return json_variant_new_null(ret);
         }
-        if (n == (size_t) -1) /* determine length automatically */
+        if (n == SIZE_MAX) /* determine length automatically */
                 n = strlen(s);
         else if (memchr(s, 0, n)) /* don't allow embedded NUL, as we can't express that in JSON */
                 return -EINVAL;
@@ -2508,7 +2508,7 @@ static int json_parse_string(const char **p, char **ret) {
                         continue;
                 }
 
-                len = utf8_encoded_valid_unichar(c, (size_t) -1);
+                len = utf8_encoded_valid_unichar(c, SIZE_MAX);
                 if (len < 0)
                         return len;
 
@@ -2828,7 +2828,7 @@ typedef struct JsonStack {
         size_t n_elements, n_elements_allocated;
         unsigned line_before;
         unsigned column_before;
-        size_t n_suppress; /* When building: if > 0, suppress this many subsequent elements. If == (size_t) -1, suppress all subsequent elements */
+        size_t n_suppress; /* When building: if > 0, suppress this many subsequent elements. If == SIZE_MAX, suppress all subsequent elements */
 } JsonStack;
 
 static void json_stack_release(JsonStack *s) {
@@ -3532,7 +3532,7 @@ int json_buildv(JsonVariant **ret, va_list ap) {
 
                         stack[n_stack++] = (JsonStack) {
                                 .expect = EXPECT_ARRAY_ELEMENT,
-                                .n_suppress = current->n_suppress != 0 ? (size_t) -1 : 0, /* if we shall suppress the
+                                .n_suppress = current->n_suppress != 0 ? SIZE_MAX : 0, /* if we shall suppress the
                                                                                            * new array, then we should
                                                                                            * also suppress all array
                                                                                            * members */
@@ -3729,7 +3729,7 @@ int json_buildv(JsonVariant **ret, va_list ap) {
 
                         stack[n_stack++] = (JsonStack) {
                                 .expect = EXPECT_OBJECT_KEY,
-                                .n_suppress = current->n_suppress != 0 ? (size_t) -1 : 0, /* if we shall suppress the
+                                .n_suppress = current->n_suppress != 0 ? SIZE_MAX : 0, /* if we shall suppress the
                                                                                            * new object, then we should
                                                                                            * also suppress all object
                                                                                            * members */
@@ -3801,7 +3801,7 @@ int json_buildv(JsonVariant **ret, va_list ap) {
 
                         n_subtract = 1; /* we generated one item */
 
-                        if (!b && current->n_suppress != (size_t) -1)
+                        if (!b && current->n_suppress != SIZE_MAX)
                                 current->n_suppress += 2; /* Suppress this one and the next item */
 
                         current->expect = EXPECT_OBJECT_VALUE;
@@ -3819,9 +3819,9 @@ int json_buildv(JsonVariant **ret, va_list ap) {
                 }
 
                 /* If we are supposed to suppress items, let's subtract how many items where generated from that
-                 * counter. Except if the counter is (size_t) -1, i.e. we shall suppress an infinite number of elements
+                 * counter. Except if the counter is SIZE_MAX, i.e. we shall suppress an infinite number of elements
                  * on this stack level */
-                if (current->n_suppress != (size_t) -1) {
+                if (current->n_suppress != SIZE_MAX) {
                         if (current->n_suppress <= n_subtract) /* Saturated */
                                 current->n_suppress = 0;
                         else
@@ -4233,7 +4233,7 @@ int json_dispatch_uid_gid(const char *name, JsonVariant *variant, JsonDispatchFl
         assert_cc(sizeof(gid_t) == sizeof(uint32_t));
 
         DISABLE_WARNING_TYPE_LIMITS;
-        assert_cc(((uid_t) -1 < (uid_t) 0) == ((gid_t) -1 < (gid_t) 0));
+        assert_cc((UID_INVALID < (uid_t) 0) == (GID_INVALID < (gid_t) 0));
         REENABLE_WARNING;
 
         if (json_variant_is_null(variant)) {
@@ -4448,7 +4448,7 @@ int json_variant_unbase64(JsonVariant *v, void **ret, size_t *ret_size) {
         if (!json_variant_is_string(v))
                 return -EINVAL;
 
-        return unbase64mem(json_variant_string(v), (size_t) -1, ret, ret_size);
+        return unbase64mem(json_variant_string(v), SIZE_MAX, ret, ret_size);
 }
 
 int json_variant_unhex(JsonVariant *v, void **ret, size_t *ret_size) {
@@ -4456,7 +4456,7 @@ int json_variant_unhex(JsonVariant *v, void **ret, size_t *ret_size) {
         if (!json_variant_is_string(v))
                 return -EINVAL;
 
-        return unhexmem(json_variant_string(v), (size_t) -1, ret, ret_size);
+        return unhexmem(json_variant_string(v), SIZE_MAX, ret, ret_size);
 }
 
 static const char* const json_variant_type_table[_JSON_VARIANT_TYPE_MAX] = {
index d14740db882b77f8e7979e7ad51aa40abe5d940c..148701a54fed71ba4faf834bda77971da477764f 100644 (file)
@@ -71,7 +71,7 @@ int json_variant_new_null(JsonVariant **ret);
 int json_variant_new_id128(JsonVariant **ret, sd_id128_t id);
 
 static inline int json_variant_new_string(JsonVariant **ret, const char *s) {
-        return json_variant_new_stringn(ret, s, (size_t) -1);
+        return json_variant_new_stringn(ret, s, SIZE_MAX);
 }
 
 JsonVariant *json_variant_ref(JsonVariant *v);
index a217c1e0810d91975e59ab19505b326ea54c0c44..7c61c334e9008b5dd1914fd0189be84aa087a3ed 100644 (file)
@@ -1323,7 +1323,7 @@ int show_journal(
         assert(mode >= 0);
         assert(mode < _OUTPUT_MODE_MAX);
 
-        if (how_many == (unsigned) -1)
+        if (how_many == UINT_MAX)
                 need_seek = true;
         else {
                 /* Seek to end */
index 7c4c271d7d0b39a0e1ead63d45d73fff08c2ff67..8d194bf1b7c387096681d4f9c28f8d041d8a6416 100644 (file)
@@ -16,7 +16,7 @@
                           CLONE_NEWUSER|                                \
                           CLONE_NEWUTS))
 
-#define NAMESPACE_FLAGS_INITIAL  ((unsigned long) -1)
+#define NAMESPACE_FLAGS_INITIAL  (ULONG_MAX)
 
 int namespace_flags_from_string(const char *name, unsigned long *ret);
 int namespace_flags_to_string(unsigned long flags, char **ret);
index d140c371c2474df4e4c33c2567158a392d86ab9a..4bbad7e37be48abb80c63c156d83a19ccfd97c9c 100644 (file)
@@ -37,7 +37,7 @@ static bool stderr_redirected = false;
 _noreturn_ static void pager_fallback(void) {
         int r;
 
-        r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, (uint64_t) -1, 0);
+        r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, UINT64_MAX, 0);
         if (r < 0) {
                 log_error_errno(r, "Internal pager failed: %m");
                 _exit(EXIT_FAILURE);
index 754b4f5a94f92d3395601f4f95b302ba7cd7ea48..4c309f925f15d2fd26687c63ac8d18a228ee64c3 100644 (file)
@@ -646,24 +646,24 @@ int pty_forward_set_width_height(PTYForward *f, unsigned width, unsigned height)
 
         assert(f);
 
-        if (width == (unsigned) -1 && height == (unsigned) -1)
+        if (width == UINT_MAX && height == UINT_MAX)
                 return 0; /* noop */
 
-        if (width != (unsigned) -1 &&
+        if (width != UINT_MAX &&
             (width == 0 || width > USHRT_MAX))
                 return -ERANGE;
 
-        if (height != (unsigned) -1 &&
+        if (height != UINT_MAX &&
             (height == 0 || height > USHRT_MAX))
                 return -ERANGE;
 
-        if (width == (unsigned) -1 || height == (unsigned) -1) {
+        if (width == UINT_MAX || height == UINT_MAX) {
                 if (ioctl(f->master, TIOCGWINSZ, &ws) < 0)
                         return -errno;
 
-                if (width != (unsigned) -1)
+                if (width != UINT_MAX)
                         ws.ws_col = width;
-                if (height != (unsigned) -1)
+                if (height != UINT_MAX)
                         ws.ws_row = height;
         } else
                 ws = (struct winsize) {
index 9d732dca2cdeb53c750677828dee23cd6974cc7f..06aede9d364697058630066f5ec107d232f4fa33 100644 (file)
@@ -458,7 +458,7 @@ size_t udev_replace_chars(char *str, const char *allow) {
                 }
 
                 /* accept valid utf8 */
-                len = utf8_encoded_valid_unichar(str + i, (size_t) -1);
+                len = utf8_encoded_valid_unichar(str + i, SIZE_MAX);
                 if (len > 1) {
                         i += len;
                         continue;
index b470a2f37c24e895ff8888aa9ed53c8c37d812b5..bc35edd72928f833fac71196abc6ad81d700518b 100644 (file)
@@ -570,7 +570,7 @@ static int json_dispatch_umask(const char *name, JsonVariant *variant, JsonDispa
         uintmax_t k;
 
         if (json_variant_is_null(variant)) {
-                *m = (mode_t) -1;
+                *m = MODE_INVALID;
                 return 0;
         }
 
@@ -590,7 +590,7 @@ static int json_dispatch_access_mode(const char *name, JsonVariant *variant, Jso
         uintmax_t k;
 
         if (json_variant_is_null(variant)) {
-                *m = (mode_t) -1;
+                *m = MODE_INVALID;
                 return 0;
         }
 
@@ -866,7 +866,7 @@ static int dispatch_pkcs11_key_data(const char *name, JsonVariant *variant, Json
         if (!json_variant_is_string(variant))
                 return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a string.", strna(name));
 
-        r = unbase64mem(json_variant_string(variant), (size_t) -1, &b, &l);
+        r = unbase64mem(json_variant_string(variant), SIZE_MAX, &b, &l);
         if (r < 0)
                 return json_log(variant, flags, r, "Failed to decode encrypted PKCS#11 key: %m");
 
@@ -933,7 +933,7 @@ static int dispatch_fido2_hmac_credential(const char *name, JsonVariant *variant
         if (!json_variant_is_string(variant))
                 return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a string.", strna(name));
 
-        r = unbase64mem(json_variant_string(variant), (size_t) -1, &b, &l);
+        r = unbase64mem(json_variant_string(variant), SIZE_MAX, &b, &l);
         if (r < 0)
                 return json_log(variant, flags, r, "Failed to decode FIDO2 credential ID: %m");
 
@@ -963,7 +963,7 @@ static int dispatch_fido2_hmac_credential_array(const char *name, JsonVariant *v
                 if (!array)
                         return log_oom();
 
-                r = unbase64mem(json_variant_string(e), (size_t) -1, &b, &l);
+                r = unbase64mem(json_variant_string(e), SIZE_MAX, &b, &l);
                 if (r < 0)
                         return json_log(variant, flags, r, "Failed to decode FIDO2 credential ID: %m");
 
@@ -993,7 +993,7 @@ static int dispatch_fido2_hmac_salt_value(const char *name, JsonVariant *variant
         if (!json_variant_is_string(variant))
                 return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a string.", strna(name));
 
-        r = unbase64mem(json_variant_string(variant), (size_t) -1, &b, &l);
+        r = unbase64mem(json_variant_string(variant), SIZE_MAX, &b, &l);
         if (r < 0)
                 return json_log(variant, flags, r, "Failed to decode FIDO2 salt: %m");
 
@@ -1754,7 +1754,7 @@ const char *user_record_skeleton_directory(UserRecord *h) {
 mode_t user_record_access_mode(UserRecord *h) {
         assert(h);
 
-        return h->access_mode != (mode_t) -1 ? h->access_mode : 0700;
+        return h->access_mode != MODE_INVALID ? h->access_mode : 0700;
 }
 
 const char* user_record_home_directory(UserRecord *h) {
index 245bb37ae464a715555e8e624b9abd7d80370ce4..03819e38cd7c046c3533c2327aad1a62fbda0568 100644 (file)
@@ -3,7 +3,7 @@
 
 #include <stdbool.h>
 
-#define VERB_ANY ((unsigned) -1)
+#define VERB_ANY (UINT_MAX)
 
 typedef enum VerbFlags {
         VERB_DEFAULT      = 1 << 0,  /* The verb to run if no verb is specified */
index 6410a4194478dd16fa7462a2c5c64f972fc58dd6..c3c81f03fbd0b1241ed7a3fa43f0fecb51cdcbe9 100644 (file)
@@ -648,7 +648,7 @@ static void print_status_info(
         if (i->status_errno > 0)
                 printf("      Error: %i (%s)\n", i->status_errno, strerror_safe(i->status_errno));
 
-        if (i->ip_ingress_bytes != (uint64_t) -1 && i->ip_egress_bytes != (uint64_t) -1) {
+        if (i->ip_ingress_bytes != UINT64_MAX && i->ip_egress_bytes != UINT64_MAX) {
                 char buf_in[FORMAT_BYTES_MAX], buf_out[FORMAT_BYTES_MAX];
 
                 printf("         IP: %s in, %s out\n",
@@ -664,16 +664,16 @@ static void print_status_info(
                         format_bytes(buf_out, sizeof(buf_out), i->io_write_bytes));
         }
 
-        if (i->tasks_current != (uint64_t) -1) {
+        if (i->tasks_current != UINT64_MAX) {
                 printf("      Tasks: %" PRIu64, i->tasks_current);
 
-                if (i->tasks_max != (uint64_t) -1)
+                if (i->tasks_max != UINT64_MAX)
                         printf(" (limit: %" PRIu64 ")\n", i->tasks_max);
                 else
                         printf("\n");
         }
 
-        if (i->memory_current != (uint64_t) -1) {
+        if (i->memory_current != UINT64_MAX) {
                 char buf[FORMAT_BYTES_MAX];
 
                 printf("     Memory: %s", format_bytes(buf, sizeof(buf), i->memory_current));
@@ -714,7 +714,7 @@ static void print_status_info(
                 printf("\n");
         }
 
-        if (i->cpu_usage_nsec != (uint64_t) -1) {
+        if (i->cpu_usage_nsec != UINT64_MAX) {
                 char buf[FORMAT_TIMESPAN_MAX];
                 printf("        CPU: %s\n", format_timespan(buf, sizeof(buf), i->cpu_usage_nsec / NSEC_PER_USEC, USEC_PER_MSEC));
         }
@@ -1823,16 +1823,16 @@ static int show_one(
         _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
         _cleanup_set_free_ Set *found_properties = NULL;
         _cleanup_(unit_status_info_free) UnitStatusInfo info = {
-                .memory_current = (uint64_t) -1,
+                .memory_current = UINT64_MAX,
                 .memory_high = CGROUP_LIMIT_MAX,
                 .memory_max = CGROUP_LIMIT_MAX,
                 .memory_swap_max = CGROUP_LIMIT_MAX,
-                .memory_limit = (uint64_t) -1,
-                .cpu_usage_nsec = (uint64_t) -1,
-                .tasks_current = (uint64_t) -1,
-                .tasks_max = (uint64_t) -1,
-                .ip_ingress_bytes = (uint64_t) -1,
-                .ip_egress_bytes = (uint64_t) -1,
+                .memory_limit = UINT64_MAX,
+                .cpu_usage_nsec = UINT64_MAX,
+                .tasks_current = UINT64_MAX,
+                .tasks_max = UINT64_MAX,
+                .ip_ingress_bytes = UINT64_MAX,
+                .ip_egress_bytes = UINT64_MAX,
                 .io_read_bytes = UINT64_MAX,
                 .io_write_bytes = UINT64_MAX,
         };
index d1d520afbd54dbe715e79eddef99df6a3498ec1c..66e4075b5c9d2e3eee43b692627d5fbe412238a3 100644 (file)
@@ -81,7 +81,7 @@ enum {
         SD_LLDP_SYSTEM_CAPABILITIES_TPMR     = 1 << 10,
 };
 
-#define SD_LLDP_SYSTEM_CAPABILITIES_ALL ((uint16_t) -1)
+#define SD_LLDP_SYSTEM_CAPABILITIES_ALL (UINT16_MAX)
 
 #define SD_LLDP_SYSTEM_CAPABILITIES_ALL_ROUTERS                         \
         ((uint16_t)                                                     \
index ee58d18137d4ad0d8f2e9ccaec6ebeb903de5749..530bfd516e95784b7afaa85812353f6d78141165 100644 (file)
@@ -68,7 +68,7 @@ int sd_resolve_get_fd(sd_resolve *resolve);
  * POLLOUT, ...) to check for. */
 int sd_resolve_get_events(sd_resolve *resolve);
 
-/* Return the poll() timeout to pass. Returns (uint64_t) -1 as
+/* Return the poll() timeout to pass. Returns UINT64_MAX as
  * timeout if no timeout is needed. */
 int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *timeout_usec);
 
index 4e231be856ebd63f9f37f9660588f36b2aa78715..aad044d418ec04bbc38e557daf2fe4157adb37bf 100644 (file)
@@ -256,7 +256,7 @@ static int make_backup(const char *target, const char *x) {
         if (r < 0)
                 return r;
 
-        r = copy_bytes(src, fileno(dst), (uint64_t) -1, COPY_REFLINK);
+        r = copy_bytes(src, fileno(dst), UINT64_MAX, COPY_REFLINK);
         if (r < 0)
                 return r;
 
@@ -539,7 +539,7 @@ static int write_temporary_shadow(const char *shadow_path, FILE **tmpfile, char
                         .sp_warn = -1,
                         .sp_inact = -1,
                         .sp_expire = -1,
-                        .sp_flag = (unsigned long) -1, /* this appears to be what everybody does ... */
+                        .sp_flag = ULONG_MAX, /* this appears to be what everybody does ... */
                 };
 
                 r = putspent_sane(&n, shadow);
index 9c5d551d276255a96ed3d29cc46777ad1c806d64..42922a35007da5d1e3a77c1623d5ecf531816e96 100644 (file)
@@ -4,7 +4,7 @@
 
 int main(int argc, const char *argv[]) {
         _cleanup_bitmap_free_ Bitmap *b = NULL, *b2 = NULL;
-        unsigned n = (unsigned) -1, i = 0;
+        unsigned n = UINT_MAX, i = 0;
 
         b = bitmap_new();
         assert_se(b);
@@ -59,10 +59,10 @@ int main(int argc, const char *argv[]) {
                 else if (i == 1)
                         i = 256;
                 else if (i == 256)
-                        i = (unsigned) -1;
+                        i = UINT_MAX;
         }
 
-        assert_se(i == (unsigned) -1);
+        assert_se(i == UINT_MAX);
 
         i = 0;
 
@@ -73,10 +73,10 @@ int main(int argc, const char *argv[]) {
                 else if (i == 1)
                         i = 256;
                 else if (i == 256)
-                        i = (unsigned) -1;
+                        i = UINT_MAX;
         }
 
-        assert_se(i == (unsigned) -1);
+        assert_se(i == UINT_MAX);
 
         b2 = bitmap_copy(b);
         assert_se(b2);
@@ -92,7 +92,7 @@ int main(int argc, const char *argv[]) {
         bitmap_free(b2);
         b2 = NULL;
 
-        assert_se(bitmap_set(b, (unsigned) -1) == -ERANGE);
+        assert_se(bitmap_set(b, UINT_MAX) == -ERANGE);
 
         bitmap_free(b);
         b = NULL;
index e0b7f2280843db66a371c6da1b5c4259fd5a7d3f..01ec7f8770482e5bb5034fcc3cd906a178102a40 100644 (file)
@@ -59,7 +59,7 @@ static void test_next(const char *input, const char *new_tz, usec_t after, usec_
         u = after;
         r = calendar_spec_next_usec(c, after, &u);
         printf("At: %s\n", r < 0 ? strerror_safe(r) : format_timestamp_style(buf, sizeof buf, u, TIMESTAMP_US));
-        if (expect != (usec_t)-1)
+        if (expect != USEC_INFINITY)
                 assert_se(r >= 0 && u == expect);
         else
                 assert(r == -ENOENT);
index 211b4a492595275c499e2ee7f3fdb96c551a69bc..43118202b85e9d7f236df503878535b0502ebe25 100644 (file)
@@ -207,7 +207,7 @@ static void test_copy_bytes(void) {
 
         assert_se(pipe2(pipefd, O_CLOEXEC) == 0);
 
-        r = copy_bytes(infd, pipefd[1], (uint64_t) -1, 0);
+        r = copy_bytes(infd, pipefd[1], UINT64_MAX, 0);
         assert_se(r == 0);
 
         r = read(pipefd[0], buf, sizeof(buf));
@@ -249,7 +249,7 @@ static void test_copy_bytes_regular_file(const char *src, bool try_reflink, uint
         assert_se(fd3 >= 0);
 
         r = copy_bytes(fd, fd2, max_bytes, try_reflink ? COPY_REFLINK : 0);
-        if (max_bytes == (uint64_t) -1)
+        if (max_bytes == UINT64_MAX)
                 assert_se(r == 0);
         else
                 assert_se(IN_SET(r, 0, 1));
@@ -258,14 +258,14 @@ static void test_copy_bytes_regular_file(const char *src, bool try_reflink, uint
         assert_se(fstat(fd2, &buf2) == 0);
         assert_se((uint64_t) buf2.st_size == MIN((uint64_t) buf.st_size, max_bytes));
 
-        if (max_bytes < (uint64_t) -1)
+        if (max_bytes < UINT64_MAX)
                 /* Make sure the file is now higher than max_bytes */
                 assert_se(ftruncate(fd2, max_bytes + 1) == 0);
 
         assert_se(lseek(fd2, 0, SEEK_SET) == 0);
 
         r = copy_bytes(fd2, fd3, max_bytes, try_reflink ? COPY_REFLINK : 0);
-        if (max_bytes == (uint64_t) -1)
+        if (max_bytes == UINT64_MAX)
                 assert_se(r == 0);
         else
                 /* We cannot distinguish between the input being exactly max_bytes
@@ -277,7 +277,7 @@ static void test_copy_bytes_regular_file(const char *src, bool try_reflink, uint
 
         assert_se(fstat(fd3, &buf3) == 0);
 
-        if (max_bytes == (uint64_t) -1)
+        if (max_bytes == UINT64_MAX)
                 assert_se(buf3.st_size == buf2.st_size);
         else
                 assert_se((uint64_t) buf3.st_size == max_bytes);
@@ -312,7 +312,7 @@ static void test_copy_proc(void) {
 
         assert_se(mkdtemp_malloc(NULL, &p) >= 0);
         assert_se(f = path_join(p, "version"));
-        assert_se(copy_file("/proc/version", f, 0, (mode_t) -1, 0, 0, 0) >= 0);
+        assert_se(copy_file("/proc/version", f, 0, MODE_INVALID, 0, 0, 0) >= 0);
 
         assert_se(read_one_line_file("/proc/version", &a) >= 0);
         assert_se(read_one_line_file(f, &b) >= 0);
@@ -327,8 +327,8 @@ int main(int argc, char *argv[]) {
         test_copy_file_fd();
         test_copy_tree();
         test_copy_bytes();
-        test_copy_bytes_regular_file(argv[0], false, (uint64_t) -1);
-        test_copy_bytes_regular_file(argv[0], true, (uint64_t) -1);
+        test_copy_bytes_regular_file(argv[0], false, UINT64_MAX);
+        test_copy_bytes_regular_file(argv[0], true, UINT64_MAX);
         test_copy_bytes_regular_file(argv[0], false, 1000); /* smaller than copy buffer size */
         test_copy_bytes_regular_file(argv[0], true, 1000);
         test_copy_bytes_regular_file(argv[0], false, 32000); /* larger than copy buffer size */
index a5834eba364a0812ed89a9e4b31950eb2bc19cd7..659b69008203f1d3a1d6e038a7e96308c180e41f 100644 (file)
@@ -703,28 +703,28 @@ static const char buffer[] =
 static void test_read_line_one_file(FILE *f) {
         _cleanup_free_ char *line = NULL;
 
-        assert_se(read_line(f, (size_t) -1, &line) == 15 && streq(line, "Some test data"));
+        assert_se(read_line(f, SIZE_MAX, &line) == 15 && streq(line, "Some test data"));
         line = mfree(line);
 
-        assert_se(read_line(f, (size_t) -1, &line) > 0 && streq(line, "루Non-ascii chars: ąę„”"));
+        assert_se(read_line(f, SIZE_MAX, &line) > 0 && streq(line, "루Non-ascii chars: ąę„”"));
         line = mfree(line);
 
-        assert_se(read_line(f, (size_t) -1, &line) == 13 && streq(line, "terminators"));
+        assert_se(read_line(f, SIZE_MAX, &line) == 13 && streq(line, "terminators"));
         line = mfree(line);
 
-        assert_se(read_line(f, (size_t) -1, &line) == 15 && streq(line, "and even more"));
+        assert_se(read_line(f, SIZE_MAX, &line) == 15 && streq(line, "and even more"));
         line = mfree(line);
 
-        assert_se(read_line(f, (size_t) -1, &line) == 25 && streq(line, "now the same with a NUL"));
+        assert_se(read_line(f, SIZE_MAX, &line) == 25 && streq(line, "now the same with a NUL"));
         line = mfree(line);
 
-        assert_se(read_line(f, (size_t) -1, &line) == 10 && streq(line, "and more"));
+        assert_se(read_line(f, SIZE_MAX, &line) == 10 && streq(line, "and more"));
         line = mfree(line);
 
-        assert_se(read_line(f, (size_t) -1, &line) == 16 && streq(line, "and even more"));
+        assert_se(read_line(f, SIZE_MAX, &line) == 16 && streq(line, "and even more"));
         line = mfree(line);
 
-        assert_se(read_line(f, (size_t) -1, &line) == 20 && streq(line, "and yet even more"));
+        assert_se(read_line(f, SIZE_MAX, &line) == 20 && streq(line, "and yet even more"));
         line = mfree(line);
 
         assert_se(read_line(f, 1024, &line) == 30 && streq(line, "With newlines, and a NUL byte"));
@@ -736,7 +736,7 @@ static void test_read_line_one_file(FILE *f) {
         assert_se(read_line(f, 1024, &line) == 14 && streq(line, "an empty line"));
         line = mfree(line);
 
-        assert_se(read_line(f, (size_t) -1, NULL) == 16);
+        assert_se(read_line(f, SIZE_MAX, NULL) == 16);
 
         assert_se(read_line(f, 16, &line) == -ENOBUFS);
         line = mfree(line);
@@ -819,11 +819,11 @@ static void test_read_line4(void) {
 
                 assert_se(f = fmemopen_unlocked((void*) eof_endings[i].string, eof_endings[i].length, "r"));
 
-                r = read_line(f, (size_t) -1, &s);
+                r = read_line(f, SIZE_MAX, &s);
                 assert_se((size_t) r == eof_endings[i].length);
                 assert_se(streq_ptr(s, "foo"));
 
-                assert_se(read_line(f, (size_t) -1, NULL) == 0); /* Ensure we hit EOF */
+                assert_se(read_line(f, SIZE_MAX, NULL) == 0); /* Ensure we hit EOF */
         }
 }
 
index b2943e6fc1c44d2e3f83be0159ada7978c88ecb5..44d92a719d1b6dcdf69e08232dbf14a618712e4a 100644 (file)
@@ -75,7 +75,7 @@ static void test_multiline(void) {
                         "lines     \n"));
         formatted = mfree(formatted);
 
-        table_set_cell_height_max(table, (size_t) -1);
+        table_set_cell_height_max(table, SIZE_MAX);
         assert_se(table_format(table, &formatted) >= 0);
         fputs(formatted, stdout);
         assert_se(streq(formatted,
@@ -131,7 +131,7 @@ static void test_multiline(void) {
                         "          line…\n"));
         formatted = mfree(formatted);
 
-        table_set_cell_height_max(table, (size_t) -1);
+        table_set_cell_height_max(table, SIZE_MAX);
         assert_se(table_format(table, &formatted) >= 0);
         fputs(formatted, stdout);
         assert_se(streq(formatted,
@@ -189,7 +189,7 @@ static void test_strv(void) {
                         "lines     \n"));
         formatted = mfree(formatted);
 
-        table_set_cell_height_max(table, (size_t) -1);
+        table_set_cell_height_max(table, SIZE_MAX);
         assert_se(table_format(table, &formatted) >= 0);
         fputs(formatted, stdout);
         assert_se(streq(formatted,
@@ -245,7 +245,7 @@ static void test_strv(void) {
                         "          line…\n"));
         formatted = mfree(formatted);
 
-        table_set_cell_height_max(table, (size_t) -1);
+        table_set_cell_height_max(table, SIZE_MAX);
         assert_se(table_format(table, &formatted) >= 0);
         fputs(formatted, stdout);
         assert_se(streq(formatted,
@@ -300,7 +300,7 @@ static void test_strv_wrapped(void) {
                         "three different lines two lines\n"));
         formatted = mfree(formatted);
 
-        table_set_cell_height_max(table, (size_t) -1);
+        table_set_cell_height_max(table, SIZE_MAX);
         assert_se(table_format(table, &formatted) >= 0);
         fputs(formatted, stdout);
         assert_se(streq(formatted,
@@ -352,7 +352,7 @@ static void test_strv_wrapped(void) {
                         "                  ___7___ ___8___\n"));
         formatted = mfree(formatted);
 
-        table_set_cell_height_max(table, (size_t) -1);
+        table_set_cell_height_max(table, SIZE_MAX);
         assert_se(table_format(table, &formatted) >= 0);
         fputs(formatted, stdout);
         assert_se(streq(formatted,
@@ -443,8 +443,8 @@ int main(int argc, char *argv[]) {
 
         formatted = mfree(formatted);
 
-        table_set_width(t, (size_t) -1);
-        assert_se(table_set_sort(t, (size_t) 0, (size_t) 2, (size_t) -1) >= 0);
+        table_set_width(t, SIZE_MAX);
+        assert_se(table_set_sort(t, (size_t) 0, (size_t) 2, SIZE_MAX) >= 0);
 
         assert_se(table_format(t, &formatted) >= 0);
         printf("%s\n", formatted);
@@ -485,7 +485,7 @@ int main(int argc, char *argv[]) {
 
         formatted = mfree(formatted);
 
-        assert_se(table_set_display(t, (size_t) 2, (size_t) 0, (size_t) 2, (size_t) 0, (size_t) 0, (size_t) -1) >= 0);
+        assert_se(table_set_display(t, (size_t) 2, (size_t) 0, (size_t) 2, (size_t) 0, (size_t) 0, SIZE_MAX) >= 0);
 
         assert_se(table_format(t, &formatted) >= 0);
         printf("%s\n", formatted);
index 8d6984d04cc22ab2be9c0a174da43af565b743f2..c42c48722f9fe6b214c767532d2905b6888c0abd 100644 (file)
@@ -864,7 +864,7 @@ static void test_conservative_rename(void) {
         assert_se(access(q, F_OK) < 0 && errno == ENOENT);
 
         /* Check that a manual copy is detected */
-        assert_se(copy_file(p, q, 0, (mode_t) -1, 0, 0, COPY_REFLINK) >= 0);
+        assert_se(copy_file(p, q, 0, MODE_INVALID, 0, 0, COPY_REFLINK) >= 0);
         assert_se(conservative_renameat(AT_FDCWD, q, AT_FDCWD, p) == 0);
         assert_se(access(q, F_OK) < 0 && errno == ENOENT);
 
index f0f96797690439d0477968c228ddb16fd9cb6c0f..c9d318b8d16183e3261a6506f8154b060b07c69b 100644 (file)
@@ -80,7 +80,7 @@ static void test_unhexmem_one(const char *s, size_t l, int retval) {
         if (retval == 0) {
                 char *answer;
 
-                if (l == (size_t) -1)
+                if (l == SIZE_MAX)
                         l = strlen(s);
 
                 assert_se(hex = hexmem(mem, len));
@@ -96,15 +96,15 @@ static void test_unhexmem(void) {
 
         test_unhexmem_one(NULL, 0, 0);
         test_unhexmem_one("", 0, 0);
-        test_unhexmem_one("", (size_t) -1, 0);
-        test_unhexmem_one("   \n \t\r   \t\t \n\n\n", (size_t) -1, 0);
+        test_unhexmem_one("", SIZE_MAX, 0);
+        test_unhexmem_one("   \n \t\r   \t\t \n\n\n", SIZE_MAX, 0);
         test_unhexmem_one(hex_invalid, strlen(hex_invalid), -EINVAL);
         test_unhexmem_one(hex_invalid, (size_t) - 1, -EINVAL);
         test_unhexmem_one(hex, strlen(hex) - 1, -EPIPE);
         test_unhexmem_one(hex, strlen(hex), 0);
-        test_unhexmem_one(hex, (size_t) -1, 0);
+        test_unhexmem_one(hex, SIZE_MAX, 0);
         test_unhexmem_one(hex_space, strlen(hex_space), 0);
-        test_unhexmem_one(hex_space, (size_t) -1, 0);
+        test_unhexmem_one(hex_space, SIZE_MAX, 0);
 }
 
 /* https://tools.ietf.org/html/rfc4648#section-10 */
@@ -186,7 +186,7 @@ static void test_unbase32hexmem_one(const char *hex, bool padding, int retval, c
         _cleanup_free_ void *mem = NULL;
         size_t len;
 
-        assert_se(unbase32hexmem(hex, (size_t) -1, padding, &mem, &len) == retval);
+        assert_se(unbase32hexmem(hex, SIZE_MAX, padding, &mem, &len) == retval);
         if (retval == 0) {
                 char *str;
 
@@ -279,7 +279,7 @@ static void test_unbase64mem_one(const char *input, const char *output, int ret)
         _cleanup_free_ void *buffer = NULL;
         size_t size = 0;
 
-        assert_se(unbase64mem(input, (size_t) -1, &buffer, &size) == ret);
+        assert_se(unbase64mem(input, SIZE_MAX, &buffer, &size) == ret);
 
         if (ret >= 0) {
                 assert_se(size == strlen(output));
index 4bfa18195e5abccd1f2b38a9db903de5c4f18733..de902ca4270b6ce81b6f9aa99a6ec3d311a3b254 100644 (file)
@@ -72,7 +72,7 @@ static void test_struct(void) {
         assert_se(prioq_peek(q) == NULL);
         assert_se(prioq_peek_by_index(q, 0) == NULL);
         assert_se(prioq_peek_by_index(q, 1) == NULL);
-        assert_se(prioq_peek_by_index(q, (unsigned) -1) == NULL);
+        assert_se(prioq_peek_by_index(q, UINT_MAX) == NULL);
 
         for (i = 0; i < SET_SIZE; i++) {
                 assert_se(t = new0(struct test, 1));
index c7b6d8dd534ec427e4bf68c39fcd683d6de4c149..042b94634b01372007be7eb56967e9a0fcfdb906 100644 (file)
@@ -75,7 +75,7 @@ static void test_utf8_encoded_valid_unichar(void) {
         assert_se(utf8_encoded_valid_unichar("\302\256", 1) == -EINVAL); /* truncated */
         assert_se(utf8_encoded_valid_unichar("\302\256", 2) == 2);
         assert_se(utf8_encoded_valid_unichar("\302\256", 3) == 2);
-        assert_se(utf8_encoded_valid_unichar("\302\256", (size_t) -1) == 2);
+        assert_se(utf8_encoded_valid_unichar("\302\256", SIZE_MAX) == 2);
         assert_se(utf8_encoded_valid_unichar("a", 1) == 1);
         assert_se(utf8_encoded_valid_unichar("a", 2) == 1);
         assert_se(utf8_encoded_valid_unichar("\341\204", 1) == -EINVAL); /* truncated, potentially valid */
@@ -196,7 +196,7 @@ static void test_utf8_n_codepoints(void) {
         assert_se(utf8_n_codepoints("串") == 1);
         assert_se(utf8_n_codepoints("") == 0);
         assert_se(utf8_n_codepoints("…👊🔪💐…") == 5);
-        assert_se(utf8_n_codepoints("\xF1") == (size_t) -1);
+        assert_se(utf8_n_codepoints("\xF1") == SIZE_MAX);
 }
 
 static void test_utf8_console_width(void) {
@@ -207,7 +207,7 @@ static void test_utf8_console_width(void) {
         assert_se(utf8_console_width("串") == 2);
         assert_se(utf8_console_width("") == 0);
         assert_se(utf8_console_width("…👊🔪💐…") == 8);
-        assert_se(utf8_console_width("\xF1") == (size_t) -1);
+        assert_se(utf8_console_width("\xF1") == SIZE_MAX);
 }
 
 static void test_utf8_to_utf16(void) {