mirror of
https://github.com/systemd/systemd.git
synced 2025-03-31 14:50:15 +03:00
Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
tree-wide: use UINT64_MAX or friends
This commit is contained in:
commit
63dc82d378
@ -1528,11 +1528,11 @@ static int assess(const struct security_info *info, Table *overview_table, Analy
|
||||
if (!details_table)
|
||||
return log_oom();
|
||||
|
||||
(void) table_set_sort(details_table, (size_t) 3, (size_t) 1, (size_t) -1);
|
||||
(void) table_set_sort(details_table, (size_t) 3, (size_t) 1);
|
||||
(void) table_set_reverse(details_table, 3, true);
|
||||
|
||||
if (getenv_bool("SYSTEMD_ANALYZE_DEBUG") <= 0)
|
||||
(void) table_set_display(details_table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 6, (size_t) -1);
|
||||
(void) table_set_display(details_table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 6);
|
||||
}
|
||||
|
||||
for (i = 0; i < ELEMENTSOF(security_assessor_table); i++) {
|
||||
|
@ -1090,7 +1090,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = table_set_sort(table, (size_t) 0, (size_t) SIZE_MAX);
|
||||
r = table_set_sort(table, (size_t) 0);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -1357,7 +1357,7 @@ static int dump(int argc, char *argv[], void *userdata) {
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
fflush(stdout);
|
||||
return copy_bytes(fd, STDOUT_FILENO, (uint64_t) -1, 0);
|
||||
return copy_bytes(fd, STDOUT_FILENO, UINT64_MAX, 0);
|
||||
}
|
||||
|
||||
static int cat_config(int argc, char *argv[], void *userdata) {
|
||||
@ -1622,7 +1622,7 @@ static int dump_capabilities(int argc, char *argv[], void *userdata) {
|
||||
return table_log_add_error(r);
|
||||
}
|
||||
|
||||
(void) table_set_sort(table, (size_t) 1, (size_t) -1);
|
||||
(void) table_set_sort(table, (size_t) 1);
|
||||
}
|
||||
|
||||
(void) pager_open(arg_pager_flags);
|
||||
|
@ -166,7 +166,7 @@ static int run(int argc, char *argv[]) {
|
||||
return r;
|
||||
|
||||
if (arg_timeout > 0)
|
||||
timeout = now(CLOCK_MONOTONIC) + arg_timeout;
|
||||
timeout = usec_add(now(CLOCK_MONOTONIC), arg_timeout);
|
||||
else
|
||||
timeout = 0;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define AUDIT_SESSION_INVALID ((uint32_t) -1)
|
||||
#define AUDIT_SESSION_INVALID (UINT32_MAX)
|
||||
|
||||
int audit_session_from_pid(pid_t pid, uint32_t *id);
|
||||
int audit_loginuid_from_pid(pid_t pid, uid_t *uid);
|
||||
|
@ -396,18 +396,18 @@ static bool btrfs_ioctl_search_args_inc(struct btrfs_ioctl_search_args *args) {
|
||||
* comparing. This call increases the counter by one, dealing
|
||||
* with the overflow between the overflows */
|
||||
|
||||
if (args->key.min_offset < (uint64_t) -1) {
|
||||
if (args->key.min_offset < UINT64_MAX) {
|
||||
args->key.min_offset++;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args->key.min_type < (uint8_t) -1) {
|
||||
if (args->key.min_type < UINT8_MAX) {
|
||||
args->key.min_type++;
|
||||
args->key.min_offset = 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (args->key.min_objectid < (uint64_t) -1) {
|
||||
if (args->key.min_objectid < UINT64_MAX) {
|
||||
args->key.min_objectid++;
|
||||
args->key.min_offset = 0;
|
||||
args->key.min_type = 0;
|
||||
@ -464,11 +464,11 @@ int btrfs_subvol_get_info_fd(int fd, uint64_t subvol_id, BtrfsSubvolInfo *ret) {
|
||||
.key.max_type = BTRFS_ROOT_ITEM_KEY,
|
||||
|
||||
.key.min_offset = 0,
|
||||
.key.max_offset = (uint64_t) -1,
|
||||
.key.max_offset = UINT64_MAX,
|
||||
|
||||
/* No restrictions on the other components */
|
||||
.key.min_transid = 0,
|
||||
.key.max_transid = (uint64_t) -1,
|
||||
.key.max_transid = UINT64_MAX,
|
||||
};
|
||||
|
||||
bool found = false;
|
||||
@ -562,7 +562,7 @@ int btrfs_qgroup_get_quota_fd(int fd, uint64_t qgroupid, BtrfsQuotaInfo *ret) {
|
||||
|
||||
/* No restrictions on the other components */
|
||||
.key.min_transid = 0,
|
||||
.key.max_transid = (uint64_t) -1,
|
||||
.key.max_transid = UINT64_MAX,
|
||||
};
|
||||
|
||||
bool found_info = false, found_limit = false;
|
||||
@ -624,12 +624,12 @@ int btrfs_qgroup_get_quota_fd(int fd, uint64_t qgroupid, BtrfsQuotaInfo *ret) {
|
||||
if (le64toh(qli->flags) & BTRFS_QGROUP_LIMIT_MAX_RFER)
|
||||
ret->referenced_max = le64toh(qli->max_rfer);
|
||||
else
|
||||
ret->referenced_max = (uint64_t) -1;
|
||||
ret->referenced_max = UINT64_MAX;
|
||||
|
||||
if (le64toh(qli->flags) & BTRFS_QGROUP_LIMIT_MAX_EXCL)
|
||||
ret->exclusive_max = le64toh(qli->max_excl);
|
||||
else
|
||||
ret->exclusive_max = (uint64_t) -1;
|
||||
ret->exclusive_max = UINT64_MAX;
|
||||
|
||||
found_limit = true;
|
||||
}
|
||||
@ -648,13 +648,13 @@ finish:
|
||||
return -ENODATA;
|
||||
|
||||
if (!found_info) {
|
||||
ret->referenced = (uint64_t) -1;
|
||||
ret->exclusive = (uint64_t) -1;
|
||||
ret->referenced = UINT64_MAX;
|
||||
ret->exclusive = UINT64_MAX;
|
||||
}
|
||||
|
||||
if (!found_limit) {
|
||||
ret->referenced_max = (uint64_t) -1;
|
||||
ret->exclusive_max = (uint64_t) -1;
|
||||
ret->referenced_max = UINT64_MAX;
|
||||
ret->exclusive_max = UINT64_MAX;
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -671,7 +671,7 @@ int btrfs_qgroup_get_quota(const char *path, uint64_t qgroupid, BtrfsQuotaInfo *
|
||||
}
|
||||
|
||||
int btrfs_subvol_find_subtree_qgroup(int fd, uint64_t subvol_id, uint64_t *ret) {
|
||||
uint64_t level, lowest = (uint64_t) -1, lowest_qgroupid = 0;
|
||||
uint64_t level, lowest = UINT64_MAX, lowest_qgroupid = 0;
|
||||
_cleanup_free_ uint64_t *qgroups = NULL;
|
||||
int r, n;
|
||||
|
||||
@ -713,13 +713,13 @@ int btrfs_subvol_find_subtree_qgroup(int fd, uint64_t subvol_id, uint64_t *ret)
|
||||
if (id != subvol_id)
|
||||
continue;
|
||||
|
||||
if (lowest == (uint64_t) -1 || level < lowest) {
|
||||
if (lowest == UINT64_MAX || level < lowest) {
|
||||
lowest_qgroupid = qgroups[i];
|
||||
lowest = level;
|
||||
}
|
||||
}
|
||||
|
||||
if (lowest == (uint64_t) -1) {
|
||||
if (lowest == UINT64_MAX) {
|
||||
/* No suitable higher-level qgroup found, let's return
|
||||
* the leaf qgroup instead, and indicate that with the
|
||||
* return value. */
|
||||
@ -1089,7 +1089,7 @@ static int subvol_remove_children(int fd, const char *subvolume, uint64_t subvol
|
||||
.key.max_type = BTRFS_ROOT_BACKREF_KEY,
|
||||
|
||||
.key.min_transid = 0,
|
||||
.key.max_transid = (uint64_t) -1,
|
||||
.key.max_transid = UINT64_MAX,
|
||||
};
|
||||
|
||||
struct btrfs_ioctl_vol_args vol_args = {};
|
||||
@ -1265,7 +1265,7 @@ int btrfs_qgroup_copy_limits(int fd, uint64_t old_qgroupid, uint64_t new_qgroupi
|
||||
|
||||
/* No restrictions on the other components */
|
||||
.key.min_transid = 0,
|
||||
.key.max_transid = (uint64_t) -1,
|
||||
.key.max_transid = UINT64_MAX,
|
||||
};
|
||||
|
||||
int r;
|
||||
@ -1451,7 +1451,7 @@ static int subvol_snapshot_children(
|
||||
.key.max_type = BTRFS_ROOT_BACKREF_KEY,
|
||||
|
||||
.key.min_transid = 0,
|
||||
.key.max_transid = (uint64_t) -1,
|
||||
.key.max_transid = UINT64_MAX,
|
||||
};
|
||||
|
||||
struct btrfs_ioctl_vol_args_v2 vol_args = {
|
||||
@ -1721,10 +1721,10 @@ int btrfs_qgroup_find_parents(int fd, uint64_t qgroupid, uint64_t **ret) {
|
||||
|
||||
/* No restrictions on the other components */
|
||||
.key.min_offset = 0,
|
||||
.key.max_offset = (uint64_t) -1,
|
||||
.key.max_offset = UINT64_MAX,
|
||||
|
||||
.key.min_transid = 0,
|
||||
.key.max_transid = (uint64_t) -1,
|
||||
.key.max_transid = UINT64_MAX,
|
||||
};
|
||||
|
||||
_cleanup_free_ uint64_t *items = NULL;
|
||||
@ -1965,10 +1965,10 @@ int btrfs_subvol_get_parent(int fd, uint64_t subvol_id, uint64_t *ret) {
|
||||
|
||||
/* No restrictions on the other components */
|
||||
.key.min_offset = 0,
|
||||
.key.max_offset = (uint64_t) -1,
|
||||
.key.max_offset = UINT64_MAX,
|
||||
|
||||
.key.min_transid = 0,
|
||||
.key.max_transid = (uint64_t) -1,
|
||||
.key.max_transid = UINT64_MAX,
|
||||
};
|
||||
int r;
|
||||
|
||||
|
@ -405,7 +405,7 @@ bool capability_quintet_mangle(CapabilityQuintet *q) {
|
||||
|
||||
combined = q->effective | q->bounding | q->inheritable | q->permitted;
|
||||
|
||||
ambient_supported = q->ambient != (uint64_t) -1;
|
||||
ambient_supported = q->ambient != UINT64_MAX;
|
||||
if (ambient_supported)
|
||||
combined |= q->ambient;
|
||||
|
||||
@ -437,7 +437,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
|
||||
_cleanup_cap_free_ cap_t c = NULL, modified = NULL;
|
||||
int r;
|
||||
|
||||
if (q->ambient != (uint64_t) -1) {
|
||||
if (q->ambient != UINT64_MAX) {
|
||||
bool changed = false;
|
||||
|
||||
c = cap_get_proc();
|
||||
@ -479,7 +479,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (q->inheritable != (uint64_t) -1 || q->permitted != (uint64_t) -1 || q->effective != (uint64_t) -1) {
|
||||
if (q->inheritable != UINT64_MAX || q->permitted != UINT64_MAX || q->effective != UINT64_MAX) {
|
||||
bool changed = false;
|
||||
|
||||
if (!c) {
|
||||
@ -492,7 +492,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
|
||||
uint64_t m = UINT64_C(1) << i;
|
||||
cap_value_t cv = (cap_value_t) i;
|
||||
|
||||
if (q->inheritable != (uint64_t) -1) {
|
||||
if (q->inheritable != UINT64_MAX) {
|
||||
cap_flag_value_t old_value, new_value;
|
||||
|
||||
if (cap_get_flag(c, cv, CAP_INHERITABLE, &old_value) < 0) {
|
||||
@ -515,7 +515,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
|
||||
}
|
||||
}
|
||||
|
||||
if (q->permitted != (uint64_t) -1) {
|
||||
if (q->permitted != UINT64_MAX) {
|
||||
cap_flag_value_t old_value, new_value;
|
||||
|
||||
if (cap_get_flag(c, cv, CAP_PERMITTED, &old_value) < 0) {
|
||||
@ -535,7 +535,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
|
||||
}
|
||||
}
|
||||
|
||||
if (q->effective != (uint64_t) -1) {
|
||||
if (q->effective != UINT64_MAX) {
|
||||
cap_flag_value_t old_value, new_value;
|
||||
|
||||
if (cap_get_flag(c, cv, CAP_EFFECTIVE, &old_value) < 0) {
|
||||
@ -559,7 +559,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
|
||||
if (changed) {
|
||||
/* In order to change the bounding caps, we need to keep CAP_SETPCAP for a bit
|
||||
* longer. Let's add it to our list hence for now. */
|
||||
if (q->bounding != (uint64_t) -1) {
|
||||
if (q->bounding != UINT64_MAX) {
|
||||
cap_value_t cv = CAP_SETPCAP;
|
||||
|
||||
modified = cap_dup(c);
|
||||
@ -587,7 +587,7 @@ int capability_quintet_enforce(const CapabilityQuintet *q) {
|
||||
}
|
||||
}
|
||||
|
||||
if (q->bounding != (uint64_t) -1) {
|
||||
if (q->bounding != UINT64_MAX) {
|
||||
r = capability_bounding_set_drop(q->bounding, false);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "missing_capability.h"
|
||||
#include "util.h"
|
||||
|
||||
#define CAP_ALL (uint64_t) -1
|
||||
#define CAP_ALL UINT64_MAX
|
||||
|
||||
unsigned cap_last_cap(void);
|
||||
int have_effective_cap(int value);
|
||||
@ -49,7 +49,7 @@ bool ambient_capabilities_supported(void);
|
||||
#define CAP_TO_MASK_CORRECTED(x) (1U << ((x) & 31U))
|
||||
|
||||
typedef struct CapabilityQuintet {
|
||||
/* Stores all five types of capabilities in one go. Note that we use (uint64_t) -1 for unset here. This hence
|
||||
/* Stores all five types of capabilities in one go. Note that we use UINT64_MAX for unset here. This hence
|
||||
* needs to be updated as soon as Linux learns more than 63 caps. */
|
||||
uint64_t effective;
|
||||
uint64_t bounding;
|
||||
@ -60,14 +60,14 @@ typedef struct CapabilityQuintet {
|
||||
|
||||
assert_cc(CAP_LAST_CAP < 64);
|
||||
|
||||
#define CAPABILITY_QUINTET_NULL { (uint64_t) -1, (uint64_t) -1, (uint64_t) -1, (uint64_t) -1, (uint64_t) -1 }
|
||||
#define CAPABILITY_QUINTET_NULL { UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX, UINT64_MAX }
|
||||
|
||||
static inline bool capability_quintet_is_set(const CapabilityQuintet *q) {
|
||||
return q->effective != (uint64_t) -1 ||
|
||||
q->bounding != (uint64_t) -1 ||
|
||||
q->inheritable != (uint64_t) -1 ||
|
||||
q->permitted != (uint64_t) -1 ||
|
||||
q->ambient != (uint64_t) -1;
|
||||
return q->effective != UINT64_MAX ||
|
||||
q->bounding != UINT64_MAX ||
|
||||
q->inheritable != UINT64_MAX ||
|
||||
q->permitted != UINT64_MAX ||
|
||||
q->ambient != UINT64_MAX;
|
||||
}
|
||||
|
||||
/* Mangles the specified caps quintet taking the current bounding set into account:
|
||||
|
@ -1975,7 +1975,7 @@ int cg_kernel_controllers(Set **ret) {
|
||||
return r;
|
||||
|
||||
/* Ignore the header line */
|
||||
(void) read_line(f, (size_t) -1, NULL);
|
||||
(void) read_line(f, SIZE_MAX, NULL);
|
||||
|
||||
for (;;) {
|
||||
char *controller;
|
||||
|
@ -75,13 +75,13 @@ CGroupMask get_cpu_accounting_mask(void);
|
||||
bool cpu_accounting_is_cheap(void);
|
||||
|
||||
/* Special values for all weight knobs on unified hierarchy */
|
||||
#define CGROUP_WEIGHT_INVALID ((uint64_t) -1)
|
||||
#define CGROUP_WEIGHT_INVALID (UINT64_MAX)
|
||||
#define CGROUP_WEIGHT_MIN UINT64_C(1)
|
||||
#define CGROUP_WEIGHT_MAX UINT64_C(10000)
|
||||
#define CGROUP_WEIGHT_DEFAULT UINT64_C(100)
|
||||
|
||||
#define CGROUP_LIMIT_MIN UINT64_C(0)
|
||||
#define CGROUP_LIMIT_MAX ((uint64_t) -1)
|
||||
#define CGROUP_LIMIT_MAX (UINT64_MAX)
|
||||
|
||||
static inline bool CGROUP_WEIGHT_IS_OK(uint64_t x) {
|
||||
return
|
||||
@ -106,7 +106,7 @@ const char* cgroup_io_limit_type_to_string(CGroupIOLimitType t) _const_;
|
||||
CGroupIOLimitType cgroup_io_limit_type_from_string(const char *s) _pure_;
|
||||
|
||||
/* Special values for the cpu.shares attribute */
|
||||
#define CGROUP_CPU_SHARES_INVALID ((uint64_t) -1)
|
||||
#define CGROUP_CPU_SHARES_INVALID (UINT64_MAX)
|
||||
#define CGROUP_CPU_SHARES_MIN UINT64_C(2)
|
||||
#define CGROUP_CPU_SHARES_MAX UINT64_C(262144)
|
||||
#define CGROUP_CPU_SHARES_DEFAULT UINT64_C(1024)
|
||||
@ -118,7 +118,7 @@ static inline bool CGROUP_CPU_SHARES_IS_OK(uint64_t x) {
|
||||
}
|
||||
|
||||
/* Special values for the blkio.weight attribute */
|
||||
#define CGROUP_BLKIO_WEIGHT_INVALID ((uint64_t) -1)
|
||||
#define CGROUP_BLKIO_WEIGHT_INVALID (UINT64_MAX)
|
||||
#define CGROUP_BLKIO_WEIGHT_MIN UINT64_C(10)
|
||||
#define CGROUP_BLKIO_WEIGHT_MAX UINT64_C(1000)
|
||||
#define CGROUP_BLKIO_WEIGHT_DEFAULT UINT64_C(500)
|
||||
|
@ -361,7 +361,7 @@ int copy_bytes_full(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (max_bytes != (uint64_t) -1) {
|
||||
if (max_bytes != UINT64_MAX) {
|
||||
assert(max_bytes >= (uint64_t) n);
|
||||
max_bytes -= n;
|
||||
}
|
||||
@ -642,7 +642,7 @@ static int fd_copy_regular(
|
||||
if (fdt < 0)
|
||||
return -errno;
|
||||
|
||||
r = copy_bytes_full(fdf, fdt, (uint64_t) -1, copy_flags, NULL, NULL, progress, userdata);
|
||||
r = copy_bytes_full(fdf, fdt, UINT64_MAX, copy_flags, NULL, NULL, progress, userdata);
|
||||
if (r < 0) {
|
||||
(void) unlinkat(dt, to, 0);
|
||||
return r;
|
||||
@ -1051,7 +1051,7 @@ int copy_file_fd_full(
|
||||
if (fdf < 0)
|
||||
return -errno;
|
||||
|
||||
r = copy_bytes_full(fdf, fdt, (uint64_t) -1, copy_flags, NULL, NULL, progress_bytes, userdata);
|
||||
r = copy_bytes_full(fdf, fdt, UINT64_MAX, copy_flags, NULL, NULL, progress_bytes, userdata);
|
||||
|
||||
(void) copy_times(fdf, fdt, copy_flags);
|
||||
(void) copy_xattr(fdf, fdt);
|
||||
@ -1081,7 +1081,7 @@ int copy_file_full(
|
||||
if (fdf < 0)
|
||||
return -errno;
|
||||
|
||||
if (mode == (mode_t) -1)
|
||||
if (mode == MODE_INVALID)
|
||||
if (fstat(fdf, &st) < 0)
|
||||
return -errno;
|
||||
|
||||
@ -1092,7 +1092,7 @@ int copy_file_full(
|
||||
return r;
|
||||
}
|
||||
fdt = open(to, flags|O_WRONLY|O_CREAT|O_CLOEXEC|O_NOCTTY,
|
||||
mode != (mode_t) -1 ? mode : st.st_mode);
|
||||
mode != MODE_INVALID ? mode : st.st_mode);
|
||||
if (copy_flags & COPY_MAC_CREATE)
|
||||
mac_selinux_create_file_clear();
|
||||
if (fdt < 0)
|
||||
@ -1102,7 +1102,7 @@ int copy_file_full(
|
||||
if (chattr_mask != 0)
|
||||
(void) chattr_fd(fdt, chattr_flags, chattr_mask & CHATTR_EARLY_FL, NULL);
|
||||
|
||||
r = copy_bytes_full(fdf, fdt, (uint64_t) -1, copy_flags, NULL, NULL, progress_bytes, userdata);
|
||||
r = copy_bytes_full(fdf, fdt, UINT64_MAX, copy_flags, NULL, NULL, progress_bytes, userdata);
|
||||
if (r < 0) {
|
||||
close(fdt);
|
||||
(void) unlink(to);
|
||||
|
@ -28,7 +28,7 @@ int encode_devnode_name(const char *str, char *str_enc, size_t len) {
|
||||
for (i = 0, j = 0; str[i] != '\0'; i++) {
|
||||
int seqlen;
|
||||
|
||||
seqlen = utf8_encoded_valid_unichar(str + i, (size_t) -1);
|
||||
seqlen = utf8_encoded_valid_unichar(str + i, SIZE_MAX);
|
||||
if (seqlen > 1) {
|
||||
|
||||
if (len-j < (size_t)seqlen)
|
||||
|
@ -20,7 +20,7 @@ static int parse_env_file_internal(
|
||||
void *userdata,
|
||||
int *n_pushed) {
|
||||
|
||||
size_t key_alloc = 0, n_key = 0, value_alloc = 0, n_value = 0, last_value_whitespace = (size_t) -1, last_key_whitespace = (size_t) -1;
|
||||
size_t key_alloc = 0, n_key = 0, value_alloc = 0, n_value = 0, last_value_whitespace = SIZE_MAX, last_key_whitespace = SIZE_MAX;
|
||||
_cleanup_free_ char *contents = NULL, *key = NULL, *value = NULL;
|
||||
unsigned line = 1;
|
||||
char *p;
|
||||
@ -56,7 +56,7 @@ static int parse_env_file_internal(
|
||||
state = COMMENT;
|
||||
else if (!strchr(WHITESPACE, c)) {
|
||||
state = KEY;
|
||||
last_key_whitespace = (size_t) -1;
|
||||
last_key_whitespace = SIZE_MAX;
|
||||
|
||||
if (!GREEDY_REALLOC(key, key_alloc, n_key+2))
|
||||
return -ENOMEM;
|
||||
@ -72,11 +72,11 @@ static int parse_env_file_internal(
|
||||
n_key = 0;
|
||||
} else if (c == '=') {
|
||||
state = PRE_VALUE;
|
||||
last_value_whitespace = (size_t) -1;
|
||||
last_value_whitespace = SIZE_MAX;
|
||||
} else {
|
||||
if (!strchr(WHITESPACE, c))
|
||||
last_key_whitespace = (size_t) -1;
|
||||
else if (last_key_whitespace == (size_t) -1)
|
||||
last_key_whitespace = SIZE_MAX;
|
||||
else if (last_key_whitespace == SIZE_MAX)
|
||||
last_key_whitespace = n_key;
|
||||
|
||||
if (!GREEDY_REALLOC(key, key_alloc, n_key+2))
|
||||
@ -97,7 +97,7 @@ static int parse_env_file_internal(
|
||||
value[n_value] = 0;
|
||||
|
||||
/* strip trailing whitespace from key */
|
||||
if (last_key_whitespace != (size_t) -1)
|
||||
if (last_key_whitespace != SIZE_MAX)
|
||||
key[last_key_whitespace] = 0;
|
||||
|
||||
r = push(fname, line, key, value, userdata, n_pushed);
|
||||
@ -136,11 +136,11 @@ static int parse_env_file_internal(
|
||||
value[n_value] = 0;
|
||||
|
||||
/* Chomp off trailing whitespace from value */
|
||||
if (last_value_whitespace != (size_t) -1)
|
||||
if (last_value_whitespace != SIZE_MAX)
|
||||
value[last_value_whitespace] = 0;
|
||||
|
||||
/* strip trailing whitespace from key */
|
||||
if (last_key_whitespace != (size_t) -1)
|
||||
if (last_key_whitespace != SIZE_MAX)
|
||||
key[last_key_whitespace] = 0;
|
||||
|
||||
r = push(fname, line, key, value, userdata, n_pushed);
|
||||
@ -153,11 +153,11 @@ static int parse_env_file_internal(
|
||||
|
||||
} else if (c == '\\') {
|
||||
state = VALUE_ESCAPE;
|
||||
last_value_whitespace = (size_t) -1;
|
||||
last_value_whitespace = SIZE_MAX;
|
||||
} else {
|
||||
if (!strchr(WHITESPACE, c))
|
||||
last_value_whitespace = (size_t) -1;
|
||||
else if (last_value_whitespace == (size_t) -1)
|
||||
last_value_whitespace = SIZE_MAX;
|
||||
else if (last_value_whitespace == SIZE_MAX)
|
||||
last_value_whitespace = n_value;
|
||||
|
||||
if (!GREEDY_REALLOC(value, value_alloc, n_value+2))
|
||||
@ -255,11 +255,11 @@ static int parse_env_file_internal(
|
||||
value[n_value] = 0;
|
||||
|
||||
if (state == VALUE)
|
||||
if (last_value_whitespace != (size_t) -1)
|
||||
if (last_value_whitespace != SIZE_MAX)
|
||||
value[last_value_whitespace] = 0;
|
||||
|
||||
/* strip trailing whitespace from key */
|
||||
if (last_key_whitespace != (size_t) -1)
|
||||
if (last_key_whitespace != SIZE_MAX)
|
||||
key[last_key_whitespace] = 0;
|
||||
|
||||
r = push(fname, line, key, value, userdata, n_pushed);
|
||||
|
@ -114,7 +114,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
|
||||
* instead be copied directly.
|
||||
*/
|
||||
|
||||
if (length != (size_t) -1 && length < 1)
|
||||
if (length != SIZE_MAX && length < 1)
|
||||
return -EINVAL;
|
||||
|
||||
switch (p[0]) {
|
||||
@ -159,7 +159,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
|
||||
/* hexadecimal encoding */
|
||||
int a, b;
|
||||
|
||||
if (length != (size_t) -1 && length < 3)
|
||||
if (length != SIZE_MAX && length < 3)
|
||||
return -EINVAL;
|
||||
|
||||
a = unhexchar(p[1]);
|
||||
@ -187,7 +187,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
|
||||
size_t i;
|
||||
uint32_t c;
|
||||
|
||||
if (length != (size_t) -1 && length < 5)
|
||||
if (length != SIZE_MAX && length < 5)
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
@ -214,7 +214,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
|
||||
size_t i;
|
||||
char32_t c;
|
||||
|
||||
if (length != (size_t) -1 && length < 9)
|
||||
if (length != SIZE_MAX && length < 9)
|
||||
return -EINVAL;
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
@ -251,7 +251,7 @@ int cunescape_one(const char *p, size_t length, char32_t *ret, bool *eight_bit,
|
||||
int a, b, c;
|
||||
char32_t m;
|
||||
|
||||
if (length != (size_t) -1 && length < 3)
|
||||
if (length != SIZE_MAX && length < 3)
|
||||
return -EINVAL;
|
||||
|
||||
a = unoctchar(p[0]);
|
||||
|
@ -91,7 +91,7 @@ int extract_first_word(const char **p, char **ret, const char *separators, Extra
|
||||
char32_t u;
|
||||
|
||||
if ((flags & EXTRACT_CUNESCAPE) &&
|
||||
(r = cunescape_one(*p, (size_t) -1, &u, &eight_bit, false)) >= 0) {
|
||||
(r = cunescape_one(*p, SIZE_MAX, &u, &eight_bit, false)) >= 0) {
|
||||
/* A valid escaped sequence */
|
||||
assert(r >= 1);
|
||||
|
||||
|
@ -47,7 +47,7 @@ char *format_bytes_full(char *buf, size_t l, uint64_t t, FormatBytesFlag flag) {
|
||||
|
||||
assert_cc(ELEMENTSOF(table_iec) == ELEMENTSOF(table_si));
|
||||
|
||||
if (t == (uint64_t) -1)
|
||||
if (t == UINT64_MAX)
|
||||
return NULL;
|
||||
|
||||
table = flag & FORMAT_BYTES_USE_IEC ? table_iec : table_si;
|
||||
|
@ -119,7 +119,7 @@ int unhexmem_full(const char *p, size_t l, bool secure, void **ret, size_t *ret_
|
||||
assert(ret_len);
|
||||
assert(p || l == 0);
|
||||
|
||||
if (l == (size_t) -1)
|
||||
if (l == SIZE_MAX)
|
||||
l = strlen(p);
|
||||
|
||||
/* Note that the calculation of memory size is an upper boundary, as we ignore whitespace while decoding */
|
||||
@ -309,7 +309,7 @@ int unbase32hexmem(const char *p, size_t l, bool padding, void **mem, size_t *_l
|
||||
assert(mem);
|
||||
assert(_len);
|
||||
|
||||
if (l == (size_t) -1)
|
||||
if (l == SIZE_MAX)
|
||||
l = strlen(p);
|
||||
|
||||
/* padding ensures any base32hex input has input divisible by 8 */
|
||||
@ -708,7 +708,7 @@ int unbase64mem_full(const char *p, size_t l, bool secure, void **ret, size_t *r
|
||||
assert(ret);
|
||||
assert(ret_size);
|
||||
|
||||
if (l == (size_t) -1)
|
||||
if (l == SIZE_MAX)
|
||||
l = strlen(p);
|
||||
|
||||
/* A group of four input bytes needs three output bytes, in case of padding we need to add two or three extra
|
||||
|
@ -62,7 +62,7 @@ static inline bool FILE_SIZE_VALID_OR_INFINITY(uint64_t l) {
|
||||
|
||||
/* Same as above, but allows one extra value: -1 as indication for infinity. */
|
||||
|
||||
if (l == (uint64_t) -1)
|
||||
if (l == UINT64_MAX)
|
||||
return true;
|
||||
|
||||
return FILE_SIZE_VALID(l);
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
typedef struct Prioq Prioq;
|
||||
|
||||
#define PRIOQ_IDX_NULL ((unsigned) -1)
|
||||
#define PRIOQ_IDX_NULL (UINT_MAX)
|
||||
|
||||
Prioq *prioq_new(compare_func_t compare);
|
||||
Prioq *prioq_free(Prioq *q);
|
||||
|
@ -756,7 +756,7 @@ int wait_for_terminate_with_timeout(pid_t pid, usec_t timeout) {
|
||||
|
||||
/* Drop into a sigtimewait-based timeout. Waiting for the
|
||||
* pid to exit. */
|
||||
until = now(CLOCK_MONOTONIC) + timeout;
|
||||
until = usec_add(now(CLOCK_MONOTONIC), timeout);
|
||||
for (;;) {
|
||||
usec_t n;
|
||||
siginfo_t status = {};
|
||||
|
@ -19,7 +19,7 @@ bool ratelimit_below(RateLimit *r) {
|
||||
ts = now(CLOCK_MONOTONIC);
|
||||
|
||||
if (r->begin <= 0 ||
|
||||
ts - r->begin > r->interval) {
|
||||
usec_sub_unsigned(ts, r->begin) > r->interval) {
|
||||
r->begin = ts;
|
||||
|
||||
/* Reset counter */
|
||||
|
@ -71,7 +71,7 @@ char *strnappend(const char *s, const char *suffix, size_t b) {
|
||||
assert(suffix);
|
||||
|
||||
a = strlen(s);
|
||||
if (b > ((size_t) -1) - a)
|
||||
if (b > (SIZE_MAX) - a)
|
||||
return NULL;
|
||||
|
||||
r = new(char, a+b+1);
|
||||
@ -307,7 +307,7 @@ static char *ascii_ellipsize_mem(const char *s, size_t old_length, size_t new_le
|
||||
|
||||
assert(s);
|
||||
assert(percent <= 100);
|
||||
assert(new_length != (size_t) -1);
|
||||
assert(new_length != SIZE_MAX);
|
||||
|
||||
if (old_length <= new_length)
|
||||
return strndup(s, old_length);
|
||||
@ -378,7 +378,7 @@ char *ellipsize_mem(const char *s, size_t old_length, size_t new_length, unsigne
|
||||
assert(s);
|
||||
assert(percent <= 100);
|
||||
|
||||
if (new_length == (size_t) -1)
|
||||
if (new_length == SIZE_MAX)
|
||||
return strndup(s, old_length);
|
||||
|
||||
if (new_length == 0)
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "strv.h"
|
||||
#include "terminal-util.h"
|
||||
#include "time-util.h"
|
||||
#include "user-util.h"
|
||||
#include "util.h"
|
||||
|
||||
static volatile unsigned cached_columns = 0;
|
||||
@ -440,11 +441,11 @@ int acquire_terminal(
|
||||
|
||||
assert(ts != USEC_INFINITY);
|
||||
|
||||
n = now(CLOCK_MONOTONIC);
|
||||
if (ts + timeout < n)
|
||||
n = usec_sub_unsigned(now(CLOCK_MONOTONIC), ts);
|
||||
if (n >= timeout)
|
||||
return -ETIMEDOUT;
|
||||
|
||||
r = fd_wait_for_event(notify, POLLIN, ts + timeout - n);
|
||||
r = fd_wait_for_event(notify, POLLIN, usec_sub_unsigned(timeout, n));
|
||||
if (r < 0)
|
||||
return r;
|
||||
if (r == 0)
|
||||
@ -1341,7 +1342,7 @@ int vt_restore(int fd) {
|
||||
q = -errno;
|
||||
}
|
||||
|
||||
r = fchmod_and_chown(fd, TTY_MODE, 0, (gid_t) -1);
|
||||
r = fchmod_and_chown(fd, TTY_MODE, 0, GID_INVALID);
|
||||
if (r < 0) {
|
||||
log_debug_errno(r, "Failed to chmod()/chown() VT, ignoring: %m");
|
||||
if (q >= 0)
|
||||
|
@ -882,7 +882,7 @@ char *mangle_gecos(const char *d) {
|
||||
continue;
|
||||
}
|
||||
|
||||
len = utf8_encoded_valid_unichar(i, (size_t) -1);
|
||||
len = utf8_encoded_valid_unichar(i, SIZE_MAX);
|
||||
if (len < 0) {
|
||||
*i = ' ';
|
||||
continue;
|
||||
|
@ -156,14 +156,14 @@ char *utf8_is_valid_n(const char *str, size_t len_bytes) {
|
||||
|
||||
assert(str);
|
||||
|
||||
for (const char *p = str; len_bytes != (size_t) -1 ? (size_t) (p - str) < len_bytes : *p != '\0'; ) {
|
||||
for (const char *p = str; len_bytes != SIZE_MAX ? (size_t) (p - str) < len_bytes : *p != '\0'; ) {
|
||||
int len;
|
||||
|
||||
if (_unlikely_(*p == '\0') && len_bytes != (size_t) -1)
|
||||
if (_unlikely_(*p == '\0') && len_bytes != SIZE_MAX)
|
||||
return NULL; /* embedded NUL */
|
||||
|
||||
len = utf8_encoded_valid_unichar(p,
|
||||
len_bytes != (size_t) -1 ? len_bytes - (p - str) : (size_t) -1);
|
||||
len_bytes != SIZE_MAX ? len_bytes - (p - str) : SIZE_MAX);
|
||||
if (_unlikely_(len < 0))
|
||||
return NULL; /* invalid character */
|
||||
|
||||
@ -185,7 +185,7 @@ char *utf8_escape_invalid(const char *str) {
|
||||
while (*str) {
|
||||
int len;
|
||||
|
||||
len = utf8_encoded_valid_unichar(str, (size_t) -1);
|
||||
len = utf8_encoded_valid_unichar(str, SIZE_MAX);
|
||||
if (len > 0) {
|
||||
s = mempcpy(s, str, len);
|
||||
str += len;
|
||||
@ -233,7 +233,7 @@ char *utf8_escape_non_printable_full(const char *str, size_t console_width) {
|
||||
if (!*str) /* done! */
|
||||
goto finish;
|
||||
|
||||
len = utf8_encoded_valid_unichar(str, (size_t) -1);
|
||||
len = utf8_encoded_valid_unichar(str, SIZE_MAX);
|
||||
if (len > 0) {
|
||||
if (utf8_is_printable(str, len)) {
|
||||
int w;
|
||||
@ -508,7 +508,7 @@ int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
|
||||
assert(str);
|
||||
assert(length > 0);
|
||||
|
||||
/* We read until NUL, at most length bytes. (size_t) -1 may be used to disable the length check. */
|
||||
/* We read until NUL, at most length bytes. SIZE_MAX may be used to disable the length check. */
|
||||
|
||||
len = utf8_encoded_expected_len(str[0]);
|
||||
if (len == 0)
|
||||
@ -545,14 +545,14 @@ int utf8_encoded_valid_unichar(const char *str, size_t length /* bytes */) {
|
||||
size_t utf8_n_codepoints(const char *str) {
|
||||
size_t n = 0;
|
||||
|
||||
/* Returns the number of UTF-8 codepoints in this string, or (size_t) -1 if the string is not valid UTF-8. */
|
||||
/* Returns the number of UTF-8 codepoints in this string, or SIZE_MAX if the string is not valid UTF-8. */
|
||||
|
||||
while (*str != 0) {
|
||||
int k;
|
||||
|
||||
k = utf8_encoded_valid_unichar(str, (size_t) -1);
|
||||
k = utf8_encoded_valid_unichar(str, SIZE_MAX);
|
||||
if (k < 0)
|
||||
return (size_t) -1;
|
||||
return SIZE_MAX;
|
||||
|
||||
str += k;
|
||||
n++;
|
||||
@ -572,7 +572,7 @@ size_t utf8_console_width(const char *str) {
|
||||
|
||||
w = utf8_char_console_width(str);
|
||||
if (w < 0)
|
||||
return (size_t) -1;
|
||||
return SIZE_MAX;
|
||||
|
||||
n += w;
|
||||
str = utf8_next_char(str);
|
||||
|
@ -16,7 +16,7 @@ bool unichar_is_valid(char32_t c);
|
||||
|
||||
char *utf8_is_valid_n(const char *str, size_t len_bytes) _pure_;
|
||||
static inline char *utf8_is_valid(const char *s) {
|
||||
return utf8_is_valid_n(s, (size_t) -1);
|
||||
return utf8_is_valid_n(s, SIZE_MAX);
|
||||
}
|
||||
char *ascii_is_valid(const char *s) _pure_;
|
||||
char *ascii_is_valid_n(const char *str, size_t len);
|
||||
@ -27,7 +27,7 @@ bool utf8_is_printable_newline(const char* str, size_t length, bool allow_newlin
|
||||
char *utf8_escape_invalid(const char *s);
|
||||
char *utf8_escape_non_printable_full(const char *str, size_t console_width);
|
||||
static inline char *utf8_escape_non_printable(const char *str) {
|
||||
return utf8_escape_non_printable_full(str, (size_t) -1);
|
||||
return utf8_escape_non_printable_full(str, SIZE_MAX);
|
||||
}
|
||||
|
||||
size_t utf8_encode_unichar(char *out_utf8, char32_t g);
|
||||
|
@ -147,7 +147,7 @@ static int parse_crtime(le64_t le, usec_t *usec) {
|
||||
assert(usec);
|
||||
|
||||
u = le64toh(le);
|
||||
if (IN_SET(u, 0, (uint64_t) -1))
|
||||
if (IN_SET(u, 0, UINT64_MAX))
|
||||
return -EIO;
|
||||
|
||||
*usec = (usec_t) u;
|
||||
|
@ -541,7 +541,7 @@ static int copy_file_with_version_check(const char *from, const char *to, bool f
|
||||
return log_error_errno(errno, "Failed to open \"%s\" for writing: %m", t);
|
||||
}
|
||||
|
||||
r = copy_bytes(fd_from, fd_to, (uint64_t) -1, COPY_REFLINK);
|
||||
r = copy_bytes(fd_from, fd_to, UINT64_MAX, COPY_REFLINK);
|
||||
if (r < 0) {
|
||||
(void) unlink(t);
|
||||
return log_error_errno(r, "Failed to copy data from \"%s\" to \"%s\": %m", from, t);
|
||||
|
@ -470,7 +470,7 @@ static VOID print_status(Config *config, CHAR16 *loaded_image_path) {
|
||||
if (entry->call)
|
||||
Print(L"internal call yes\n");
|
||||
|
||||
if (entry->tries_left != (UINTN) -1)
|
||||
if (entry->tries_left != UINTN_MAX)
|
||||
Print(L"counting boots yes\n"
|
||||
"tries done %u\n"
|
||||
"tries left %u\n"
|
||||
@ -1077,7 +1077,7 @@ static VOID config_entry_parse_tries(
|
||||
CHAR16 *file,
|
||||
CHAR16 *suffix) {
|
||||
|
||||
UINTN left = (UINTN) -1, done = (UINTN) -1, factor = 1, i, next_left, next_done;
|
||||
UINTN left = UINTN_MAX, done = UINTN_MAX, factor = 1, i, next_left, next_done;
|
||||
_cleanup_freepool_ CHAR16 *prefix = NULL;
|
||||
|
||||
/*
|
||||
@ -1114,46 +1114,46 @@ static VOID config_entry_parse_tries(
|
||||
switch (file[i]) {
|
||||
|
||||
case '+':
|
||||
if (left == (UINTN) -1) /* didn't read at least one digit for 'left'? */
|
||||
if (left == UINTN_MAX) /* didn't read at least one digit for 'left'? */
|
||||
return;
|
||||
|
||||
if (done == (UINTN) -1) /* no 'done' counter? If so, it's equivalent to 0 */
|
||||
if (done == UINTN_MAX) /* no 'done' counter? If so, it's equivalent to 0 */
|
||||
done = 0;
|
||||
|
||||
goto good;
|
||||
|
||||
case '-':
|
||||
if (left == (UINTN) -1) /* didn't parse any digit yet? */
|
||||
if (left == UINTN_MAX) /* didn't parse any digit yet? */
|
||||
return;
|
||||
|
||||
if (done != (UINTN) -1) /* already encountered a dash earlier? */
|
||||
if (done != UINTN_MAX) /* already encountered a dash earlier? */
|
||||
return;
|
||||
|
||||
/* So we encountered a dash. This means this counter is of the form +LEFT-DONE. Let's assign
|
||||
* what we already parsed to 'done', and start fresh for the 'left' part. */
|
||||
|
||||
done = left;
|
||||
left = (UINTN) -1;
|
||||
left = UINTN_MAX;
|
||||
factor = 1;
|
||||
break;
|
||||
|
||||
case '0'...'9': {
|
||||
UINTN new_factor;
|
||||
|
||||
if (left == (UINTN) -1)
|
||||
if (left == UINTN_MAX)
|
||||
left = file[i] - '0';
|
||||
else {
|
||||
UINTN new_left, digit;
|
||||
|
||||
digit = file[i] - '0';
|
||||
if (digit > (UINTN) -1 / factor) /* overflow check */
|
||||
if (digit > UINTN_MAX / factor) /* overflow check */
|
||||
return;
|
||||
|
||||
new_left = left + digit * factor;
|
||||
if (new_left < left) /* overflow check */
|
||||
return;
|
||||
|
||||
if (new_left == (UINTN) -1) /* don't allow us to be confused */
|
||||
if (new_left == UINTN_MAX) /* don't allow us to be confused */
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1197,7 +1197,7 @@ static VOID config_entry_bump_counters(
|
||||
UINTN file_info_size, a, b;
|
||||
EFI_STATUS r;
|
||||
|
||||
if (entry->tries_left == (UINTN) -1)
|
||||
if (entry->tries_left == UINTN_MAX)
|
||||
return;
|
||||
|
||||
if (!entry->path || !entry->current_name || !entry->next_name)
|
||||
@ -1275,8 +1275,8 @@ static VOID config_entry_add_from_file(
|
||||
entry = AllocatePool(sizeof(ConfigEntry));
|
||||
|
||||
*entry = (ConfigEntry) {
|
||||
.tries_done = (UINTN) -1,
|
||||
.tries_left = (UINTN) -1,
|
||||
.tries_done = UINTN_MAX,
|
||||
.tries_left = UINTN_MAX,
|
||||
};
|
||||
|
||||
while ((line = line_get_key_value(content, (CHAR8 *)" \t", &pos, &key, &value))) {
|
||||
@ -1482,8 +1482,8 @@ static INTN config_entry_compare(ConfigEntry *a, ConfigEntry *b) {
|
||||
if (r != 0)
|
||||
return r;
|
||||
|
||||
if (a->tries_left == (UINTN) -1 ||
|
||||
b->tries_left == (UINTN) -1)
|
||||
if (a->tries_left == UINTN_MAX ||
|
||||
b->tries_left == UINTN_MAX)
|
||||
return 0;
|
||||
|
||||
/* If both items have boot counting, and otherwise are identical, put the entry with more tries left last */
|
||||
@ -1701,8 +1701,8 @@ static BOOLEAN config_entry_add_call(
|
||||
.title = StrDuplicate(title),
|
||||
.call = call,
|
||||
.no_autoselect = TRUE,
|
||||
.tries_done = (UINTN) -1,
|
||||
.tries_left = (UINTN) -1,
|
||||
.tries_done = UINTN_MAX,
|
||||
.tries_left = UINTN_MAX,
|
||||
};
|
||||
|
||||
config_add_entry(config, entry);
|
||||
@ -1730,8 +1730,8 @@ static ConfigEntry *config_entry_add_loader(
|
||||
.loader = StrDuplicate(loader),
|
||||
.id = StrDuplicate(id),
|
||||
.key = key,
|
||||
.tries_done = (UINTN) -1,
|
||||
.tries_left = (UINTN) -1,
|
||||
.tries_done = UINTN_MAX,
|
||||
.tries_left = UINTN_MAX,
|
||||
};
|
||||
|
||||
StrLwr(entry->id);
|
||||
@ -1971,9 +1971,9 @@ static VOID config_load_xbootldr(
|
||||
EFI_HANDLE *device) {
|
||||
|
||||
EFI_DEVICE_PATH *partition_path, *disk_path, *copy;
|
||||
UINT32 found_partition_number = (UINT32) -1;
|
||||
UINT64 found_partition_start = (UINT64) -1;
|
||||
UINT64 found_partition_size = (UINT64) -1;
|
||||
UINT32 found_partition_number = UINT32_MAX;
|
||||
UINT64 found_partition_start = UINT64_MAX;
|
||||
UINT64 found_partition_size = UINT64_MAX;
|
||||
UINT8 found_partition_signature[16] = {};
|
||||
EFI_HANDLE new_device;
|
||||
EFI_FILE *root_dir;
|
||||
@ -2053,7 +2053,7 @@ static VOID config_load_xbootldr(
|
||||
continue;
|
||||
|
||||
/* Calculate CRC check */
|
||||
c = ~crc32_exclude_offset((UINT32) -1,
|
||||
c = ~crc32_exclude_offset(UINT32_MAX,
|
||||
(const UINT8*) &gpt_header_buffer,
|
||||
h->Header.HeaderSize,
|
||||
OFFSETOF(EFI_PARTITION_TABLE_HEADER, Header.CRC32),
|
||||
@ -2087,7 +2087,7 @@ static VOID config_load_xbootldr(
|
||||
continue;
|
||||
|
||||
/* Calculate CRC of entries array, too */
|
||||
c = ~crc32((UINT32) -1, entries, sz);
|
||||
c = ~crc32(UINT32_MAX, entries, sz);
|
||||
if (c != h->PartitionEntryArrayCRC32)
|
||||
continue;
|
||||
|
||||
|
@ -67,5 +67,11 @@ static inline void FileHandleClosep(EFI_FILE_HANDLE *handle) {
|
||||
|
||||
#define UINTN_MAX (~(UINTN)0)
|
||||
#define INTN_MAX ((INTN)(UINTN_MAX>>1))
|
||||
#ifndef UINT32_MAX
|
||||
#define UINT32_MAX ((UINT32) -1)
|
||||
#endif
|
||||
#ifndef UINT64_MAX
|
||||
#define UINT64_MAX ((UINT64) -1)
|
||||
#endif
|
||||
|
||||
EFI_STATUS log_oom(void);
|
||||
|
@ -211,7 +211,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set empty string: %m");
|
||||
|
||||
r = table_set_sort(table, (size_t) COLUMN_NAME, (size_t) -1);
|
||||
r = table_set_sort(table, (size_t) COLUMN_NAME);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set sort column: %m");
|
||||
|
||||
@ -224,8 +224,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
(size_t) COLUMN_UNIT,
|
||||
(size_t) COLUMN_SESSION,
|
||||
(size_t) COLUMN_DESCRIPTION,
|
||||
(size_t) COLUMN_MACHINE,
|
||||
(size_t) -1);
|
||||
(size_t) COLUMN_MACHINE);
|
||||
else
|
||||
r = table_set_display(table, (size_t) COLUMN_NAME,
|
||||
(size_t) COLUMN_PID,
|
||||
@ -234,8 +233,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
|
||||
(size_t) COLUMN_CONNECTION,
|
||||
(size_t) COLUMN_UNIT,
|
||||
(size_t) COLUMN_SESSION,
|
||||
(size_t) COLUMN_DESCRIPTION,
|
||||
(size_t) -1);
|
||||
(size_t) COLUMN_DESCRIPTION);
|
||||
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to set columns to display: %m");
|
||||
@ -1330,7 +1328,7 @@ static int monitor(int argc, char **argv, int (*dump)(sd_bus_message *m, FILE *f
|
||||
if (r > 0)
|
||||
continue;
|
||||
|
||||
r = sd_bus_wait(bus, (uint64_t) -1);
|
||||
r = sd_bus_wait(bus, UINT64_MAX);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to wait for bus: %m");
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ typedef struct Group {
|
||||
} Group;
|
||||
|
||||
static unsigned arg_depth = 3;
|
||||
static unsigned arg_iterations = (unsigned) -1;
|
||||
static unsigned arg_iterations = UINT_MAX;
|
||||
static bool arg_batch = false;
|
||||
static bool arg_raw = false;
|
||||
static usec_t arg_delay = 1*USEC_PER_SEC;
|
||||
@ -943,7 +943,7 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
signal(SIGWINCH, columns_lines_cache_reset);
|
||||
|
||||
if (arg_iterations == (unsigned) -1)
|
||||
if (arg_iterations == UINT_MAX)
|
||||
arg_iterations = on_tty() ? 0 : 1;
|
||||
|
||||
while (!quit) {
|
||||
@ -953,7 +953,7 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
t = now(CLOCK_MONOTONIC);
|
||||
|
||||
if (t >= last_refresh + arg_delay || immediate_refresh) {
|
||||
if (t >= usec_add(last_refresh, arg_delay) || immediate_refresh) {
|
||||
|
||||
r = refresh(root, a, b, iteration++);
|
||||
if (r < 0)
|
||||
@ -976,9 +976,9 @@ static int run(int argc, char *argv[]) {
|
||||
fflush(stdout);
|
||||
|
||||
if (arg_batch)
|
||||
(void) usleep(last_refresh + arg_delay - t);
|
||||
(void) usleep(usec_add(usec_sub_unsigned(last_refresh, t), arg_delay));
|
||||
else {
|
||||
r = read_one_char(stdin, &key, last_refresh + arg_delay - t, NULL);
|
||||
r = read_one_char(stdin, &key, usec_add(usec_sub_unsigned(last_refresh, t), arg_delay), NULL);
|
||||
if (r == -ETIMEDOUT)
|
||||
continue;
|
||||
if (r < 0)
|
||||
@ -1053,10 +1053,7 @@ static int run(int argc, char *argv[]) {
|
||||
break;
|
||||
|
||||
case '+':
|
||||
if (arg_delay < USEC_PER_SEC)
|
||||
arg_delay += USEC_PER_MSEC*250;
|
||||
else
|
||||
arg_delay += USEC_PER_SEC;
|
||||
arg_delay = usec_add(arg_delay, arg_delay < USEC_PER_SEC ? USEC_PER_MSEC * 250 : USEC_PER_SEC);
|
||||
|
||||
fprintf(stdout, "\nIncreased delay to %s.", format_timespan(h, sizeof(h), arg_delay, 0));
|
||||
fflush(stdout);
|
||||
@ -1066,10 +1063,8 @@ static int run(int argc, char *argv[]) {
|
||||
case '-':
|
||||
if (arg_delay <= USEC_PER_MSEC*500)
|
||||
arg_delay = USEC_PER_MSEC*250;
|
||||
else if (arg_delay < USEC_PER_MSEC*1250)
|
||||
arg_delay -= USEC_PER_MSEC*250;
|
||||
else
|
||||
arg_delay -= USEC_PER_SEC;
|
||||
arg_delay = usec_sub_unsigned(arg_delay, arg_delay < USEC_PER_MSEC * 1250 ? USEC_PER_MSEC * 250 : USEC_PER_SEC);
|
||||
|
||||
fprintf(stdout, "\nDecreased delay to %s.", format_timespan(h, sizeof(h), arg_delay, 0));
|
||||
fflush(stdout);
|
||||
|
@ -3309,7 +3309,7 @@ int bus_exec_context_set_transient_property(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (rl == (uint64_t) -1)
|
||||
if (rl == UINT64_MAX)
|
||||
x = RLIM_INFINITY;
|
||||
else {
|
||||
x = (rlim_t) rl;
|
||||
|
@ -1069,7 +1069,7 @@ static int property_get_current_memory(
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
uint64_t sz = (uint64_t) -1;
|
||||
uint64_t sz = UINT64_MAX;
|
||||
Unit *u = userdata;
|
||||
int r;
|
||||
|
||||
@ -1093,7 +1093,7 @@ static int property_get_current_tasks(
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
uint64_t cn = (uint64_t) -1;
|
||||
uint64_t cn = UINT64_MAX;
|
||||
Unit *u = userdata;
|
||||
int r;
|
||||
|
||||
@ -1117,7 +1117,7 @@ static int property_get_cpu_usage(
|
||||
void *userdata,
|
||||
sd_bus_error *error) {
|
||||
|
||||
nsec_t ns = (nsec_t) -1;
|
||||
nsec_t ns = NSEC_INFINITY;
|
||||
Unit *u = userdata;
|
||||
int r;
|
||||
|
||||
|
@ -2508,7 +2508,7 @@ static int write_credential(
|
||||
* user can no longer chmod() the file to gain write access. */
|
||||
return r;
|
||||
|
||||
if (fchown(fd, uid, (gid_t) -1) < 0)
|
||||
if (fchown(fd, uid, GID_INVALID) < 0)
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
@ -2626,7 +2626,7 @@ static int acquire_credentials(
|
||||
if (!ownership_ok)
|
||||
return r;
|
||||
|
||||
if (fchown(dfd, uid, (gid_t) -1) < 0)
|
||||
if (fchown(dfd, uid, GID_INVALID) < 0)
|
||||
return -errno;
|
||||
}
|
||||
}
|
||||
|
@ -1094,7 +1094,7 @@ int config_parse_exec_input_data(
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = unbase64mem(rvalue, (size_t) -1, &p, &sz);
|
||||
r = unbase64mem(rvalue, SIZE_MAX, &p, &sz);
|
||||
if (r < 0) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, r,
|
||||
"Failed to decode base64 data, ignoring: %s", rvalue);
|
||||
|
@ -544,7 +544,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
|
||||
if (proc_cmdline_value_missing(key, value))
|
||||
return 0;
|
||||
|
||||
r = unbase64mem(value, (size_t) -1, &p, &sz);
|
||||
r = unbase64mem(value, SIZE_MAX, &p, &sz);
|
||||
if (r < 0)
|
||||
log_warning_errno(r, "Failed to parse systemd.random_seed= argument, ignoring: %s", value);
|
||||
|
||||
|
@ -2200,7 +2200,7 @@ static unsigned manager_dispatch_dbus_queue(Manager *m) {
|
||||
/* When we are reloading, let's not wait with generating signals, since we need to exit the manager as quickly
|
||||
* as we can. There's no point in throttling generation of signals in that case. */
|
||||
if (MANAGER_IS_RELOADING(m) || m->send_reloading_done || m->pending_reload_message)
|
||||
budget = (unsigned) -1; /* infinite budget in this case */
|
||||
budget = UINT_MAX; /* infinite budget in this case */
|
||||
else {
|
||||
/* Anything to do at all? */
|
||||
if (!m->dbus_unit_queue && !m->dbus_job_queue)
|
||||
@ -2232,7 +2232,7 @@ static unsigned manager_dispatch_dbus_queue(Manager *m) {
|
||||
bus_unit_send_change_signal(u);
|
||||
n++;
|
||||
|
||||
if (budget != (unsigned) -1)
|
||||
if (budget != UINT_MAX)
|
||||
budget--;
|
||||
}
|
||||
|
||||
@ -2242,7 +2242,7 @@ static unsigned manager_dispatch_dbus_queue(Manager *m) {
|
||||
bus_job_send_change_signal(j);
|
||||
n++;
|
||||
|
||||
if (budget != (unsigned) -1)
|
||||
if (budget != UINT_MAX)
|
||||
budget--;
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ static void socket_init(Unit *u) {
|
||||
s->control_command_id = _SOCKET_EXEC_COMMAND_INVALID;
|
||||
|
||||
s->trigger_limit.interval = USEC_INFINITY;
|
||||
s->trigger_limit.burst = (unsigned) -1;
|
||||
s->trigger_limit.burst = UINT_MAX;
|
||||
}
|
||||
|
||||
static void socket_unwatch_control_pid(Socket *s) {
|
||||
@ -313,7 +313,7 @@ static int socket_add_extras(Socket *s) {
|
||||
if (s->trigger_limit.interval == USEC_INFINITY)
|
||||
s->trigger_limit.interval = 2 * USEC_PER_SEC;
|
||||
|
||||
if (s->trigger_limit.burst == (unsigned) -1) {
|
||||
if (s->trigger_limit.burst == UINT_MAX) {
|
||||
if (s->accept)
|
||||
s->trigger_limit.burst = 200;
|
||||
else
|
||||
|
@ -66,7 +66,7 @@ static int uid_from_file_name(const char *filename, uid_t *uid) {
|
||||
}
|
||||
|
||||
static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t max_use) {
|
||||
uint64_t fs_size = 0, fs_free = (uint64_t) -1;
|
||||
uint64_t fs_size = 0, fs_free = UINT64_MAX;
|
||||
struct statvfs sv;
|
||||
|
||||
assert(fd >= 0);
|
||||
@ -76,7 +76,7 @@ static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t
|
||||
fs_free = sv.f_frsize * sv.f_bfree;
|
||||
}
|
||||
|
||||
if (max_use == (uint64_t) -1) {
|
||||
if (max_use == UINT64_MAX) {
|
||||
|
||||
if (fs_size > 0) {
|
||||
max_use = PAGE_ALIGN(fs_size / 10); /* 10% */
|
||||
@ -94,7 +94,7 @@ static bool vacuum_necessary(int fd, uint64_t sum, uint64_t keep_free, uint64_t
|
||||
if (max_use > 0 && sum > max_use)
|
||||
return true;
|
||||
|
||||
if (keep_free == (uint64_t) -1) {
|
||||
if (keep_free == UINT64_MAX) {
|
||||
|
||||
if (fs_size > 0) {
|
||||
keep_free = PAGE_ALIGN((fs_size * 3) / 20); /* 15% */
|
||||
|
@ -141,8 +141,8 @@ static bool arg_compress = true;
|
||||
static uint64_t arg_process_size_max = PROCESS_SIZE_MAX;
|
||||
static uint64_t arg_external_size_max = EXTERNAL_SIZE_MAX;
|
||||
static uint64_t arg_journal_size_max = JOURNAL_SIZE_MAX;
|
||||
static uint64_t arg_keep_free = (uint64_t) -1;
|
||||
static uint64_t arg_max_use = (uint64_t) -1;
|
||||
static uint64_t arg_keep_free = UINT64_MAX;
|
||||
static uint64_t arg_max_use = UINT64_MAX;
|
||||
|
||||
static int parse_config(void) {
|
||||
static const ConfigTableItem items[] = {
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
if (coredump_vacuum(-1, (uint64_t) -1, 70 * 1024) < 0)
|
||||
if (coredump_vacuum(-1, UINT64_MAX, 70 * 1024) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
return EXIT_SUCCESS;
|
||||
|
@ -42,7 +42,7 @@ static int search_policy_hash(
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"TPM2 token data lacks 'tpm2-policy-hash' field.");
|
||||
|
||||
r = unhexmem(json_variant_string(w), (size_t) -1, &thash, &thash_size);
|
||||
r = unhexmem(json_variant_string(w), SIZE_MAX, &thash, &thash_size);
|
||||
if (r < 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid base64 data in 'tpm2-policy-hash' field.");
|
||||
|
@ -138,7 +138,7 @@ int find_fido2_auto_data(
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"FIDO2 token data lacks 'fido2-credential' field.");
|
||||
|
||||
r = unbase64mem(json_variant_string(w), (size_t) -1, &cid, &cid_size);
|
||||
r = unbase64mem(json_variant_string(w), SIZE_MAX, &cid, &cid_size);
|
||||
if (r < 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid base64 data in 'fido2-credential' field.");
|
||||
@ -150,7 +150,7 @@ int find_fido2_auto_data(
|
||||
|
||||
assert(!salt);
|
||||
assert(salt_size == 0);
|
||||
r = unbase64mem(json_variant_string(w), (size_t) -1, &salt, &salt_size);
|
||||
r = unbase64mem(json_variant_string(w), SIZE_MAX, &salt, &salt_size);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to decode base64 encoded salt.");
|
||||
|
||||
|
@ -214,7 +214,7 @@ int find_pkcs11_auto_data(
|
||||
|
||||
assert(!key);
|
||||
assert(key_size == 0);
|
||||
r = unbase64mem(json_variant_string(w), (size_t) -1, &key, &key_size);
|
||||
r = unbase64mem(json_variant_string(w), SIZE_MAX, &key, &key_size);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to decode base64 encoded key.");
|
||||
|
||||
|
@ -125,7 +125,7 @@ int find_tpm2_auto_data(
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"TPM2 token data lacks 'tpm2-blob' field.");
|
||||
|
||||
r = unbase64mem(json_variant_string(w), (size_t) -1, &blob, &blob_size);
|
||||
r = unbase64mem(json_variant_string(w), SIZE_MAX, &blob, &blob_size);
|
||||
if (r < 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid base64 data in 'tpm2-blob' field.");
|
||||
@ -136,7 +136,7 @@ int find_tpm2_auto_data(
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"TPM2 token data lacks 'tpm2-policy-hash' field.");
|
||||
|
||||
r = unhexmem(json_variant_string(w), (size_t) -1, &policy_hash, &policy_hash_size);
|
||||
r = unhexmem(json_variant_string(w), SIZE_MAX, &policy_hash, &policy_hash_size);
|
||||
if (r < 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Invalid base64 data in 'tpm2-policy-hash' field.");
|
||||
|
@ -320,7 +320,7 @@ static int parse_one_option(const char *option) {
|
||||
_cleanup_free_ void *cid = NULL;
|
||||
size_t cid_size;
|
||||
|
||||
r = unbase64mem(val, (size_t) -1, &cid, &cid_size);
|
||||
r = unbase64mem(val, SIZE_MAX, &cid, &cid_size);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to decode FIDO2 CID data: %m");
|
||||
|
||||
@ -1503,10 +1503,9 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
flags = determine_flags();
|
||||
|
||||
if (arg_timeout == USEC_INFINITY)
|
||||
until = usec_add(now(CLOCK_MONOTONIC), arg_timeout);
|
||||
if (until == USEC_INFINITY)
|
||||
until = 0;
|
||||
else
|
||||
until = now(CLOCK_MONOTONIC) + arg_timeout;
|
||||
|
||||
arg_key_size = (arg_key_size > 0 ? arg_key_size : (256 / 8));
|
||||
|
||||
|
@ -627,7 +627,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
|
||||
|
||||
/* Copying to stdout? */
|
||||
if (streq(arg_target, "-")) {
|
||||
r = copy_bytes(source_fd, STDOUT_FILENO, (uint64_t) -1, COPY_REFLINK);
|
||||
r = copy_bytes(source_fd, STDOUT_FILENO, UINT64_MAX, COPY_REFLINK);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to copy bytes from %s in mage '%s' to stdout: %m", arg_source, arg_image);
|
||||
|
||||
@ -653,7 +653,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
|
||||
if (target_fd < 0)
|
||||
return log_error_errno(errno, "Failed to create regular file at target path '%s': %m", arg_target);
|
||||
|
||||
r = copy_bytes(source_fd, target_fd, (uint64_t) -1, COPY_REFLINK);
|
||||
r = copy_bytes(source_fd, target_fd, UINT64_MAX, COPY_REFLINK);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to copy bytes from %s in mage '%s' to '%s': %m", arg_source, arg_image, arg_target);
|
||||
|
||||
@ -684,7 +684,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
|
||||
if (target_fd < 0)
|
||||
return log_error_errno(errno, "Failed to open target file '%s': %m", arg_target);
|
||||
|
||||
r = copy_bytes(STDIN_FILENO, target_fd, (uint64_t) -1, COPY_REFLINK);
|
||||
r = copy_bytes(STDIN_FILENO, target_fd, UINT64_MAX, COPY_REFLINK);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to copy bytes from stdin to '%s' in image '%s': %m", arg_target, arg_image);
|
||||
|
||||
@ -722,7 +722,7 @@ static int action_copy(DissectedImage *m, LoopDevice *d) {
|
||||
if (target_fd < 0)
|
||||
return log_error_errno(errno, "Failed to open target file '%s': %m", arg_target);
|
||||
|
||||
r = copy_bytes(source_fd, target_fd, (uint64_t) -1, COPY_REFLINK);
|
||||
r = copy_bytes(source_fd, target_fd, UINT64_MAX, COPY_REFLINK);
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to copy bytes from '%s' to '%s' in image '%s': %m", arg_source, arg_target, arg_image);
|
||||
|
||||
|
@ -771,7 +771,7 @@ static int write_root_shadow(const char *shadow_path, const char *hashed_passwor
|
||||
.sp_warn = -1,
|
||||
.sp_inact = -1,
|
||||
.sp_expire = -1,
|
||||
.sp_flag = (unsigned long) -1, /* this appears to be what everybody does ... */
|
||||
.sp_flag = ULONG_MAX, /* this appears to be what everybody does ... */
|
||||
};
|
||||
|
||||
if (errno != ENOENT)
|
||||
|
@ -171,7 +171,7 @@ static int list_homes(int argc, char *argv[], void *userdata) {
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
if (table_get_rows(table) > 1 || !FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
|
||||
r = table_set_sort(table, (size_t) 0, (size_t) -1);
|
||||
r = table_set_sort(table, (size_t) 0);
|
||||
if (r < 0)
|
||||
return table_log_sort_error(r);
|
||||
|
||||
|
@ -95,7 +95,7 @@ int raw_export_new(
|
||||
.input_fd = -1,
|
||||
.on_finished = on_finished,
|
||||
.userdata = userdata,
|
||||
.last_percent = (unsigned) -1,
|
||||
.last_percent = UINT_MAX,
|
||||
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
|
||||
};
|
||||
|
||||
|
@ -97,8 +97,8 @@ int tar_export_new(
|
||||
.tar_fd = -1,
|
||||
.on_finished = on_finished,
|
||||
.userdata = userdata,
|
||||
.quota_referenced = (uint64_t) -1,
|
||||
.last_percent = (unsigned) -1,
|
||||
.quota_referenced = UINT64_MAX,
|
||||
.last_percent = UINT_MAX,
|
||||
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
|
||||
};
|
||||
|
||||
@ -120,7 +120,7 @@ static void tar_export_report_progress(TarExport *e) {
|
||||
assert(e);
|
||||
|
||||
/* Do we have any quota info? If not, we don't know anything about the progress */
|
||||
if (e->quota_referenced == (uint64_t) -1)
|
||||
if (e->quota_referenced == UINT64_MAX)
|
||||
return;
|
||||
|
||||
if (e->written_uncompressed >= e->quota_referenced)
|
||||
@ -281,7 +281,7 @@ int tar_export_start(TarExport *e, const char *path, int fd, ImportCompressType
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
e->quota_referenced = (uint64_t) -1;
|
||||
e->quota_referenced = UINT64_MAX;
|
||||
|
||||
if (btrfs_might_be_subvol(&e->st)) {
|
||||
BtrfsQuotaInfo q;
|
||||
|
@ -104,7 +104,7 @@ int raw_import_new(
|
||||
.output_fd = -1,
|
||||
.on_finished = on_finished,
|
||||
.userdata = userdata,
|
||||
.last_percent = (unsigned) -1,
|
||||
.last_percent = UINT_MAX,
|
||||
.image_root = TAKE_PTR(root),
|
||||
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
|
||||
};
|
||||
|
@ -113,7 +113,7 @@ int tar_import_new(
|
||||
.tar_fd = -1,
|
||||
.on_finished = on_finished,
|
||||
.userdata = userdata,
|
||||
.last_percent = (unsigned) -1,
|
||||
.last_percent = UINT_MAX,
|
||||
.image_root = TAKE_PTR(root),
|
||||
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
|
||||
};
|
||||
|
@ -161,7 +161,7 @@ static int transfer_new(Manager *m, Transfer **ret) {
|
||||
.stdin_fd = -1,
|
||||
.stdout_fd = -1,
|
||||
.verify = _IMPORT_VERIFY_INVALID,
|
||||
.progress_percent= (unsigned) -1,
|
||||
.progress_percent= UINT_MAX,
|
||||
};
|
||||
|
||||
id = m->current_transfer_id + 1;
|
||||
@ -186,7 +186,7 @@ static int transfer_new(Manager *m, Transfer **ret) {
|
||||
static double transfer_percent_as_double(Transfer *t) {
|
||||
assert(t);
|
||||
|
||||
if (t->progress_percent == (unsigned) -1)
|
||||
if (t->progress_percent == UINT_MAX)
|
||||
return -DBL_MAX;
|
||||
|
||||
return (double) t->progress_percent / 100.0;
|
||||
|
@ -176,7 +176,7 @@ void pull_job_curl_on_finished(CurlGlue *g, CURL *curl, CURLcode result) {
|
||||
goto finish;
|
||||
}
|
||||
|
||||
if (j->content_length != (uint64_t) -1 &&
|
||||
if (j->content_length != UINT64_MAX &&
|
||||
j->content_length != j->written_compressed) {
|
||||
log_error("Download truncated.");
|
||||
r = -EIO;
|
||||
@ -293,7 +293,7 @@ static int pull_job_write_compressed(PullJob *j, void *p, size_t sz) {
|
||||
if (j->written_compressed + sz > j->compressed_max)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EFBIG), "File overly large, refusing.");
|
||||
|
||||
if (j->content_length != (uint64_t) -1 &&
|
||||
if (j->content_length != UINT64_MAX &&
|
||||
j->written_compressed + sz > j->content_length)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EFBIG),
|
||||
"Content length incorrect.");
|
||||
@ -502,7 +502,7 @@ static size_t pull_job_header_callback(void *contents, size_t size, size_t nmemb
|
||||
if (r > 0) {
|
||||
(void) safe_atou64(length, &j->content_length);
|
||||
|
||||
if (j->content_length != (uint64_t) -1) {
|
||||
if (j->content_length != UINT64_MAX) {
|
||||
char bytes[FORMAT_BYTES_MAX];
|
||||
|
||||
if (j->content_length > j->compressed_max) {
|
||||
@ -604,7 +604,7 @@ int pull_job_new(PullJob **ret, const char *url, CurlGlue *glue, void *userdata)
|
||||
.disk_fd = -1,
|
||||
.userdata = userdata,
|
||||
.glue = glue,
|
||||
.content_length = (uint64_t) -1,
|
||||
.content_length = UINT64_MAX,
|
||||
.start_usec = now(CLOCK_MONOTONIC),
|
||||
.compressed_max = 64LLU * 1024LLU * 1024LLU * 1024LLU, /* 64GB safety limit */
|
||||
.uncompressed_max = 64LLU * 1024LLU * 1024LLU * 1024LLU, /* 64GB safety limit */
|
||||
|
@ -364,7 +364,7 @@ static int raw_pull_make_local_copy(RawPull *i) {
|
||||
* since it reduces fragmentation caused by not allowing in-place writes. */
|
||||
(void) import_set_nocow_and_log(dfd, tp);
|
||||
|
||||
r = copy_bytes(i->raw_job->disk_fd, dfd, (uint64_t) -1, COPY_REFLINK);
|
||||
r = copy_bytes(i->raw_job->disk_fd, dfd, UINT64_MAX, COPY_REFLINK);
|
||||
if (r < 0) {
|
||||
(void) unlink(tp);
|
||||
return log_error_errno(r, "Failed to make writable copy of image: %m");
|
||||
|
@ -471,7 +471,7 @@ static int setup_microhttpd_server(RemoteServer *s,
|
||||
}
|
||||
|
||||
r = sd_event_add_time(s->events, &d->timer_event,
|
||||
CLOCK_MONOTONIC, (uint64_t) -1, 0,
|
||||
CLOCK_MONOTONIC, UINT64_MAX, 0,
|
||||
null_timer_event_handler, d);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to add timer_event: %m");
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include "journal-remote.h"
|
||||
|
||||
static int do_rotate(JournalFile **f, bool compress, bool seal) {
|
||||
int r = journal_file_rotate(f, compress, (uint64_t) -1, seal, NULL);
|
||||
int r = journal_file_rotate(f, compress, UINT64_MAX, seal, NULL);
|
||||
if (r < 0) {
|
||||
if (*f)
|
||||
log_error_errno(r, "Failed to rotate %s: %m", (*f)->path);
|
||||
|
@ -62,7 +62,7 @@ static int open_output(RemoteServer *s, Writer *w, const char* host) {
|
||||
|
||||
r = journal_file_open_reliably(filename,
|
||||
O_RDWR|O_CREAT, 0640,
|
||||
s->compress, (uint64_t) -1, s->seal,
|
||||
s->compress, UINT64_MAX, s->seal,
|
||||
&w->metrics,
|
||||
w->mmap, NULL,
|
||||
NULL, &w->journal);
|
||||
|
@ -399,7 +399,7 @@ int open_journal_for_upload(Uploader *u,
|
||||
return log_error_errno(r, "Failed to register input event: %m");
|
||||
|
||||
log_debug("Listening for journal events on fd:%d, timeout %d",
|
||||
fd, u->timeout == (uint64_t) -1 ? -1 : (int) u->timeout);
|
||||
fd, u->timeout == UINT64_MAX ? -1 : (int) u->timeout);
|
||||
} else
|
||||
log_debug("Not listening for journal events.");
|
||||
|
||||
|
@ -27,7 +27,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
assert_se(stdout_stream_install(&s, stream_fds[0], &stream) >= 0);
|
||||
assert_se(write(stream_fds[1], data, size) == (ssize_t) size);
|
||||
while (ioctl(stream_fds[0], SIOCINQ, &v) == 0 && v)
|
||||
sd_event_run(s.event, (uint64_t) -1);
|
||||
sd_event_run(s.event, UINT64_MAX);
|
||||
if (s.n_stdout_streams)
|
||||
stdout_stream_destroy(stream);
|
||||
server_done(&s);
|
||||
|
@ -69,7 +69,7 @@
|
||||
static size_t cache_max(void) {
|
||||
static size_t cached = -1;
|
||||
|
||||
if (cached == (size_t) -1) {
|
||||
if (cached == SIZE_MAX) {
|
||||
uint64_t mem_total;
|
||||
int r;
|
||||
|
||||
|
@ -105,7 +105,7 @@ static int server_process_entry(
|
||||
*
|
||||
* Note that *remaining is altered on both success and failure. */
|
||||
|
||||
size_t n = 0, j, tn = (size_t) -1, m = 0, entry_size = 0;
|
||||
size_t n = 0, j, tn = SIZE_MAX, m = 0, entry_size = 0;
|
||||
char *identifier = NULL, *message = NULL;
|
||||
struct iovec *iovec = NULL;
|
||||
int priority = LOG_INFO;
|
||||
|
@ -144,7 +144,7 @@ static int cache_space_refresh(Server *s, JournalStorage *storage) {
|
||||
|
||||
ts = now(CLOCK_MONOTONIC);
|
||||
|
||||
if (space->timestamp != 0 && space->timestamp + RECHECK_SPACE_USEC > ts)
|
||||
if (space->timestamp != 0 && usec_add(space->timestamp, RECHECK_SPACE_USEC) > ts)
|
||||
return 0;
|
||||
|
||||
r = determine_path_usage(s, storage->path, &vfs_used, &vfs_avail);
|
||||
@ -1206,7 +1206,7 @@ finish:
|
||||
server_driver_message(s, 0, NULL,
|
||||
LOG_MESSAGE("Time spent on flushing to %s is %s for %u entries.",
|
||||
s->system_storage.path,
|
||||
format_timespan(ts, sizeof(ts), now(CLOCK_MONOTONIC) - start, 0),
|
||||
format_timespan(ts, sizeof(ts), usec_sub_unsigned(now(CLOCK_MONOTONIC), start), 0),
|
||||
n),
|
||||
NULL);
|
||||
|
||||
@ -2187,7 +2187,7 @@ int server_init(Server *s, const char *namespace) {
|
||||
.notify_fd = -1,
|
||||
|
||||
.compress.enabled = true,
|
||||
.compress.threshold_bytes = (uint64_t) -1,
|
||||
.compress.threshold_bytes = UINT64_MAX,
|
||||
.seal = true,
|
||||
|
||||
.set_audit = true,
|
||||
@ -2595,7 +2595,7 @@ int config_parse_compress(
|
||||
|
||||
if (isempty(rvalue)) {
|
||||
compress->enabled = true;
|
||||
compress->threshold_bytes = (uint64_t) -1;
|
||||
compress->threshold_bytes = UINT64_MAX;
|
||||
} else if (streq(rvalue, "1")) {
|
||||
log_syntax(unit, LOG_WARNING, filename, line, 0,
|
||||
"Compress= ambiguously specified as 1, enabling compression with default threshold");
|
||||
|
@ -43,7 +43,7 @@ static void test_config_compress(void) {
|
||||
/* Invalid Case */
|
||||
COMPRESS_PARSE_CHECK("-1", true, 111);
|
||||
COMPRESS_PARSE_CHECK("blah blah", true, 111);
|
||||
COMPRESS_PARSE_CHECK("", true, (uint64_t)-1);
|
||||
COMPRESS_PARSE_CHECK("", true, UINT64_MAX);
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
@ -41,7 +41,7 @@ static void fuzz_client(const uint8_t *data, size_t size, bool is_information_re
|
||||
|
||||
assert_se(write(test_dhcp_fd[1], data, size) == (ssize_t) size);
|
||||
|
||||
sd_event_run(e, (uint64_t) -1);
|
||||
sd_event_run(e, UINT64_MAX);
|
||||
|
||||
assert_se(sd_dhcp6_client_stop(client) >= 0);
|
||||
|
||||
|
@ -53,7 +53,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||
assert_se(sd_ndisc_set_mac(nd, &mac_addr) >= 0);
|
||||
assert_se(sd_ndisc_start(nd) >= 0);
|
||||
assert_se(write(test_fd[1], data, size) == (ssize_t) size);
|
||||
(void) sd_event_run(e, (uint64_t) -1);
|
||||
(void) sd_event_run(e, UINT64_MAX);
|
||||
assert_se(sd_ndisc_stop(nd) >= 0);
|
||||
close(test_fd[1]);
|
||||
|
||||
|
@ -22,7 +22,7 @@ int lldp_network_bind_raw_socket(int ifindex) {
|
||||
BPF_STMT(BPF_LD + BPF_H + BPF_ABS, offsetof(struct ethhdr, h_proto)), /* A <- protocol */
|
||||
BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, ETHERTYPE_LLDP, 1, 0), /* A != ETHERTYPE_LLDP */
|
||||
BPF_STMT(BPF_RET + BPF_K, 0), /* drop packet */
|
||||
BPF_STMT(BPF_RET + BPF_K, (uint32_t) -1), /* accept packet */
|
||||
BPF_STMT(BPF_RET + BPF_K, UINT32_MAX), /* accept packet */
|
||||
};
|
||||
|
||||
static const struct sock_fprog fprog = {
|
||||
|
@ -2229,7 +2229,7 @@ int sd_dhcp_client_new(sd_dhcp_client **ret, int anonymize) {
|
||||
.mtu = DHCP_DEFAULT_MIN_SIZE,
|
||||
.port = DHCP_PORT_CLIENT,
|
||||
.anonymize = !!anonymize,
|
||||
.max_attempts = (uint64_t) -1,
|
||||
.max_attempts = UINT64_MAX,
|
||||
.ip_service_type = -1,
|
||||
};
|
||||
/* NOTE: this could be moved to a function. */
|
||||
|
@ -1257,13 +1257,13 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
|
||||
}
|
||||
|
||||
if (client_id_hex) {
|
||||
r = unhexmem(client_id_hex, (size_t) -1, &lease->client_id, &lease->client_id_len);
|
||||
r = unhexmem(client_id_hex, SIZE_MAX, &lease->client_id, &lease->client_id_len);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to parse client ID %s, ignoring: %m", client_id_hex);
|
||||
}
|
||||
|
||||
if (vendor_specific_hex) {
|
||||
r = unhexmem(vendor_specific_hex, (size_t) -1, &lease->vendor_specific, &lease->vendor_specific_len);
|
||||
r = unhexmem(vendor_specific_hex, SIZE_MAX, &lease->vendor_specific, &lease->vendor_specific_len);
|
||||
if (r < 0)
|
||||
log_debug_errno(r, "Failed to parse vendor specific data %s, ignoring: %m", vendor_specific_hex);
|
||||
}
|
||||
@ -1275,7 +1275,7 @@ int dhcp_lease_load(sd_dhcp_lease **ret, const char *lease_file) {
|
||||
if (!options[i])
|
||||
continue;
|
||||
|
||||
r = unhexmem(options[i], (size_t) -1, &data, &len);
|
||||
r = unhexmem(options[i], SIZE_MAX, &data, &len);
|
||||
if (r < 0) {
|
||||
log_debug_errno(r, "Failed to parse private DHCP option %s, ignoring: %m", options[i]);
|
||||
continue;
|
||||
|
@ -373,7 +373,7 @@ _public_ int sd_lldp_new(sd_lldp **ret) {
|
||||
.n_ref = 1,
|
||||
.fd = -1,
|
||||
.neighbors_max = LLDP_DEFAULT_NEIGHBORS_MAX,
|
||||
.capability_mask = (uint16_t) -1,
|
||||
.capability_mask = UINT16_MAX,
|
||||
};
|
||||
|
||||
lldp->neighbor_by_id = hashmap_new(&lldp_neighbor_hash_ops);
|
||||
|
@ -308,7 +308,7 @@ static void test_discover_message(sd_event *e) {
|
||||
|
||||
assert_se(IN_SET(res, 0, -EINPROGRESS));
|
||||
|
||||
sd_event_run(e, (uint64_t) -1);
|
||||
sd_event_run(e, UINT64_MAX);
|
||||
|
||||
sd_dhcp_client_stop(client);
|
||||
sd_dhcp_client_unref(client);
|
||||
|
@ -160,25 +160,25 @@ static void test_basic_request(sd_event *e) {
|
||||
assert_se(sd_ipv4ll_set_ifindex(ll, 1) == 0);
|
||||
assert_se(sd_ipv4ll_start(ll) == 1);
|
||||
|
||||
sd_event_run(e, (uint64_t) -1);
|
||||
sd_event_run(e, UINT64_MAX);
|
||||
assert_se(sd_ipv4ll_start(ll) == 0);
|
||||
|
||||
assert_se(sd_ipv4ll_is_running(ll));
|
||||
|
||||
/* PROBE */
|
||||
sd_event_run(e, (uint64_t) -1);
|
||||
sd_event_run(e, UINT64_MAX);
|
||||
assert_se(recv(test_fd[1], &arp, sizeof(struct ether_arp), 0) == sizeof(struct ether_arp));
|
||||
|
||||
if (extended) {
|
||||
/* PROBE */
|
||||
sd_event_run(e, (uint64_t) -1);
|
||||
sd_event_run(e, UINT64_MAX);
|
||||
assert_se(recv(test_fd[1], &arp, sizeof(struct ether_arp), 0) == sizeof(struct ether_arp));
|
||||
|
||||
/* PROBE */
|
||||
sd_event_run(e, (uint64_t) -1);
|
||||
sd_event_run(e, UINT64_MAX);
|
||||
assert_se(recv(test_fd[1], &arp, sizeof(struct ether_arp), 0) == sizeof(struct ether_arp));
|
||||
|
||||
sd_event_run(e, (uint64_t) -1);
|
||||
sd_event_run(e, UINT64_MAX);
|
||||
assert_se(basic_request_handler_bind == 1);
|
||||
}
|
||||
|
||||
|
@ -741,7 +741,7 @@ _public_ int sd_bus_get_owner_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **r
|
||||
mask &= ~SD_BUS_CREDS_AUGMENT;
|
||||
|
||||
do_label = bus->label && (mask & SD_BUS_CREDS_SELINUX_CONTEXT);
|
||||
do_groups = bus->n_groups != (size_t) -1 && (mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS);
|
||||
do_groups = bus->n_groups != SIZE_MAX && (mask & SD_BUS_CREDS_SUPPLEMENTARY_GIDS);
|
||||
|
||||
/* Avoid allocating anything if we have no chance of returning useful data */
|
||||
if (!bus->ucred_valid && !do_label && !do_groups)
|
||||
|
@ -81,7 +81,7 @@ _public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
|
||||
m->header->version);
|
||||
|
||||
/* Display synthetic message serial number in a more readable
|
||||
* format than (uint32_t) -1 */
|
||||
* format than UINT32_MAX */
|
||||
if (BUS_MESSAGE_COOKIE(m) == 0xFFFFFFFFULL)
|
||||
fprintf(f, " Cookie=-1");
|
||||
else
|
||||
|
@ -162,7 +162,7 @@ static void *message_extend_fields(sd_bus_message *m, size_t align, size_t sz, b
|
||||
new_size = start + sz;
|
||||
|
||||
if (new_size < start ||
|
||||
new_size > (size_t) ((uint32_t) -1))
|
||||
new_size > (size_t) (UINT32_MAX))
|
||||
goto poison;
|
||||
|
||||
if (old_size == new_size)
|
||||
@ -1337,7 +1337,7 @@ static void *message_extend_body(
|
||||
added = padding + sz;
|
||||
|
||||
/* Check for 32bit overflows */
|
||||
if (end_body > (size_t) ((uint32_t) -1) ||
|
||||
if (end_body > (size_t) (UINT32_MAX) ||
|
||||
end_body < start_body) {
|
||||
m->poisoned = true;
|
||||
return NULL;
|
||||
@ -2340,13 +2340,13 @@ _public_ int sd_bus_message_appendv(
|
||||
assert_return(!m->sealed, -EPERM);
|
||||
assert_return(!m->poisoned, -ESTALE);
|
||||
|
||||
n_array = (unsigned) -1;
|
||||
n_array = UINT_MAX;
|
||||
n_struct = strlen(types);
|
||||
|
||||
for (;;) {
|
||||
const char *t;
|
||||
|
||||
if (n_array == 0 || (n_array == (unsigned) -1 && n_struct == 0)) {
|
||||
if (n_array == 0 || (n_array == UINT_MAX && n_struct == 0)) {
|
||||
r = type_stack_pop(stack, ELEMENTSOF(stack), &stack_ptr, &types, &n_struct, &n_array);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -2361,7 +2361,7 @@ _public_ int sd_bus_message_appendv(
|
||||
}
|
||||
|
||||
t = types;
|
||||
if (n_array != (unsigned) -1)
|
||||
if (n_array != UINT_MAX)
|
||||
n_array--;
|
||||
else {
|
||||
types++;
|
||||
@ -2445,7 +2445,7 @@ _public_ int sd_bus_message_appendv(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (n_array == (unsigned) -1) {
|
||||
if (n_array == UINT_MAX) {
|
||||
types += k;
|
||||
n_struct -= k;
|
||||
}
|
||||
@ -2478,7 +2478,7 @@ _public_ int sd_bus_message_appendv(
|
||||
|
||||
types = s;
|
||||
n_struct = strlen(s);
|
||||
n_array = (unsigned) -1;
|
||||
n_array = UINT_MAX;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -2502,7 +2502,7 @@ _public_ int sd_bus_message_appendv(
|
||||
return r;
|
||||
}
|
||||
|
||||
if (n_array == (unsigned) -1) {
|
||||
if (n_array == UINT_MAX) {
|
||||
types += k - 1;
|
||||
n_struct -= k - 1;
|
||||
}
|
||||
@ -2513,7 +2513,7 @@ _public_ int sd_bus_message_appendv(
|
||||
|
||||
types = t + 1;
|
||||
n_struct = k - 2;
|
||||
n_array = (unsigned) -1;
|
||||
n_array = UINT_MAX;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -2675,7 +2675,7 @@ _public_ int sd_bus_message_append_array_memfd(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (offset == 0 && size == (uint64_t) -1)
|
||||
if (offset == 0 && size == UINT64_MAX)
|
||||
size = real_size;
|
||||
else if (offset + size > real_size)
|
||||
return -EMSGSIZE;
|
||||
@ -2692,7 +2692,7 @@ _public_ int sd_bus_message_append_array_memfd(
|
||||
if (size % sz != 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (size > (uint64_t) (uint32_t) -1)
|
||||
if (size > (uint64_t) UINT32_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
r = sd_bus_message_open_container(m, SD_BUS_TYPE_ARRAY, CHAR_TO_STR(type));
|
||||
@ -2750,7 +2750,7 @@ _public_ int sd_bus_message_append_string_memfd(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (offset == 0 && size == (uint64_t) -1)
|
||||
if (offset == 0 && size == UINT64_MAX)
|
||||
size = real_size;
|
||||
else if (offset + size > real_size)
|
||||
return -EMSGSIZE;
|
||||
@ -2759,7 +2759,7 @@ _public_ int sd_bus_message_append_string_memfd(
|
||||
if (size == 0)
|
||||
return -EINVAL;
|
||||
|
||||
if (size > (uint64_t) (uint32_t) -1)
|
||||
if (size > (uint64_t) UINT32_MAX)
|
||||
return -EINVAL;
|
||||
|
||||
c = message_get_last_container(m);
|
||||
@ -4430,7 +4430,7 @@ _public_ int sd_bus_message_readv(
|
||||
* in a single stackframe. We hence implement our own
|
||||
* home-grown stack in an array. */
|
||||
|
||||
n_array = (unsigned) -1; /* length of current array entries */
|
||||
n_array = UINT_MAX; /* length of current array entries */
|
||||
n_struct = strlen(types); /* length of current struct contents signature */
|
||||
|
||||
for (;;) {
|
||||
@ -4438,7 +4438,7 @@ _public_ int sd_bus_message_readv(
|
||||
|
||||
n_loop++;
|
||||
|
||||
if (n_array == 0 || (n_array == (unsigned) -1 && n_struct == 0)) {
|
||||
if (n_array == 0 || (n_array == UINT_MAX && n_struct == 0)) {
|
||||
r = type_stack_pop(stack, ELEMENTSOF(stack), &stack_ptr, &types, &n_struct, &n_array);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -4453,7 +4453,7 @@ _public_ int sd_bus_message_readv(
|
||||
}
|
||||
|
||||
t = types;
|
||||
if (n_array != (unsigned) -1)
|
||||
if (n_array != UINT_MAX)
|
||||
n_array--;
|
||||
else {
|
||||
types++;
|
||||
@ -4514,7 +4514,7 @@ _public_ int sd_bus_message_readv(
|
||||
}
|
||||
}
|
||||
|
||||
if (n_array == (unsigned) -1) {
|
||||
if (n_array == UINT_MAX) {
|
||||
types += k;
|
||||
n_struct -= k;
|
||||
}
|
||||
@ -4553,7 +4553,7 @@ _public_ int sd_bus_message_readv(
|
||||
|
||||
types = s;
|
||||
n_struct = strlen(s);
|
||||
n_array = (unsigned) -1;
|
||||
n_array = UINT_MAX;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -4581,7 +4581,7 @@ _public_ int sd_bus_message_readv(
|
||||
}
|
||||
}
|
||||
|
||||
if (n_array == (unsigned) -1) {
|
||||
if (n_array == UINT_MAX) {
|
||||
types += k - 1;
|
||||
n_struct -= k - 1;
|
||||
}
|
||||
@ -4592,7 +4592,7 @@ _public_ int sd_bus_message_readv(
|
||||
|
||||
types = t + 1;
|
||||
n_struct = k - 2;
|
||||
n_array = (unsigned) -1;
|
||||
n_array = UINT_MAX;
|
||||
|
||||
break;
|
||||
}
|
||||
@ -5034,7 +5034,7 @@ static int message_skip_fields(
|
||||
char t;
|
||||
size_t l;
|
||||
|
||||
if (array_size != (uint32_t) -1 &&
|
||||
if (array_size != UINT32_MAX &&
|
||||
array_size <= *ri - original_index)
|
||||
return 0;
|
||||
|
||||
@ -5122,7 +5122,7 @@ static int message_skip_fields(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
r = message_skip_fields(m, ri, (uint32_t) -1, (const char**) &s);
|
||||
r = message_skip_fields(m, ri, UINT32_MAX, (const char**) &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -5140,7 +5140,7 @@ static int message_skip_fields(
|
||||
strncpy(sig, *signature + 1, l);
|
||||
sig[l] = '\0';
|
||||
|
||||
r = message_skip_fields(m, ri, (uint32_t) -1, (const char**) &s);
|
||||
r = message_skip_fields(m, ri, UINT32_MAX, (const char**) &s);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@ -5247,7 +5247,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
|
||||
_cleanup_free_ char *sig = NULL;
|
||||
const char *signature;
|
||||
uint64_t field_type;
|
||||
size_t item_size = (size_t) -1;
|
||||
size_t item_size = SIZE_MAX;
|
||||
|
||||
if (BUS_MESSAGE_IS_GVARIANT(m)) {
|
||||
uint64_t *u64;
|
||||
@ -5461,7 +5461,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
|
||||
|
||||
default:
|
||||
if (!BUS_MESSAGE_IS_GVARIANT(m))
|
||||
r = message_skip_fields(m, &ri, (uint32_t) -1, (const char **) &signature);
|
||||
r = message_skip_fields(m, &ri, UINT32_MAX, (const char **) &signature);
|
||||
}
|
||||
|
||||
if (r < 0)
|
||||
|
@ -620,7 +620,7 @@ static void bus_get_peercred(sd_bus *b) {
|
||||
assert(b);
|
||||
assert(!b->ucred_valid);
|
||||
assert(!b->label);
|
||||
assert(b->n_groups == (size_t) -1);
|
||||
assert(b->n_groups == SIZE_MAX);
|
||||
|
||||
/* Get the peer for socketpair() sockets */
|
||||
b->ucred_valid = getpeercred(b->input_fd, &b->ucred) >= 0;
|
||||
|
@ -247,7 +247,7 @@ _public_ int sd_bus_new(sd_bus **ret) {
|
||||
.creds_mask = SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME,
|
||||
.accept_fd = true,
|
||||
.original_pid = getpid_cached(),
|
||||
.n_groups = (size_t) -1,
|
||||
.n_groups = SIZE_MAX,
|
||||
.close_on_exit = true,
|
||||
};
|
||||
|
||||
@ -1964,8 +1964,8 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) {
|
||||
* hence let's fill something in for synthetic messages. Since
|
||||
* synthetic messages might have a fake sender and we don't
|
||||
* want to interfere with the real sender's serial numbers we
|
||||
* pick a fixed, artificial one. We use (uint32_t) -1 rather
|
||||
* than (uint64_t) -1 since dbus1 only had 32bit identifiers,
|
||||
* pick a fixed, artificial one. We use UINT32_MAX rather
|
||||
* than UINT64_MAX since dbus1 only had 32bit identifiers,
|
||||
* even though kdbus can do 64bit. */
|
||||
return sd_bus_message_seal(m, 0xFFFFFFFFULL, 0);
|
||||
}
|
||||
@ -2205,7 +2205,9 @@ _public_ int sd_bus_send_to(sd_bus *bus, sd_bus_message *m, const char *destinat
|
||||
static usec_t calc_elapse(sd_bus *bus, uint64_t usec) {
|
||||
assert(bus);
|
||||
|
||||
if (usec == (uint64_t) -1)
|
||||
assert_cc(sizeof(usec_t) == sizeof(uint64_t));
|
||||
|
||||
if (usec == USEC_INFINITY)
|
||||
return 0;
|
||||
|
||||
/* We start all timeouts the instant we enter BUS_HELLO/BUS_RUNNING state, so that the don't run in parallel
|
||||
@ -2215,7 +2217,7 @@ static usec_t calc_elapse(sd_bus *bus, uint64_t usec) {
|
||||
if (IN_SET(bus->state, BUS_WATCH_BIND, BUS_OPENING, BUS_AUTHENTICATING))
|
||||
return usec;
|
||||
else
|
||||
return now(CLOCK_MONOTONIC) + usec;
|
||||
return usec_add(now(CLOCK_MONOTONIC), usec);
|
||||
}
|
||||
|
||||
static int timeout_compare(const void *a, const void *b) {
|
||||
@ -2330,7 +2332,7 @@ int bus_ensure_running(sd_bus *bus) {
|
||||
if (r > 0)
|
||||
continue;
|
||||
|
||||
r = sd_bus_wait(bus, (uint64_t) -1);
|
||||
r = sd_bus_wait(bus, UINT64_MAX);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
@ -2458,7 +2460,7 @@ _public_ int sd_bus_call(
|
||||
|
||||
left = timeout - n;
|
||||
} else
|
||||
left = (uint64_t) -1;
|
||||
left = UINT64_MAX;
|
||||
|
||||
r = bus_poll(bus, true, left);
|
||||
if (r < 0)
|
||||
@ -2578,12 +2580,12 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
|
||||
|
||||
c = prioq_peek(bus->reply_callbacks_prioq);
|
||||
if (!c) {
|
||||
*timeout_usec = (uint64_t) -1;
|
||||
*timeout_usec = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (c->timeout_usec == 0) {
|
||||
*timeout_usec = (uint64_t) -1;
|
||||
*timeout_usec = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2596,7 +2598,7 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
|
||||
|
||||
case BUS_WATCH_BIND:
|
||||
case BUS_OPENING:
|
||||
*timeout_usec = (uint64_t) -1;
|
||||
*timeout_usec = UINT64_MAX;
|
||||
return 0;
|
||||
|
||||
default:
|
||||
@ -3308,7 +3310,7 @@ static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout_usec != (uint64_t) -1 && (m == USEC_INFINITY || timeout_usec < m))
|
||||
if (timeout_usec != UINT64_MAX && (m == USEC_INFINITY || timeout_usec < m))
|
||||
m = timeout_usec;
|
||||
|
||||
r = ppoll_usec(p, n, m);
|
||||
@ -3374,7 +3376,7 @@ _public_ int sd_bus_flush(sd_bus *bus) {
|
||||
if (bus->wqueue_size <= 0)
|
||||
return 0;
|
||||
|
||||
r = bus_poll(bus, false, (uint64_t) -1);
|
||||
r = bus_poll(bus, false, UINT64_MAX);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
@ -127,7 +127,7 @@ static int server(sd_bus *bus) {
|
||||
}
|
||||
|
||||
if (r == 0) {
|
||||
r = sd_bus_wait(bus, (uint64_t) -1);
|
||||
r = sd_bus_wait(bus, UINT64_MAX);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to wait: %m");
|
||||
goto fail;
|
||||
@ -472,7 +472,7 @@ static void* client2(void *p) {
|
||||
goto finish;
|
||||
}
|
||||
if (r == 0) {
|
||||
r = sd_bus_wait(bus, (uint64_t) -1);
|
||||
r = sd_bus_wait(bus, UINT64_MAX);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to wait: %m");
|
||||
goto finish;
|
||||
|
@ -255,7 +255,7 @@ static void *server(void *p) {
|
||||
}
|
||||
|
||||
if (r == 0) {
|
||||
r = sd_bus_wait(bus, (uint64_t) -1);
|
||||
r = sd_bus_wait(bus, UINT64_MAX);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to wait: %m");
|
||||
goto fail;
|
||||
|
@ -47,7 +47,7 @@ static void *server(void *p) {
|
||||
}
|
||||
|
||||
if (r == 0) {
|
||||
r = sd_bus_wait(bus, (uint64_t) -1);
|
||||
r = sd_bus_wait(bus, UINT64_MAX);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to wait: %m");
|
||||
goto fail;
|
||||
|
@ -98,7 +98,7 @@ int device_get_devnode_mode(sd_device *device, mode_t *mode) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (device->devmode == (mode_t) -1)
|
||||
if (device->devmode == MODE_INVALID)
|
||||
return -ENOENT;
|
||||
|
||||
if (mode)
|
||||
@ -116,7 +116,7 @@ int device_get_devnode_uid(sd_device *device, uid_t *uid) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (device->devuid == (uid_t) -1)
|
||||
if (device->devuid == UID_INVALID)
|
||||
return -ENOENT;
|
||||
|
||||
if (uid)
|
||||
@ -154,7 +154,7 @@ int device_get_devnode_gid(sd_device *device, gid_t *gid) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (device->devgid == (gid_t) -1)
|
||||
if (device->devgid == GID_INVALID)
|
||||
return -ENOENT;
|
||||
|
||||
if (gid)
|
||||
|
@ -26,6 +26,7 @@
|
||||
#include "string-util.h"
|
||||
#include "strv.h"
|
||||
#include "strxcpyx.h"
|
||||
#include "user-util.h"
|
||||
#include "util.h"
|
||||
|
||||
int device_new_aux(sd_device **ret) {
|
||||
@ -40,9 +41,9 @@ int device_new_aux(sd_device **ret) {
|
||||
*device = (sd_device) {
|
||||
.n_ref = 1,
|
||||
.watch_handle = -1,
|
||||
.devmode = (mode_t) -1,
|
||||
.devuid = (uid_t) -1,
|
||||
.devgid = (gid_t) -1,
|
||||
.devmode = MODE_INVALID,
|
||||
.devuid = UID_INVALID,
|
||||
.devgid = GID_INVALID,
|
||||
.action = _SD_DEVICE_ACTION_INVALID,
|
||||
};
|
||||
|
||||
|
@ -1236,7 +1236,7 @@ _public_ int sd_event_add_time(
|
||||
|
||||
assert_return(e, -EINVAL);
|
||||
assert_return(e = event_resolve(e), -ENOPKG);
|
||||
assert_return(accuracy != (uint64_t) -1, -EINVAL);
|
||||
assert_return(accuracy != UINT64_MAX, -EINVAL);
|
||||
assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
|
||||
assert_return(!event_pid_changed(e), -ECHILD);
|
||||
|
||||
@ -2594,10 +2594,11 @@ _public_ int sd_event_source_set_time_relative(sd_event_source *s, uint64_t usec
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (usec >= USEC_INFINITY - t)
|
||||
usec = usec_add(t, usec);
|
||||
if (usec == USEC_INFINITY)
|
||||
return -EOVERFLOW;
|
||||
|
||||
return sd_event_source_set_time(s, t + usec);
|
||||
return sd_event_source_set_time(s, usec);
|
||||
}
|
||||
|
||||
_public_ int sd_event_source_get_time_accuracy(sd_event_source *s, uint64_t *usec) {
|
||||
@ -2614,7 +2615,7 @@ _public_ int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec
|
||||
int r;
|
||||
|
||||
assert_return(s, -EINVAL);
|
||||
assert_return(usec != (uint64_t) -1, -EINVAL);
|
||||
assert_return(usec != UINT64_MAX, -EINVAL);
|
||||
assert_return(EVENT_SOURCE_IS_TIME(s->type), -EDOM);
|
||||
assert_return(s->event->state != SD_EVENT_FINISHED, -ESTALE);
|
||||
assert_return(!event_pid_changed(s->event), -ECHILD);
|
||||
@ -4082,7 +4083,7 @@ _public_ int sd_event_loop(sd_event *e) {
|
||||
_unused_ _cleanup_(sd_event_unrefp) sd_event *ref = NULL;
|
||||
|
||||
while (e->state != SD_EVENT_FINISHED) {
|
||||
r = sd_event_run(e, (uint64_t) -1);
|
||||
r = sd_event_run(e, UINT64_MAX);
|
||||
if (r < 0)
|
||||
return r;
|
||||
}
|
||||
|
@ -217,7 +217,7 @@ static void test_basic(bool with_pidfd) {
|
||||
got_unref = false;
|
||||
assert_se(sd_event_add_io(e, &t, k[0], EPOLLIN, unref_handler, NULL) >= 0);
|
||||
assert_se(write(k[1], &ch, 1) == 1);
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
assert_se(got_unref);
|
||||
|
||||
got_a = false, got_b = false, got_c = false, got_d = 0;
|
||||
@ -227,10 +227,10 @@ static void test_basic(bool with_pidfd) {
|
||||
assert_se(sd_event_add_io(e, &w, d[0], EPOLLIN, io_handler, INT_TO_PTR('d')) >= 0);
|
||||
assert_se(sd_event_source_set_enabled(w, SD_EVENT_ONESHOT) >= 0);
|
||||
assert_se(write(d[1], &ch, 1) >= 0);
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
assert_se(got_d == 1);
|
||||
assert_se(write(d[1], &ch, 1) >= 0);
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
assert_se(got_d == 2);
|
||||
|
||||
assert_se(sd_event_add_io(e, &x, a[0], EPOLLIN, io_handler, INT_TO_PTR('a')) >= 0);
|
||||
@ -258,15 +258,15 @@ static void test_basic(bool with_pidfd) {
|
||||
|
||||
assert_se(!got_a && !got_b && !got_c);
|
||||
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
|
||||
assert_se(!got_a && got_b && !got_c);
|
||||
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
|
||||
assert_se(!got_a && got_b && got_c);
|
||||
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
|
||||
assert_se(got_a && got_b && got_c);
|
||||
|
||||
@ -357,19 +357,19 @@ static void test_rtqueue(void) {
|
||||
assert_se(n_rtqueue == 0);
|
||||
assert_se(last_rtqueue_sigval == 0);
|
||||
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
assert_se(n_rtqueue == 1);
|
||||
assert_se(last_rtqueue_sigval == 2); /* first SIGRTMIN+3 */
|
||||
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
assert_se(n_rtqueue == 2);
|
||||
assert_se(last_rtqueue_sigval == 4); /* second SIGRTMIN+3 */
|
||||
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
assert_se(n_rtqueue == 3);
|
||||
assert_se(last_rtqueue_sigval == 3); /* first SIGUSR2 */
|
||||
|
||||
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
|
||||
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
|
||||
assert_se(n_rtqueue == 4);
|
||||
assert_se(last_rtqueue_sigval == 1); /* SIGRTMIN+2 */
|
||||
|
||||
|
@ -176,7 +176,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
|
||||
if (ret != LZMA_OK)
|
||||
return -ENOMEM;
|
||||
|
||||
space = MIN(src_size * 2, dst_max ?: (size_t) -1);
|
||||
space = MIN(src_size * 2, dst_max ?: SIZE_MAX);
|
||||
if (!greedy_realloc(dst, dst_alloc_size, space, 1))
|
||||
return -ENOMEM;
|
||||
|
||||
@ -202,7 +202,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
|
||||
return -ENOBUFS;
|
||||
|
||||
used = space - s.avail_out;
|
||||
space = MIN(2 * space, dst_max ?: (size_t) -1);
|
||||
space = MIN(2 * space, dst_max ?: SIZE_MAX);
|
||||
if (!greedy_realloc(dst, dst_alloc_size, space, 1))
|
||||
return -ENOMEM;
|
||||
|
||||
@ -554,7 +554,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
size_t m = sizeof(buf);
|
||||
ssize_t n;
|
||||
|
||||
if (max_bytes != (uint64_t) -1 && (uint64_t) m > max_bytes)
|
||||
if (max_bytes != UINT64_MAX && (uint64_t) m > max_bytes)
|
||||
m = (size_t) max_bytes;
|
||||
|
||||
n = read(fdf, buf, m);
|
||||
@ -566,7 +566,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
s.next_in = buf;
|
||||
s.avail_in = n;
|
||||
|
||||
if (max_bytes != (uint64_t) -1) {
|
||||
if (max_bytes != UINT64_MAX) {
|
||||
assert(max_bytes >= (uint64_t) n);
|
||||
max_bytes -= n;
|
||||
}
|
||||
@ -664,7 +664,7 @@ int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes) {
|
||||
offset += n;
|
||||
total_out += n;
|
||||
|
||||
if (max_bytes != (uint64_t) -1 && total_out > (size_t) max_bytes) {
|
||||
if (max_bytes != UINT64_MAX && total_out > (size_t) max_bytes) {
|
||||
r = log_debug_errno(SYNTHETIC_ERRNO(EFBIG),
|
||||
"Compressed stream longer than %" PRIu64 " bytes", max_bytes);
|
||||
goto cleanup;
|
||||
@ -752,7 +752,7 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
|
||||
|
||||
n = sizeof(out) - s.avail_out;
|
||||
|
||||
if (max_bytes != (uint64_t) -1) {
|
||||
if (max_bytes != UINT64_MAX) {
|
||||
if (max_bytes < (uint64_t) n)
|
||||
return -EFBIG;
|
||||
|
||||
@ -816,7 +816,7 @@ int decompress_stream_lz4(int in, int out, uint64_t max_bytes) {
|
||||
total_in += used;
|
||||
total_out += produced;
|
||||
|
||||
if (max_bytes != (uint64_t) -1 && total_out > (size_t) max_bytes) {
|
||||
if (max_bytes != UINT64_MAX && total_out > (size_t) max_bytes) {
|
||||
log_debug("Decompressed stream longer than %"PRIu64" bytes", max_bytes);
|
||||
r = -EFBIG;
|
||||
goto cleanup;
|
||||
|
@ -1561,7 +1561,7 @@ bool journal_field_valid(const char *p, size_t l, bool allow_protected) {
|
||||
|
||||
http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html */
|
||||
|
||||
if (l == (size_t) -1)
|
||||
if (l == SIZE_MAX)
|
||||
l = strlen(p);
|
||||
|
||||
/* No empty field names */
|
||||
@ -2352,7 +2352,7 @@ static int generic_array_bisect(
|
||||
uint64_t *ret_offset,
|
||||
uint64_t *ret_idx) {
|
||||
|
||||
uint64_t a, p, t = 0, i = 0, last_p = 0, last_index = (uint64_t) -1;
|
||||
uint64_t a, p, t = 0, i = 0, last_p = 0, last_index = UINT64_MAX;
|
||||
bool subtract_one = false;
|
||||
Object *o, *array = NULL;
|
||||
int r;
|
||||
@ -2422,7 +2422,7 @@ static int generic_array_bisect(
|
||||
left = 0;
|
||||
right -= 1;
|
||||
|
||||
if (last_index != (uint64_t) -1) {
|
||||
if (last_index != UINT64_MAX) {
|
||||
assert(last_index <= right);
|
||||
|
||||
/* If we cached the last index we
|
||||
@ -2522,7 +2522,7 @@ static int generic_array_bisect(
|
||||
|
||||
n -= k;
|
||||
t += k;
|
||||
last_index = (uint64_t) -1;
|
||||
last_index = UINT64_MAX;
|
||||
a = le64toh(array->entry_array.next_entry_array_offset);
|
||||
}
|
||||
|
||||
@ -2533,7 +2533,7 @@ found:
|
||||
return 0;
|
||||
|
||||
/* Let's cache this item for the next invocation */
|
||||
chain_cache_put(f->chain_cache, ci, first, a, le64toh(array->entry_array.items[0]), t, subtract_one ? (i > 0 ? i-1 : (uint64_t) -1) : i);
|
||||
chain_cache_put(f->chain_cache, ci, first, a, le64toh(array->entry_array.items[0]), t, subtract_one ? (i > 0 ? i-1 : UINT64_MAX) : i);
|
||||
|
||||
if (subtract_one && i == 0)
|
||||
p = last_p;
|
||||
@ -3447,7 +3447,7 @@ int journal_file_open(
|
||||
#elif HAVE_XZ
|
||||
.compress_xz = compress,
|
||||
#endif
|
||||
.compress_threshold_bytes = compress_threshold_bytes == (uint64_t) -1 ?
|
||||
.compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ?
|
||||
DEFAULT_COMPRESS_THRESHOLD :
|
||||
MAX(MIN_COMPRESS_THRESHOLD, compress_threshold_bytes),
|
||||
#if HAVE_GCRYPT
|
||||
@ -3964,12 +3964,12 @@ void journal_reset_metrics(JournalMetrics *m) {
|
||||
/* Set everything to "pick automatic values". */
|
||||
|
||||
*m = (JournalMetrics) {
|
||||
.min_use = (uint64_t) -1,
|
||||
.max_use = (uint64_t) -1,
|
||||
.min_size = (uint64_t) -1,
|
||||
.max_size = (uint64_t) -1,
|
||||
.keep_free = (uint64_t) -1,
|
||||
.n_max_files = (uint64_t) -1,
|
||||
.min_use = UINT64_MAX,
|
||||
.max_use = UINT64_MAX,
|
||||
.min_size = UINT64_MAX,
|
||||
.max_size = UINT64_MAX,
|
||||
.keep_free = UINT64_MAX,
|
||||
.n_max_files = UINT64_MAX,
|
||||
};
|
||||
}
|
||||
|
||||
@ -3986,7 +3986,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
|
||||
else
|
||||
log_debug_errno(errno, "Failed to determine disk size: %m");
|
||||
|
||||
if (m->max_use == (uint64_t) -1) {
|
||||
if (m->max_use == UINT64_MAX) {
|
||||
|
||||
if (fs_size > 0)
|
||||
m->max_use = CLAMP(PAGE_ALIGN(fs_size / 10), /* 10% of file system size */
|
||||
@ -4000,7 +4000,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
|
||||
m->max_use = JOURNAL_FILE_SIZE_MIN*2;
|
||||
}
|
||||
|
||||
if (m->min_use == (uint64_t) -1) {
|
||||
if (m->min_use == UINT64_MAX) {
|
||||
if (fs_size > 0)
|
||||
m->min_use = CLAMP(PAGE_ALIGN(fs_size / 50), /* 2% of file system size */
|
||||
MIN_USE_LOW, MIN_USE_HIGH);
|
||||
@ -4011,7 +4011,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
|
||||
if (m->min_use > m->max_use)
|
||||
m->min_use = m->max_use;
|
||||
|
||||
if (m->max_size == (uint64_t) -1)
|
||||
if (m->max_size == UINT64_MAX)
|
||||
m->max_size = MIN(PAGE_ALIGN(m->max_use / 8), /* 8 chunks */
|
||||
MAX_SIZE_UPPER);
|
||||
else
|
||||
@ -4025,14 +4025,14 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
|
||||
m->max_use = m->max_size*2;
|
||||
}
|
||||
|
||||
if (m->min_size == (uint64_t) -1)
|
||||
if (m->min_size == UINT64_MAX)
|
||||
m->min_size = JOURNAL_FILE_SIZE_MIN;
|
||||
else
|
||||
m->min_size = CLAMP(PAGE_ALIGN(m->min_size),
|
||||
JOURNAL_FILE_SIZE_MIN,
|
||||
m->max_size ?: UINT64_MAX);
|
||||
|
||||
if (m->keep_free == (uint64_t) -1) {
|
||||
if (m->keep_free == UINT64_MAX) {
|
||||
if (fs_size > 0)
|
||||
m->keep_free = MIN(PAGE_ALIGN(fs_size / 20), /* 5% of file system size */
|
||||
KEEP_FREE_UPPER);
|
||||
@ -4040,7 +4040,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
|
||||
m->keep_free = DEFAULT_KEEP_FREE;
|
||||
}
|
||||
|
||||
if (m->n_max_files == (uint64_t) -1)
|
||||
if (m->n_max_files == UINT64_MAX)
|
||||
m->n_max_files = DEFAULT_N_MAX_FILES;
|
||||
|
||||
log_debug("Fixed min_use=%s max_use=%s max_size=%s min_size=%s keep_free=%s n_max_files=%" PRIu64,
|
||||
|
@ -2542,7 +2542,7 @@ _public_ int sd_journal_get_timeout(sd_journal *j, uint64_t *timeout_usec) {
|
||||
return fd;
|
||||
|
||||
if (!j->on_network) {
|
||||
*timeout_usec = (uint64_t) -1;
|
||||
*timeout_usec = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -2724,13 +2724,10 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (t != (uint64_t) -1) {
|
||||
usec_t n;
|
||||
if (t != UINT64_MAX) {
|
||||
t = usec_sub_unsigned(t, now(CLOCK_MONOTONIC));
|
||||
|
||||
n = now(CLOCK_MONOTONIC);
|
||||
t = t > n ? t - n : 0;
|
||||
|
||||
if (timeout_usec == (uint64_t) -1 || timeout_usec > t)
|
||||
if (timeout_usec == UINT64_MAX || timeout_usec > t)
|
||||
timeout_usec = t;
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ _noreturn_ static void log_assert_errno(const char *text, int error, const char
|
||||
|
||||
static JournalFile *test_open(const char *name) {
|
||||
JournalFile *f;
|
||||
assert_ret(journal_file_open(-1, name, O_RDWR|O_CREAT, 0644, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f));
|
||||
assert_ret(journal_file_open(-1, name, O_RDWR|O_CREAT, 0644, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f));
|
||||
return f;
|
||||
}
|
||||
|
||||
@ -206,7 +206,7 @@ static void test_sequence_numbers(void) {
|
||||
mkdtemp_chdir_chattr(t);
|
||||
|
||||
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0644,
|
||||
true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0);
|
||||
true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &one) == 0);
|
||||
|
||||
append_number(one, 1, &seqnum);
|
||||
printf("seqnum=%"PRIu64"\n", seqnum);
|
||||
@ -223,7 +223,7 @@ static void test_sequence_numbers(void) {
|
||||
memcpy(&seqnum_id, &one->header->seqnum_id, sizeof(sd_id128_t));
|
||||
|
||||
assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0644,
|
||||
true, (uint64_t) -1, false, NULL, NULL, NULL, one, &two) == 0);
|
||||
true, UINT64_MAX, false, NULL, NULL, NULL, one, &two) == 0);
|
||||
|
||||
assert_se(two->header->state == STATE_ONLINE);
|
||||
assert_se(!sd_id128_equal(two->header->file_id, one->header->file_id));
|
||||
@ -254,7 +254,7 @@ static void test_sequence_numbers(void) {
|
||||
seqnum = 0;
|
||||
|
||||
assert_se(journal_file_open(-1, "two.journal", O_RDWR, 0,
|
||||
true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &two) == 0);
|
||||
true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &two) == 0);
|
||||
|
||||
assert_se(sd_id128_equal(two->header->seqnum_id, seqnum_id));
|
||||
|
||||
|
@ -73,9 +73,9 @@ static void run_test(void) {
|
||||
assert_se(chdir(t) >= 0);
|
||||
(void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
|
||||
|
||||
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0);
|
||||
assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &two) == 0);
|
||||
assert_se(journal_file_open(-1, "three.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &three) == 0);
|
||||
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &one) == 0);
|
||||
assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &two) == 0);
|
||||
assert_se(journal_file_open(-1, "three.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &three) == 0);
|
||||
|
||||
for (i = 0; i < N_ENTRIES; i++) {
|
||||
char *p, *q;
|
||||
|
@ -41,7 +41,7 @@ static int raw_verify(const char *fn, const char *verification_key) {
|
||||
JournalFile *f;
|
||||
int r;
|
||||
|
||||
r = journal_file_open(-1, fn, O_RDONLY, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f);
|
||||
r = journal_file_open(-1, fn, O_RDONLY, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f);
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
log_info("Generating...");
|
||||
|
||||
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
|
||||
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
|
||||
|
||||
for (n = 0; n < N_ENTRIES; n++) {
|
||||
struct iovec iovec;
|
||||
@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
log_info("Verifying...");
|
||||
|
||||
assert_se(journal_file_open(-1, "test.journal", O_RDONLY, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
|
||||
assert_se(journal_file_open(-1, "test.journal", O_RDONLY, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
|
||||
/* journal_file_print_header(f); */
|
||||
journal_file_dump(f);
|
||||
|
||||
|
@ -37,7 +37,7 @@ static void test_non_empty(void) {
|
||||
|
||||
mkdtemp_chdir_chattr(t);
|
||||
|
||||
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f) == 0);
|
||||
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f) == 0);
|
||||
|
||||
assert_se(dual_timestamp_get(&ts));
|
||||
assert_se(sd_id128_randomize(&fake_boot_id) == 0);
|
||||
@ -98,8 +98,8 @@ static void test_non_empty(void) {
|
||||
|
||||
assert_se(journal_file_move_to_entry_by_seqnum(f, 10, DIRECTION_DOWN, &o, NULL) == 0);
|
||||
|
||||
journal_file_rotate(&f, true, (uint64_t) -1, true, NULL);
|
||||
journal_file_rotate(&f, true, (uint64_t) -1, true, NULL);
|
||||
journal_file_rotate(&f, true, UINT64_MAX, true, NULL);
|
||||
journal_file_rotate(&f, true, UINT64_MAX, true, NULL);
|
||||
|
||||
(void) journal_file_close(f);
|
||||
|
||||
@ -124,13 +124,13 @@ static void test_empty(void) {
|
||||
|
||||
mkdtemp_chdir_chattr(t);
|
||||
|
||||
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, false, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f1) == 0);
|
||||
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, false, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f1) == 0);
|
||||
|
||||
assert_se(journal_file_open(-1, "test-compress.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f2) == 0);
|
||||
assert_se(journal_file_open(-1, "test-compress.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f2) == 0);
|
||||
|
||||
assert_se(journal_file_open(-1, "test-seal.journal", O_RDWR|O_CREAT, 0666, false, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f3) == 0);
|
||||
assert_se(journal_file_open(-1, "test-seal.journal", O_RDWR|O_CREAT, 0666, false, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f3) == 0);
|
||||
|
||||
assert_se(journal_file_open(-1, "test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f4) == 0);
|
||||
assert_se(journal_file_open(-1, "test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f4) == 0);
|
||||
|
||||
journal_file_print_header(f1);
|
||||
puts("");
|
||||
@ -224,8 +224,8 @@ static void test_min_compress_size(void) {
|
||||
* carefully */
|
||||
|
||||
/* DEFAULT_MIN_COMPRESS_SIZE is 512 */
|
||||
assert_se(!check_compressed((uint64_t) -1, 255));
|
||||
assert_se(check_compressed((uint64_t) -1, 513));
|
||||
assert_se(!check_compressed(UINT64_MAX, 255));
|
||||
assert_se(check_compressed(UINT64_MAX, 513));
|
||||
|
||||
/* compress everything */
|
||||
assert_se(check_compressed(0, 96));
|
||||
|
@ -1043,9 +1043,9 @@ _public_ int sd_login_monitor_get_timeout(sd_login_monitor *m, uint64_t *timeout
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(timeout_usec, -EINVAL);
|
||||
|
||||
/* For now we will only return (uint64_t) -1, since we don't
|
||||
/* For now we will only return UINT64_MAX, since we don't
|
||||
* need any timeout. However, let's have this API to keep our
|
||||
* options open should we later on need it. */
|
||||
*timeout_usec = (uint64_t) -1;
|
||||
*timeout_usec = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
@ -277,7 +277,7 @@ static void test_monitor(void) {
|
||||
nw = now(CLOCK_MONOTONIC);
|
||||
|
||||
r = poll(&pollfd, 1,
|
||||
timeout == (uint64_t) -1 ? -1 :
|
||||
timeout == UINT64_MAX ? -1 :
|
||||
timeout > nw ? (int) ((timeout - nw) / 1000) :
|
||||
0);
|
||||
|
||||
|
@ -512,13 +512,13 @@ int sd_netlink_process(sd_netlink *rtnl, sd_netlink_message **ret) {
|
||||
}
|
||||
|
||||
static usec_t calc_elapse(uint64_t usec) {
|
||||
if (usec == (uint64_t) -1)
|
||||
if (usec == UINT64_MAX)
|
||||
return 0;
|
||||
|
||||
if (usec == 0)
|
||||
usec = RTNL_DEFAULT_TIMEOUT;
|
||||
|
||||
return now(CLOCK_MONOTONIC) + usec;
|
||||
return usec_add(now(CLOCK_MONOTONIC), usec);
|
||||
}
|
||||
|
||||
static int rtnl_poll(sd_netlink *rtnl, bool need_more, uint64_t timeout_usec) {
|
||||
@ -550,7 +550,7 @@ static int rtnl_poll(sd_netlink *rtnl, bool need_more, uint64_t timeout_usec) {
|
||||
}
|
||||
}
|
||||
|
||||
if (timeout_usec != (uint64_t) -1 && (m == USEC_INFINITY || timeout_usec < m))
|
||||
if (timeout_usec != UINT64_MAX && (m == USEC_INFINITY || timeout_usec < m))
|
||||
m = timeout_usec;
|
||||
|
||||
r = fd_wait_for_event(rtnl->fd, e, m);
|
||||
@ -606,7 +606,7 @@ int sd_netlink_call_async(
|
||||
if (r < 0)
|
||||
return r;
|
||||
|
||||
if (usec != (uint64_t) -1) {
|
||||
if (usec != UINT64_MAX) {
|
||||
r = prioq_ensure_allocated(&nl->reply_callbacks_prioq, timeout_compare);
|
||||
if (r < 0)
|
||||
return r;
|
||||
@ -714,7 +714,7 @@ int sd_netlink_read(sd_netlink *rtnl,
|
||||
|
||||
left = timeout - n;
|
||||
} else
|
||||
left = (uint64_t) -1;
|
||||
left = UINT64_MAX;
|
||||
|
||||
r = rtnl_poll(rtnl, true, left);
|
||||
if (r < 0)
|
||||
@ -766,7 +766,7 @@ int sd_netlink_get_timeout(const sd_netlink *rtnl, uint64_t *timeout_usec) {
|
||||
|
||||
c = prioq_peek(rtnl->reply_callbacks_prioq);
|
||||
if (!c) {
|
||||
*timeout_usec = (uint64_t) -1;
|
||||
*timeout_usec = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -461,9 +461,9 @@ _public_ int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *tim
|
||||
assert_return(m, -EINVAL);
|
||||
assert_return(timeout_usec, -EINVAL);
|
||||
|
||||
/* For now we will only return (uint64_t) -1, since we don't
|
||||
/* For now we will only return UINT64_MAX, since we don't
|
||||
* need any timeout. However, let's have this API to keep our
|
||||
* options open should we later on need it. */
|
||||
*timeout_usec = (uint64_t) -1;
|
||||
*timeout_usec = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
@ -621,7 +621,7 @@ _public_ int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *usec) {
|
||||
assert_return(usec, -EINVAL);
|
||||
assert_return(!resolve_pid_changed(resolve), -ECHILD);
|
||||
|
||||
*usec = (uint64_t) -1;
|
||||
*usec = UINT64_MAX;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -131,7 +131,7 @@ static int print_inhibitors(sd_bus *bus) {
|
||||
return bus_log_parse_error(r);
|
||||
|
||||
if (table_get_rows(table) > 1) {
|
||||
r = table_set_sort(table, (size_t) 1, (size_t) 0, (size_t) 5, (size_t) 6, (size_t) -1);
|
||||
r = table_set_sort(table, (size_t) 1, (size_t) 0, (size_t) 5, (size_t) 6);
|
||||
if (r < 0)
|
||||
return table_log_sort_error(r);
|
||||
|
||||
|
@ -90,7 +90,7 @@ static int show_table(Table *table, const char *word) {
|
||||
assert(word);
|
||||
|
||||
if (table_get_rows(table) > 1 || OUTPUT_MODE_IS_JSON(arg_output)) {
|
||||
r = table_set_sort(table, (size_t) 0, (size_t) -1);
|
||||
r = table_set_sort(table, (size_t) 0);
|
||||
if (r < 0)
|
||||
return table_log_sort_error(r);
|
||||
|
||||
|
@ -1637,7 +1637,7 @@ static int execute_shutdown_or_sleep(
|
||||
m->action_what = w;
|
||||
|
||||
/* Make sure the lid switch is ignored for a while */
|
||||
manager_set_lid_switch_ignore(m, now(CLOCK_MONOTONIC) + m->holdoff_timeout_usec);
|
||||
manager_set_lid_switch_ignore(m, usec_add(now(CLOCK_MONOTONIC), m->holdoff_timeout_usec));
|
||||
|
||||
return 0;
|
||||
|
||||
@ -4084,7 +4084,7 @@ int manager_start_scope(
|
||||
return r;
|
||||
|
||||
/* disable TasksMax= for the session scope, rely on the slice setting for it */
|
||||
r = sd_bus_message_append(m, "(sv)", "TasksMax", "t", (uint64_t)-1);
|
||||
r = sd_bus_message_append(m, "(sv)", "TasksMax", "t", UINT64_MAX);
|
||||
if (r < 0)
|
||||
return bus_log_create_error(r);
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user