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) {
#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);
* 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;
.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;
/* 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;
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;
}
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;
}
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;
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. */
.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 = {};
/* No restrictions on the other components */
.key.min_transid = 0,
- .key.max_transid = (uint64_t) -1,
+ .key.max_transid = UINT64_MAX,
};
int r;
.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 = {
/* 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;
/* 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;
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;
_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();
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) {
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) {
}
}
- 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) {
}
}
- 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) {
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);
}
}
- if (q->bounding != (uint64_t) -1) {
+ if (q->bounding != UINT64_MAX) {
r = capability_bounding_set_drop(q->bounding, false);
if (r < 0)
return r;
#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);
#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;
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:
return r;
/* Ignore the header line */
- (void) read_line(f, (size_t) -1, NULL);
+ (void) read_line(f, SIZE_MAX, NULL);
for (;;) {
char *controller;
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
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)
}
/* 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)
return r;
}
- if (max_bytes != (uint64_t) -1) {
+ if (max_bytes != UINT64_MAX) {
assert(max_bytes >= (uint64_t) n);
max_bytes -= n;
}
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;
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);
if (fdf < 0)
return -errno;
- if (mode == (mode_t) -1)
+ if (mode == MODE_INVALID)
if (fstat(fdf, &st) < 0)
return -errno;
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)
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);
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)
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;
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;
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))
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);
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);
} 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))
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);
* instead be copied directly.
*/
- if (length != (size_t) -1 && length < 1)
+ if (length != SIZE_MAX && length < 1)
return -EINVAL;
switch (p[0]) {
/* hexadecimal encoding */
int a, b;
- if (length != (size_t) -1 && length < 3)
+ if (length != SIZE_MAX && length < 3)
return -EINVAL;
a = unhexchar(p[1]);
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++) {
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++) {
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]);
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);
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;
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 */
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 */
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
/* 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);
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);
assert(suffix);
a = strlen(s);
- if (b > ((size_t) -1) - a)
+ if (b > (SIZE_MAX) - a)
return NULL;
r = new(char, a+b+1);
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);
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)
#include "strv.h"
#include "terminal-util.h"
#include "time-util.h"
+#include "user-util.h"
#include "util.h"
static volatile unsigned cached_columns = 0;
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)
continue;
}
- len = utf8_encoded_valid_unichar(i, (size_t) -1);
+ len = utf8_encoded_valid_unichar(i, SIZE_MAX);
if (len < 0) {
*i = ' ';
continue;
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 */
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;
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;
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)
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++;
w = utf8_char_console_width(str);
if (w < 0)
- return (size_t) -1;
+ return SIZE_MAX;
n += w;
str = utf8_next_char(str);
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);
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);
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;
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);
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");
}
} 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;
signal(SIGWINCH, columns_lines_cache_reset);
- if (arg_iterations == (unsigned) -1)
+ if (arg_iterations == UINT_MAX)
arg_iterations = on_tty() ? 0 : 1;
while (!quit) {
if (r < 0)
return r;
- if (rl == (uint64_t) -1)
+ if (rl == UINT64_MAX)
x = RLIM_INFINITY;
else {
x = (rlim_t) rl;
void *userdata,
sd_bus_error *error) {
- uint64_t sz = (uint64_t) -1;
+ uint64_t sz = UINT64_MAX;
Unit *u = userdata;
int r;
void *userdata,
sd_bus_error *error) {
- uint64_t cn = (uint64_t) -1;
+ uint64_t cn = UINT64_MAX;
Unit *u = userdata;
int r;
void *userdata,
sd_bus_error *error) {
- nsec_t ns = (nsec_t) -1;
+ nsec_t ns = NSEC_INFINITY;
Unit *u = userdata;
int r;
* 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;
}
}
if (!ownership_ok)
return r;
- if (fchown(dfd, uid, (gid_t) -1) < 0)
+ if (fchown(dfd, uid, GID_INVALID) < 0)
return -errno;
}
}
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);
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);
/* 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)
bus_unit_send_change_signal(u);
n++;
- if (budget != (unsigned) -1)
+ if (budget != UINT_MAX)
budget--;
}
bus_job_send_change_signal(j);
n++;
- if (budget != (unsigned) -1)
+ if (budget != UINT_MAX)
budget--;
}
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) {
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
}
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);
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% */
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% */
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[] = {
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;
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.");
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.");
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.");
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.");
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.");
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.");
_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");
/* 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);
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);
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);
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);
.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)
.input_fd = -1,
.on_finished = on_finished,
.userdata = userdata,
- .last_percent = (unsigned) -1,
+ .last_percent = UINT_MAX,
.progress_ratelimit = { 100 * USEC_PER_MSEC, 1 },
};
.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 },
};
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)
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;
.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 },
};
.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 },
};
.stdin_fd = -1,
.stdout_fd = -1,
.verify = _IMPORT_VERIFY_INVALID,
- .progress_percent= (unsigned) -1,
+ .progress_percent= UINT_MAX,
};
id = m->current_transfer_id + 1;
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;
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;
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.");
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) {
.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 */
* 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");
}
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");
#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);
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);
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.");
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);
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;
*
* 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;
.notify_fd = -1,
.compress.enabled = true,
- .compress.threshold_bytes = (uint64_t) -1,
+ .compress.threshold_bytes = UINT64_MAX,
.seal = true,
.set_audit = true,
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");
/* 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[]) {
assert_se(write(test_dhcp_fd[1], data, size) == (ssize_t) size);
- sd_event_run(e, (uint64_t) -1);
+ sd_event_run(e, UINT64_MAX);
assert_se(sd_dhcp6_client_stop(client) >= 0);
assert_se(sd_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]);
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 = {
.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. */
}
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);
}
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;
.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);
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);
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);
}
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)
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
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)
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;
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;
}
t = types;
- if (n_array != (unsigned) -1)
+ if (n_array != UINT_MAX)
n_array--;
else {
types++;
return r;
}
- if (n_array == (unsigned) -1) {
+ if (n_array == UINT_MAX) {
types += k;
n_struct -= k;
}
types = s;
n_struct = strlen(s);
- n_array = (unsigned) -1;
+ n_array = UINT_MAX;
break;
}
return r;
}
- if (n_array == (unsigned) -1) {
+ if (n_array == UINT_MAX) {
types += k - 1;
n_struct -= k - 1;
}
types = t + 1;
n_struct = k - 2;
- n_array = (unsigned) -1;
+ n_array = UINT_MAX;
break;
}
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;
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));
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;
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);
* 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 (;;) {
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;
}
t = types;
- if (n_array != (unsigned) -1)
+ if (n_array != UINT_MAX)
n_array--;
else {
types++;
}
}
- if (n_array == (unsigned) -1) {
+ if (n_array == UINT_MAX) {
types += k;
n_struct -= k;
}
types = s;
n_struct = strlen(s);
- n_array = (unsigned) -1;
+ n_array = UINT_MAX;
break;
}
}
}
- if (n_array == (unsigned) -1) {
+ if (n_array == UINT_MAX) {
types += k - 1;
n_struct -= k - 1;
}
types = t + 1;
n_struct = k - 2;
- n_array = (unsigned) -1;
+ n_array = UINT_MAX;
break;
}
char t;
size_t l;
- if (array_size != (uint32_t) -1 &&
+ if (array_size != UINT32_MAX &&
array_size <= *ri - original_index)
return 0;
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;
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;
}
_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;
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)
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;
.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,
};
* 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);
}
if (r > 0)
continue;
- r = sd_bus_wait(bus, (uint64_t) -1);
+ r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0)
return r;
}
left = timeout - n;
} else
- left = (uint64_t) -1;
+ left = UINT64_MAX;
r = bus_poll(bus, true, left);
if (r < 0)
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;
}
case BUS_WATCH_BIND:
case BUS_OPENING:
- *timeout_usec = (uint64_t) -1;
+ *timeout_usec = UINT64_MAX;
return 0;
default:
}
}
- 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);
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;
}
}
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;
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;
}
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;
}
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;
if (r < 0)
return r;
- if (device->devmode == (mode_t) -1)
+ if (device->devmode == MODE_INVALID)
return -ENOENT;
if (mode)
if (r < 0)
return r;
- if (device->devuid == (uid_t) -1)
+ if (device->devuid == UID_INVALID)
return -ENOENT;
if (uid)
if (r < 0)
return r;
- if (device->devgid == (gid_t) -1)
+ if (device->devgid == GID_INVALID)
return -ENOENT;
if (gid)
#include "string-util.h"
#include "strv.h"
#include "strxcpyx.h"
+#include "user-util.h"
#include "util.h"
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,
};
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);
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);
_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;
}
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;
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);
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);
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 */
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;
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;
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);
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;
}
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;
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;
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;
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 */
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;
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
n -= k;
t += k;
- last_index = (uint64_t) -1;
+ last_index = UINT64_MAX;
a = le64toh(array->entry_array.next_entry_array_offset);
}
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;
#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
/* 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,
};
}
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 */
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);
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
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);
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,
return fd;
if (!j->on_network) {
- *timeout_usec = (uint64_t) -1;
+ *timeout_usec = UINT64_MAX;
return 0;
}
if (r < 0)
return r;
- if (t != (uint64_t) -1) {
+ if (t != UINT64_MAX) {
t = usec_sub_unsigned(t, now(CLOCK_MONOTONIC));
- if (timeout_usec == (uint64_t) -1 || timeout_usec > t)
+ if (timeout_usec == UINT64_MAX || timeout_usec > t)
timeout_usec = t;
}
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;
}
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);
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));
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));
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;
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;
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;
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);
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);
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);
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("");
* 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));
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;
}
nw = now(CLOCK_MONOTONIC);
r = poll(&pollfd, 1,
- timeout == (uint64_t) -1 ? -1 :
+ timeout == UINT64_MAX ? -1 :
timeout > nw ? (int) ((timeout - nw) / 1000) :
0);
}
static usec_t calc_elapse(uint64_t usec) {
- if (usec == (uint64_t) -1)
+ if (usec == UINT64_MAX)
return 0;
if (usec == 0)
}
}
- 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);
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;
left = timeout - n;
} else
- left = (uint64_t) -1;
+ left = UINT64_MAX;
r = rtnl_poll(rtnl, true, left);
if (r < 0)
c = prioq_peek(rtnl->reply_callbacks_prioq);
if (!c) {
- *timeout_usec = (uint64_t) -1;
+ *timeout_usec = UINT64_MAX;
return 0;
}
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;
}
assert_return(usec, -EINVAL);
assert_return(!resolve_pid_changed(resolve), -ECHILD);
- *usec = (uint64_t) -1;
+ *usec = UINT64_MAX;
return 0;
}
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);
if (r > 0)
continue;
- r = sd_event_run(m->event, (uint64_t) -1);
+ r = sd_event_run(m->event, UINT64_MAX);
if (r < 0)
return r;
}
return PAM_SUCCESS;
if (streq(limit, "infinity")) {
- r = sd_bus_message_append(m, "(sv)", "MemoryMax", "t", (uint64_t)-1);
+ r = sd_bus_message_append(m, "(sv)", "MemoryMax", "t", UINT64_MAX);
if (r < 0)
return pam_bus_log_create_error(handle, r);
assert(prefix);
if (flags & OUTPUT_FULL_WIDTH)
- max_width = (size_t) -1;
+ max_width = SIZE_MAX;
else if (n_columns < 10)
max_width = 10;
else
return -ENOMEM;
r = show_sysfs_one(seat, dev_list, i_dev, n_dev, sysfs, p,
- n_columns == (unsigned) -1 || n_columns < 2 ? n_columns : n_columns - 2,
+ n_columns == UINT_MAX || n_columns < 2 ? n_columns : n_columns - 2,
flags);
if (r < 0)
return r;
if (r < 0)
_exit(EXIT_FAILURE);
- r = copy_bytes(fd, pair[1], (uint64_t) -1, 0);
+ r = copy_bytes(fd, pair[1], UINT64_MAX, 0);
if (r < 0)
_exit(EXIT_FAILURE);
};
PoolStatusInfo info = {
- .usage = (uint64_t) -1,
- .limit = (uint64_t) -1,
+ .usage = UINT64_MAX,
+ .limit = UINT64_MAX,
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
if (STR_IN_SET(argv[argc-1], "-", "none", "infinity"))
- limit = (uint64_t) -1;
+ limit = UINT64_MAX;
else {
r = parse_size(argv[argc-1], 1024, &limit);
if (r < 0)
sd_bus_error *error) {
_cleanup_close_ int fd = -1;
- uint64_t usage = (uint64_t) -1;
+ uint64_t usage = UINT64_MAX;
assert(bus);
assert(reply);
sd_bus_error *error) {
_cleanup_close_ int fd = -1;
- uint64_t size = (uint64_t) -1;
+ uint64_t size = UINT64_MAX;
assert(bus);
assert(reply);
}
if (streq(rvalue, "infinity")) {
- network->dhcp_max_attempts = (uint64_t) -1;
+ network->dhcp_max_attempts = UINT64_MAX;
return 0;
}
goto finalize;
}
- if (l->n_dns != (unsigned) -1)
+ if (l->n_dns != UINT_MAX)
for (unsigned i = 0; i < l->n_dns; i++)
in_addr_full_free(l->dns[i]);
.ifindex = ifindex,
.iftype = iftype,
- .n_dns = (unsigned) -1,
+ .n_dns = UINT_MAX,
.dns_default_route = -1,
.llmnr = _RESOLVE_SUPPORT_INVALID,
.mdns = _RESOLVE_SUPPORT_INVALID,
}
void link_dns_settings_clear(Link *link) {
- if (link->n_dns != (unsigned) -1)
+ if (link->n_dns != UINT_MAX)
for (unsigned i = 0; i < link->n_dns; i++)
in_addr_full_free(link->dns[i]);
link->dns = mfree(link->dns);
- link->n_dns = (unsigned) -1;
+ link->n_dns = UINT_MAX;
link->search_domains = ordered_set_free_free(link->search_domains);
link->route_domains = ordered_set_free_free(link->route_domains);
return -ENOMEM;
*sr_iov = (SRIOV) {
- .vf = (uint32_t) -1,
+ .vf = UINT32_MAX,
.vlan_proto = ETH_P_8021Q,
.vf_spoof_check_setting = -1,
.trust = -1,
if (section_is_invalid(sr_iov->section))
return -EINVAL;
- if (sr_iov->vf == (uint32_t) -1)
+ if (sr_iov->vf == UINT32_MAX)
return log_warning_errno(SYNTHETIC_ERRNO(EINVAL),
"%s: [SRIOV] section without VirtualFunction= field configured. "
"Ignoring [SRIOV] section from line %u.",
if (isempty(rvalue)) {
if (streq(lvalue, "VirtualFunction"))
- sr_iov->vf = (uint32_t) -1;
+ sr_iov->vf = UINT32_MAX;
else if (streq(lvalue, "VLANId"))
sr_iov->vlan = 0;
else if (streq(lvalue, "QualityOfService"))
continue;
/* First add the static configured entries */
- if (link->n_dns != (unsigned) -1)
+ if (link->n_dns != UINT_MAX)
r = ordered_set_put_dns_servers(dns, link->ifindex, link->dns, link->n_dns);
else
r = ordered_set_put_dns_servers(dns, link->ifindex, link->network->dns, link->network->n_dns);
fputs("DNS=", f);
space = false;
- if (link->n_dns != (unsigned) -1)
+ if (link->n_dns != UINT_MAX)
link_save_dns(link, f, link->dns, link->n_dns, &space);
else
link_save_dns(link, f, link->network->dns, link->network->n_dns, &space);
ucred data, and sd_pid_notify() uses the real UID for filling in ucred. */
if (arg_gid != GID_INVALID &&
- setregid(arg_gid, (gid_t) -1) < 0)
+ setregid(arg_gid, GID_INVALID) < 0)
return log_error_errno(errno, "Failed to change GID: %m");
if (arg_uid != UID_INVALID &&
- setreuid(arg_uid, (uid_t) -1) < 0)
+ setreuid(arg_uid, UID_INVALID) < 0)
return log_error_errno(errno, "Failed to change UID: %m");
if (arg_pid > 0)
m |= UINT64_C(1) << cap;
}
- if (*mask == (uint64_t) -1)
+ if (*mask == UINT64_MAX)
*mask = m;
else
*mask |= m;
if (r < 0)
return r;
- if (s->full_capabilities.bounding != (uint64_t) -1) {
+ if (s->full_capabilities.bounding != UINT64_MAX) {
s->capability = s->full_capabilities.bounding;
s->drop_capability = ~s->full_capabilities.bounding;
}
assert_cc(sizeof(uid_t) == sizeof(gid_t));
/* This is very much like oci_uid_gid(), except the checks are a bit different, as this is a UID range rather
- * than a specific UID, and hence (uid_t) -1 has no special significance. OTOH a range of zero makes no
+ * than a specific UID, and hence UID_INVALID has no special significance. OTOH a range of zero makes no
* sense. */
k = json_variant_unsigned(v);
*node = (DeviceNode) {
.uid = UID_INVALID,
.gid = GID_INVALID,
- .major = (unsigned) -1,
- .minor = (unsigned) -1,
+ .major = UINT_MAX,
+ .minor = UINT_MAX,
.mode = 0644,
};
if (S_ISCHR(node->mode) || S_ISBLK(node->mode)) {
_cleanup_free_ char *path = NULL;
- if (node->major == (unsigned) -1 || node->minor == (unsigned) -1) {
+ if (node->major == UINT_MAX || node->minor == UINT_MAX) {
r = json_log(e, flags, SYNTHETIC_ERRNO(EINVAL),
"Major/minor required when device node is device node");
goto fail_element;
JSON_VARIANT_ARRAY_FOREACH(e, v) {
struct device_data data = {
- .major = (unsigned) -1,
- .minor = (unsigned) -1,
+ .major = UINT_MAX,
+ .minor = UINT_MAX,
}, *a;
static const JsonDispatch table[] = {
* is really borked in the spec, with one exception: the entry that's supposed to
* drop the kernel's default we ignore silently */
- if (!data.r || !data.w || !data.m || data.type != 0 || data.major != (unsigned) -1 || data.minor != (unsigned) -1)
+ if (!data.r || !data.w || !data.m || data.type != 0 || data.major != UINT_MAX || data.minor != UINT_MAX)
json_log(v, flags|JSON_WARNING, 0, "Devices cgroup allow list with arbitrary 'allow' entries not supported, ignoring.");
/* We ignore the 'deny' entry as for us that's implied */
continue;
}
- if (data.minor != (unsigned) -1 && data.major == (unsigned) -1)
+ if (data.minor != UINT_MAX && data.major == UINT_MAX)
return json_log(v, flags, SYNTHETIC_ERRNO(EOPNOTSUPP),
"Device cgroup allow list entries with minors but no majors not supported.");
- if (data.major != (unsigned) -1 && data.type == 0)
+ if (data.major != UINT_MAX && data.type == 0)
return json_log(v, flags, SYNTHETIC_ERRNO(EOPNOTSUPP),
"Device cgroup allow list entries with majors but no device node type not supported.");
char access[4];
size_t n = 0;
- if (list[i].minor == (unsigned) -1) {
+ if (list[i].minor == UINT_MAX) {
const char *t;
if (list[i].type == S_IFBLK)
t = "char";
}
- if (list[i].major == (unsigned) -1) {
+ if (list[i].major == UINT_MAX) {
pattern = strjoin(t, "-*");
if (!pattern)
return log_oom();
}
} else {
- assert(list[i].major != (unsigned) -1); /* If a minor is specified, then a major also needs to be specified */
+ assert(list[i].major != UINT_MAX); /* If a minor is specified, then a major also needs to be specified */
r = device_path_make_major_minor(list[i].type, makedev(list[i].major, list[i].minor), &pattern);
if (r < 0)
unsigned minor;
uintmax_t weight;
} data = {
- .major = (unsigned) -1,
- .minor = (unsigned) -1,
+ .major = UINT_MAX,
+ .minor = UINT_MAX,
.weight = UINTMAX_MAX,
};
unsigned minor;
uintmax_t rate;
} data = {
- .major = (unsigned) -1,
- .minor = (unsigned) -1,
+ .major = UINT_MAX,
+ .minor = UINT_MAX,
};
static const JsonDispatch table[] = {
{ "args", JSON_VARIANT_ARRAY, oci_seccomp_args, 0, 0 },
};
struct syscall_rule rule = {
- .action = (uint32_t) -1,
+ .action = UINT32_MAX,
};
char **i;
.gid = GID_INVALID,
.console_mode = _CONSOLE_MODE_INVALID,
- .console_width = (unsigned) -1,
- .console_height = (unsigned) -1,
+ .console_width = UINT_MAX,
+ .console_height = UINT_MAX,
- .clone_ns_flags = (unsigned long) -1,
+ .clone_ns_flags = ULONG_MAX,
.use_cgns = -1,
};
break;
if (streq(word, "all"))
- u = (uint64_t) -1;
+ u = UINT64_MAX;
else {
r = capability_from_name(word);
if (r < 0) {
static CPUSet arg_cpu_set = {};
static ResolvConfMode arg_resolv_conf = RESOLV_CONF_AUTO;
static TimezoneMode arg_timezone = TIMEZONE_AUTO;
-static unsigned arg_console_width = (unsigned) -1, arg_console_height = (unsigned) -1;
+static unsigned arg_console_width = UINT_MAX, arg_console_height = UINT_MAX;
static DeviceNode* arg_extra_nodes = NULL;
static size_t arg_n_extra_nodes = 0;
static char **arg_sysctl = NULL;
}
if (streq(t, "all"))
- mask = (uint64_t) -1;
+ mask = UINT64_MAX;
else {
r = capability_from_name(t);
if (r < 0)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Cannot use --port= without private networking.");
if (arg_caps_ambient) {
- if (arg_caps_ambient == (uint64_t)-1)
+ if (arg_caps_ambient == UINT64_MAX)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "AmbientCapability= does not support the value all.");
if ((arg_caps_ambient & arg_caps_retain) != arg_caps_ambient)
if (capability_quintet_is_set(&arg_full_capabilities)) {
q = arg_full_capabilities;
- if (q.bounding == (uint64_t) -1)
+ if (q.bounding == UINT64_MAX)
q.bounding = uid == 0 ? arg_caps_retain : 0;
- if (q.effective == (uint64_t) -1)
+ if (q.effective == UINT64_MAX)
q.effective = uid == 0 ? q.bounding : 0;
- if (q.inheritable == (uint64_t) -1)
+ if (q.inheritable == UINT64_MAX)
q.inheritable = uid == 0 ? q.bounding : arg_caps_ambient;
- if (q.permitted == (uint64_t) -1)
+ if (q.permitted == UINT64_MAX)
q.permitted = uid == 0 ? q.bounding : arg_caps_ambient;
- if (q.ambient == (uint64_t) -1 && ambient_capabilities_supported())
+ if (q.ambient == UINT64_MAX && ambient_capabilities_supported())
q.ambient = arg_caps_ambient;
if (capability_quintet_mangle(&q))
.effective = uid == 0 ? arg_caps_retain : 0,
.inheritable = uid == 0 ? arg_caps_retain : arg_caps_ambient,
.permitted = uid == 0 ? arg_caps_retain : arg_caps_ambient,
- .ambient = ambient_capabilities_supported() ? arg_caps_ambient : (uint64_t) -1,
+ .ambient = ambient_capabilities_supported() ? arg_caps_ambient : UINT64_MAX,
};
/* If we're not using OCI, proceed with mangled capabilities (so we don't error out)
arg_uid_range = UINT32_C(0x10000);
}
- if (arg_uid_shift > (uid_t) -1 - arg_uid_range)
+ if (arg_uid_shift > UID_INVALID - arg_uid_range)
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
"UID base too high for UID range.");
}
if ((arg_settings_mask & SETTING_CLONE_NS_FLAGS) == 0 &&
- settings->clone_ns_flags != (unsigned long) -1) {
+ settings->clone_ns_flags != ULONG_MAX) {
if (!arg_settings_trusted)
log_warning("Ignoring namespace setting, file '%s' is not trusted.", path);
if (r < 0)
return log_error_errno(r, "Failed to create PTY forwarder: %m");
- if (arg_console_width != (unsigned) -1 || arg_console_height != (unsigned) -1)
+ if (arg_console_width != UINT_MAX || arg_console_height != UINT_MAX)
(void) pty_forward_set_width_height(forward,
arg_console_width,
arg_console_height);
/* Try to flush whatever is still queued in the pty */
if (master >= 0) {
- (void) copy_bytes(master, STDOUT_FILENO, (uint64_t) -1, 0);
+ (void) copy_bytes(master, STDOUT_FILENO, UINT64_MAX, 0);
master = safe_close(master);
}
return bus_log_parse_error(r);
fflush(stdout);
- return copy_bytes(fd, STDOUT_FILENO, (uint64_t) -1, 0);
+ return copy_bytes(fd, STDOUT_FILENO, UINT64_MAX, 0);
}
static int parse_argv(int argc, char *argv[]) {
static int acquire_root_devno(const char *p, int mode, char **ret, int *ret_fd) {
_cleanup_close_ int fd = -1;
struct stat st;
- dev_t devno, fd_devno = (mode_t) -1;
+ dev_t devno, fd_devno = MODE_INVALID;
int r;
assert(p);
/* Only if we still lock at the same block device we can reuse the fd. Otherwise return an
* invalidated fd. */
- *ret_fd = fd_devno != (mode_t) -1 && fd_devno == devno ? TAKE_FD(fd) : -1;
+ *ret_fd = fd_devno != MODE_INVALID && fd_devno == devno ? TAKE_FD(fd) : -1;
return 0;
}
(void) polkit_agent_open_if_enabled(arg_transport, arg_ask_password);
if (STR_IN_SET(argv[argc-1], "-", "none", "infinity"))
- limit = (uint64_t) -1;
+ limit = UINT64_MAX;
else {
r = parse_size(argv[argc-1], 1024, &limit);
if (r < 0)
sd_bus_error *error) {
_cleanup_close_ int fd = -1;
- uint64_t usage = (uint64_t) -1;
+ uint64_t usage = UINT64_MAX;
assert(bus);
assert(reply);
sd_bus_error *error) {
_cleanup_close_ int fd = -1;
- uint64_t size = (uint64_t) -1;
+ uint64_t size = UINT64_MAX;
assert(bus);
assert(reply);
.rr = dns_resource_record_ref(rr),
.answer = dns_answer_ref(answer),
.full_packet = dns_packet_ref(full_packet),
- .until = calculate_until(rr, (uint32_t) -1, timestamp, false),
+ .until = calculate_until(rr, UINT32_MAX, timestamp, false),
.query_flags = query_flags & CACHEABLE_QUERY_FLAGS,
.shared_owner = shared_owner,
.dnssec_result = dnssec_result,
assert(rrsig->key->type == DNS_TYPE_RRSIG);
/* Check if this RRSIG RR is already prepared */
- if (rrsig->n_skip_labels_source != (unsigned) -1)
+ if (rrsig->n_skip_labels_source != UINT_MAX)
return 0;
if (rrsig->rrsig.inception > rrsig->rrsig.expiration)
/* Ignore NSEC3 RRs generated from wildcards. If these NSEC3 RRs weren't correctly signed we can't make this
* check (since rr->n_skip_labels_source is -1), but that's OK, as we won't trust them anyway in that case. */
- if (!IN_SET(rr->n_skip_labels_source, 0, (unsigned) -1))
+ if (!IN_SET(rr->n_skip_labels_source, 0, UINT_MAX))
return 0;
/* Ignore NSEC3 RRs that are located anywhere else than one label below the zone */
- if (!IN_SET(rr->n_skip_labels_signer, 1, (unsigned) -1))
+ if (!IN_SET(rr->n_skip_labels_signer, 1, UINT_MAX))
return 0;
if (!nsec3)
.rindex = DNS_PACKET_HEADER_SIZE,
.allocated = a,
.max_size = max_size,
- .opt_start = (size_t) -1,
- .opt_size = (size_t) -1,
+ .opt_start = SIZE_MAX,
+ .opt_size = SIZE_MAX,
};
*ret = p;
.rindex = DNS_PACKET_HEADER_SIZE,
.allocated = p->size,
.max_size = p->max_size,
- .opt_start = (size_t) -1,
- .opt_size = (size_t) -1,
+ .opt_start = SIZE_MAX,
+ .opt_size = SIZE_MAX,
};
memcpy(DNS_PACKET_DATA(c), DNS_PACKET_DATA(p), p->size);
assert(rcode >= 0);
assert(rcode <= _DNS_RCODE_MAX);
- if (p->opt_start != (size_t) -1)
+ if (p->opt_start != SIZE_MAX)
return -EBUSY;
- assert(p->opt_size == (size_t) -1);
+ assert(p->opt_size == SIZE_MAX);
saved_size = p->size;
int dns_packet_truncate_opt(DnsPacket *p) {
assert(p);
- if (p->opt_start == (size_t) -1) {
- assert(p->opt_size == (size_t) -1);
+ if (p->opt_start == SIZE_MAX) {
+ assert(p->opt_size == SIZE_MAX);
return 0;
}
- assert(p->opt_size != (size_t) -1);
+ assert(p->opt_size != SIZE_MAX);
assert(DNS_PACKET_ARCOUNT(p) > 0);
if (p->opt_start + p->opt_size != p->size)
dns_packet_truncate(p, p->opt_start);
DNS_PACKET_HEADER(p)->arcount = htobe16(DNS_PACKET_ARCOUNT(p) - 1);
- p->opt_start = p->opt_size = (size_t) -1;
+ p->opt_start = p->opt_size = SIZE_MAX;
return 1;
}
assert(p);
assert(max_udp_size >= DNS_PACKET_UNICAST_SIZE_MAX);
- if (p->opt_start == (size_t) -1) /* No OPT section, nothing to patch */
+ if (p->opt_start == SIZE_MAX) /* No OPT section, nothing to patch */
return 0;
- assert(p->opt_size != (size_t) -1);
+ assert(p->opt_size != SIZE_MAX);
assert(p->opt_size >= 5);
unaligned_write_be16(DNS_PACKET_DATA(p) + p->opt_start + 3, max_udp_size);
/* Static/const keys created with DNS_RESOURCE_KEY_CONST will
* set this to -1, they should not be reffed/unreffed */
- assert(k->n_ref != (unsigned) -1);
+ assert(k->n_ref != UINT_MAX);
assert(k->n_ref > 0);
k->n_ref++;
if (!k)
return NULL;
- assert(k->n_ref != (unsigned) -1);
+ assert(k->n_ref != UINT_MAX);
assert(k->n_ref > 0);
if (k->n_ref == 1) {
return false;
/* We refuse merging const keys */
- if ((*a)->n_ref == (unsigned) -1)
+ if ((*a)->n_ref == UINT_MAX)
return false;
- if ((*b)->n_ref == (unsigned) -1)
+ if ((*b)->n_ref == UINT_MAX)
return false;
/* Already the same? */
.n_ref = 1,
.key = dns_resource_key_ref(key),
.expiry = USEC_INFINITY,
- .n_skip_labels_signer = (unsigned) -1,
- .n_skip_labels_source = (unsigned) -1,
+ .n_skip_labels_signer = UINT_MAX,
+ .n_skip_labels_source = UINT_MAX,
};
return rr;
/* Returns the RRset's signer, if it is known. */
- if (rr->n_skip_labels_signer == (unsigned) -1)
+ if (rr->n_skip_labels_signer == UINT_MAX)
return -ENODATA;
n = dns_resource_key_name(rr->key);
/* Returns the RRset's synthesizing source, if it is known. */
- if (rr->n_skip_labels_source == (unsigned) -1)
+ if (rr->n_skip_labels_source == UINT_MAX)
return -ENODATA;
n = dns_resource_key_name(rr->key);
/* Returns > 0 if the RR is generated from a wildcard, and is not the asterisk name itself */
- if (rr->n_skip_labels_source == (unsigned) -1)
+ if (rr->n_skip_labels_source == UINT_MAX)
return -ENODATA;
if (rr->n_skip_labels_source == 0)
* resource key object. */
#define DNS_RESOURCE_KEY_CONST(c, t, n) \
((DnsResourceKey) { \
- .n_ref = (unsigned) -1, \
+ .n_ref = UINT_MAX, \
.class = c, \
.type = t, \
._name = (char*) n, \
t->answer_dnssec_result = _DNSSEC_RESULT_INVALID;
t->answer_source = _DNS_TRANSACTION_SOURCE_INVALID;
t->answer_query_flags = 0;
- t->answer_nsec_ttl = (uint32_t) -1;
+ t->answer_nsec_ttl = UINT32_MAX;
t->answer_errno = 0;
}
.dns_udp_fd = -1,
.answer_source = _DNS_TRANSACTION_SOURCE_INVALID,
.answer_dnssec_result = _DNSSEC_RESULT_INVALID,
- .answer_nsec_ttl = (uint32_t) -1,
+ .answer_nsec_ttl = UINT32_MAX,
.key = dns_resource_key_ref(key),
.query_flags = query_flags,
.bypass = dns_packet_ref(bypass),
dns_transaction_process_reply(t, p, false);
}
- dns_cache_put(&scope->cache, scope->manager->enable_cache, NULL, DNS_PACKET_RCODE(p), p->answer, NULL, false, _DNSSEC_RESULT_INVALID, (uint32_t) -1, p->family, &p->sender);
+ dns_cache_put(&scope->cache, scope->manager->enable_cache, NULL, DNS_PACKET_RCODE(p), p->answer, NULL, false, _DNSSEC_RESULT_INVALID, UINT32_MAX, p->family, &p->sender);
} else if (dns_packet_validate_query(p) > 0) {
log_debug("Got mDNS query packet for id %u", DNS_PACKET_ID(p));
return 0;
size_t m = utf8_n_codepoints(str);
- if (m == (size_t) -1)
+ if (m == SIZE_MAX)
m = strlen(str); /* Not a valid UTF-8 string? If so, let's backspace the number of bytes
* output. Most likely this happened because we are not in an UTF-8 locale,
* and in that case that is the correct thing to do. And even if it's not,
for (;;) {
size_t z;
- z = utf8_encoded_valid_unichar(passphrase + q, (size_t) -1);
+ z = utf8_encoded_valid_unichar(passphrase + q, SIZE_MAX);
if (z == 0) {
- q = (size_t) -1; /* Invalid UTF8! */
+ q = SIZE_MAX; /* Invalid UTF8! */
break;
}
q += z;
}
- p = codepoint = q == (size_t) -1 ? p - 1 : q;
+ p = codepoint = q == SIZE_MAX ? p - 1 : q;
explicit_bzero_safe(passphrase + p, sizeof(passphrase) - p);
} else if (!dirty && !(flags & ASK_PASSWORD_SILENT)) {
if (!(flags & ASK_PASSWORD_SILENT) && ttyfd >= 0) {
/* Check if we got a complete UTF-8 character now. If so, let's output one '*'. */
- n = utf8_encoded_valid_unichar(passphrase + codepoint, (size_t) -1);
+ n = utf8_encoded_valid_unichar(passphrase + codepoint, SIZE_MAX);
if (n >= 0) {
if (flags & ASK_PASSWORD_ECHO)
(void) loop_write(ttyfd, passphrase + codepoint, n, false);
#define BITMAPS_MAX_ENTRY 0xffff
/* This indicates that we reached the end of the bitmap */
-#define BITMAP_END ((unsigned) -1)
+#define BITMAP_END (UINT_MAX)
#define BITMAP_NUM_TO_OFFSET(n) ((n) / (sizeof(uint64_t) * 8))
#define BITMAP_NUM_TO_REM(n) ((n) % (sizeof(uint64_t) * 8))
x = is_soft ? buf.rlim_cur : buf.rlim_max;
}
- /* rlim_t might have different sizes, let's map RLIMIT_INFINITY to (uint64_t) -1, so that it is the same on all
+ /* rlim_t might have different sizes, let's map RLIMIT_INFINITY to UINT64_MAX, so that it is the same on all
* archs */
- u = x == RLIM_INFINITY ? (uint64_t) -1 : (uint64_t) x;
+ u = x == RLIM_INFINITY ? UINT64_MAX : (uint64_t) x;
return sd_bus_message_append(reply, "t", u);
}
} else if ((STR_IN_SET(name, "CPUWeight", "StartupCPUWeight", "IOWeight", "StartupIOWeight") && u == CGROUP_WEIGHT_INVALID) ||
(STR_IN_SET(name, "CPUShares", "StartupCPUShares") && u == CGROUP_CPU_SHARES_INVALID) ||
(STR_IN_SET(name, "BlockIOWeight", "StartupBlockIOWeight") && u == CGROUP_BLKIO_WEIGHT_INVALID) ||
- (STR_IN_SET(name, "MemoryCurrent", "TasksCurrent") && u == (uint64_t) -1) ||
- (endswith(name, "NSec") && u == (uint64_t) -1))
+ (STR_IN_SET(name, "MemoryCurrent", "TasksCurrent") && u == UINT64_MAX) ||
+ (endswith(name, "NSec") && u == UINT64_MAX))
bus_print_property_value(name, expected_value, value, "[not set]");
else if ((STR_IN_SET(name, "DefaultMemoryLow", "DefaultMemoryMin", "MemoryLow", "MemoryHigh", "MemoryMax", "MemorySwapMax", "MemoryLimit") && u == CGROUP_LIMIT_MAX) ||
- (STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == (uint64_t) -1) ||
- (startswith(name, "Limit") && u == (uint64_t) -1) ||
- (startswith(name, "DefaultLimit") && u == (uint64_t) -1))
+ (STR_IN_SET(name, "TasksMax", "DefaultTasksMax") && u == UINT64_MAX) ||
+ (startswith(name, "Limit") && u == UINT64_MAX) ||
+ (startswith(name, "DefaultLimit") && u == UINT64_MAX))
bus_print_property_value(name, expected_value, value, "infinity");
- else if (STR_IN_SET(name, "IPIngressBytes", "IPIngressPackets", "IPEgressBytes", "IPEgressPackets") && u == (uint64_t) -1)
+ else if (STR_IN_SET(name, "IPIngressBytes", "IPIngressPackets", "IPEgressBytes", "IPEgressPackets") && u == UINT64_MAX)
bus_print_property_value(name, expected_value, value, "[no data]");
else
bus_print_property_valuef(name, expected_value, value, "%"PRIu64, u);
_cleanup_free_ void *decoded = NULL;
size_t sz;
- r = unbase64mem(eq, (size_t) -1, &decoded, &sz);
+ r = unbase64mem(eq, SIZE_MAX, &decoded, &sz);
if (r < 0)
return log_error_errno(r, "Failed to decode base64 data '%s': %m", eq);
else
idle = true;
- r = sd_event_run(e, exiting || !idle ? (uint64_t) -1 : timeout);
+ r = sd_event_run(e, exiting || !idle ? UINT64_MAX : timeout);
if (r < 0)
return r;
if (r > 0)
return 0;
- r = sd_bus_wait(bus, (uint64_t) -1);
+ r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0)
return r;
}
if (r > 0)
continue;
- r = sd_bus_wait(d->bus, (uint64_t) -1);
+ r = sd_bus_wait(d->bus, UINT64_MAX);
if (r < 0)
return r;
}
continue;
}
- r = copy_bytes(fd, fds[2*k+1], (uint64_t) -1, 0);
+ r = copy_bytes(fd, fds[2*k+1], UINT64_MAX, 0);
if (r < 0) {
(void) write(error_pipe[1], &r, sizeof(r));
_exit(EXIT_FAILURE);
}
static TableCell* TABLE_INDEX_TO_CELL(size_t index) {
- assert(index != (size_t) -1);
+ assert(index != SIZE_MAX);
return SIZE_TO_PTR(index + 1);
}
size_t n_cells;
bool header; /* Whether to show the header row? */
- size_t width; /* If == 0 format this as wide as necessary. If (size_t) -1 format this to console
+ size_t width; /* If == 0 format this as wide as necessary. If SIZE_MAX format this to console
* width or less wide, but not wider. Otherwise the width to format this table in. */
- size_t cell_height_max; /* Maximum number of lines per cell. (If there are more, ellipsis is shown. If (size_t) -1 then no limit is set, the default. == 0 is not allowed.) */
+ size_t cell_height_max; /* Maximum number of lines per cell. (If there are more, ellipsis is shown. If SIZE_MAX then no limit is set, the default. == 0 is not allowed.) */
TableData **data;
size_t n_allocated;
*t = (struct Table) {
.n_columns = n_columns,
.header = true,
- .width = (size_t) -1,
- .cell_height_max = (size_t) -1,
+ .width = SIZE_MAX,
+ .cell_height_max = SIZE_MAX,
};
return TAKE_PTR(t);
p = NULL;
/* If formatting parameters are left unspecified, copy from the previous row */
- if (minimum_width == (size_t) -1)
+ if (minimum_width == SIZE_MAX)
minimum_width = p ? p->minimum_width : 1;
- if (weight == (unsigned) -1)
+ if (weight == UINT_MAX)
weight = p ? p->weight : DEFAULT_WEIGHT;
- if (align_percent == (unsigned) -1)
+ if (align_percent == UINT_MAX)
align_percent = p ? p->align_percent : 0;
- if (ellipsize_percent == (unsigned) -1)
+ if (ellipsize_percent == UINT_MAX)
ellipsize_percent = p ? p->ellipsize_percent : 100;
assert(align_percent <= 100);
assert(t);
assert(cell);
- if (minimum_width == (size_t) -1)
+ if (minimum_width == SIZE_MAX)
minimum_width = 1;
r = table_dedup_cell(t, cell);
assert(t);
assert(cell);
- if (weight == (unsigned) -1)
+ if (weight == UINT_MAX)
weight = DEFAULT_WEIGHT;
r = table_dedup_cell(t, cell);
assert(t);
assert(cell);
- if (percent == (unsigned) -1)
+ if (percent == UINT_MAX)
percent = 0;
assert(percent <= 100);
assert(t);
assert(cell);
- if (percent == (unsigned) -1)
+ if (percent == UINT_MAX)
percent = 100;
assert(percent <= 100);
void table_set_cell_height_max(Table *t, size_t height) {
assert(t);
- assert(height >= 1 || height == (size_t) -1);
+ assert(height >= 1 || height == SIZE_MAX);
t->cell_height_max = height;
}
t->display_map[t->n_display_map++] = column;
column = va_arg(ap, size_t);
- if (column == (size_t) -1)
+ if (column == SIZE_MAX)
break;
}
t->sort_map[t->n_sort_map++] = column;
column = va_arg(ap, size_t);
- if (column == (size_t) -1)
+ if (column == SIZE_MAX)
break;
}
va_end(ap);
k = utf8_console_width(s);
s = NULL;
}
- if (k == (size_t) -1)
+ if (k == SIZE_MAX)
return -EINVAL;
if (k > max_width)
max_width = k;
if (!t)
return -ENOMEM;
- if (table->cell_height_max != (size_t) -1) {
+ if (table->cell_height_max != SIZE_MAX) {
r = string_truncate_lines(t, table->cell_height_max, &truncated);
if (r < 0)
return r;
if (r < 0)
return r;
- if (d->maximum_width != (size_t) -1 && width > d->maximum_width)
+ if (d->maximum_width != SIZE_MAX && width > d->maximum_width)
width = d->maximum_width;
if (width < d->minimum_width)
for (size_t j = 0; j < display_columns; j++) {
minimum_width[j] = 1;
- maximum_width[j] = (size_t) -1;
+ maximum_width[j] = SIZE_MAX;
}
for (unsigned pass = 0; pass < 2; pass++) {
/* First pass: determine column sizes */
for (size_t j = 0; j < display_columns; j++)
- requested_width[j] = (size_t) -1;
+ requested_width[j] = SIZE_MAX;
bool any_soft = false;
}
/* Determine the biggest width that any cell in this column would like to have */
- if (requested_width[j] == (size_t) -1 ||
+ if (requested_width[j] == SIZE_MAX ||
requested_width[j] < req_width)
requested_width[j] = req_width;
minimum_width[j] = d->minimum_width;
/* Determine the maximum width any cell in this column needs */
- if (d->maximum_width != (size_t) -1 &&
- (maximum_width[j] == (size_t) -1 ||
+ if (d->maximum_width != SIZE_MAX &&
+ (maximum_width[j] == SIZE_MAX ||
maximum_width[j] > d->maximum_width))
maximum_width[j] = d->maximum_width;
table_minimum_width += minimum_width[j];
- if (maximum_width[j] == (size_t) -1)
- table_maximum_width = (size_t) -1;
+ if (maximum_width[j] == SIZE_MAX)
+ table_maximum_width = SIZE_MAX;
else
table_maximum_width += maximum_width[j];
}
/* Calculate effective table width */
- if (t->width != 0 && t->width != (size_t) -1)
+ if (t->width != 0 && t->width != SIZE_MAX)
table_effective_width = t->width;
else if (t->width == 0 ||
((pass > 0 || !any_soft) && (pager_have() || !isatty(STDOUT_FILENO))))
else
table_effective_width = MIN(table_requested_width, columns());
- if (table_maximum_width != (size_t) -1 && table_effective_width > table_maximum_width)
+ if (table_maximum_width != SIZE_MAX && table_effective_width > table_maximum_width)
table_effective_width = table_maximum_width;
if (table_effective_width < table_minimum_width)
else
width[j] = requested_width[j] + (extra * column_weight[j]) / weight_sum;
- if (maximum_width[j] != (size_t) -1 && width[j] > maximum_width[j])
+ if (maximum_width[j] != SIZE_MAX && width[j] > maximum_width[j])
width[j] = maximum_width[j];
if (width[j] < minimum_width[j])
extra = table_effective_width - table_minimum_width;
for (size_t j = 0; j < display_columns; j++)
- width[j] = (size_t) -1;
+ width[j] = SIZE_MAX;
for (;;) {
bool restart = false;
size_t delta, w;
/* Did this column already get something assigned? If so, let's skip to the next */
- if (width[j] != (size_t) -1)
+ if (width[j] != SIZE_MAX)
continue;
if (weight_sum == 0)
return r;
if (r > 0) {
/* There are more lines to come */
- if ((t->cell_height_max == (size_t) -1 || n_subline + 1 < t->cell_height_max))
+ if ((t->cell_height_max == SIZE_MAX || n_subline + 1 < t->cell_height_max))
more_sublines = true; /* There are more lines to come */
else
lines_truncated = true;
case TABLE_SIZE:
case TABLE_BPS:
- if (d->size == (uint64_t) -1)
+ if (d->size == UINT64_MAX)
return json_variant_new_null(ret);
return json_variant_new_unsigned(ret, d->size);
int table_add_cell_full(Table *t, TableCell **ret_cell, TableDataType type, const void *data, size_t minimum_width, size_t maximum_width, unsigned weight, unsigned align_percent, unsigned ellipsize_percent);
static inline int table_add_cell(Table *t, TableCell **ret_cell, TableDataType type, const void *data) {
- return table_add_cell_full(t, ret_cell, type, data, (size_t) -1, (size_t) -1, (unsigned) -1, (unsigned) -1, (unsigned) -1);
+ return table_add_cell_full(t, ret_cell, type, data, SIZE_MAX, SIZE_MAX, UINT_MAX, UINT_MAX, UINT_MAX);
}
int table_add_cell_stringf(Table *t, TableCell **ret_cell, const char *format, ...) _printf_(3, 4);
assert_return(ret, -EINVAL);
if (!s) {
- assert_return(IN_SET(n, 0, (size_t) -1), -EINVAL);
+ assert_return(IN_SET(n, 0, SIZE_MAX), -EINVAL);
return json_variant_new_null(ret);
}
- if (n == (size_t) -1) /* determine length automatically */
+ if (n == SIZE_MAX) /* determine length automatically */
n = strlen(s);
else if (memchr(s, 0, n)) /* don't allow embedded NUL, as we can't express that in JSON */
return -EINVAL;
continue;
}
- len = utf8_encoded_valid_unichar(c, (size_t) -1);
+ len = utf8_encoded_valid_unichar(c, SIZE_MAX);
if (len < 0)
return len;
size_t n_elements, n_elements_allocated;
unsigned line_before;
unsigned column_before;
- size_t n_suppress; /* When building: if > 0, suppress this many subsequent elements. If == (size_t) -1, suppress all subsequent elements */
+ size_t n_suppress; /* When building: if > 0, suppress this many subsequent elements. If == SIZE_MAX, suppress all subsequent elements */
} JsonStack;
static void json_stack_release(JsonStack *s) {
stack[n_stack++] = (JsonStack) {
.expect = EXPECT_ARRAY_ELEMENT,
- .n_suppress = current->n_suppress != 0 ? (size_t) -1 : 0, /* if we shall suppress the
+ .n_suppress = current->n_suppress != 0 ? SIZE_MAX : 0, /* if we shall suppress the
* new array, then we should
* also suppress all array
* members */
stack[n_stack++] = (JsonStack) {
.expect = EXPECT_OBJECT_KEY,
- .n_suppress = current->n_suppress != 0 ? (size_t) -1 : 0, /* if we shall suppress the
+ .n_suppress = current->n_suppress != 0 ? SIZE_MAX : 0, /* if we shall suppress the
* new object, then we should
* also suppress all object
* members */
n_subtract = 1; /* we generated one item */
- if (!b && current->n_suppress != (size_t) -1)
+ if (!b && current->n_suppress != SIZE_MAX)
current->n_suppress += 2; /* Suppress this one and the next item */
current->expect = EXPECT_OBJECT_VALUE;
}
/* If we are supposed to suppress items, let's subtract how many items where generated from that
- * counter. Except if the counter is (size_t) -1, i.e. we shall suppress an infinite number of elements
+ * counter. Except if the counter is SIZE_MAX, i.e. we shall suppress an infinite number of elements
* on this stack level */
- if (current->n_suppress != (size_t) -1) {
+ if (current->n_suppress != SIZE_MAX) {
if (current->n_suppress <= n_subtract) /* Saturated */
current->n_suppress = 0;
else
assert_cc(sizeof(gid_t) == sizeof(uint32_t));
DISABLE_WARNING_TYPE_LIMITS;
- assert_cc(((uid_t) -1 < (uid_t) 0) == ((gid_t) -1 < (gid_t) 0));
+ assert_cc((UID_INVALID < (uid_t) 0) == (GID_INVALID < (gid_t) 0));
REENABLE_WARNING;
if (json_variant_is_null(variant)) {
if (!json_variant_is_string(v))
return -EINVAL;
- return unbase64mem(json_variant_string(v), (size_t) -1, ret, ret_size);
+ return unbase64mem(json_variant_string(v), SIZE_MAX, ret, ret_size);
}
int json_variant_unhex(JsonVariant *v, void **ret, size_t *ret_size) {
if (!json_variant_is_string(v))
return -EINVAL;
- return unhexmem(json_variant_string(v), (size_t) -1, ret, ret_size);
+ return unhexmem(json_variant_string(v), SIZE_MAX, ret, ret_size);
}
static const char* const json_variant_type_table[_JSON_VARIANT_TYPE_MAX] = {
int json_variant_new_id128(JsonVariant **ret, sd_id128_t id);
static inline int json_variant_new_string(JsonVariant **ret, const char *s) {
- return json_variant_new_stringn(ret, s, (size_t) -1);
+ return json_variant_new_stringn(ret, s, SIZE_MAX);
}
JsonVariant *json_variant_ref(JsonVariant *v);
assert(mode >= 0);
assert(mode < _OUTPUT_MODE_MAX);
- if (how_many == (unsigned) -1)
+ if (how_many == UINT_MAX)
need_seek = true;
else {
/* Seek to end */
CLONE_NEWUSER| \
CLONE_NEWUTS))
-#define NAMESPACE_FLAGS_INITIAL ((unsigned long) -1)
+#define NAMESPACE_FLAGS_INITIAL (ULONG_MAX)
int namespace_flags_from_string(const char *name, unsigned long *ret);
int namespace_flags_to_string(unsigned long flags, char **ret);
_noreturn_ static void pager_fallback(void) {
int r;
- r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, (uint64_t) -1, 0);
+ r = copy_bytes(STDIN_FILENO, STDOUT_FILENO, UINT64_MAX, 0);
if (r < 0) {
log_error_errno(r, "Internal pager failed: %m");
_exit(EXIT_FAILURE);
assert(f);
- if (width == (unsigned) -1 && height == (unsigned) -1)
+ if (width == UINT_MAX && height == UINT_MAX)
return 0; /* noop */
- if (width != (unsigned) -1 &&
+ if (width != UINT_MAX &&
(width == 0 || width > USHRT_MAX))
return -ERANGE;
- if (height != (unsigned) -1 &&
+ if (height != UINT_MAX &&
(height == 0 || height > USHRT_MAX))
return -ERANGE;
- if (width == (unsigned) -1 || height == (unsigned) -1) {
+ if (width == UINT_MAX || height == UINT_MAX) {
if (ioctl(f->master, TIOCGWINSZ, &ws) < 0)
return -errno;
- if (width != (unsigned) -1)
+ if (width != UINT_MAX)
ws.ws_col = width;
- if (height != (unsigned) -1)
+ if (height != UINT_MAX)
ws.ws_row = height;
} else
ws = (struct winsize) {
}
/* accept valid utf8 */
- len = utf8_encoded_valid_unichar(str + i, (size_t) -1);
+ len = utf8_encoded_valid_unichar(str + i, SIZE_MAX);
if (len > 1) {
i += len;
continue;
uintmax_t k;
if (json_variant_is_null(variant)) {
- *m = (mode_t) -1;
+ *m = MODE_INVALID;
return 0;
}
uintmax_t k;
if (json_variant_is_null(variant)) {
- *m = (mode_t) -1;
+ *m = MODE_INVALID;
return 0;
}
if (!json_variant_is_string(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a string.", strna(name));
- r = unbase64mem(json_variant_string(variant), (size_t) -1, &b, &l);
+ r = unbase64mem(json_variant_string(variant), SIZE_MAX, &b, &l);
if (r < 0)
return json_log(variant, flags, r, "Failed to decode encrypted PKCS#11 key: %m");
if (!json_variant_is_string(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a string.", strna(name));
- r = unbase64mem(json_variant_string(variant), (size_t) -1, &b, &l);
+ r = unbase64mem(json_variant_string(variant), SIZE_MAX, &b, &l);
if (r < 0)
return json_log(variant, flags, r, "Failed to decode FIDO2 credential ID: %m");
if (!array)
return log_oom();
- r = unbase64mem(json_variant_string(e), (size_t) -1, &b, &l);
+ r = unbase64mem(json_variant_string(e), SIZE_MAX, &b, &l);
if (r < 0)
return json_log(variant, flags, r, "Failed to decode FIDO2 credential ID: %m");
if (!json_variant_is_string(variant))
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a string.", strna(name));
- r = unbase64mem(json_variant_string(variant), (size_t) -1, &b, &l);
+ r = unbase64mem(json_variant_string(variant), SIZE_MAX, &b, &l);
if (r < 0)
return json_log(variant, flags, r, "Failed to decode FIDO2 salt: %m");
mode_t user_record_access_mode(UserRecord *h) {
assert(h);
- return h->access_mode != (mode_t) -1 ? h->access_mode : 0700;
+ return h->access_mode != MODE_INVALID ? h->access_mode : 0700;
}
const char* user_record_home_directory(UserRecord *h) {
#include <stdbool.h>
-#define VERB_ANY ((unsigned) -1)
+#define VERB_ANY (UINT_MAX)
typedef enum VerbFlags {
VERB_DEFAULT = 1 << 0, /* The verb to run if no verb is specified */
if (i->status_errno > 0)
printf(" Error: %i (%s)\n", i->status_errno, strerror_safe(i->status_errno));
- if (i->ip_ingress_bytes != (uint64_t) -1 && i->ip_egress_bytes != (uint64_t) -1) {
+ if (i->ip_ingress_bytes != UINT64_MAX && i->ip_egress_bytes != UINT64_MAX) {
char buf_in[FORMAT_BYTES_MAX], buf_out[FORMAT_BYTES_MAX];
printf(" IP: %s in, %s out\n",
format_bytes(buf_out, sizeof(buf_out), i->io_write_bytes));
}
- if (i->tasks_current != (uint64_t) -1) {
+ if (i->tasks_current != UINT64_MAX) {
printf(" Tasks: %" PRIu64, i->tasks_current);
- if (i->tasks_max != (uint64_t) -1)
+ if (i->tasks_max != UINT64_MAX)
printf(" (limit: %" PRIu64 ")\n", i->tasks_max);
else
printf("\n");
}
- if (i->memory_current != (uint64_t) -1) {
+ if (i->memory_current != UINT64_MAX) {
char buf[FORMAT_BYTES_MAX];
printf(" Memory: %s", format_bytes(buf, sizeof(buf), i->memory_current));
printf("\n");
}
- if (i->cpu_usage_nsec != (uint64_t) -1) {
+ if (i->cpu_usage_nsec != UINT64_MAX) {
char buf[FORMAT_TIMESPAN_MAX];
printf(" CPU: %s\n", format_timespan(buf, sizeof(buf), i->cpu_usage_nsec / NSEC_PER_USEC, USEC_PER_MSEC));
}
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
_cleanup_set_free_ Set *found_properties = NULL;
_cleanup_(unit_status_info_free) UnitStatusInfo info = {
- .memory_current = (uint64_t) -1,
+ .memory_current = UINT64_MAX,
.memory_high = CGROUP_LIMIT_MAX,
.memory_max = CGROUP_LIMIT_MAX,
.memory_swap_max = CGROUP_LIMIT_MAX,
- .memory_limit = (uint64_t) -1,
- .cpu_usage_nsec = (uint64_t) -1,
- .tasks_current = (uint64_t) -1,
- .tasks_max = (uint64_t) -1,
- .ip_ingress_bytes = (uint64_t) -1,
- .ip_egress_bytes = (uint64_t) -1,
+ .memory_limit = UINT64_MAX,
+ .cpu_usage_nsec = UINT64_MAX,
+ .tasks_current = UINT64_MAX,
+ .tasks_max = UINT64_MAX,
+ .ip_ingress_bytes = UINT64_MAX,
+ .ip_egress_bytes = UINT64_MAX,
.io_read_bytes = UINT64_MAX,
.io_write_bytes = UINT64_MAX,
};
SD_LLDP_SYSTEM_CAPABILITIES_TPMR = 1 << 10,
};
-#define SD_LLDP_SYSTEM_CAPABILITIES_ALL ((uint16_t) -1)
+#define SD_LLDP_SYSTEM_CAPABILITIES_ALL (UINT16_MAX)
#define SD_LLDP_SYSTEM_CAPABILITIES_ALL_ROUTERS \
((uint16_t) \
* POLLOUT, ...) to check for. */
int sd_resolve_get_events(sd_resolve *resolve);
-/* Return the poll() timeout to pass. Returns (uint64_t) -1 as
+/* Return the poll() timeout to pass. Returns UINT64_MAX as
* timeout if no timeout is needed. */
int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *timeout_usec);
if (r < 0)
return r;
- r = copy_bytes(src, fileno(dst), (uint64_t) -1, COPY_REFLINK);
+ r = copy_bytes(src, fileno(dst), UINT64_MAX, COPY_REFLINK);
if (r < 0)
return r;
.sp_warn = -1,
.sp_inact = -1,
.sp_expire = -1,
- .sp_flag = (unsigned long) -1, /* this appears to be what everybody does ... */
+ .sp_flag = ULONG_MAX, /* this appears to be what everybody does ... */
};
r = putspent_sane(&n, shadow);
int main(int argc, const char *argv[]) {
_cleanup_bitmap_free_ Bitmap *b = NULL, *b2 = NULL;
- unsigned n = (unsigned) -1, i = 0;
+ unsigned n = UINT_MAX, i = 0;
b = bitmap_new();
assert_se(b);
else if (i == 1)
i = 256;
else if (i == 256)
- i = (unsigned) -1;
+ i = UINT_MAX;
}
- assert_se(i == (unsigned) -1);
+ assert_se(i == UINT_MAX);
i = 0;
else if (i == 1)
i = 256;
else if (i == 256)
- i = (unsigned) -1;
+ i = UINT_MAX;
}
- assert_se(i == (unsigned) -1);
+ assert_se(i == UINT_MAX);
b2 = bitmap_copy(b);
assert_se(b2);
bitmap_free(b2);
b2 = NULL;
- assert_se(bitmap_set(b, (unsigned) -1) == -ERANGE);
+ assert_se(bitmap_set(b, UINT_MAX) == -ERANGE);
bitmap_free(b);
b = NULL;
u = after;
r = calendar_spec_next_usec(c, after, &u);
printf("At: %s\n", r < 0 ? strerror_safe(r) : format_timestamp_style(buf, sizeof buf, u, TIMESTAMP_US));
- if (expect != (usec_t)-1)
+ if (expect != USEC_INFINITY)
assert_se(r >= 0 && u == expect);
else
assert(r == -ENOENT);
assert_se(pipe2(pipefd, O_CLOEXEC) == 0);
- r = copy_bytes(infd, pipefd[1], (uint64_t) -1, 0);
+ r = copy_bytes(infd, pipefd[1], UINT64_MAX, 0);
assert_se(r == 0);
r = read(pipefd[0], buf, sizeof(buf));
assert_se(fd3 >= 0);
r = copy_bytes(fd, fd2, max_bytes, try_reflink ? COPY_REFLINK : 0);
- if (max_bytes == (uint64_t) -1)
+ if (max_bytes == UINT64_MAX)
assert_se(r == 0);
else
assert_se(IN_SET(r, 0, 1));
assert_se(fstat(fd2, &buf2) == 0);
assert_se((uint64_t) buf2.st_size == MIN((uint64_t) buf.st_size, max_bytes));
- if (max_bytes < (uint64_t) -1)
+ if (max_bytes < UINT64_MAX)
/* Make sure the file is now higher than max_bytes */
assert_se(ftruncate(fd2, max_bytes + 1) == 0);
assert_se(lseek(fd2, 0, SEEK_SET) == 0);
r = copy_bytes(fd2, fd3, max_bytes, try_reflink ? COPY_REFLINK : 0);
- if (max_bytes == (uint64_t) -1)
+ if (max_bytes == UINT64_MAX)
assert_se(r == 0);
else
/* We cannot distinguish between the input being exactly max_bytes
assert_se(fstat(fd3, &buf3) == 0);
- if (max_bytes == (uint64_t) -1)
+ if (max_bytes == UINT64_MAX)
assert_se(buf3.st_size == buf2.st_size);
else
assert_se((uint64_t) buf3.st_size == max_bytes);
assert_se(mkdtemp_malloc(NULL, &p) >= 0);
assert_se(f = path_join(p, "version"));
- assert_se(copy_file("/proc/version", f, 0, (mode_t) -1, 0, 0, 0) >= 0);
+ assert_se(copy_file("/proc/version", f, 0, MODE_INVALID, 0, 0, 0) >= 0);
assert_se(read_one_line_file("/proc/version", &a) >= 0);
assert_se(read_one_line_file(f, &b) >= 0);
test_copy_file_fd();
test_copy_tree();
test_copy_bytes();
- test_copy_bytes_regular_file(argv[0], false, (uint64_t) -1);
- test_copy_bytes_regular_file(argv[0], true, (uint64_t) -1);
+ test_copy_bytes_regular_file(argv[0], false, UINT64_MAX);
+ test_copy_bytes_regular_file(argv[0], true, UINT64_MAX);
test_copy_bytes_regular_file(argv[0], false, 1000); /* smaller than copy buffer size */
test_copy_bytes_regular_file(argv[0], true, 1000);
test_copy_bytes_regular_file(argv[0], false, 32000); /* larger than copy buffer size */
static void test_read_line_one_file(FILE *f) {
_cleanup_free_ char *line = NULL;
- assert_se(read_line(f, (size_t) -1, &line) == 15 && streq(line, "Some test data"));
+ assert_se(read_line(f, SIZE_MAX, &line) == 15 && streq(line, "Some test data"));
line = mfree(line);
- assert_se(read_line(f, (size_t) -1, &line) > 0 && streq(line, "루Non-ascii chars: ąę„”"));
+ assert_se(read_line(f, SIZE_MAX, &line) > 0 && streq(line, "루Non-ascii chars: ąę„”"));
line = mfree(line);
- assert_se(read_line(f, (size_t) -1, &line) == 13 && streq(line, "terminators"));
+ assert_se(read_line(f, SIZE_MAX, &line) == 13 && streq(line, "terminators"));
line = mfree(line);
- assert_se(read_line(f, (size_t) -1, &line) == 15 && streq(line, "and even more"));
+ assert_se(read_line(f, SIZE_MAX, &line) == 15 && streq(line, "and even more"));
line = mfree(line);
- assert_se(read_line(f, (size_t) -1, &line) == 25 && streq(line, "now the same with a NUL"));
+ assert_se(read_line(f, SIZE_MAX, &line) == 25 && streq(line, "now the same with a NUL"));
line = mfree(line);
- assert_se(read_line(f, (size_t) -1, &line) == 10 && streq(line, "and more"));
+ assert_se(read_line(f, SIZE_MAX, &line) == 10 && streq(line, "and more"));
line = mfree(line);
- assert_se(read_line(f, (size_t) -1, &line) == 16 && streq(line, "and even more"));
+ assert_se(read_line(f, SIZE_MAX, &line) == 16 && streq(line, "and even more"));
line = mfree(line);
- assert_se(read_line(f, (size_t) -1, &line) == 20 && streq(line, "and yet even more"));
+ assert_se(read_line(f, SIZE_MAX, &line) == 20 && streq(line, "and yet even more"));
line = mfree(line);
assert_se(read_line(f, 1024, &line) == 30 && streq(line, "With newlines, and a NUL byte"));
assert_se(read_line(f, 1024, &line) == 14 && streq(line, "an empty line"));
line = mfree(line);
- assert_se(read_line(f, (size_t) -1, NULL) == 16);
+ assert_se(read_line(f, SIZE_MAX, NULL) == 16);
assert_se(read_line(f, 16, &line) == -ENOBUFS);
line = mfree(line);
assert_se(f = fmemopen_unlocked((void*) eof_endings[i].string, eof_endings[i].length, "r"));
- r = read_line(f, (size_t) -1, &s);
+ r = read_line(f, SIZE_MAX, &s);
assert_se((size_t) r == eof_endings[i].length);
assert_se(streq_ptr(s, "foo"));
- assert_se(read_line(f, (size_t) -1, NULL) == 0); /* Ensure we hit EOF */
+ assert_se(read_line(f, SIZE_MAX, NULL) == 0); /* Ensure we hit EOF */
}
}
"lines \n"));
formatted = mfree(formatted);
- table_set_cell_height_max(table, (size_t) -1);
+ table_set_cell_height_max(table, SIZE_MAX);
assert_se(table_format(table, &formatted) >= 0);
fputs(formatted, stdout);
assert_se(streq(formatted,
" line…\n"));
formatted = mfree(formatted);
- table_set_cell_height_max(table, (size_t) -1);
+ table_set_cell_height_max(table, SIZE_MAX);
assert_se(table_format(table, &formatted) >= 0);
fputs(formatted, stdout);
assert_se(streq(formatted,
"lines \n"));
formatted = mfree(formatted);
- table_set_cell_height_max(table, (size_t) -1);
+ table_set_cell_height_max(table, SIZE_MAX);
assert_se(table_format(table, &formatted) >= 0);
fputs(formatted, stdout);
assert_se(streq(formatted,
" line…\n"));
formatted = mfree(formatted);
- table_set_cell_height_max(table, (size_t) -1);
+ table_set_cell_height_max(table, SIZE_MAX);
assert_se(table_format(table, &formatted) >= 0);
fputs(formatted, stdout);
assert_se(streq(formatted,
"three different lines two lines\n"));
formatted = mfree(formatted);
- table_set_cell_height_max(table, (size_t) -1);
+ table_set_cell_height_max(table, SIZE_MAX);
assert_se(table_format(table, &formatted) >= 0);
fputs(formatted, stdout);
assert_se(streq(formatted,
" ___7___ ___8___\n"));
formatted = mfree(formatted);
- table_set_cell_height_max(table, (size_t) -1);
+ table_set_cell_height_max(table, SIZE_MAX);
assert_se(table_format(table, &formatted) >= 0);
fputs(formatted, stdout);
assert_se(streq(formatted,
formatted = mfree(formatted);
- table_set_width(t, (size_t) -1);
- assert_se(table_set_sort(t, (size_t) 0, (size_t) 2, (size_t) -1) >= 0);
+ table_set_width(t, SIZE_MAX);
+ assert_se(table_set_sort(t, (size_t) 0, (size_t) 2, SIZE_MAX) >= 0);
assert_se(table_format(t, &formatted) >= 0);
printf("%s\n", formatted);
formatted = mfree(formatted);
- assert_se(table_set_display(t, (size_t) 2, (size_t) 0, (size_t) 2, (size_t) 0, (size_t) 0, (size_t) -1) >= 0);
+ assert_se(table_set_display(t, (size_t) 2, (size_t) 0, (size_t) 2, (size_t) 0, (size_t) 0, SIZE_MAX) >= 0);
assert_se(table_format(t, &formatted) >= 0);
printf("%s\n", formatted);
assert_se(access(q, F_OK) < 0 && errno == ENOENT);
/* Check that a manual copy is detected */
- assert_se(copy_file(p, q, 0, (mode_t) -1, 0, 0, COPY_REFLINK) >= 0);
+ assert_se(copy_file(p, q, 0, MODE_INVALID, 0, 0, COPY_REFLINK) >= 0);
assert_se(conservative_renameat(AT_FDCWD, q, AT_FDCWD, p) == 0);
assert_se(access(q, F_OK) < 0 && errno == ENOENT);
if (retval == 0) {
char *answer;
- if (l == (size_t) -1)
+ if (l == SIZE_MAX)
l = strlen(s);
assert_se(hex = hexmem(mem, len));
test_unhexmem_one(NULL, 0, 0);
test_unhexmem_one("", 0, 0);
- test_unhexmem_one("", (size_t) -1, 0);
- test_unhexmem_one(" \n \t\r \t\t \n\n\n", (size_t) -1, 0);
+ test_unhexmem_one("", SIZE_MAX, 0);
+ test_unhexmem_one(" \n \t\r \t\t \n\n\n", SIZE_MAX, 0);
test_unhexmem_one(hex_invalid, strlen(hex_invalid), -EINVAL);
test_unhexmem_one(hex_invalid, (size_t) - 1, -EINVAL);
test_unhexmem_one(hex, strlen(hex) - 1, -EPIPE);
test_unhexmem_one(hex, strlen(hex), 0);
- test_unhexmem_one(hex, (size_t) -1, 0);
+ test_unhexmem_one(hex, SIZE_MAX, 0);
test_unhexmem_one(hex_space, strlen(hex_space), 0);
- test_unhexmem_one(hex_space, (size_t) -1, 0);
+ test_unhexmem_one(hex_space, SIZE_MAX, 0);
}
/* https://tools.ietf.org/html/rfc4648#section-10 */
_cleanup_free_ void *mem = NULL;
size_t len;
- assert_se(unbase32hexmem(hex, (size_t) -1, padding, &mem, &len) == retval);
+ assert_se(unbase32hexmem(hex, SIZE_MAX, padding, &mem, &len) == retval);
if (retval == 0) {
char *str;
_cleanup_free_ void *buffer = NULL;
size_t size = 0;
- assert_se(unbase64mem(input, (size_t) -1, &buffer, &size) == ret);
+ assert_se(unbase64mem(input, SIZE_MAX, &buffer, &size) == ret);
if (ret >= 0) {
assert_se(size == strlen(output));
assert_se(prioq_peek(q) == NULL);
assert_se(prioq_peek_by_index(q, 0) == NULL);
assert_se(prioq_peek_by_index(q, 1) == NULL);
- assert_se(prioq_peek_by_index(q, (unsigned) -1) == NULL);
+ assert_se(prioq_peek_by_index(q, UINT_MAX) == NULL);
for (i = 0; i < SET_SIZE; i++) {
assert_se(t = new0(struct test, 1));
assert_se(utf8_encoded_valid_unichar("\302\256", 1) == -EINVAL); /* truncated */
assert_se(utf8_encoded_valid_unichar("\302\256", 2) == 2);
assert_se(utf8_encoded_valid_unichar("\302\256", 3) == 2);
- assert_se(utf8_encoded_valid_unichar("\302\256", (size_t) -1) == 2);
+ assert_se(utf8_encoded_valid_unichar("\302\256", SIZE_MAX) == 2);
assert_se(utf8_encoded_valid_unichar("a", 1) == 1);
assert_se(utf8_encoded_valid_unichar("a", 2) == 1);
assert_se(utf8_encoded_valid_unichar("\341\204", 1) == -EINVAL); /* truncated, potentially valid */
assert_se(utf8_n_codepoints("串") == 1);
assert_se(utf8_n_codepoints("") == 0);
assert_se(utf8_n_codepoints("…👊🔪💐…") == 5);
- assert_se(utf8_n_codepoints("\xF1") == (size_t) -1);
+ assert_se(utf8_n_codepoints("\xF1") == SIZE_MAX);
}
static void test_utf8_console_width(void) {
assert_se(utf8_console_width("串") == 2);
assert_se(utf8_console_width("") == 0);
assert_se(utf8_console_width("…👊🔪💐…") == 8);
- assert_se(utf8_console_width("\xF1") == (size_t) -1);
+ assert_se(utf8_console_width("\xF1") == SIZE_MAX);
}
static void test_utf8_to_utf16(void) {