1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-08 21:17:47 +03:00

tree-wide: use UINT64_MAX or friends

This commit is contained in:
Yu Watanabe 2021-03-03 13:07:10 +09:00
parent ef1e0b9a46
commit f5fbe71d95
150 changed files with 530 additions and 528 deletions

View File

@ -1357,7 +1357,7 @@ static int dump(int argc, char *argv[], void *userdata) {
return bus_log_parse_error(r); return bus_log_parse_error(r);
fflush(stdout); 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) { static int cat_config(int argc, char *argv[], void *userdata) {

View File

@ -5,7 +5,7 @@
#include <stdint.h> #include <stdint.h>
#include <sys/types.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_session_from_pid(pid_t pid, uint32_t *id);
int audit_loginuid_from_pid(pid_t pid, uid_t *uid); int audit_loginuid_from_pid(pid_t pid, uid_t *uid);

View File

@ -396,18 +396,18 @@ static bool btrfs_ioctl_search_args_inc(struct btrfs_ioctl_search_args *args) {
* comparing. This call increases the counter by one, dealing * comparing. This call increases the counter by one, dealing
* with the overflow between the overflows */ * 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++; args->key.min_offset++;
return true; return true;
} }
if (args->key.min_type < (uint8_t) -1) { if (args->key.min_type < UINT8_MAX) {
args->key.min_type++; args->key.min_type++;
args->key.min_offset = 0; args->key.min_offset = 0;
return true; return true;
} }
if (args->key.min_objectid < (uint64_t) -1) { if (args->key.min_objectid < UINT64_MAX) {
args->key.min_objectid++; args->key.min_objectid++;
args->key.min_offset = 0; args->key.min_offset = 0;
args->key.min_type = 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.max_type = BTRFS_ROOT_ITEM_KEY,
.key.min_offset = 0, .key.min_offset = 0,
.key.max_offset = (uint64_t) -1, .key.max_offset = UINT64_MAX,
/* No restrictions on the other components */ /* No restrictions on the other components */
.key.min_transid = 0, .key.min_transid = 0,
.key.max_transid = (uint64_t) -1, .key.max_transid = UINT64_MAX,
}; };
bool found = false; 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 */ /* No restrictions on the other components */
.key.min_transid = 0, .key.min_transid = 0,
.key.max_transid = (uint64_t) -1, .key.max_transid = UINT64_MAX,
}; };
bool found_info = false, found_limit = false; 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) if (le64toh(qli->flags) & BTRFS_QGROUP_LIMIT_MAX_RFER)
ret->referenced_max = le64toh(qli->max_rfer); ret->referenced_max = le64toh(qli->max_rfer);
else else
ret->referenced_max = (uint64_t) -1; ret->referenced_max = UINT64_MAX;
if (le64toh(qli->flags) & BTRFS_QGROUP_LIMIT_MAX_EXCL) if (le64toh(qli->flags) & BTRFS_QGROUP_LIMIT_MAX_EXCL)
ret->exclusive_max = le64toh(qli->max_excl); ret->exclusive_max = le64toh(qli->max_excl);
else else
ret->exclusive_max = (uint64_t) -1; ret->exclusive_max = UINT64_MAX;
found_limit = true; found_limit = true;
} }
@ -648,13 +648,13 @@ finish:
return -ENODATA; return -ENODATA;
if (!found_info) { if (!found_info) {
ret->referenced = (uint64_t) -1; ret->referenced = UINT64_MAX;
ret->exclusive = (uint64_t) -1; ret->exclusive = UINT64_MAX;
} }
if (!found_limit) { if (!found_limit) {
ret->referenced_max = (uint64_t) -1; ret->referenced_max = UINT64_MAX;
ret->exclusive_max = (uint64_t) -1; ret->exclusive_max = UINT64_MAX;
} }
return 0; 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) { 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; _cleanup_free_ uint64_t *qgroups = NULL;
int r, n; 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) if (id != subvol_id)
continue; continue;
if (lowest == (uint64_t) -1 || level < lowest) { if (lowest == UINT64_MAX || level < lowest) {
lowest_qgroupid = qgroups[i]; lowest_qgroupid = qgroups[i];
lowest = level; lowest = level;
} }
} }
if (lowest == (uint64_t) -1) { if (lowest == UINT64_MAX) {
/* No suitable higher-level qgroup found, let's return /* No suitable higher-level qgroup found, let's return
* the leaf qgroup instead, and indicate that with the * the leaf qgroup instead, and indicate that with the
* return value. */ * 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.max_type = BTRFS_ROOT_BACKREF_KEY,
.key.min_transid = 0, .key.min_transid = 0,
.key.max_transid = (uint64_t) -1, .key.max_transid = UINT64_MAX,
}; };
struct btrfs_ioctl_vol_args vol_args = {}; 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 */ /* No restrictions on the other components */
.key.min_transid = 0, .key.min_transid = 0,
.key.max_transid = (uint64_t) -1, .key.max_transid = UINT64_MAX,
}; };
int r; int r;
@ -1451,7 +1451,7 @@ static int subvol_snapshot_children(
.key.max_type = BTRFS_ROOT_BACKREF_KEY, .key.max_type = BTRFS_ROOT_BACKREF_KEY,
.key.min_transid = 0, .key.min_transid = 0,
.key.max_transid = (uint64_t) -1, .key.max_transid = UINT64_MAX,
}; };
struct btrfs_ioctl_vol_args_v2 vol_args = { 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 */ /* No restrictions on the other components */
.key.min_offset = 0, .key.min_offset = 0,
.key.max_offset = (uint64_t) -1, .key.max_offset = UINT64_MAX,
.key.min_transid = 0, .key.min_transid = 0,
.key.max_transid = (uint64_t) -1, .key.max_transid = UINT64_MAX,
}; };
_cleanup_free_ uint64_t *items = NULL; _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 */ /* No restrictions on the other components */
.key.min_offset = 0, .key.min_offset = 0,
.key.max_offset = (uint64_t) -1, .key.max_offset = UINT64_MAX,
.key.min_transid = 0, .key.min_transid = 0,
.key.max_transid = (uint64_t) -1, .key.max_transid = UINT64_MAX,
}; };
int r; int r;

View File

@ -405,7 +405,7 @@ bool capability_quintet_mangle(CapabilityQuintet *q) {
combined = q->effective | q->bounding | q->inheritable | q->permitted; 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) if (ambient_supported)
combined |= q->ambient; combined |= q->ambient;
@ -437,7 +437,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
_cleanup_cap_free_ cap_t c = NULL, modified = NULL; _cleanup_cap_free_ cap_t c = NULL, modified = NULL;
int r; int r;
if (q->ambient != (uint64_t) -1) { if (q->ambient != UINT64_MAX) {
bool changed = false; bool changed = false;
c = cap_get_proc(); c = cap_get_proc();
@ -479,7 +479,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
return r; 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; bool changed = false;
if (!c) { if (!c) {
@ -492,7 +492,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
uint64_t m = UINT64_C(1) << i; uint64_t m = UINT64_C(1) << i;
cap_value_t cv = (cap_value_t) 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; cap_flag_value_t old_value, new_value;
if (cap_get_flag(c, cv, CAP_INHERITABLE, &old_value) < 0) { 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; cap_flag_value_t old_value, new_value;
if (cap_get_flag(c, cv, CAP_PERMITTED, &old_value) < 0) { 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; cap_flag_value_t old_value, new_value;
if (cap_get_flag(c, cv, CAP_EFFECTIVE, &old_value) < 0) { if (cap_get_flag(c, cv, CAP_EFFECTIVE, &old_value) < 0) {
@ -559,7 +559,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
if (changed) { if (changed) {
/* In order to change the bounding caps, we need to keep CAP_SETPCAP for a bit /* 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. */ * 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; cap_value_t cv = CAP_SETPCAP;
modified = cap_dup(c); 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); r = capability_bounding_set_drop(q->bounding, false);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -10,7 +10,7 @@
#include "missing_capability.h" #include "missing_capability.h"
#include "util.h" #include "util.h"
#define CAP_ALL (uint64_t) -1 #define CAP_ALL UINT64_MAX
unsigned cap_last_cap(void); unsigned cap_last_cap(void);
int have_effective_cap(int value); int have_effective_cap(int value);
@ -49,7 +49,7 @@ bool ambient_capabilities_supported(void);
#define CAP_TO_MASK_CORRECTED(x) (1U << ((x) & 31U)) #define CAP_TO_MASK_CORRECTED(x) (1U << ((x) & 31U))
typedef struct CapabilityQuintet { 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. */ * needs to be updated as soon as Linux learns more than 63 caps. */
uint64_t effective; uint64_t effective;
uint64_t bounding; uint64_t bounding;
@ -60,14 +60,14 @@ typedef struct CapabilityQuintet {
assert_cc(CAP_LAST_CAP < 64); 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) { static inline bool capability_quintet_is_set(const CapabilityQuintet *q) {
return q->effective != (uint64_t) -1 || return q->effective != UINT64_MAX ||
q->bounding != (uint64_t) -1 || q->bounding != UINT64_MAX ||
q->inheritable != (uint64_t) -1 || q->inheritable != UINT64_MAX ||
q->permitted != (uint64_t) -1 || q->permitted != UINT64_MAX ||
q->ambient != (uint64_t) -1; q->ambient != UINT64_MAX;
} }
/* Mangles the specified caps quintet taking the current bounding set into account: /* Mangles the specified caps quintet taking the current bounding set into account:

View File

@ -1975,7 +1975,7 @@ int cg_kernel_controllers(Set **ret) {
return r; return r;
/* Ignore the header line */ /* Ignore the header line */
(void) read_line(f, (size_t) -1, NULL); (void) read_line(f, SIZE_MAX, NULL);
for (;;) { for (;;) {
char *controller; char *controller;

View File

@ -75,13 +75,13 @@ CGroupMask get_cpu_accounting_mask(void);
bool cpu_accounting_is_cheap(void); bool cpu_accounting_is_cheap(void);
/* Special values for all weight knobs on unified hierarchy */ /* 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_MIN UINT64_C(1)
#define CGROUP_WEIGHT_MAX UINT64_C(10000) #define CGROUP_WEIGHT_MAX UINT64_C(10000)
#define CGROUP_WEIGHT_DEFAULT UINT64_C(100) #define CGROUP_WEIGHT_DEFAULT UINT64_C(100)
#define CGROUP_LIMIT_MIN UINT64_C(0) #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) { static inline bool CGROUP_WEIGHT_IS_OK(uint64_t x) {
return 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_; CGroupIOLimitType cgroup_io_limit_type_from_string(const char *s) _pure_;
/* Special values for the cpu.shares attribute */ /* 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_MIN UINT64_C(2)
#define CGROUP_CPU_SHARES_MAX UINT64_C(262144) #define CGROUP_CPU_SHARES_MAX UINT64_C(262144)
#define CGROUP_CPU_SHARES_DEFAULT UINT64_C(1024) #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 */ /* 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_MIN UINT64_C(10)
#define CGROUP_BLKIO_WEIGHT_MAX UINT64_C(1000) #define CGROUP_BLKIO_WEIGHT_MAX UINT64_C(1000)
#define CGROUP_BLKIO_WEIGHT_DEFAULT UINT64_C(500) #define CGROUP_BLKIO_WEIGHT_DEFAULT UINT64_C(500)

View File

@ -361,7 +361,7 @@ int copy_bytes_full(
return r; return r;
} }
if (max_bytes != (uint64_t) -1) { if (max_bytes != UINT64_MAX) {
assert(max_bytes >= (uint64_t) n); assert(max_bytes >= (uint64_t) n);
max_bytes -= n; max_bytes -= n;
} }
@ -642,7 +642,7 @@ static int fd_copy_regular(
if (fdt < 0) if (fdt < 0)
return -errno; 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) { if (r < 0) {
(void) unlinkat(dt, to, 0); (void) unlinkat(dt, to, 0);
return r; return r;
@ -1051,7 +1051,7 @@ int copy_file_fd_full(
if (fdf < 0) if (fdf < 0)
return -errno; 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_times(fdf, fdt, copy_flags);
(void) copy_xattr(fdf, fdt); (void) copy_xattr(fdf, fdt);
@ -1081,7 +1081,7 @@ int copy_file_full(
if (fdf < 0) if (fdf < 0)
return -errno; return -errno;
if (mode == (mode_t) -1) if (mode == MODE_INVALID)
if (fstat(fdf, &st) < 0) if (fstat(fdf, &st) < 0)
return -errno; return -errno;
@ -1092,7 +1092,7 @@ int copy_file_full(
return r; return r;
} }
fdt = open(to, flags|O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY, 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) if (copy_flags & COPY_MAC_CREATE)
mac_selinux_create_file_clear(); mac_selinux_create_file_clear();
if (fdt < 0) if (fdt < 0)
@ -1102,7 +1102,7 @@ int copy_file_full(
if (chattr_mask != 0) if (chattr_mask != 0)
(void) chattr_fd(fdt, chattr_flags, chattr_mask & CHATTR_EARLY_FL, NULL); (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) { if (r < 0) {
close(fdt); close(fdt);
(void) unlink(to); (void) unlink(to);

View File

@ -28,7 +28,7 @@ int encode_devnode_name(const char *str, char *str_enc, size_t len) {
for (i = 0, j = 0; str[i] != '\0'; i++) { for (i = 0, j = 0; str[i] != '\0'; i++) {
int seqlen; 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 (seqlen > 1) {
if (len-j < (size_t)seqlen) if (len-j < (size_t)seqlen)

View File

@ -20,7 +20,7 @@ static int parse_env_file_internal(
void *userdata, void *userdata,
int *n_pushed) { 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; _cleanup_free_ char *contents = NULL, *key = NULL, *value = NULL;
unsigned line = 1; unsigned line = 1;
char *p; char *p;
@ -56,7 +56,7 @@ static int parse_env_file_internal(
state = COMMENT; state = COMMENT;
else if (!strchr(WHITESPACE, c)) { else if (!strchr(WHITESPACE, c)) {
state = KEY; state = KEY;
last_key_whitespace = (size_t) -1; last_key_whitespace = SIZE_MAX;
if (!GREEDY_REALLOC(key, key_alloc, n_key+2)) if (!GREEDY_REALLOC(key, key_alloc, n_key+2))
return -ENOMEM; return -ENOMEM;
@ -72,11 +72,11 @@ static int parse_env_file_internal(
n_key = 0; n_key = 0;
} else if (c == '=') { } else if (c == '=') {
state = PRE_VALUE; state = PRE_VALUE;
last_value_whitespace = (size_t) -1; last_value_whitespace = SIZE_MAX;
} else { } else {
if (!strchr(WHITESPACE, c)) if (!strchr(WHITESPACE, c))
last_key_whitespace = (size_t) -1; last_key_whitespace = SIZE_MAX;
else if (last_key_whitespace == (size_t) -1) else if (last_key_whitespace == SIZE_MAX)
last_key_whitespace = n_key; last_key_whitespace = n_key;
if (!GREEDY_REALLOC(key, key_alloc, n_key+2)) if (!GREEDY_REALLOC(key, key_alloc, n_key+2))
@ -97,7 +97,7 @@ static int parse_env_file_internal(
value[n_value] = 0; value[n_value] = 0;
/* strip trailing whitespace from key */ /* strip trailing whitespace from key */
if (last_key_whitespace != (size_t) -1) if (last_key_whitespace != SIZE_MAX)
key[last_key_whitespace] = 0; key[last_key_whitespace] = 0;
r = push(fname, line, key, value, userdata, n_pushed); r = push(fname, line, key, value, userdata, n_pushed);
@ -136,11 +136,11 @@ static int parse_env_file_internal(
value[n_value] = 0; value[n_value] = 0;
/* Chomp off trailing whitespace from value */ /* Chomp off trailing whitespace from value */
if (last_value_whitespace != (size_t) -1) if (last_value_whitespace != SIZE_MAX)
value[last_value_whitespace] = 0; value[last_value_whitespace] = 0;
/* strip trailing whitespace from key */ /* strip trailing whitespace from key */
if (last_key_whitespace != (size_t) -1) if (last_key_whitespace != SIZE_MAX)
key[last_key_whitespace] = 0; key[last_key_whitespace] = 0;
r = push(fname, line, key, value, userdata, n_pushed); r = push(fname, line, key, value, userdata, n_pushed);
@ -153,11 +153,11 @@ static int parse_env_file_internal(
} else if (c == '\\') { } else if (c == '\\') {
state = VALUE_ESCAPE; state = VALUE_ESCAPE;
last_value_whitespace = (size_t) -1; last_value_whitespace = SIZE_MAX;
} else { } else {
if (!strchr(WHITESPACE, c)) if (!strchr(WHITESPACE, c))
last_value_whitespace = (size_t) -1; last_value_whitespace = SIZE_MAX;
else if (last_value_whitespace == (size_t) -1) else if (last_value_whitespace == SIZE_MAX)
last_value_whitespace = n_value; last_value_whitespace = n_value;
if (!GREEDY_REALLOC(value, value_alloc, n_value+2)) if (!GREEDY_REALLOC(value, value_alloc, n_value+2))
@ -255,11 +255,11 @@ static int parse_env_file_internal(
value[n_value] = 0; value[n_value] = 0;
if (state == VALUE) if (state == VALUE)
if (last_value_whitespace != (size_t) -1) if (last_value_whitespace != SIZE_MAX)
value[last_value_whitespace] = 0; value[last_value_whitespace] = 0;
/* strip trailing whitespace from key */ /* strip trailing whitespace from key */
if (last_key_whitespace != (size_t) -1) if (last_key_whitespace != SIZE_MAX)
key[last_key_whitespace] = 0; key[last_key_whitespace] = 0;
r = push(fname, line, key, value, userdata, n_pushed); r = push(fname, line, key, value, userdata, n_pushed);

View File

@ -114,7 +114,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
* instead be copied directly. * instead be copied directly.
*/ */
if (length != (size_t) -1 && length < 1) if (length != SIZE_MAX && length < 1)
return -EINVAL; return -EINVAL;
switch (p[0]) { switch (p[0]) {
@ -159,7 +159,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
/* hexadecimal encoding */ /* hexadecimal encoding */
int a, b; int a, b;
if (length != (size_t) -1 && length < 3) if (length != SIZE_MAX && length < 3)
return -EINVAL; return -EINVAL;
a = unhexchar(p[1]); 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; size_t i;
uint32_t c; uint32_t c;
if (length != (size_t) -1 && length < 5) if (length != SIZE_MAX && length < 5)
return -EINVAL; return -EINVAL;
for (i = 0; i < 4; i++) { 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; size_t i;
char32_t c; char32_t c;
if (length != (size_t) -1 && length < 9) if (length != SIZE_MAX && length < 9)
return -EINVAL; return -EINVAL;
for (i = 0; i < 8; i++) { 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; int a, b, c;
char32_t m; char32_t m;
if (length != (size_t) -1 && length < 3) if (length != SIZE_MAX && length < 3)
return -EINVAL; return -EINVAL;
a = unoctchar(p[0]); a = unoctchar(p[0]);

View File

@ -91,7 +91,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
char32_t u; char32_t u;
if ((flags & EXTRACT_CUNESCAPE) && 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 */ /* A valid escaped sequence */
assert(r >= 1); assert(r >= 1);

View File

@ -47,7 +47,7 @@ char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) {
assert_cc(ELEMENTSOF(table_iec) == ELEMENTSOF(table_si)); assert_cc(ELEMENTSOF(table_iec) == ELEMENTSOF(table_si));
if (t == (uint64_t) -1) if (t == UINT64_MAX)
return NULL; return NULL;
table = flag & FORMAT_BYTES_USE_IEC ? table_iec : table_si; table = flag & FORMAT_BYTES_USE_IEC ? table_iec : table_si;

View File

@ -119,7 +119,7 @@ int unhexmem_full(const char *p, size_t l, bool secure, void **ret, size_t *ret_
assert(ret_len); assert(ret_len);
assert(p || l == 0); assert(p || l == 0);
if (l == (size_t) -1) if (l == SIZE_MAX)
l = strlen(p); l = strlen(p);
/* Note that the calculation of memory size is an upper boundary, as we ignore whitespace while decoding */ /* 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(mem);
assert(_len); assert(_len);
if (l == (size_t) -1) if (l == SIZE_MAX)
l = strlen(p); l = strlen(p);
/* padding ensures any base32hex input has input divisible by 8 */ /* 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);
assert(ret_size); assert(ret_size);
if (l == (size_t) -1) if (l == SIZE_MAX)
l = strlen(p); 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 /* A group of four input bytes needs three output bytes, in case of padding we need to add two or three extra

View File

@ -62,7 +62,7 @@ static inline bool FILE_SIZE_VALID_OR_INFINITY(uint64_t l) {
/* Same as above, but allows one extra value: -1 as indication for infinity. */ /* 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 true;
return FILE_SIZE_VALID(l); return FILE_SIZE_VALID(l);

View File

@ -8,7 +8,7 @@
typedef struct Prioq Prioq; 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_new(compare_func_t compare);
Prioq *prioq_free(Prioq *q); Prioq *prioq_free(Prioq *q);

View File

@ -71,7 +71,7 @@ char *strnappend(const char *s, const char *suffix, size_t b) {
assert(suffix); assert(suffix);
a = strlen(s); a = strlen(s);
if (b > ((size_t) -1) - a) if (b > (SIZE_MAX) - a)
return NULL; return NULL;
r = new(char, a+b+1); 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(s);
assert(percent <= 100); assert(percent <= 100);
assert(new_length != (size_t) -1); assert(new_length != SIZE_MAX);
if (old_length <= new_length) if (old_length <= new_length)
return strndup(s, old_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(s);
assert(percent <= 100); assert(percent <= 100);
if (new_length == (size_t) -1) if (new_length == SIZE_MAX)
return strndup(s, old_length); return strndup(s, old_length);
if (new_length == 0) if (new_length == 0)

View File

@ -41,6 +41,7 @@
#include "strv.h" #include "strv.h"
#include "terminal-util.h" #include "terminal-util.h"
#include "time-util.h" #include "time-util.h"
#include "user-util.h"
#include "util.h" #include "util.h"
static volatile unsigned cached_columns = 0; static volatile unsigned cached_columns = 0;
@ -1341,7 +1342,7 @@ int vt_restore(int fd) {
q = -errno; 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) { if (r < 0) {
log_debug_errno(r, "Failed to chmod()/chown() VT, ignoring: %m"); log_debug_errno(r, "Failed to chmod()/chown() VT, ignoring: %m");
if (q >= 0) if (q >= 0)

View File

@ -882,7 +882,7 @@ char *mangle_gecos(const char *d) {
continue; continue;
} }
len = utf8_encoded_valid_unichar(i, (size_t) -1); len = utf8_encoded_valid_unichar(i, SIZE_MAX);
if (len < 0) { if (len < 0) {
*i = ' '; *i = ' ';
continue; continue;

View File

@ -156,14 +156,14 @@ char *utf8_is_valid_n(const char *str, size_t len_bytes) {
assert(str); 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; int len;
if (_unlikely_(*p == '\0') && len_bytes != (size_t) -1) if (_unlikely_(*p == '\0') && len_bytes != SIZE_MAX)
return NULL; /* embedded NUL */ return NULL; /* embedded NUL */
len = utf8_encoded_valid_unichar(p, 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)) if (_unlikely_(len < 0))
return NULL; /* invalid character */ return NULL; /* invalid character */
@ -185,7 +185,7 @@ char *utf8_escape_invalid(const char *str) {
while (*str) { while (*str) {
int len; int len;
len = utf8_encoded_valid_unichar(str, (size_t) -1); len = utf8_encoded_valid_unichar(str, SIZE_MAX);
if (len > 0) { if (len > 0) {
s = mempcpy(s, str, len); s = mempcpy(s, str, len);
str += len; str += len;
@ -233,7 +233,7 @@ char *utf8_escape_non_printable_full(const char *str, size_t console_width) {
if (!*str) /* done! */ if (!*str) /* done! */
goto finish; goto finish;
len = utf8_encoded_valid_unichar(str, (size_t) -1); len = utf8_encoded_valid_unichar(str, SIZE_MAX);
if (len > 0) { if (len > 0) {
if (utf8_is_printable(str, len)) { if (utf8_is_printable(str, len)) {
int w; int w;
@ -508,7 +508,7 @@ int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
assert(str); assert(str);
assert(length > 0); 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]); len = utf8_encoded_expected_len(str[0]);
if (len == 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 utf8_n_codepoints(const char *str) {
size_t n = 0; 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) { while (*str != 0) {
int k; int k;
k = utf8_encoded_valid_unichar(str, (size_t) -1); k = utf8_encoded_valid_unichar(str, SIZE_MAX);
if (k < 0) if (k < 0)
return (size_t) -1; return SIZE_MAX;
str += k; str += k;
n++; n++;
@ -572,7 +572,7 @@ size_t utf8_console_width(const char *str) {
w = utf8_char_console_width(str); w = utf8_char_console_width(str);
if (w < 0) if (w < 0)
return (size_t) -1; return SIZE_MAX;
n += w; n += w;
str = utf8_next_char(str); str = utf8_next_char(str);

View File

@ -16,7 +16,7 @@ bool unichar_is_valid(char32_t c);
char *utf8_is_valid_n(const char *str, size_t len_bytes) _pure_; char *utf8_is_valid_n(const char *str, size_t len_bytes) _pure_;
static inline char *utf8_is_valid(const char *s) { 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(const char *s) _pure_;
char *ascii_is_valid_n(const char *str, size_t len); 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_invalid(const char *s);
char *utf8_escape_non_printable_full(const char *str, size_t console_width); char *utf8_escape_non_printable_full(const char *str, size_t console_width);
static inline char *utf8_escape_non_printable(const char *str) { 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); size_t utf8_encode_unichar(char *out_utf8, char32_t g);

View File

@ -147,7 +147,7 @@ static int parse_crtime(le64_t le, usec_t *usec) {
assert(usec); assert(usec);
u = le64toh(le); u = le64toh(le);
if (IN_SET(u, 0, (uint64_t) -1)) if (IN_SET(u, 0, UINT64_MAX))
return -EIO; return -EIO;
*usec = (usec_t) u; *usec = (usec_t) u;

View File

@ -541,7 +541,7 @@ static int copy_file_with_version_check(const char *from, const char *to, bool f
return log_error_errno(errno, "Failed to open \"%s\" for writing: %m", t); 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) { if (r < 0) {
(void) unlink(t); (void) unlink(t);
return log_error_errno(r, "Failed to copy data from \"%s\" to \"%s\": %m", from, t); return log_error_errno(r, "Failed to copy data from \"%s\" to \"%s\": %m", from, t);

View File

@ -1328,7 +1328,7 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f
if (r > 0) if (r > 0)
continue; continue;
r = sd_bus_wait(bus, (uint64_t) -1); r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to wait for bus: %m"); return log_error_errno(r, "Failed to wait for bus: %m");
} }

View File

@ -56,7 +56,7 @@ typedef struct Group {
} Group; } Group;
static unsigned arg_depth = 3; 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_batch = false;
static bool arg_raw = false; static bool arg_raw = false;
static usec_t arg_delay = 1*USEC_PER_SEC; 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); signal(SIGWINCH, columns_lines_cache_reset);
if (arg_iterations == (unsigned) -1) if (arg_iterations == UINT_MAX)
arg_iterations = on_tty() ? 0 : 1; arg_iterations = on_tty() ? 0 : 1;
while (!quit) { while (!quit) {

View File

@ -3309,7 +3309,7 @@ int bus_exec_context_set_transient_property(
if (r < 0) if (r < 0)
return r; return r;
if (rl == (uint64_t) -1) if (rl == UINT64_MAX)
x = RLIM_INFINITY; x = RLIM_INFINITY;
else { else {
x = (rlim_t) rl; x = (rlim_t) rl;

View File

@ -1069,7 +1069,7 @@ static int property_get_current_memory(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
uint64_t sz = (uint64_t) -1; uint64_t sz = UINT64_MAX;
Unit *u = userdata; Unit *u = userdata;
int r; int r;
@ -1093,7 +1093,7 @@ static int property_get_current_tasks(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
uint64_t cn = (uint64_t) -1; uint64_t cn = UINT64_MAX;
Unit *u = userdata; Unit *u = userdata;
int r; int r;
@ -1117,7 +1117,7 @@ static int property_get_cpu_usage(
void *userdata, void *userdata,
sd_bus_error *error) { sd_bus_error *error) {
nsec_t ns = (nsec_t) -1; nsec_t ns = NSEC_INFINITY;
Unit *u = userdata; Unit *u = userdata;
int r; int r;

View File

@ -2508,7 +2508,7 @@ static int write_credential(
* user can no longer chmod() the file to gain write access. */ * user can no longer chmod() the file to gain write access. */
return r; return r;
if (fchown(fd, uid, (gid_t) -1) < 0) if (fchown(fd, uid, GID_INVALID) < 0)
return -errno; return -errno;
} }
} }
@ -2626,7 +2626,7 @@ static int acquire_credentials(
if (!ownership_ok) if (!ownership_ok)
return r; return r;
if (fchown(dfd, uid, (gid_t) -1) < 0) if (fchown(dfd, uid, GID_INVALID) < 0)
return -errno; return -errno;
} }
} }

View File

@ -1094,7 +1094,7 @@ int config_parse_exec_input_data(
return 0; return 0;
} }
r = unbase64mem(rvalue, (size_t) -1, &p, &sz); r = unbase64mem(rvalue, SIZE_MAX, &p, &sz);
if (r < 0) { if (r < 0) {
log_syntax(unit, LOG_WARNING, filename, line, r, log_syntax(unit, LOG_WARNING, filename, line, r,
"Failed to decode base64 data, ignoring: %s", rvalue); "Failed to decode base64 data, ignoring: %s", rvalue);

View File

@ -544,7 +544,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
if (proc_cmdline_value_missing(key, value)) if (proc_cmdline_value_missing(key, value))
return 0; return 0;
r = unbase64mem(value, (size_t) -1, &p, &sz); r = unbase64mem(value, SIZE_MAX, &p, &sz);
if (r < 0) if (r < 0)
log_warning_errno(r, "Failed to parse systemd.random_seed= argument, ignoring: %s", value); log_warning_errno(r, "Failed to parse systemd.random_seed= argument, ignoring: %s", value);

View File

@ -2200,7 +2200,7 @@ static unsigned manager_dispatch_dbus_queue(Manager *m) {
/* When we are reloading, let's not wait with generating signals, since we need to exit the manager as quickly /* 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. */ * 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) 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 { else {
/* Anything to do at all? */ /* Anything to do at all? */
if (!m->dbus_unit_queue && !m->dbus_job_queue) 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); bus_unit_send_change_signal(u);
n++; n++;
if (budget != (unsigned) -1) if (budget != UINT_MAX)
budget--; budget--;
} }
@ -2242,7 +2242,7 @@ static unsigned manager_dispatch_dbus_queue(Manager *m) {
bus_job_send_change_signal(j); bus_job_send_change_signal(j);
n++; n++;
if (budget != (unsigned) -1) if (budget != UINT_MAX)
budget--; budget--;
} }

View File

@ -99,7 +99,7 @@ static void socket_init(Unit *u) {
s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID; s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID;
s->trigger_limit.interval = USEC_INFINITY; 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) { 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) if (s->trigger_limit.interval == USEC_INFINITY)
s->trigger_limit.interval = 2 * USEC_PER_SEC; 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) if (s->accept)
s->trigger_limit.burst = 200; s->trigger_limit.burst = 200;
else else

View File

@ -66,7 +66,7 @@ static int uid_from_file_name(const char *filename, uid_t *uid) {
} }
static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t max_use) { 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; struct statvfs sv;
assert(fd >= 0); 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; fs_free = sv.f_frsize * sv.f_bfree;
} }
if (max_use == (uint64_t) -1) { if (max_use == UINT64_MAX) {
if (fs_size > 0) { if (fs_size > 0) {
max_use = PAGE_ALIGN(fs_size / 10); /* 10% */ 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) if (max_use > 0 && sum > max_use)
return true; return true;
if (keep_free == (uint64_t) -1) { if (keep_free == UINT64_MAX) {
if (fs_size > 0) { if (fs_size > 0) {
keep_free = PAGE_ALIGN((fs_size * 3) / 20); /* 15% */ keep_free = PAGE_ALIGN((fs_size * 3) / 20); /* 15% */

View File

@ -141,8 +141,8 @@ static bool arg_compress = true;
static uint64_t arg_process_size_max = PROCESS_SIZE_MAX; static uint64_t arg_process_size_max = PROCESS_SIZE_MAX;
static uint64_t arg_external_size_max = EXTERNAL_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_journal_size_max = JOURNAL_SIZE_MAX;
static uint64_t arg_keep_free = (uint64_t) -1; static uint64_t arg_keep_free = UINT64_MAX;
static uint64_t arg_max_use = (uint64_t) -1; static uint64_t arg_max_use = UINT64_MAX;
static int parse_config(void) { static int parse_config(void) {
static const ConfigTableItem items[] = { static const ConfigTableItem items[] = {

View File

@ -6,7 +6,7 @@
int main(int argc, char *argv[]) { 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_FAILURE;
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -42,7 +42,7 @@ static int search_policy_hash(
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"TPM2 token data lacks 'tpm2-policy-hash' field."); "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) if (r < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Invalid base64 data in 'tpm2-policy-hash' field."); "Invalid base64 data in 'tpm2-policy-hash' field.");

View File

@ -138,7 +138,7 @@ int find_fido2_auto_data(
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"FIDO2 token data lacks 'fido2-credential' field."); "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) if (r < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Invalid base64 data in 'fido2-credential' field."); "Invalid base64 data in 'fido2-credential' field.");
@ -150,7 +150,7 @@ int find_fido2_auto_data(
assert(!salt); assert(!salt);
assert(salt_size == 0); 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) if (r < 0)
return log_error_errno(r, "Failed to decode base64 encoded salt."); return log_error_errno(r, "Failed to decode base64 encoded salt.");

View File

@ -214,7 +214,7 @@ int find_pkcs11_auto_data(
assert(!key); assert(!key);
assert(key_size == 0); 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) if (r < 0)
return log_error_errno(r, "Failed to decode base64 encoded key."); return log_error_errno(r, "Failed to decode base64 encoded key.");

View File

@ -125,7 +125,7 @@ int find_tpm2_auto_data(
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"TPM2 token data lacks 'tpm2-blob' field."); "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) if (r < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Invalid base64 data in 'tpm2-blob' field."); "Invalid base64 data in 'tpm2-blob' field.");
@ -136,7 +136,7 @@ int find_tpm2_auto_data(
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"TPM2 token data lacks 'tpm2-policy-hash' field."); "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) if (r < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"Invalid base64 data in 'tpm2-policy-hash' field."); "Invalid base64 data in 'tpm2-policy-hash' field.");

View File

@ -320,7 +320,7 @@ static int parse_one_option(const char *option) {
_cleanup_free_ void *cid = NULL; _cleanup_free_ void *cid = NULL;
size_t cid_size; size_t cid_size;
r = unbase64mem(val, (size_t) -1, &cid, &cid_size); r = unbase64mem(val, SIZE_MAX, &cid, &cid_size);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to decode FIDO2 CID data: %m"); return log_error_errno(r, "Failed to decode FIDO2 CID data: %m");

View File

@ -627,7 +627,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
/* Copying to stdout? */ /* Copying to stdout? */
if (streq(arg_target, "-")) { 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) if (r < 0)
return log_error_errno(r, "Failed to copy bytes from %s in mage '%s' to stdout: %m", arg_source, arg_image); 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) if (target_fd < 0)
return log_error_errno(errno, "Failed to create regular file at target path '%s': %m", arg_target); 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) 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); 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) if (target_fd < 0)
return log_error_errno(errno, "Failed to open target file '%s': %m", arg_target); 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) if (r < 0)
return log_error_errno(r, "Failed to copy bytes from stdin to '%s' in image '%s': %m", arg_target, arg_image); 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) if (target_fd < 0)
return log_error_errno(errno, "Failed to open target file '%s': %m", arg_target); 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) 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); return log_error_errno(r, "Failed to copy bytes from '%s' to '%s' in image '%s': %m", arg_source, arg_target, arg_image);

View File

@ -771,7 +771,7 @@ static int write_root_shadow(const char *shadow_path, const char *hashed_passwor
.sp_warn = -1, .sp_warn = -1,
.sp_inact = -1, .sp_inact = -1,
.sp_expire = -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) if (errno != ENOENT)

View File

@ -95,7 +95,7 @@ int raw_export_new(
.input_fd = -1, .input_fd = -1,
.on_finished = on_finished, .on_finished = on_finished,
.userdata = userdata, .userdata = userdata,
.last_percent = (unsigned) -1, .last_percent = UINT_MAX,
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 }, .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
}; };

View File

@ -97,8 +97,8 @@ int tar_export_new(
.tar_fd = -1, .tar_fd = -1,
.on_finished = on_finished, .on_finished = on_finished,
.userdata = userdata, .userdata = userdata,
.quota_referenced = (uint64_t) -1, .quota_referenced = UINT64_MAX,
.last_percent = (unsigned) -1, .last_percent = UINT_MAX,
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 }, .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
}; };
@ -120,7 +120,7 @@ static void tar_export_report_progress(TarExport *e) {
assert(e); assert(e);
/* Do we have any quota info? If not, we don't know anything about the progress */ /* 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; return;
if (e->written_uncompressed >= e->quota_referenced) 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) if (r < 0)
return r; return r;
e->quota_referenced = (uint64_t) -1; e->quota_referenced = UINT64_MAX;
if (btrfs_might_be_subvol(&e->st)) { if (btrfs_might_be_subvol(&e->st)) {
BtrfsQuotaInfo q; BtrfsQuotaInfo q;

View File

@ -104,7 +104,7 @@ int raw_import_new(
.output_fd = -1, .output_fd = -1,
.on_finished = on_finished, .on_finished = on_finished,
.userdata = userdata, .userdata = userdata,
.last_percent = (unsigned) -1, .last_percent = UINT_MAX,
.image_root = TAKE_PTR(root), .image_root = TAKE_PTR(root),
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 }, .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
}; };

View File

@ -113,7 +113,7 @@ int tar_import_new(
.tar_fd = -1, .tar_fd = -1,
.on_finished = on_finished, .on_finished = on_finished,
.userdata = userdata, .userdata = userdata,
.last_percent = (unsigned) -1, .last_percent = UINT_MAX,
.image_root = TAKE_PTR(root), .image_root = TAKE_PTR(root),
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 }, .progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
}; };

View File

@ -161,7 +161,7 @@ static int transfer_new(Manager *m, Transfer **ret) {
.stdin_fd = -1, .stdin_fd = -1,
.stdout_fd = -1, .stdout_fd = -1,
.verify = _IMPORT_VERIFY_INVALID, .verify = _IMPORT_VERIFY_INVALID,
.progress_percent= (unsigned) -1, .progress_percent= UINT_MAX,
}; };
id = m->current_transfer_id + 1; 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) { static double transfer_percent_as_double(Transfer *t) {
assert(t); assert(t);
if (t->progress_percent == (unsigned) -1) if (t->progress_percent == UINT_MAX)
return -DBL_MAX; return -DBL_MAX;
return (double) t->progress_percent / 100.0; return (double) t->progress_percent / 100.0;

View File

@ -176,7 +176,7 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
goto finish; goto finish;
} }
if (j->content_length != (uint64_t) -1 && if (j->content_length != UINT64_MAX &&
j->content_length != j->written_compressed) { j->content_length != j->written_compressed) {
log_error("Download truncated."); log_error("Download truncated.");
r = -EIO; 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) if (j->written_compressed + sz > j->compressed_max)
return log_error_errno(SYNTHETIC_ERRNO(EFBIG), "File overly large, refusing."); 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) j->written_compressed + sz > j->content_length)
return log_error_errno(SYNTHETIC_ERRNO(EFBIG), return log_error_errno(SYNTHETIC_ERRNO(EFBIG),
"Content length incorrect."); "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) { if (r > 0) {
(void) safe_atou64(length, &j->content_length); (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]; char bytes[FORMAT_BYTES_MAX];
if (j->content_length > j->compressed_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, .disk_fd = -1,
.userdata = userdata, .userdata = userdata,
.glue = glue, .glue = glue,
.content_length = (uint64_t) -1, .content_length = UINT64_MAX,
.start_usec = now(CLOCK_MONOTONIC), .start_usec = now(CLOCK_MONOTONIC),
.compressed_max = 64LLU * 1024LLU * 1024LLU * 1024LLU, /* 64GB safety limit */ .compressed_max = 64LLU * 1024LLU * 1024LLU * 1024LLU, /* 64GB safety limit */
.uncompressed_max = 64LLU * 1024LLU * 1024LLU * 1024LLU, /* 64GB safety limit */ .uncompressed_max = 64LLU * 1024LLU * 1024LLU * 1024LLU, /* 64GB safety limit */

View File

@ -364,7 +364,7 @@ static int raw_pull_make_local_copy(RawPull *i) {
* since it reduces fragmentation caused by not allowing in-place writes. */ * since it reduces fragmentation caused by not allowing in-place writes. */
(void) import_set_nocow_and_log(dfd, tp); (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) { if (r < 0) {
(void) unlink(tp); (void) unlink(tp);
return log_error_errno(r, "Failed to make writable copy of image: %m"); return log_error_errno(r, "Failed to make writable copy of image: %m");

View File

@ -471,7 +471,7 @@ static int setup_microhttpd_server(RemoteServer *s,
} }
r = sd_event_add_time(s->events, &d->timer_event, 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); null_timer_event_handler, d);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to add timer_event: %m"); log_error_errno(r, "Failed to add timer_event: %m");

View File

@ -4,7 +4,7 @@
#include "journal-remote.h" #include "journal-remote.h"
static int do_rotate(JournalFile **f, bool compress, bool seal) { 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 (r < 0) {
if (*f) if (*f)
log_error_errno(r, "Failed to rotate %s: %m", (*f)->path); log_error_errno(r, "Failed to rotate %s: %m", (*f)->path);

View File

@ -62,7 +62,7 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) {
r = journal_file_open_reliably(filename, r = journal_file_open_reliably(filename,
O_RDWR|O_CREAT, 0640, O_RDWR|O_CREAT, 0640,
s->compress, (uint64_t) -1, s->seal, s->compress, UINT64_MAX, s->seal,
&w->metrics, &w->metrics,
w->mmap, NULL, w->mmap, NULL,
NULL, &w->journal); NULL, &w->journal);

View File

@ -399,7 +399,7 @@ int open_journal_for_upload(Uploader *u,
return log_error_errno(r, "Failed to register input event: %m"); return log_error_errno(r, "Failed to register input event: %m");
log_debug("Listening for journal events on fd:%d, timeout %d", 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 } else
log_debug("Not listening for journal events."); log_debug("Not listening for journal events.");

View File

@ -27,7 +27,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
assert_se(stdout_stream_install(&s, stream_fds[0], &stream) >= 0); assert_se(stdout_stream_install(&s, stream_fds[0], &stream) >= 0);
assert_se(write(stream_fds[1], data, size) == (ssize_t) size); assert_se(write(stream_fds[1], data, size) == (ssize_t) size);
while (ioctl(stream_fds[0], SIOCINQ, &v) == 0 && v) 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) if (s.n_stdout_streams)
stdout_stream_destroy(stream); stdout_stream_destroy(stream);
server_done(&s); server_done(&s);

View File

@ -69,7 +69,7 @@
static size_t cache_max(void) { static size_t cache_max(void) {
static size_t cached = -1; static size_t cached = -1;
if (cached == (size_t) -1) { if (cached == SIZE_MAX) {
uint64_t mem_total; uint64_t mem_total;
int r; int r;

View File

@ -105,7 +105,7 @@ static int server_process_entry(
* *
* Note that *remaining is altered on both success and failure. */ * 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; char *identifier = NULL, *message = NULL;
struct iovec *iovec = NULL; struct iovec *iovec = NULL;
int priority = LOG_INFO; int priority = LOG_INFO;

View File

@ -2185,7 +2185,7 @@ int server_init(Server *s, const char *namespace) {
.notify_fd = -1, .notify_fd = -1,
.compress.enabled = true, .compress.enabled = true,
.compress.threshold_bytes = (uint64_t) -1, .compress.threshold_bytes = UINT64_MAX,
.seal = true, .seal = true,
.set_audit = true, .set_audit = true,
@ -2593,7 +2593,7 @@ int config_parse_compress(
if (isempty(rvalue)) { if (isempty(rvalue)) {
compress->enabled = true; compress->enabled = true;
compress->threshold_bytes = (uint64_t) -1; compress->threshold_bytes = UINT64_MAX;
} else if (streq(rvalue, "1")) { } else if (streq(rvalue, "1")) {
log_syntax(unit, LOG_WARNING, filename, line, 0, log_syntax(unit, LOG_WARNING, filename, line, 0,
"Compress= ambiguously specified as 1, enabling compression with default threshold"); "Compress= ambiguously specified as 1, enabling compression with default threshold");

View File

@ -43,7 +43,7 @@ static void test_config_compress(void) {
/* Invalid Case */ /* Invalid Case */
COMPRESS_PARSE_CHECK("-1", true, 111); COMPRESS_PARSE_CHECK("-1", true, 111);
COMPRESS_PARSE_CHECK("blah blah", 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[]) { int main(int argc, char *argv[]) {

View File

@ -41,7 +41,7 @@ static void fuzz_client(const uint8_t *data, size_t size, bool is_information_re
assert_se(write(test_dhcp_fd[1], data, size) == (ssize_t) size); 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); assert_se(sd_dhcp6_client_stop(client) >= 0);

View File

@ -53,7 +53,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0); assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
assert_se(sd_ndisc_start(nd) >= 0); assert_se(sd_ndisc_start(nd) >= 0);
assert_se(write(test_fd[1], data, size) == (ssize_t) size); 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); assert_se(sd_ndisc_stop(nd) >= 0);
close(test_fd[1]); close(test_fd[1]);

View File

@ -22,7 +22,7 @@ int lldp_network_bind_raw_socket(int ifindex) {
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, offsetof(struct ethhdr, h_proto)), /* A <- protocol */ BPF_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_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, 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 = { static const struct sock_fprog fprog = {

View File

@ -2229,7 +2229,7 @@ int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize) {
.mtu = DHCP_DEFAULT_MIN_SIZE, .mtu = DHCP_DEFAULT_MIN_SIZE,
.port = DHCP_PORT_CLIENT, .port = DHCP_PORT_CLIENT,
.anonymize = !!anonymize, .anonymize = !!anonymize,
.max_attempts = (uint64_t) -1, .max_attempts = UINT64_MAX,
.ip_service_type = -1, .ip_service_type = -1,
}; };
/* NOTE: this could be moved to a function. */ /* NOTE: this could be moved to a function. */

View File

@ -1257,13 +1257,13 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
} }
if (client_id_hex) { 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) if (r < 0)
log_debug_errno(r, "Failed to parse client ID %s, ignoring: %m", client_id_hex); log_debug_errno(r, "Failed to parse client ID %s, ignoring: %m", client_id_hex);
} }
if (vendor_specific_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) if (r < 0)
log_debug_errno(r, "Failed to parse vendor specific data %s, ignoring: %m", vendor_specific_hex); 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]) if (!options[i])
continue; continue;
r = unhexmem(options[i], (size_t) -1, &data, &len); r = unhexmem(options[i], SIZE_MAX, &data, &len);
if (r < 0) { if (r < 0) {
log_debug_errno(r, "Failed to parse private DHCP option %s, ignoring: %m", options[i]); log_debug_errno(r, "Failed to parse private DHCP option %s, ignoring: %m", options[i]);
continue; continue;

View File

@ -373,7 +373,7 @@ _public_ int sd_lldp_new(sd_lldp **ret) {
.n_ref = 1, .n_ref = 1,
.fd = -1, .fd = -1,
.neighbors_max = LLDP_DEFAULT_NEIGHBORS_MAX, .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); lldp->neighbor_by_id = hashmap_new(&lldp_neighbor_hash_ops);

View File

@ -308,7 +308,7 @@ static void test_discover_message(sd_event *e) {
assert_se(IN_SET(res, 0, -EINPROGRESS)); 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_stop(client);
sd_dhcp_client_unref(client); sd_dhcp_client_unref(client);

View File

@ -160,25 +160,25 @@ static void test_basic_request(sd_event *e) {
assert_se(sd_ipv4ll_set_ifindex(ll, 1) == 0); assert_se(sd_ipv4ll_set_ifindex(ll, 1) == 0);
assert_se(sd_ipv4ll_start(ll) == 1); 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_start(ll) == 0);
assert_se(sd_ipv4ll_is_running(ll)); assert_se(sd_ipv4ll_is_running(ll));
/* PROBE */ /* 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)); assert_se(recv(test_fd[1], &arp, sizeof(struct ether_arp), 0) == sizeof(struct ether_arp));
if (extended) { if (extended) {
/* PROBE */ /* 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)); assert_se(recv(test_fd[1], &arp, sizeof(struct ether_arp), 0) == sizeof(struct ether_arp));
/* PROBE */ /* 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)); 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); assert_se(basic_request_handler_bind == 1);
} }

View File

@ -741,7 +741,7 @@ _public_ int sd_bus_get_owner_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **r
mask &= ~SD_BUS_CREDS_AUGMENT; mask &= ~SD_BUS_CREDS_AUGMENT;
do_label = bus->label && (mask & SD_BUS_CREDS_SELINUX_CONTEXT); 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 */ /* Avoid allocating anything if we have no chance of returning useful data */
if (!bus->ucred_valid && !do_label && !do_groups) if (!bus->ucred_valid && !do_label && !do_groups)

View File

@ -81,7 +81,7 @@ _public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
m->header->version); m->header->version);
/* Display synthetic message serial number in a more readable /* Display synthetic message serial number in a more readable
* format than (uint32_t) -1 */ * format than UINT32_MAX */
if (BUS_MESSAGE_COOKIE(m) == 0xFFFFFFFFULL) if (BUS_MESSAGE_COOKIE(m) == 0xFFFFFFFFULL)
fprintf(f, " Cookie=-1"); fprintf(f, " Cookie=-1");
else else

View File

@ -162,7 +162,7 @@ static void *message_extend_fields(sd_bus_message *m, size_t align, size_t sz, b
new_size = start + sz; new_size = start + sz;
if (new_size < start || if (new_size < start ||
new_size > (size_t) ((uint32_t) -1)) new_size > (size_t) (UINT32_MAX))
goto poison; goto poison;
if (old_size == new_size) if (old_size == new_size)
@ -1337,7 +1337,7 @@ static void *message_extend_body(
added = padding + sz; added = padding + sz;
/* Check for 32bit overflows */ /* Check for 32bit overflows */
if (end_body > (size_t) ((uint32_t) -1) || if (end_body > (size_t) (UINT32_MAX) ||
end_body < start_body) { end_body < start_body) {
m->poisoned = true; m->poisoned = true;
return NULL; return NULL;
@ -2340,13 +2340,13 @@ _public_ int sd_bus_message_appendv(
assert_return(!m->sealed, -EPERM); assert_return(!m->sealed, -EPERM);
assert_return(!m->poisoned, -ESTALE); assert_return(!m->poisoned, -ESTALE);
n_array = (unsigned) -1; n_array = UINT_MAX;
n_struct = strlen(types); n_struct = strlen(types);
for (;;) { for (;;) {
const char *t; 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); r = type_stack_pop(stack, ELEMENTSOF(stack), &stack_ptr, &types, &n_struct, &n_array);
if (r < 0) if (r < 0)
return r; return r;
@ -2361,7 +2361,7 @@ _public_ int sd_bus_message_appendv(
} }
t = types; t = types;
if (n_array != (unsigned) -1) if (n_array != UINT_MAX)
n_array--; n_array--;
else { else {
types++; types++;
@ -2445,7 +2445,7 @@ _public_ int sd_bus_message_appendv(
return r; return r;
} }
if (n_array == (unsigned) -1) { if (n_array == UINT_MAX) {
types += k; types += k;
n_struct -= k; n_struct -= k;
} }
@ -2478,7 +2478,7 @@ _public_ int sd_bus_message_appendv(
types = s; types = s;
n_struct = strlen(s); n_struct = strlen(s);
n_array = (unsigned) -1; n_array = UINT_MAX;
break; break;
} }
@ -2502,7 +2502,7 @@ _public_ int sd_bus_message_appendv(
return r; return r;
} }
if (n_array == (unsigned) -1) { if (n_array == UINT_MAX) {
types += k - 1; types += k - 1;
n_struct -= k - 1; n_struct -= k - 1;
} }
@ -2513,7 +2513,7 @@ _public_ int sd_bus_message_appendv(
types = t + 1; types = t + 1;
n_struct = k - 2; n_struct = k - 2;
n_array = (unsigned) -1; n_array = UINT_MAX;
break; break;
} }
@ -2675,7 +2675,7 @@ _public_ int sd_bus_message_append_array_memfd(
if (r < 0) if (r < 0)
return r; return r;
if (offset == 0 && size == (uint64_t) -1) if (offset == 0 && size == UINT64_MAX)
size = real_size; size = real_size;
else if (offset + size > real_size) else if (offset + size > real_size)
return -EMSGSIZE; return -EMSGSIZE;
@ -2692,7 +2692,7 @@ _public_ int sd_bus_message_append_array_memfd(
if (size % sz != 0) if (size % sz != 0)
return -EINVAL; return -EINVAL;
if (size > (uint64_t) (uint32_t) -1) if (size > (uint64_t) UINT32_MAX)
return -EINVAL; return -EINVAL;
r = sd_bus_message_open_container(m, SD_BUS_TYPE_ARRAY, CHAR_TO_STR(type)); 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) if (r < 0)
return r; return r;
if (offset == 0 && size == (uint64_t) -1) if (offset == 0 && size == UINT64_MAX)
size = real_size; size = real_size;
else if (offset + size > real_size) else if (offset + size > real_size)
return -EMSGSIZE; return -EMSGSIZE;
@ -2759,7 +2759,7 @@ _public_ int sd_bus_message_append_string_memfd(
if (size == 0) if (size == 0)
return -EINVAL; return -EINVAL;
if (size > (uint64_t) (uint32_t) -1) if (size > (uint64_t) UINT32_MAX)
return -EINVAL; return -EINVAL;
c = message_get_last_container(m); 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 * in a single stackframe. We hence implement our own
* home-grown stack in an array. */ * 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 */ n_struct = strlen(types); /* length of current struct contents signature */
for (;;) { for (;;) {
@ -4438,7 +4438,7 @@ _public_ int sd_bus_message_readv(
n_loop++; 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); r = type_stack_pop(stack, ELEMENTSOF(stack), &stack_ptr, &types, &n_struct, &n_array);
if (r < 0) if (r < 0)
return r; return r;
@ -4453,7 +4453,7 @@ _public_ int sd_bus_message_readv(
} }
t = types; t = types;
if (n_array != (unsigned) -1) if (n_array != UINT_MAX)
n_array--; n_array--;
else { else {
types++; types++;
@ -4514,7 +4514,7 @@ _public_ int sd_bus_message_readv(
} }
} }
if (n_array == (unsigned) -1) { if (n_array == UINT_MAX) {
types += k; types += k;
n_struct -= k; n_struct -= k;
} }
@ -4553,7 +4553,7 @@ _public_ int sd_bus_message_readv(
types = s; types = s;
n_struct = strlen(s); n_struct = strlen(s);
n_array = (unsigned) -1; n_array = UINT_MAX;
break; break;
} }
@ -4581,7 +4581,7 @@ _public_ int sd_bus_message_readv(
} }
} }
if (n_array == (unsigned) -1) { if (n_array == UINT_MAX) {
types += k - 1; types += k - 1;
n_struct -= k - 1; n_struct -= k - 1;
} }
@ -4592,7 +4592,7 @@ _public_ int sd_bus_message_readv(
types = t + 1; types = t + 1;
n_struct = k - 2; n_struct = k - 2;
n_array = (unsigned) -1; n_array = UINT_MAX;
break; break;
} }
@ -5034,7 +5034,7 @@ static int message_skip_fields(
char t; char t;
size_t l; size_t l;
if (array_size != (uint32_t) -1 && if (array_size != UINT32_MAX &&
array_size <= *ri - original_index) array_size <= *ri - original_index)
return 0; return 0;
@ -5122,7 +5122,7 @@ static int message_skip_fields(
if (r < 0) if (r < 0)
return r; 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) if (r < 0)
return r; return r;
@ -5140,7 +5140,7 @@ static int message_skip_fields(
strncpy(sig, *signature + 1, l); strncpy(sig, *signature + 1, l);
sig[l] = '\0'; 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) if (r < 0)
return r; return r;
} }
@ -5247,7 +5247,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
_cleanup_free_ char *sig = NULL; _cleanup_free_ char *sig = NULL;
const char *signature; const char *signature;
uint64_t field_type; uint64_t field_type;
size_t item_size = (size_t) -1; size_t item_size = SIZE_MAX;
if (BUS_MESSAGE_IS_GVARIANT(m)) { if (BUS_MESSAGE_IS_GVARIANT(m)) {
uint64_t *u64; uint64_t *u64;
@ -5461,7 +5461,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
default: default:
if (!BUS_MESSAGE_IS_GVARIANT(m)) 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) if (r < 0)

View File

@ -620,7 +620,7 @@ static void bus_get_peercred(sd_bus *b) {
assert(b); assert(b);
assert(!b->ucred_valid); assert(!b->ucred_valid);
assert(!b->label); assert(!b->label);
assert(b->n_groups == (size_t) -1); assert(b->n_groups == SIZE_MAX);
/* Get the peer for socketpair() sockets */ /* Get the peer for socketpair() sockets */
b->ucred_valid = getpeercred(b->input_fd, &b->ucred) >= 0; b->ucred_valid = getpeercred(b->input_fd, &b->ucred) >= 0;

View File

@ -247,7 +247,7 @@ _public_ int sd_bus_new(sd_bus **ret) {
.creds_mask = SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME, .creds_mask = SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME,
.accept_fd = true, .accept_fd = true,
.original_pid = getpid_cached(), .original_pid = getpid_cached(),
.n_groups = (size_t) -1, .n_groups = SIZE_MAX,
.close_on_exit = true, .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 * hence let's fill something in for synthetic messages. Since
* synthetic messages might have a fake sender and we don't * synthetic messages might have a fake sender and we don't
* want to interfere with the real sender's serial numbers we * want to interfere with the real sender's serial numbers we
* pick a fixed, artificial one. We use (uint32_t) -1 rather * pick a fixed, artificial one. We use UINT32_MAX rather
* than (uint64_t) -1 since dbus1 only had 32bit identifiers, * than UINT64_MAX since dbus1 only had 32bit identifiers,
* even though kdbus can do 64bit. */ * even though kdbus can do 64bit. */
return sd_bus_message_seal(m, 0xFFFFFFFFULL, 0); return sd_bus_message_seal(m, 0xFFFFFFFFULL, 0);
} }
@ -2332,7 +2332,7 @@ int bus_ensure_running(sd_bus *bus) {
if (r > 0) if (r > 0)
continue; continue;
r = sd_bus_wait(bus, (uint64_t) -1); r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) if (r < 0)
return r; return r;
} }
@ -2460,7 +2460,7 @@ _public_ int sd_bus_call(
left = timeout - n; left = timeout - n;
} else } else
left = (uint64_t) -1; left = UINT64_MAX;
r = bus_poll(bus, true, left); r = bus_poll(bus, true, left);
if (r < 0) 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); c = prioq_peek(bus->reply_callbacks_prioq);
if (!c) { if (!c) {
*timeout_usec = (uint64_t) -1; *timeout_usec = UINT64_MAX;
return 0; return 0;
} }
if (c->timeout_usec == 0) { if (c->timeout_usec == 0) {
*timeout_usec = (uint64_t) -1; *timeout_usec = UINT64_MAX;
return 0; 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_WATCH_BIND:
case BUS_OPENING: case BUS_OPENING:
*timeout_usec = (uint64_t) -1; *timeout_usec = UINT64_MAX;
return 0; return 0;
default: 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; m = timeout_usec;
r = ppoll_usec(p, n, m); r = ppoll_usec(p, n, m);
@ -3376,7 +3376,7 @@ _public_ int sd_bus_flush(sd_bus *bus) {
if (bus->wqueue_size <= 0) if (bus->wqueue_size <= 0)
return 0; return 0;
r = bus_poll(bus, false, (uint64_t) -1); r = bus_poll(bus, false, UINT64_MAX);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -127,7 +127,7 @@ static int server(sd_bus *bus) {
} }
if (r == 0) { if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1); r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to wait: %m"); log_error_errno(r, "Failed to wait: %m");
goto fail; goto fail;
@ -472,7 +472,7 @@ static void* client2(void *p) {
goto finish; goto finish;
} }
if (r == 0) { if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1); r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to wait: %m"); log_error_errno(r, "Failed to wait: %m");
goto finish; goto finish;

View File

@ -255,7 +255,7 @@ static void *server(void *p) {
} }
if (r == 0) { if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1); r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to wait: %m"); log_error_errno(r, "Failed to wait: %m");
goto fail; goto fail;

View File

@ -47,7 +47,7 @@ static void *server(void *p) {
} }
if (r == 0) { if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1); r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) { if (r < 0) {
log_error_errno(r, "Failed to wait: %m"); log_error_errno(r, "Failed to wait: %m");
goto fail; goto fail;

View File

@ -98,7 +98,7 @@ int device_get_devnode_mode(sd_device *device, mode_t *mode) {
if (r < 0) if (r < 0)
return r; return r;
if (device->devmode == (mode_t) -1) if (device->devmode == MODE_INVALID)
return -ENOENT; return -ENOENT;
if (mode) if (mode)
@ -116,7 +116,7 @@ int device_get_devnode_uid(sd_device *device, uid_t *uid) {
if (r < 0) if (r < 0)
return r; return r;
if (device->devuid == (uid_t) -1) if (device->devuid == UID_INVALID)
return -ENOENT; return -ENOENT;
if (uid) if (uid)
@ -154,7 +154,7 @@ int device_get_devnode_gid(sd_device *device, gid_t *gid) {
if (r < 0) if (r < 0)
return r; return r;
if (device->devgid == (gid_t) -1) if (device->devgid == GID_INVALID)
return -ENOENT; return -ENOENT;
if (gid) if (gid)

View File

@ -26,6 +26,7 @@
#include "string-util.h" #include "string-util.h"
#include "strv.h" #include "strv.h"
#include "strxcpyx.h" #include "strxcpyx.h"
#include "user-util.h"
#include "util.h" #include "util.h"
int device_new_aux(sd_device **ret) { int device_new_aux(sd_device **ret) {
@ -40,9 +41,9 @@ int device_new_aux(sd_device **ret) {
*device = (sd_device) { *device = (sd_device) {
.n_ref = 1, .n_ref = 1,
.watch_handle = -1, .watch_handle = -1,
.devmode = (mode_t) -1, .devmode = MODE_INVALID,
.devuid = (uid_t) -1, .devuid = UID_INVALID,
.devgid = (gid_t) -1, .devgid = GID_INVALID,
.action = _SD_DEVICE_ACTION_INVALID, .action = _SD_DEVICE_ACTION_INVALID,
}; };

View File

@ -1236,7 +1236,7 @@ _public_ int sd_event_add_time(
assert_return(e, -EINVAL); assert_return(e, -EINVAL);
assert_return(e = event_resolve(e), -ENOPKG); 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(e->state != SD_EVENT_FINISHED, -ESTALE);
assert_return(!event_pid_changed(e), -ECHILD); 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; int r;
assert_return(s, -EINVAL); 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(EVENT_SOURCE_IS_TIME(s->type), -EDOM);
assert_return(s->event->state != SD_EVENT_FINISHED, -ESTALE); assert_return(s->event->state != SD_EVENT_FINISHED, -ESTALE);
assert_return(!event_pid_changed(s->event), -ECHILD); 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; _unused_ _cleanup_(sd_event_unrefp) sd_event *ref = NULL;
while (e->state != SD_EVENT_FINISHED) { while (e->state != SD_EVENT_FINISHED) {
r = sd_event_run(e, (uint64_t) -1); r = sd_event_run(e, UINT64_MAX);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -217,7 +217,7 @@ static void test_basic(bool with_pidfd) {
got_unref = false; got_unref = false;
assert_se(sd_event_add_io(e, &t, k[0], EPOLLIN, unref_handler, NULL) >= 0); 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(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); assert_se(got_unref);
got_a = false, got_b = false, got_c = false, got_d = 0; 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_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(sd_event_source_set_enabled(w, SD_EVENT_ONESHOT) >= 0);
assert_se(write(d[1], &ch, 1) >= 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(got_d == 1);
assert_se(write(d[1], &ch, 1) >= 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 == 2); assert_se(got_d == 2);
assert_se(sd_event_add_io(e, &x, a[0], EPOLLIN, io_handler, INT_TO_PTR('a')) >= 0); 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(!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(!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(!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(got_a && got_b && got_c);
@ -357,19 +357,19 @@ static void test_rtqueue(void) {
assert_se(n_rtqueue == 0); assert_se(n_rtqueue == 0);
assert_se(last_rtqueue_sigval == 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(n_rtqueue == 1);
assert_se(last_rtqueue_sigval == 2); /* first SIGRTMIN+3 */ 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(n_rtqueue == 2);
assert_se(last_rtqueue_sigval == 4); /* second SIGRTMIN+3 */ 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(n_rtqueue == 3);
assert_se(last_rtqueue_sigval == 3); /* first SIGUSR2 */ 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(n_rtqueue == 4);
assert_se(last_rtqueue_sigval == 1); /* SIGRTMIN+2 */ assert_se(last_rtqueue_sigval == 1); /* SIGRTMIN+2 */

View File

@ -176,7 +176,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
if (ret != LZMA_OK) if (ret != LZMA_OK)
return -ENOMEM; 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)) if (!greedy_realloc(dst, dst_alloc_size, space, 1))
return -ENOMEM; return -ENOMEM;
@ -202,7 +202,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
return -ENOBUFS; return -ENOBUFS;
used = space - s.avail_out; 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)) if (!greedy_realloc(dst, dst_alloc_size, space, 1))
return -ENOMEM; return -ENOMEM;
@ -554,7 +554,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
size_t m = sizeof(buf); size_t m = sizeof(buf);
ssize_t n; 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; m = (size_t) max_bytes;
n = read(fdf, buf, m); 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.next_in = buf;
s.avail_in = n; s.avail_in = n;
if (max_bytes != (uint64_t) -1) { if (max_bytes != UINT64_MAX) {
assert(max_bytes >= (uint64_t) n); assert(max_bytes >= (uint64_t) n);
max_bytes -= n; max_bytes -= n;
} }
@ -664,7 +664,7 @@ int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes) {
offset += n; offset += n;
total_out += 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), r = log_debug_errno(SYNTHETIC_ERRNO(EFBIG),
"Compressed stream longer than %" PRIu64 " bytes", max_bytes); "Compressed stream longer than %" PRIu64 " bytes", max_bytes);
goto cleanup; goto cleanup;
@ -752,7 +752,7 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
n = sizeof(out) - s.avail_out; n = sizeof(out) - s.avail_out;
if (max_bytes != (uint64_t) -1) { if (max_bytes != UINT64_MAX) {
if (max_bytes < (uint64_t) n) if (max_bytes < (uint64_t) n)
return -EFBIG; return -EFBIG;
@ -816,7 +816,7 @@ int decompress_stream_lz4(int in, int out, uint64_t max_bytes) {
total_in += used; total_in += used;
total_out += produced; 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); log_debug("Decompressed stream longer than %"PRIu64" bytes", max_bytes);
r = -EFBIG; r = -EFBIG;
goto cleanup; goto cleanup;

View File

@ -1561,7 +1561,7 @@ bool journal_field_valid(const char *p, size_t l, bool allow_protected) {
http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html */ http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html */
if (l == (size_t) -1) if (l == SIZE_MAX)
l = strlen(p); l = strlen(p);
/* No empty field names */ /* No empty field names */
@ -2352,7 +2352,7 @@ static int generic_array_bisect(
uint64_t *ret_offset, uint64_t *ret_offset,
uint64_t *ret_idx) { 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; bool subtract_one = false;
Object *o, *array = NULL; Object *o, *array = NULL;
int r; int r;
@ -2422,7 +2422,7 @@ static int generic_array_bisect(
left = 0; left = 0;
right -= 1; right -= 1;
if (last_index != (uint64_t) -1) { if (last_index != UINT64_MAX) {
assert(last_index <= right); assert(last_index <= right);
/* If we cached the last index we /* If we cached the last index we
@ -2522,7 +2522,7 @@ static int generic_array_bisect(
n -= k; n -= k;
t += k; t += k;
last_index = (uint64_t) -1; last_index = UINT64_MAX;
a = le64toh(array->entry_array.next_entry_array_offset); a = le64toh(array->entry_array.next_entry_array_offset);
} }
@ -2533,7 +2533,7 @@ found:
return 0; return 0;
/* Let's cache this item for the next invocation */ /* 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) if (subtract_one && i == 0)
p = last_p; p = last_p;
@ -3447,7 +3447,7 @@ int journal_file_open(
#elif HAVE_XZ #elif HAVE_XZ
.compress_xz = compress, .compress_xz = compress,
#endif #endif
.compress_threshold_bytes = compress_threshold_bytes == (uint64_t) -1 ? .compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ?
DEFAULT_COMPRESS_THRESHOLD : DEFAULT_COMPRESS_THRESHOLD :
MAX(MIN_COMPRESS_THRESHOLD, compress_threshold_bytes), MAX(MIN_COMPRESS_THRESHOLD, compress_threshold_bytes),
#if HAVE_GCRYPT #if HAVE_GCRYPT
@ -3964,12 +3964,12 @@ void journal_reset_metrics(JournalMetrics *m) {
/* Set everything to "pick automatic values". */ /* Set everything to "pick automatic values". */
*m = (JournalMetrics) { *m = (JournalMetrics) {
.min_use = (uint64_t) -1, .min_use = UINT64_MAX,
.max_use = (uint64_t) -1, .max_use = UINT64_MAX,
.min_size = (uint64_t) -1, .min_size = UINT64_MAX,
.max_size = (uint64_t) -1, .max_size = UINT64_MAX,
.keep_free = (uint64_t) -1, .keep_free = UINT64_MAX,
.n_max_files = (uint64_t) -1, .n_max_files = UINT64_MAX,
}; };
} }
@ -3986,7 +3986,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
else else
log_debug_errno(errno, "Failed to determine disk size: %m"); 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) if (fs_size > 0)
m->max_use = CLAMP(PAGE_ALIGN(fs_size / 10), /* 10% of file system size */ 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; 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) if (fs_size > 0)
m->min_use = CLAMP(PAGE_ALIGN(fs_size / 50), /* 2% of file system size */ m->min_use = CLAMP(PAGE_ALIGN(fs_size / 50), /* 2% of file system size */
MIN_USE_LOW, MIN_USE_HIGH); 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) if (m->min_use > m->max_use)
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 */ m->max_size = MIN(PAGE_ALIGN(m->max_use / 8), /* 8 chunks */
MAX_SIZE_UPPER); MAX_SIZE_UPPER);
else else
@ -4025,14 +4025,14 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
m->max_use = m->max_size*2; 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; m->min_size = JOURNAL_FILE_SIZE_MIN;
else else
m->min_size = CLAMP(PAGE_ALIGN(m->min_size), m->min_size = CLAMP(PAGE_ALIGN(m->min_size),
JOURNAL_FILE_SIZE_MIN, JOURNAL_FILE_SIZE_MIN,
m->max_size ?: UINT64_MAX); m->max_size ?: UINT64_MAX);
if (m->keep_free == (uint64_t) -1) { if (m->keep_free == UINT64_MAX) {
if (fs_size > 0) if (fs_size > 0)
m->keep_free = MIN(PAGE_ALIGN(fs_size / 20), /* 5% of file system size */ m->keep_free = MIN(PAGE_ALIGN(fs_size / 20), /* 5% of file system size */
KEEP_FREE_UPPER); KEEP_FREE_UPPER);
@ -4040,7 +4040,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
m->keep_free = DEFAULT_KEEP_FREE; 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; 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, log_debug("Fixed min_use=%s max_use=%s max_size=%s min_size=%s keep_free=%s n_max_files=%" PRIu64,

View File

@ -2542,7 +2542,7 @@ _public_ int sd_journal_get_timeout(sd_journal *j, uint64_t *timeout_usec) {
return fd; return fd;
if (!j->on_network) { if (!j->on_network) {
*timeout_usec = (uint64_t) -1; *timeout_usec = UINT64_MAX;
return 0; return 0;
} }
@ -2724,10 +2724,10 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
if (r < 0) if (r < 0)
return r; return r;
if (t != (uint64_t) -1) { if (t != UINT64_MAX) {
t = usec_sub_unsigned(t, now(CLOCK_MONOTONIC)); 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; timeout_usec = t;
} }

View File

@ -35,7 +35,7 @@ _noreturn_ static void log_assert_errno(const char *text, int error, const char
static JournalFile *test_open(const char *name) { static JournalFile *test_open(const char *name) {
JournalFile *f; 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; return f;
} }
@ -206,7 +206,7 @@ static void test_sequence_numbers(void) {
mkdtemp_chdir_chattr(t); mkdtemp_chdir_chattr(t);
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0644, 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); append_number(one, 1, &seqnum);
printf("seqnum=%"PRIu64"\n", 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)); memcpy(&seqnum_id, &one->header->seqnum_id, sizeof(sd_id128_t));
assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0644, 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(two->header->state == STATE_ONLINE);
assert_se(!sd_id128_equal(two->header->file_id, one->header->file_id)); 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; seqnum = 0;
assert_se(journal_file_open(-1, "two.journal", O_RDWR, 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)); assert_se(sd_id128_equal(two->header->seqnum_id, seqnum_id));

View File

@ -73,9 +73,9 @@ static void run_test(void) {
assert_se(chdir(t) >= 0); assert_se(chdir(t) >= 0);
(void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL); (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, "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_t) -1, false, NULL, NULL, NULL, NULL, &two) == 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_t) -1, false, NULL, NULL, NULL, NULL, &three) == 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++) { for (i = 0; i < N_ENTRIES; i++) {
char *p, *q; char *p, *q;

View File

@ -41,7 +41,7 @@ static int raw_verify(const char *fn, const char *verification_key) {
JournalFile *f; JournalFile *f;
int r; 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) if (r < 0)
return r; return r;
@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
log_info("Generating..."); 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++) { for (n = 0; n < N_ENTRIES; n++) {
struct iovec iovec; struct iovec iovec;
@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
log_info("Verifying..."); 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_print_header(f); */
journal_file_dump(f); journal_file_dump(f);

View File

@ -37,7 +37,7 @@ static void test_non_empty(void) {
mkdtemp_chdir_chattr(t); 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(dual_timestamp_get(&ts));
assert_se(sd_id128_randomize(&fake_boot_id) == 0); 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); 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_MAX, true, NULL);
journal_file_rotate(&f, true, (uint64_t) -1, true, NULL); journal_file_rotate(&f, true, UINT64_MAX, true, NULL);
(void) journal_file_close(f); (void) journal_file_close(f);
@ -124,13 +124,13 @@ static void test_empty(void) {
mkdtemp_chdir_chattr(t); 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); journal_file_print_header(f1);
puts(""); puts("");
@ -224,8 +224,8 @@ static void test_min_compress_size(void) {
* carefully */ * carefully */
/* DEFAULT_MIN_COMPRESS_SIZE is 512 */ /* DEFAULT_MIN_COMPRESS_SIZE is 512 */
assert_se(!check_compressed((uint64_t) -1, 255)); assert_se(!check_compressed(UINT64_MAX, 255));
assert_se(check_compressed((uint64_t) -1, 513)); assert_se(check_compressed(UINT64_MAX, 513));
/* compress everything */ /* compress everything */
assert_se(check_compressed(0, 96)); assert_se(check_compressed(0, 96));

View File

@ -1043,9 +1043,9 @@ _public_ int sd_login_monitor_get_timeout(sd_login_monitor *m, uint64_t *timeout
assert_return(m, -EINVAL); assert_return(m, -EINVAL);
assert_return(timeout_usec, -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 * need any timeout. However, let's have this API to keep our
* options open should we later on need it. */ * options open should we later on need it. */
*timeout_usec = (uint64_t) -1; *timeout_usec = UINT64_MAX;
return 0; return 0;
} }

View File

@ -277,7 +277,7 @@ static void test_monitor(void) {
nw = now(CLOCK_MONOTONIC); nw = now(CLOCK_MONOTONIC);
r = poll(&pollfd, 1, r = poll(&pollfd, 1,
timeout == (uint64_t) -1 ? -1 : timeout == UINT64_MAX ? -1 :
timeout > nw ? (int) ((timeout - nw) / 1000) : timeout > nw ? (int) ((timeout - nw) / 1000) :
0); 0);

View File

@ -512,7 +512,7 @@ int sd_netlink_process(sd_netlink *rtnl, sd_netlink_message **ret) {
} }
static usec_t calc_elapse(uint64_t usec) { static usec_t calc_elapse(uint64_t usec) {
if (usec == (uint64_t) -1) if (usec == UINT64_MAX)
return 0; return 0;
if (usec == 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; m = timeout_usec;
r = fd_wait_for_event(rtnl->fd, e, m); r = fd_wait_for_event(rtnl->fd, e, m);
@ -606,7 +606,7 @@ int sd_netlink_call_async(
if (r < 0) if (r < 0)
return r; return r;
if (usec != (uint64_t) -1) { if (usec != UINT64_MAX) {
r = prioq_ensure_allocated(&nl->reply_callbacks_prioq, timeout_compare); r = prioq_ensure_allocated(&nl->reply_callbacks_prioq, timeout_compare);
if (r < 0) if (r < 0)
return r; return r;
@ -714,7 +714,7 @@ int sd_netlink_read(sd_netlink *rtnl,
left = timeout - n; left = timeout - n;
} else } else
left = (uint64_t) -1; left = UINT64_MAX;
r = rtnl_poll(rtnl, true, left); r = rtnl_poll(rtnl, true, left);
if (r < 0) 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); c = prioq_peek(rtnl->reply_callbacks_prioq);
if (!c) { if (!c) {
*timeout_usec = (uint64_t) -1; *timeout_usec = UINT64_MAX;
return 0; return 0;
} }

View File

@ -461,9 +461,9 @@ _public_ int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *tim
assert_return(m, -EINVAL); assert_return(m, -EINVAL);
assert_return(timeout_usec, -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 * need any timeout. However, let's have this API to keep our
* options open should we later on need it. */ * options open should we later on need it. */
*timeout_usec = (uint64_t) -1; *timeout_usec = UINT64_MAX;
return 0; return 0;
} }

View File

@ -621,7 +621,7 @@ _public_ int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *usec) {
assert_return(usec, -EINVAL); assert_return(usec, -EINVAL);
assert_return(!resolve_pid_changed(resolve), -ECHILD); assert_return(!resolve_pid_changed(resolve), -ECHILD);
*usec = (uint64_t) -1; *usec = UINT64_MAX;
return 0; return 0;
} }

View File

@ -4084,7 +4084,7 @@ int manager_start_scope(
return r; return r;
/* disable TasksMax= for the session scope, rely on the slice setting for it */ /* 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) if (r < 0)
return bus_log_create_error(r); return bus_log_create_error(r);

View File

@ -1148,7 +1148,7 @@ static int manager_run(Manager *m) {
if (r > 0) if (r > 0)
continue; continue;
r = sd_event_run(m->event, (uint64_t) -1); r = sd_event_run(m->event, UINT64_MAX);
if (r < 0) if (r < 0)
return r; return r;
} }

View File

@ -328,7 +328,7 @@ static int append_session_memory_max(pam_handle_t *handle, sd_bus_message *m, co
return PAM_SUCCESS; return PAM_SUCCESS;
if (streq(limit, "infinity")) { 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) if (r < 0)
return pam_bus_log_create_error(handle, r); return pam_bus_log_create_error(handle, r);

View File

@ -32,7 +32,7 @@ static int show_sysfs_one(
assert(prefix); assert(prefix);
if (flags & OUTPUT_FULL_WIDTH) if (flags & OUTPUT_FULL_WIDTH)
max_width = (size_t) -1; max_width = SIZE_MAX;
else if (n_columns < 10) else if (n_columns < 10)
max_width = 10; max_width = 10;
else else
@ -113,7 +113,7 @@ static int show_sysfs_one(
return -ENOMEM; return -ENOMEM;
r = show_sysfs_one(seat, dev_list, i_dev, n_dev, sysfs, p, 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); flags);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -394,7 +394,7 @@ int bus_machine_method_get_os_release(sd_bus_message *message, void *userdata, s
if (r < 0) if (r < 0)
_exit(EXIT_FAILURE); _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) if (r < 0)
_exit(EXIT_FAILURE); _exit(EXIT_FAILURE);

View File

@ -964,8 +964,8 @@ static int show_pool_info(sd_bus *bus) {
}; };
PoolStatusInfo info = { PoolStatusInfo info = {
.usage = (uint64_t) -1, .usage = UINT64_MAX,
.limit = (uint64_t) -1, .limit = UINT64_MAX,
}; };
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; _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); polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
if (STR_IN_SET(argv[argc-1], "-", "none", "infinity")) if (STR_IN_SET(argv[argc-1], "-", "none", "infinity"))
limit = (uint64_t) -1; limit = UINT64_MAX;
else { else {
r = parse_size(argv[argc-1], 1024, &limit); r = parse_size(argv[argc-1], 1024, &limit);
if (r < 0) if (r < 0)

View File

@ -45,7 +45,7 @@ static int property_get_pool_usage(
sd_bus_error *error) { sd_bus_error *error) {
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
uint64_t usage = (uint64_t) -1; uint64_t usage = UINT64_MAX;
assert(bus); assert(bus);
assert(reply); assert(reply);
@ -71,7 +71,7 @@ static int property_get_pool_limit(
sd_bus_error *error) { sd_bus_error *error) {
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
uint64_t size = (uint64_t) -1; uint64_t size = UINT64_MAX;
assert(bus); assert(bus);
assert(reply); assert(reply);

View File

@ -1507,7 +1507,7 @@ int config_parse_dhcp_max_attempts(
} }
if (streq(rvalue, "infinity")) { if (streq(rvalue, "infinity")) {
network->dhcp_max_attempts = (uint64_t) -1; network->dhcp_max_attempts = UINT64_MAX;
return 0; return 0;
} }

View File

@ -147,7 +147,7 @@ static int bus_link_method_set_dns_servers_internal(sd_bus_message *message, voi
goto finalize; goto finalize;
} }
if (l->n_dns != (unsigned) -1) if (l->n_dns != UINT_MAX)
for (unsigned i = 0; i < l->n_dns; i++) for (unsigned i = 0; i < l->n_dns; i++)
in_addr_full_free(l->dns[i]); in_addr_full_free(l->dns[i]);

View File

@ -403,7 +403,7 @@ static int link_new(Manager *manager, sd_netlink_message *message, Link **ret) {
.ifindex = ifindex, .ifindex = ifindex,
.iftype = iftype, .iftype = iftype,
.n_dns = (unsigned) -1, .n_dns = UINT_MAX,
.dns_default_route = -1, .dns_default_route = -1,
.llmnr = _RESOLVE_SUPPORT_INVALID, .llmnr = _RESOLVE_SUPPORT_INVALID,
.mdns = _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) { 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++) for (unsigned i = 0; i < link->n_dns; i++)
in_addr_full_free(link->dns[i]); in_addr_full_free(link->dns[i]);
link->dns = mfree(link->dns); 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->search_domains = ordered_set_free_free(link->search_domains);
link->route_domains = ordered_set_free_free(link->route_domains); link->route_domains = ordered_set_free_free(link->route_domains);

Some files were not shown because too many files have changed in this diff Show More