mirror of
https://github.com/Dasharo/systemd.git
synced 2026-03-06 15:02:31 -08:00
Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
tree-wide: use UINT64_MAX or friends
This commit is contained in:
@@ -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 */
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user