summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2021-03-03 13:07:10 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2021-03-05 07:10:13 +0900
commitf5fbe71d956957ca7ceb6777aed05a416fc83a43 (patch)
tree67358d417604030867a979f216bbb79939a37844 /src
parentef1e0b9a461c4baa12bdda47579c2c017209c3be (diff)
downloadsystemd-f5fbe71d956957ca7ceb6777aed05a416fc83a43.tar.gz
tree-wide: use UINT64_MAX or friends
Diffstat (limited to 'src')
-rw-r--r--src/analyze/analyze.c2
-rw-r--r--src/basic/audit-util.h2
-rw-r--r--src/basic/btrfs-util.c44
-rw-r--r--src/basic/capability-util.c16
-rw-r--r--src/basic/capability-util.h16
-rw-r--r--src/basic/cgroup-util.c2
-rw-r--r--src/basic/cgroup-util.h8
-rw-r--r--src/basic/copy.c12
-rw-r--r--src/basic/device-nodes.c2
-rw-r--r--src/basic/env-file.c26
-rw-r--r--src/basic/escape.c10
-rw-r--r--src/basic/extract-word.c2
-rw-r--r--src/basic/format-util.c2
-rw-r--r--src/basic/hexdecoct.c6
-rw-r--r--src/basic/io-util.h2
-rw-r--r--src/basic/prioq.h2
-rw-r--r--src/basic/string-util.c6
-rw-r--r--src/basic/terminal-util.c3
-rw-r--r--src/basic/user-util.c2
-rw-r--r--src/basic/utf8.c20
-rw-r--r--src/basic/utf8.h4
-rw-r--r--src/basic/xattr-util.c2
-rw-r--r--src/boot/bootctl.c2
-rw-r--r--src/busctl/busctl.c2
-rw-r--r--src/cgtop/cgtop.c4
-rw-r--r--src/core/dbus-execute.c2
-rw-r--r--src/core/dbus-unit.c6
-rw-r--r--src/core/execute.c4
-rw-r--r--src/core/load-fragment.c2
-rw-r--r--src/core/main.c2
-rw-r--r--src/core/manager.c6
-rw-r--r--src/core/socket.c4
-rw-r--r--src/coredump/coredump-vacuum.c6
-rw-r--r--src/coredump/coredump.c4
-rw-r--r--src/coredump/test-coredump-vacuum.c2
-rw-r--r--src/cryptenroll/cryptenroll-tpm2.c2
-rw-r--r--src/cryptsetup/cryptsetup-fido2.c4
-rw-r--r--src/cryptsetup/cryptsetup-pkcs11.c2
-rw-r--r--src/cryptsetup/cryptsetup-tpm2.c4
-rw-r--r--src/cryptsetup/cryptsetup.c2
-rw-r--r--src/dissect/dissect.c8
-rw-r--r--src/firstboot/firstboot.c2
-rw-r--r--src/import/export-raw.c2
-rw-r--r--src/import/export-tar.c8
-rw-r--r--src/import/import-raw.c2
-rw-r--r--src/import/import-tar.c2
-rw-r--r--src/import/importd.c4
-rw-r--r--src/import/pull-job.c8
-rw-r--r--src/import/pull-raw.c2
-rw-r--r--src/journal-remote/journal-remote-main.c2
-rw-r--r--src/journal-remote/journal-remote-write.c2
-rw-r--r--src/journal-remote/journal-remote.c2
-rw-r--r--src/journal-remote/journal-upload-journal.c2
-rw-r--r--src/journal/fuzz-journald-stream.c2
-rw-r--r--src/journal/journald-context.c2
-rw-r--r--src/journal/journald-native.c2
-rw-r--r--src/journal/journald-server.c4
-rw-r--r--src/journal/test-journal-config.c2
-rw-r--r--src/libsystemd-network/fuzz-dhcp6-client.c2
-rw-r--r--src/libsystemd-network/fuzz-ndisc-rs.c2
-rw-r--r--src/libsystemd-network/lldp-network.c2
-rw-r--r--src/libsystemd-network/sd-dhcp-client.c2
-rw-r--r--src/libsystemd-network/sd-dhcp-lease.c6
-rw-r--r--src/libsystemd-network/sd-lldp.c2
-rw-r--r--src/libsystemd-network/test-dhcp-client.c2
-rw-r--r--src/libsystemd-network/test-ipv4ll.c10
-rw-r--r--src/libsystemd/sd-bus/bus-control.c2
-rw-r--r--src/libsystemd/sd-bus/bus-dump.c2
-rw-r--r--src/libsystemd/sd-bus/bus-message.c50
-rw-r--r--src/libsystemd/sd-bus/bus-socket.c2
-rw-r--r--src/libsystemd/sd-bus/sd-bus.c20
-rw-r--r--src/libsystemd/sd-bus/test-bus-chat.c4
-rw-r--r--src/libsystemd/sd-bus/test-bus-objects.c2
-rw-r--r--src/libsystemd/sd-bus/test-bus-server.c2
-rw-r--r--src/libsystemd/sd-device/device-private.c6
-rw-r--r--src/libsystemd/sd-device/sd-device.c7
-rw-r--r--src/libsystemd/sd-event/sd-event.c6
-rw-r--r--src/libsystemd/sd-event/test-event.c20
-rw-r--r--src/libsystemd/sd-journal/compress.c14
-rw-r--r--src/libsystemd/sd-journal/journal-file.c36
-rw-r--r--src/libsystemd/sd-journal/sd-journal.c6
-rw-r--r--src/libsystemd/sd-journal/test-journal-interleaving.c8
-rw-r--r--src/libsystemd/sd-journal/test-journal-stream.c6
-rw-r--r--src/libsystemd/sd-journal/test-journal-verify.c6
-rw-r--r--src/libsystemd/sd-journal/test-journal.c18
-rw-r--r--src/libsystemd/sd-login/sd-login.c4
-rw-r--r--src/libsystemd/sd-login/test-login.c2
-rw-r--r--src/libsystemd/sd-netlink/sd-netlink.c10
-rw-r--r--src/libsystemd/sd-network/sd-network.c4
-rw-r--r--src/libsystemd/sd-resolve/sd-resolve.c2
-rw-r--r--src/login/logind-dbus.c2
-rw-r--r--src/login/logind.c2
-rw-r--r--src/login/pam_systemd.c2
-rw-r--r--src/login/sysfs-show.c4
-rw-r--r--src/machine/machine-dbus.c2
-rw-r--r--src/machine/machinectl.c6
-rw-r--r--src/machine/machined-dbus.c4
-rw-r--r--src/network/networkd-dhcp4.c2
-rw-r--r--src/network/networkd-link-bus.c2
-rw-r--r--src/network/networkd-link.c6
-rw-r--r--src/network/networkd-sriov.c6
-rw-r--r--src/network/networkd-state-file.c4
-rw-r--r--src/notify/notify.c4
-rw-r--r--src/nspawn/nspawn-oci.c38
-rw-r--r--src/nspawn/nspawn-settings.c8
-rw-r--r--src/nspawn/nspawn.c26
-rw-r--r--src/oom/oomctl.c2
-rw-r--r--src/partition/repart.c4
-rw-r--r--src/portable/portablectl.c2
-rw-r--r--src/portable/portabled-bus.c4
-rw-r--r--src/resolve/resolved-dns-cache.c2
-rw-r--r--src/resolve/resolved-dns-dnssec.c6
-rw-r--r--src/resolve/resolved-dns-packet.c24
-rw-r--r--src/resolve/resolved-dns-rr.c18
-rw-r--r--src/resolve/resolved-dns-rr.h2
-rw-r--r--src/resolve/resolved-dns-transaction.c4
-rw-r--r--src/resolve/resolved-mdns.c2
-rw-r--r--src/shared/ask-password-api.c10
-rw-r--r--src/shared/bitmap.c2
-rw-r--r--src/shared/bus-get-properties.c4
-rw-r--r--src/shared/bus-print-properties.c12
-rw-r--r--src/shared/bus-unit-util.c2
-rw-r--r--src/shared/bus-util.c2
-rw-r--r--src/shared/bus-wait-for-jobs.c2
-rw-r--r--src/shared/bus-wait-for-units.c2
-rw-r--r--src/shared/dissect-image.c2
-rw-r--r--src/shared/format-table.c66
-rw-r--r--src/shared/format-table.h2
-rw-r--r--src/shared/json.c24
-rw-r--r--src/shared/json.h2
-rw-r--r--src/shared/logs-show.c2
-rw-r--r--src/shared/nsflags.h2
-rw-r--r--src/shared/pager.c2
-rw-r--r--src/shared/ptyfwd.c12
-rw-r--r--src/shared/udev-util.c2
-rw-r--r--src/shared/user-record.c14
-rw-r--r--src/shared/verbs.h2
-rw-r--r--src/systemctl/systemctl-show.c24
-rw-r--r--src/systemd/sd-lldp.h2
-rw-r--r--src/systemd/sd-resolve.h2
-rw-r--r--src/sysusers/sysusers.c4
-rw-r--r--src/test/test-bitmap.c12
-rw-r--r--src/test/test-calendarspec.c2
-rw-r--r--src/test/test-copy.c16
-rw-r--r--src/test/test-fileio.c22
-rw-r--r--src/test/test-format-table.c18
-rw-r--r--src/test/test-fs-util.c2
-rw-r--r--src/test/test-hexdecoct.c14
-rw-r--r--src/test/test-prioq.c2
-rw-r--r--src/test/test-utf8.c6
150 files changed, 530 insertions, 528 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index f41eb66828..1a38d878a3 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -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) {
diff --git a/src/basic/audit-util.h b/src/basic/audit-util.h
index aa2177113b..765f3f4f63 100644
--- a/src/basic/audit-util.h
+++ b/src/basic/audit-util.h
@@ -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);
diff --git a/src/basic/btrfs-util.c b/src/basic/btrfs-util.c
index 0fb8dfedeb..51aaee71fd 100644
--- a/src/basic/btrfs-util.c
+++ b/src/basic/btrfs-util.c
@@ -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;
diff --git a/src/basic/capability-util.c b/src/basic/capability-util.c
index 43eb23cb05..b31a9cb211 100644
--- a/src/basic/capability-util.c
+++ b/src/basic/capability-util.c
@@ -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;
diff --git a/src/basic/capability-util.h b/src/basic/capability-util.h
index d9489d7883..dbce54531d 100644
--- a/src/basic/capability-util.h
+++ b/src/basic/capability-util.h
@@ -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:
diff --git a/src/basic/cgroup-util.c b/src/basic/cgroup-util.c
index 3c59ca5e10..0ecb8d944e 100644
--- a/src/basic/cgroup-util.c
+++ b/src/basic/cgroup-util.c
@@ -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;
diff --git a/src/basic/cgroup-util.h b/src/basic/cgroup-util.h
index 30b4819eb3..11deae2d20 100644
--- a/src/basic/cgroup-util.h
+++ b/src/basic/cgroup-util.h
@@ -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)
diff --git a/src/basic/copy.c b/src/basic/copy.c
index 6bb02c03a6..6391e34ed6 100644
--- a/src/basic/copy.c
+++ b/src/basic/copy.c
@@ -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);
diff --git a/src/basic/device-nodes.c b/src/basic/device-nodes.c
index 7eb9c351b6..158ab738e8 100644
--- a/src/basic/device-nodes.c
+++ b/src/basic/device-nodes.c
@@ -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)
diff --git a/src/basic/env-file.c b/src/basic/env-file.c
index 11362d8556..a300909360 100644
--- a/src/basic/env-file.c
+++ b/src/basic/env-file.c
@@ -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);
diff --git a/src/basic/escape.c b/src/basic/escape.c
index 31f3cda472..af785ecfa4 100644
--- a/src/basic/escape.c
+++ b/src/basic/escape.c
@@ -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]);
diff --git a/src/basic/extract-word.c b/src/basic/extract-word.c
index 4104dac9a7..4e4e7e8ce9 100644
--- a/src/basic/extract-word.c
+++ b/src/basic/extract-word.c
@@ -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);
diff --git a/src/basic/format-util.c b/src/basic/format-util.c
index 04ed4be941..9920604f3a 100644
--- a/src/basic/format-util.c
+++ b/src/basic/format-util.c
@@ -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;
diff --git a/src/basic/hexdecoct.c b/src/basic/hexdecoct.c
index da60202e57..cb0104670f 100644
--- a/src/basic/hexdecoct.c
+++ b/src/basic/hexdecoct.c
@@ -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
diff --git a/src/basic/io-util.h b/src/basic/io-util.h
index 0cd26d4c2c..d98817f760 100644
--- a/src/basic/io-util.h
+++ b/src/basic/io-util.h
@@ -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);
diff --git a/src/basic/prioq.h b/src/basic/prioq.h
index 951576c021..7c76647611 100644
--- a/src/basic/prioq.h
+++ b/src/basic/prioq.h
@@ -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);
diff --git a/src/basic/string-util.c b/src/basic/string-util.c
index 7f7122c1f1..c369f59ee1 100644
--- a/src/basic/string-util.c
+++ b/src/basic/string-util.c
@@ -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)
diff --git a/src/basic/terminal-util.c b/src/basic/terminal-util.c
index 3617a04d3b..1a3f9ccb33 100644
--- a/src/basic/terminal-util.c
+++ b/src/basic/terminal-util.c
@@ -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)
diff --git a/src/basic/user-util.c b/src/basic/user-util.c
index 933a398e73..1fad342cef 100644
--- a/src/basic/user-util.c
+++ b/src/basic/user-util.c
@@ -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;
diff --git a/src/basic/utf8.c b/src/basic/utf8.c
index d61692d07f..46c3a463b9 100644
--- a/src/basic/utf8.c
+++ b/src/basic/utf8.c
@@ -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);
diff --git a/src/basic/utf8.h b/src/basic/utf8.h
index a6ea942c62..219ca89184 100644
--- a/src/basic/utf8.h
+++ b/src/basic/utf8.h
@@ -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);
diff --git a/src/basic/xattr-util.c b/src/basic/xattr-util.c
index b9a0dc54c5..c175ce1fbc 100644
--- a/src/basic/xattr-util.c
+++ b/src/basic/xattr-util.c
@@ -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;
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 9964dda1fc..04cc7664e5 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -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);
diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c
index c8421e1ee7..cbc24bc251 100644
--- a/src/busctl/busctl.c
+++ b/src/busctl/busctl.c
@@ -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");
}
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 29817224ad..5424f2c90f 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -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) {
diff --git a/src/core/dbus-execute.c b/src/core/dbus-execute.c
index f474a02b0e..b664bbffa6 100644
--- a/src/core/dbus-execute.c
+++ b/src/core/dbus-execute.c
@@ -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;
diff --git a/src/core/dbus-unit.c b/src/core/dbus-unit.c
index 859e35eee4..39d6799b59 100644
--- a/src/core/dbus-unit.c
+++ b/src/core/dbus-unit.c
@@ -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;
diff --git a/src/core/execute.c b/src/core/execute.c
index 0214cee65e..158172bd26 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -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;
}
}
diff --git a/src/core/load-fragment.c b/src/core/load-fragment.c
index c27814ad38..f9c334cc65 100644
--- a/src/core/load-fragment.c
+++ b/src/core/load-fragment.c
@@ -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);
diff --git a/src/core/main.c b/src/core/main.c
index af5a1f426d..0ddd629851 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -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);
diff --git a/src/core/manager.c b/src/core/manager.c
index d8f80a5536..629966ea60 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -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--;
}
diff --git a/src/core/socket.c b/src/core/socket.c
index 6255e704ce..2aba8bff1c 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -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
diff --git a/src/coredump/coredump-vacuum.c b/src/coredump/coredump-vacuum.c
index d20df847e8..95c3fca661 100644
--- a/src/coredump/coredump-vacuum.c
+++ b/src/coredump/coredump-vacuum.c
@@ -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% */
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index c727cddba4..72e859a565 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -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[] = {
diff --git a/src/coredump/test-coredump-vacuum.c b/src/coredump/test-coredump-vacuum.c
index ac212ea23b..840884d961 100644
--- a/src/coredump/test-coredump-vacuum.c
+++ b/src/coredump/test-coredump-vacuum.c
@@ -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;
diff --git a/src/cryptenroll/cryptenroll-tpm2.c b/src/cryptenroll/cryptenroll-tpm2.c
index b58f3a2e7f..9c1478c474 100644
--- a/src/cryptenroll/cryptenroll-tpm2.c
+++ b/src/cryptenroll/cryptenroll-tpm2.c
@@ -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.");
diff --git a/src/cryptsetup/cryptsetup-fido2.c b/src/cryptsetup/cryptsetup-fido2.c
index 623a52fa0b..dfdb964360 100644
--- a/src/cryptsetup/cryptsetup-fido2.c
+++ b/src/cryptsetup/cryptsetup-fido2.c
@@ -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.");
diff --git a/src/cryptsetup/cryptsetup-pkcs11.c b/src/cryptsetup/cryptsetup-pkcs11.c
index a005b62caf..8d7d74fb75 100644
--- a/src/cryptsetup/cryptsetup-pkcs11.c
+++ b/src/cryptsetup/cryptsetup-pkcs11.c
@@ -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.");
diff --git a/src/cryptsetup/cryptsetup-tpm2.c b/src/cryptsetup/cryptsetup-tpm2.c
index c22f63d973..4757c5882d 100644
--- a/src/cryptsetup/cryptsetup-tpm2.c
+++ b/src/cryptsetup/cryptsetup-tpm2.c
@@ -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.");
diff --git a/src/cryptsetup/cryptsetup.c b/src/cryptsetup/cryptsetup.c
index 00de920d09..dba26a54a3 100644
--- a/src/cryptsetup/cryptsetup.c
+++ b/src/cryptsetup/cryptsetup.c
@@ -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");
diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c
index 85102d3efa..b9adbb6f7f 100644
--- a/src/dissect/dissect.c
+++ b/src/dissect/dissect.c
@@ -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);
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index c0e88e7915..feb682792d 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -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)
diff --git a/src/import/export-raw.c b/src/import/export-raw.c
index 3e0348f4c1..d42c56172f 100644
--- a/src/import/export-raw.c
+++ b/src/import/export-raw.c
@@ -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 },
};
diff --git a/src/import/export-tar.c b/src/import/export-tar.c
index 1e6b2c1268..b734c3004a 100644
--- a/src/import/export-tar.c
+++ b/src/import/export-tar.c
@@ -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;
diff --git a/src/import/import-raw.c b/src/import/import-raw.c
index 4eb59fbb25..0e7757b6f0 100644
--- a/src/import/import-raw.c
+++ b/src/import/import-raw.c
@@ -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 },
};
diff --git a/src/import/import-tar.c b/src/import/import-tar.c
index e94474389d..7c4e5127a9 100644
--- a/src/import/import-tar.c
+++ b/src/import/import-tar.c
@@ -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 },
};
diff --git a/src/import/importd.c b/src/import/importd.c
index f9e8481a6d..fa8ff68a46 100644
--- a/src/import/importd.c
+++ b/src/import/importd.c
@@ -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;
diff --git a/src/import/pull-job.c b/src/import/pull-job.c
index 908546b968..33512cd77a 100644
--- a/src/import/pull-job.c
+++ b/src/import/pull-job.c
@@ -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 */
diff --git a/src/import/pull-raw.c b/src/import/pull-raw.c
index c9bda3c3b4..9b5d8ef9e3 100644
--- a/src/import/pull-raw.c
+++ b/src/import/pull-raw.c
@@ -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");
diff --git a/src/journal-remote/journal-remote-main.c b/src/journal-remote/journal-remote-main.c
index 3e84c3dd7b..ae1d43756a 100644
--- a/src/journal-remote/journal-remote-main.c
+++ b/src/journal-remote/journal-remote-main.c
@@ -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");
diff --git a/src/journal-remote/journal-remote-write.c b/src/journal-remote/journal-remote-write.c
index 764a3ec70b..ea7162318e 100644
--- a/src/journal-remote/journal-remote-write.c
+++ b/src/journal-remote/journal-remote-write.c
@@ -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);
diff --git a/src/journal-remote/journal-remote.c b/src/journal-remote/journal-remote.c
index 0cee844452..6f71248aaf 100644
--- a/src/journal-remote/journal-remote.c
+++ b/src/journal-remote/journal-remote.c
@@ -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);
diff --git a/src/journal-remote/journal-upload-journal.c b/src/journal-remote/journal-upload-journal.c
index 3296c2268e..f23d5cf8b9 100644
--- a/src/journal-remote/journal-upload-journal.c
+++ b/src/journal-remote/journal-upload-journal.c
@@ -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.");
diff --git a/src/journal/fuzz-journald-stream.c b/src/journal/fuzz-journald-stream.c
index 038b335cb3..8a979df3ce 100644
--- a/src/journal/fuzz-journald-stream.c
+++ b/src/journal/fuzz-journald-stream.c
@@ -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);
diff --git a/src/journal/journald-context.c b/src/journal/journald-context.c
index 58151aa03d..add0a5480d 100644
--- a/src/journal/journald-context.c
+++ b/src/journal/journald-context.c
@@ -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;
diff --git a/src/journal/journald-native.c b/src/journal/journald-native.c
index 1c5849ed55..102814a403 100644
--- a/src/journal/journald-native.c
+++ b/src/journal/journald-native.c
@@ -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;
diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c
index 4234ab2e61..e76c13a3b6 100644
--- a/src/journal/journald-server.c
+++ b/src/journal/journald-server.c
@@ -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");
diff --git a/src/journal/test-journal-config.c b/src/journal/test-journal-config.c
index 4f29e1b310..bd0de9600a 100644
--- a/src/journal/test-journal-config.c
+++ b/src/journal/test-journal-config.c
@@ -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[]) {
diff --git a/src/libsystemd-network/fuzz-dhcp6-client.c b/src/libsystemd-network/fuzz-dhcp6-client.c
index e5e70dd606..acb8d9b98c 100644
--- a/src/libsystemd-network/fuzz-dhcp6-client.c
+++ b/src/libsystemd-network/fuzz-dhcp6-client.c
@@ -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);
diff --git a/src/libsystemd-network/fuzz-ndisc-rs.c b/src/libsystemd-network/fuzz-ndisc-rs.c
index d74cd2fffc..20350d449c 100644
--- a/src/libsystemd-network/fuzz-ndisc-rs.c
+++ b/src/libsystemd-network/fuzz-ndisc-rs.c
@@ -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]);
diff --git a/src/libsystemd-network/lldp-network.c b/src/libsystemd-network/lldp-network.c
index 9616cb6250..43141b2d79 100644
--- a/src/libsystemd-network/lldp-network.c
+++ b/src/libsystemd-network/lldp-network.c
@@ -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 = {
diff --git a/src/libsystemd-network/sd-dhcp-client.c b/src/libsystemd-network/sd-dhcp-client.c
index dd9cbf6ea5..fb94fdc882 100644
--- a/src/libsystemd-network/sd-dhcp-client.c
+++ b/src/libsystemd-network/sd-dhcp-client.c
@@ -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. */
diff --git a/src/libsystemd-network/sd-dhcp-lease.c b/src/libsystemd-network/sd-dhcp-lease.c
index 9fcbe17006..6d88c88e6b 100644
--- a/src/libsystemd-network/sd-dhcp-lease.c
+++ b/src/libsystemd-network/sd-dhcp-lease.c
@@ -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;
diff --git a/src/libsystemd-network/sd-lldp.c b/src/libsystemd-network/sd-lldp.c
index d3848ebf91..3c0285df4e 100644
--- a/src/libsystemd-network/sd-lldp.c
+++ b/src/libsystemd-network/sd-lldp.c
@@ -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);
diff --git a/src/libsystemd-network/test-dhcp-client.c b/src/libsystemd-network/test-dhcp-client.c
index d39d1f57a0..b464d3d700 100644
--- a/src/libsystemd-network/test-dhcp-client.c
+++ b/src/libsystemd-network/test-dhcp-client.c
@@ -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);
diff --git a/src/libsystemd-network/test-ipv4ll.c b/src/libsystemd-network/test-ipv4ll.c
index 49e1d590be..768595969b 100644
--- a/src/libsystemd-network/test-ipv4ll.c
+++ b/src/libsystemd-network/test-ipv4ll.c
@@ -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);
}
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 943877f0ea..d96b7256a1 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -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)
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index 7ee6e7012f..d5d22b0d8c 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -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
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 894d681260..fba1dbbd7d 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -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)
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
index 4881fd0d32..832526cc1b 100644
--- a/src/libsystemd/sd-bus/bus-socket.c
+++ b/src/libsystemd/sd-bus/bus-socket.c
@@ -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;
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index 9d1ef93716..e719c74370 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -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;
}
diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c
index a1d7ba173f..ba367677cf 100644
--- a/src/libsystemd/sd-bus/test-bus-chat.c
+++ b/src/libsystemd/sd-bus/test-bus-chat.c
@@ -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;
diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c
index 5ef3f30c70..a71add4342 100644
--- a/src/libsystemd/sd-bus/test-bus-objects.c
+++ b/src/libsystemd/sd-bus/test-bus-objects.c
@@ -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;
diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c
index e7a14716bc..ab4045ee15 100644
--- a/src/libsystemd/sd-bus/test-bus-server.c
+++ b/src/libsystemd/sd-bus/test-bus-server.c
@@ -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;
diff --git a/src/libsystemd/sd-device/device-private.c b/src/libsystemd/sd-device/device-private.c
index b14f43aae5..7a7204b145 100644
--- a/src/libsystemd/sd-device/device-private.c
+++ b/src/libsystemd/sd-device/device-private.c
@@ -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)
diff --git a/src/libsystemd/sd-device/sd-device.c b/src/libsystemd/sd-device/sd-device.c
index 1ef7f4d69c..964ef1318e 100644
--- a/src/libsystemd/sd-device/sd-device.c
+++ b/src/libsystemd/sd-device/sd-device.c
@@ -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,
};
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index 17ac659ec5..8ab9d419af 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -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;
}
diff --git a/src/libsystemd/sd-event/test-event.c b/src/libsystemd/sd-event/test-event.c
index 851418c960..082b23af70 100644
--- a/src/libsystemd/sd-event/test-event.c
+++ b/src/libsystemd/sd-event/test-event.c
@@ -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 */
diff --git a/src/libsystemd/sd-journal/compress.c b/src/libsystemd/sd-journal/compress.c
index 3ea3328c1e..bdcf47a25b 100644
--- a/src/libsystemd/sd-journal/compress.c
+++ b/src/libsystemd/sd-journal/compress.c
@@ -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;
diff --git a/src/libsystemd/sd-journal/journal-file.c b/src/libsystemd/sd-journal/journal-file.c
index 0bb9133e0c..f8bb708e58 100644
--- a/src/libsystemd/sd-journal/journal-file.c
+++ b/src/libsystemd/sd-journal/journal-file.c
@@ -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,
diff --git a/src/libsystemd/sd-journal/sd-journal.c b/src/libsystemd/sd-journal/sd-journal.c
index aabbfd90e5..be92f803c9 100644
--- a/src/libsystemd/sd-journal/sd-journal.c
+++ b/src/libsystemd/sd-journal/sd-journal.c
@@ -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;
}
diff --git a/src/libsystemd/sd-journal/test-journal-interleaving.c b/src/libsystemd/sd-journal/test-journal-interleaving.c
index 8c78c3bbf0..62db2266c7 100644
--- a/src/libsystemd/sd-journal/test-journal-interleaving.c
+++ b/src/libsystemd/sd-journal/test-journal-interleaving.c
@@ -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));
diff --git a/src/libsystemd/sd-journal/test-journal-stream.c b/src/libsystemd/sd-journal/test-journal-stream.c
index a121859e08..ca1eaaebfc 100644
--- a/src/libsystemd/sd-journal/test-journal-stream.c
+++ b/src/libsystemd/sd-journal/test-journal-stream.c
@@ -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;
diff --git a/src/libsystemd/sd-journal/test-journal-verify.c b/src/libsystemd/sd-journal/test-journal-verify.c
index d208e4650c..e9abfef0fc 100644
--- a/src/libsystemd/sd-journal/test-journal-verify.c
+++ b/src/libsystemd/sd-journal/test-journal-verify.c
@@ -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);
diff --git a/src/libsystemd/sd-journal/test-journal.c b/src/libsystemd/sd-journal/test-journal.c
index f8f08b5afc..fd3c4d9950 100644
--- a/src/libsystemd/sd-journal/test-journal.c
+++ b/src/libsystemd/sd-journal/test-journal.c
@@ -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));
diff --git a/src/libsystemd/sd-login/sd-login.c b/src/libsystemd/sd-login/sd-login.c
index d15dafbd95..a3da2e3f24 100644
--- a/src/libsystemd/sd-login/sd-login.c
+++ b/src/libsystemd/sd-login/sd-login.c
@@ -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;
}
diff --git a/src/libsystemd/sd-login/test-login.c b/src/libsystemd/sd-login/test-login.c
index d850323ba3..3fc394d5ee 100644
--- a/src/libsystemd/sd-login/test-login.c
+++ b/src/libsystemd/sd-login/test-login.c
@@ -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);
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
index 4ceb64cb23..f862d48253 100644
--- a/src/libsystemd/sd-netlink/sd-netlink.c
+++ b/src/libsystemd/sd-netlink/sd-netlink.c
@@ -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;
}
diff --git a/src/libsystemd/sd-network/sd-network.c b/src/libsystemd/sd-network/sd-network.c
index 060d84ae96..ccdfde9137 100644
--- a/src/libsystemd/sd-network/sd-network.c
+++ b/src/libsystemd/sd-network/sd-network.c
@@ -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;
}
diff --git a/src/libsystemd/sd-resolve/sd-resolve.c b/src/libsystemd/sd-resolve/sd-resolve.c
index 6dae398acb..ee973c0692 100644
--- a/src/libsystemd/sd-resolve/sd-resolve.c
+++ b/src/libsystemd/sd-resolve/sd-resolve.c
@@ -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;
}
diff --git a/src/login/logind-dbus.c b/src/login/logind-dbus.c
index d32ff8aa3b..a539a2e979 100644
--- a/src/login/logind-dbus.c
+++ b/src/login/logind-dbus.c
@@ -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);
diff --git a/src/login/logind.c b/src/login/logind.c
index 56235230cf..4887889fac 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -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;
}
diff --git a/src/login/pam_systemd.c b/src/login/pam_systemd.c
index a23200b3b5..2021c31bd5 100644
--- a/src/login/pam_systemd.c
+++ b/src/login/pam_systemd.c
@@ -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);
diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c
index 5a19dbfeff..5c3af06cac 100644
--- a/src/login/sysfs-show.c
+++ b/src/login/sysfs-show.c
@@ -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;
diff --git a/src/machine/machine-dbus.c b/src/machine/machine-dbus.c
index 7d6e1c7163..e7c4ed3c7c 100644
--- a/src/machine/machine-dbus.c
+++ b/src/machine/machine-dbus.c
@@ -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);
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 68d2a59e95..d7849973b8 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -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)
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index bb6a2bc576..0a6ae96bc6 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -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);
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 242b977f60..6f06e2218d 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -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;
}
diff --git a/src/network/networkd-link-bus.c b/src/network/networkd-link-bus.c
index a23c98110e..f57828b57d 100644
--- a/src/network/networkd-link-bus.c
+++ b/src/network/networkd-link-bus.c
@@ -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]);
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 9693e73351..6868a7ccb2 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -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);
diff --git a/src/network/networkd-sriov.c b/src/network/networkd-sriov.c
index d86de6799e..7a76b61c4a 100644
--- a/src/network/networkd-sriov.c
+++ b/src/network/networkd-sriov.c
@@ -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"))
diff --git a/src/network/networkd-state-file.c b/src/network/networkd-state-file.c
index 06670a7b8b..9c5c5047b3 100644
--- a/src/network/networkd-state-file.c
+++ b/src/network/networkd-state-file.c
@@ -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);
diff --git a/src/notify/notify.c b/src/notify/notify.c
index 1309d8f4e0..40cbc296bd 100644
--- a/src/notify/notify.c
+++ b/src/notify/notify.c
@@ -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)
diff --git a/src/nspawn/nspawn-oci.c b/src/nspawn/nspawn-oci.c
index 826981c3f7..1db69b4512 100644
--- a/src/nspawn/nspawn-oci.c
+++ b/src/nspawn/nspawn-oci.c
@@ -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;
diff --git a/src/nspawn/nspawn-settings.c b/src/nspawn/nspawn-settings.c
index 74a00c5275..d4619bead5 100644
--- a/src/nspawn/nspawn-settings.c
+++ b/src/nspawn/nspawn-settings.c
@@ -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) {
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c
index 1d9f1ddc55..a4ac8ed2bb 100644
--- a/src/nspawn/nspawn.c
+++ b/src/nspawn/nspawn.c
@@ -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);
}
diff --git a/src/oom/oomctl.c b/src/oom/oomctl.c
index 7fcb4b82cc..0d215cf6e9 100644
--- a/src/oom/oomctl.c
+++ b/src/oom/oomctl.c
@@ -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[]) {
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 22ad337e63..be16f5a067 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -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;
}
diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c
index 7c8e08e332..77fcd4fe6f 100644
--- a/src/portable/portablectl.c
+++ b/src/portable/portablectl.c
@@ -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)
diff --git a/src/portable/portabled-bus.c b/src/portable/portabled-bus.c
index 8de8bfc247..6d0dee99c3 100644
--- a/src/portable/portabled-bus.c
+++ b/src/portable/portabled-bus.c
@@ -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);
diff --git a/src/resolve/resolved-dns-cache.c b/src/resolve/resolved-dns-cache.c
index 395f983deb..0bf320df88 100644
--- a/src/resolve/resolved-dns-cache.c
+++ b/src/resolve/resolved-dns-cache.c
@@ -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,
diff --git a/src/resolve/resolved-dns-dnssec.c b/src/resolve/resolved-dns-dnssec.c
index 2f5776b5ed..4b12e48352 100644
--- a/src/resolve/resolved-dns-dnssec.c
+++ b/src/resolve/resolved-dns-dnssec.c
@@ -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)
diff --git a/src/resolve/resolved-dns-packet.c b/src/resolve/resolved-dns-packet.c
index 9778f5ee6b..abc978ab83 100644
--- a/src/resolve/resolved-dns-packet.c
+++ b/src/resolve/resolved-dns-packet.c
@@ -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);
diff --git a/src/resolve/resolved-dns-rr.c b/src/resolve/resolved-dns-rr.c
index 9b94ab59ea..823117e5c9 100644
--- a/src/resolve/resolved-dns-rr.c
+++ b/src/resolve/resolved-dns-rr.c
@@ -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)
diff --git a/src/resolve/resolved-dns-rr.h b/src/resolve/resolved-dns-rr.h
index d3edcadf67..ab48ea5f2a 100644
--- a/src/resolve/resolved-dns-rr.h
+++ b/src/resolve/resolved-dns-rr.h
@@ -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, \
diff --git a/src/resolve/resolved-dns-transaction.c b/src/resolve/resolved-dns-transaction.c
index 07c6eca3ba..6eac7e9c57 100644
--- a/src/resolve/resolved-dns-transaction.c
+++ b/src/resolve/resolved-dns-transaction.c
@@ -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),
diff --git a/src/resolve/resolved-mdns.c b/src/resolve/resolved-mdns.c
index e3a46f4ca1..bfd71575d6 100644
--- a/src/resolve/resolved-mdns.c
+++ b/src/resolve/resolved-mdns.c
@@ -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));
diff --git a/src/shared/ask-password-api.c b/src/shared/ask-password-api.c
index 7137eb3130..9aad834ee2 100644
--- a/src/shared/ask-password-api.c
+++ b/src/shared/ask-password-api.c
@@ -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);
diff --git a/src/shared/bitmap.c b/src/shared/bitmap.c
index 33528388f0..dcf67fbbd8 100644
--- a/src/shared/bitmap.c
+++ b/src/shared/bitmap.c
@@ -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))
diff --git a/src/shared/bus-get-properties.c b/src/shared/bus-get-properties.c
index a5ce7ef17f..feb6d3807f 100644
--- a/src/shared/bus-get-properties.c
+++ b/src/shared/bus-get-properties.c
@@ -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);
}
diff --git a/src/shared/bus-print-properties.c b/src/shared/bus-print-properties.c
index 4cea25073d..2a712be733 100644
--- a/src/shared/bus-print-properties.c
+++ b/src/shared/bus-print-properties.c
@@ -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);
diff --git a/src/shared/bus-unit-util.c b/src/shared/bus-unit-util.c
index 9ed5378791..a75178068b 100644
--- a/src/shared/bus-unit-util.c
+++ b/src/shared/bus-unit-util.c
@@ -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);
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 58211ebd03..64ca67993c 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -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;
diff --git a/src/shared/bus-wait-for-jobs.c b/src/shared/bus-wait-for-jobs.c
index 80f7785323..51b71ecc2c 100644
--- a/src/shared/bus-wait-for-jobs.c
+++ b/src/shared/bus-wait-for-jobs.c
@@ -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;
}
diff --git a/src/shared/bus-wait-for-units.c b/src/shared/bus-wait-for-units.c
index 4f1c505bd3..29620e0d1b 100644
--- a/src/shared/bus-wait-for-units.c
+++ b/src/shared/bus-wait-for-units.c
@@ -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;
}
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index a47009c3c1..997b265259 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -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);
diff --git a/src/shared/format-table.c b/src/shared/format-table.c
index c4a1b0f48f..fdb5887a1a 100644
--- a/src/shared/format-table.c
+++ b/src/shared/format-table.c
@@ -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);
diff --git a/src/shared/format-table.h b/src/shared/format-table.h
index 1a486bf5be..02a85ee94b 100644
--- a/src/shared/format-table.h
+++ b/src/shared/format-table.h
@@ -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);
diff --git a/src/shared/json.c b/src/shared/json.c
index d391eb01cc..ef1e937645 100644
--- a/src/shared/json.c
+++ b/src/shared/json.c
@@ -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] = {
diff --git a/src/shared/json.h b/src/shared/json.h
index d14740db88..148701a54f 100644
--- a/src/shared/json.h
+++ b/src/shared/json.h
@@ -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);
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index a217c1e081..7c61c334e9 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -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 */
diff --git a/src/shared/nsflags.h b/src/shared/nsflags.h
index 7c4c271d7d..8d194bf1b7 100644
--- a/src/shared/nsflags.h
+++ b/src/shared/nsflags.h
@@ -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);
diff --git a/src/shared/pager.c b/src/shared/pager.c
index d140c371c2..4bbad7e37b 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -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);
diff --git a/src/shared/ptyfwd.c b/src/shared/ptyfwd.c
index 754b4f5a94..4c309f925f 100644
--- a/src/shared/ptyfwd.c
+++ b/src/shared/ptyfwd.c
@@ -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) {
diff --git a/src/shared/udev-util.c b/src/shared/udev-util.c
index 9d732dca2c..06aede9d36 100644
--- a/src/shared/udev-util.c
+++ b/src/shared/udev-util.c
@@ -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;
diff --git a/src/shared/user-record.c b/src/shared/user-record.c
index b470a2f37c..bc35edd729 100644
--- a/src/shared/user-record.c
+++ b/src/shared/user-record.c
@@ -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) {
diff --git a/src/shared/verbs.h b/src/shared/verbs.h
index 245bb37ae4..03819e38cd 100644
--- a/src/shared/verbs.h
+++ b/src/shared/verbs.h
@@ -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 */
diff --git a/src/systemctl/systemctl-show.c b/src/systemctl/systemctl-show.c
index 6410a41944..c3c81f03fb 100644
--- a/src/systemctl/systemctl-show.c
+++ b/src/systemctl/systemctl-show.c
@@ -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,
};
diff --git a/src/systemd/sd-lldp.h b/src/systemd/sd-lldp.h
index d1d520afbd..66e4075b5c 100644
--- a/src/systemd/sd-lldp.h
+++ b/src/systemd/sd-lldp.h
@@ -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) \
diff --git a/src/systemd/sd-resolve.h b/src/systemd/sd-resolve.h
index ee58d18137..530bfd516e 100644
--- a/src/systemd/sd-resolve.h
+++ b/src/systemd/sd-resolve.h
@@ -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);
diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c
index 4e231be856..aad044d418 100644
--- a/src/sysusers/sysusers.c
+++ b/src/sysusers/sysusers.c
@@ -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);
diff --git a/src/test/test-bitmap.c b/src/test/test-bitmap.c
index 9c5d551d27..42922a3500 100644
--- a/src/test/test-bitmap.c
+++ b/src/test/test-bitmap.c
@@ -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;
diff --git a/src/test/test-calendarspec.c b/src/test/test-calendarspec.c
index e0b7f22808..01ec7f8770 100644
--- a/src/test/test-calendarspec.c
+++ b/src/test/test-calendarspec.c
@@ -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);
diff --git a/src/test/test-copy.c b/src/test/test-copy.c
index 211b4a4925..43118202b8 100644
--- a/src/test/test-copy.c
+++ b/src/test/test-copy.c
@@ -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 */
diff --git a/src/test/test-fileio.c b/src/test/test-fileio.c
index a5834eba36..659b690082 100644
--- a/src/test/test-fileio.c
+++ b/src/test/test-fileio.c
@@ -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 */
}
}
diff --git a/src/test/test-format-table.c b/src/test/test-format-table.c
index b2943e6fc1..44d92a719d 100644
--- a/src/test/test-format-table.c
+++ b/src/test/test-format-table.c
@@ -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);
diff --git a/src/test/test-fs-util.c b/src/test/test-fs-util.c
index 8d6984d04c..c42c48722f 100644
--- a/src/test/test-fs-util.c
+++ b/src/test/test-fs-util.c
@@ -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);
diff --git a/src/test/test-hexdecoct.c b/src/test/test-hexdecoct.c
index f0f9679769..c9d318b8d1 100644
--- a/src/test/test-hexdecoct.c
+++ b/src/test/test-hexdecoct.c
@@ -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));
diff --git a/src/test/test-prioq.c b/src/test/test-prioq.c
index 4bfa18195e..de902ca427 100644
--- a/src/test/test-prioq.c
+++ b/src/test/test-prioq.c
@@ -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));
diff --git a/src/test/test-utf8.c b/src/test/test-utf8.c
index c7b6d8dd53..042b94634b 100644
--- a/src/test/test-utf8.c
+++ b/src/test/test-utf8.c
@@ -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) {