tree-wide: use UINT64_MAX or friends

This commit is contained in:
Yu Watanabe
2021-03-05 07:10:13 +09:00
parent ef1e0b9a46
commit f5fbe71d95
150 changed files with 530 additions and 528 deletions
+1 -1
View File
@@ -741,7 +741,7 @@ _public_ int sd_bus_get_owner_creds(sd_bus *bus, uint64_t mask, sd_bus_creds **r
mask &= ~SD_BUS_CREDS_AUGMENT;
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)
+1 -1
View File
@@ -81,7 +81,7 @@ _public_ int sd_bus_message_dump(sd_bus_message *m, FILE *f, uint64_t flags) {
m->header->version);
/* Display synthetic message serial number in a more readable
* format than (uint32_t) -1 */
* format than UINT32_MAX */
if (BUS_MESSAGE_COOKIE(m) == 0xFFFFFFFFULL)
fprintf(f, " Cookie=-1");
else
+25 -25
View File
@@ -162,7 +162,7 @@ static void *message_extend_fields(sd_bus_message *m, size_t align, size_t sz, b
new_size = start + sz;
if (new_size < start ||
new_size > (size_t) ((uint32_t) -1))
new_size > (size_t) (UINT32_MAX))
goto poison;
if (old_size == new_size)
@@ -1337,7 +1337,7 @@ static void *message_extend_body(
added = padding + sz;
/* Check for 32bit overflows */
if (end_body > (size_t) ((uint32_t) -1) ||
if (end_body > (size_t) (UINT32_MAX) ||
end_body < start_body) {
m->poisoned = true;
return NULL;
@@ -2340,13 +2340,13 @@ _public_ int sd_bus_message_appendv(
assert_return(!m->sealed, -EPERM);
assert_return(!m->poisoned, -ESTALE);
n_array = (unsigned) -1;
n_array = UINT_MAX;
n_struct = strlen(types);
for (;;) {
const char *t;
if (n_array == 0 || (n_array == (unsigned) -1 && n_struct == 0)) {
if (n_array == 0 || (n_array == UINT_MAX && n_struct == 0)) {
r = type_stack_pop(stack, ELEMENTSOF(stack), &stack_ptr, &types, &n_struct, &n_array);
if (r < 0)
return r;
@@ -2361,7 +2361,7 @@ _public_ int sd_bus_message_appendv(
}
t = types;
if (n_array != (unsigned) -1)
if (n_array != UINT_MAX)
n_array--;
else {
types++;
@@ -2445,7 +2445,7 @@ _public_ int sd_bus_message_appendv(
return r;
}
if (n_array == (unsigned) -1) {
if (n_array == UINT_MAX) {
types += k;
n_struct -= k;
}
@@ -2478,7 +2478,7 @@ _public_ int sd_bus_message_appendv(
types = s;
n_struct = strlen(s);
n_array = (unsigned) -1;
n_array = UINT_MAX;
break;
}
@@ -2502,7 +2502,7 @@ _public_ int sd_bus_message_appendv(
return r;
}
if (n_array == (unsigned) -1) {
if (n_array == UINT_MAX) {
types += k - 1;
n_struct -= k - 1;
}
@@ -2513,7 +2513,7 @@ _public_ int sd_bus_message_appendv(
types = t + 1;
n_struct = k - 2;
n_array = (unsigned) -1;
n_array = UINT_MAX;
break;
}
@@ -2675,7 +2675,7 @@ _public_ int sd_bus_message_append_array_memfd(
if (r < 0)
return r;
if (offset == 0 && size == (uint64_t) -1)
if (offset == 0 && size == UINT64_MAX)
size = real_size;
else if (offset + size > real_size)
return -EMSGSIZE;
@@ -2692,7 +2692,7 @@ _public_ int sd_bus_message_append_array_memfd(
if (size % sz != 0)
return -EINVAL;
if (size > (uint64_t) (uint32_t) -1)
if (size > (uint64_t) UINT32_MAX)
return -EINVAL;
r = sd_bus_message_open_container(m, SD_BUS_TYPE_ARRAY, CHAR_TO_STR(type));
@@ -2750,7 +2750,7 @@ _public_ int sd_bus_message_append_string_memfd(
if (r < 0)
return r;
if (offset == 0 && size == (uint64_t) -1)
if (offset == 0 && size == UINT64_MAX)
size = real_size;
else if (offset + size > real_size)
return -EMSGSIZE;
@@ -2759,7 +2759,7 @@ _public_ int sd_bus_message_append_string_memfd(
if (size == 0)
return -EINVAL;
if (size > (uint64_t) (uint32_t) -1)
if (size > (uint64_t) UINT32_MAX)
return -EINVAL;
c = message_get_last_container(m);
@@ -4430,7 +4430,7 @@ _public_ int sd_bus_message_readv(
* in a single stackframe. We hence implement our own
* home-grown stack in an array. */
n_array = (unsigned) -1; /* length of current array entries */
n_array = UINT_MAX; /* length of current array entries */
n_struct = strlen(types); /* length of current struct contents signature */
for (;;) {
@@ -4438,7 +4438,7 @@ _public_ int sd_bus_message_readv(
n_loop++;
if (n_array == 0 || (n_array == (unsigned) -1 && n_struct == 0)) {
if (n_array == 0 || (n_array == UINT_MAX && n_struct == 0)) {
r = type_stack_pop(stack, ELEMENTSOF(stack), &stack_ptr, &types, &n_struct, &n_array);
if (r < 0)
return r;
@@ -4453,7 +4453,7 @@ _public_ int sd_bus_message_readv(
}
t = types;
if (n_array != (unsigned) -1)
if (n_array != UINT_MAX)
n_array--;
else {
types++;
@@ -4514,7 +4514,7 @@ _public_ int sd_bus_message_readv(
}
}
if (n_array == (unsigned) -1) {
if (n_array == UINT_MAX) {
types += k;
n_struct -= k;
}
@@ -4553,7 +4553,7 @@ _public_ int sd_bus_message_readv(
types = s;
n_struct = strlen(s);
n_array = (unsigned) -1;
n_array = UINT_MAX;
break;
}
@@ -4581,7 +4581,7 @@ _public_ int sd_bus_message_readv(
}
}
if (n_array == (unsigned) -1) {
if (n_array == UINT_MAX) {
types += k - 1;
n_struct -= k - 1;
}
@@ -4592,7 +4592,7 @@ _public_ int sd_bus_message_readv(
types = t + 1;
n_struct = k - 2;
n_array = (unsigned) -1;
n_array = UINT_MAX;
break;
}
@@ -5034,7 +5034,7 @@ static int message_skip_fields(
char t;
size_t l;
if (array_size != (uint32_t) -1 &&
if (array_size != UINT32_MAX &&
array_size <= *ri - original_index)
return 0;
@@ -5122,7 +5122,7 @@ static int message_skip_fields(
if (r < 0)
return r;
r = message_skip_fields(m, ri, (uint32_t) -1, (const char**) &s);
r = message_skip_fields(m, ri, UINT32_MAX, (const char**) &s);
if (r < 0)
return r;
@@ -5140,7 +5140,7 @@ static int message_skip_fields(
strncpy(sig, *signature + 1, l);
sig[l] = '\0';
r = message_skip_fields(m, ri, (uint32_t) -1, (const char**) &s);
r = message_skip_fields(m, ri, UINT32_MAX, (const char**) &s);
if (r < 0)
return r;
}
@@ -5247,7 +5247,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
_cleanup_free_ char *sig = NULL;
const char *signature;
uint64_t field_type;
size_t item_size = (size_t) -1;
size_t item_size = SIZE_MAX;
if (BUS_MESSAGE_IS_GVARIANT(m)) {
uint64_t *u64;
@@ -5461,7 +5461,7 @@ int bus_message_parse_fields(sd_bus_message *m) {
default:
if (!BUS_MESSAGE_IS_GVARIANT(m))
r = message_skip_fields(m, &ri, (uint32_t) -1, (const char **) &signature);
r = message_skip_fields(m, &ri, UINT32_MAX, (const char **) &signature);
}
if (r < 0)
+1 -1
View File
@@ -620,7 +620,7 @@ static void bus_get_peercred(sd_bus *b) {
assert(b);
assert(!b->ucred_valid);
assert(!b->label);
assert(b->n_groups == (size_t) -1);
assert(b->n_groups == SIZE_MAX);
/* Get the peer for socketpair() sockets */
b->ucred_valid = getpeercred(b->input_fd, &b->ucred) >= 0;
+10 -10
View File
@@ -247,7 +247,7 @@ _public_ int sd_bus_new(sd_bus **ret) {
.creds_mask = SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME,
.accept_fd = true,
.original_pid = getpid_cached(),
.n_groups = (size_t) -1,
.n_groups = SIZE_MAX,
.close_on_exit = true,
};
@@ -1964,8 +1964,8 @@ int bus_seal_synthetic_message(sd_bus *b, sd_bus_message *m) {
* hence let's fill something in for synthetic messages. Since
* synthetic messages might have a fake sender and we don't
* want to interfere with the real sender's serial numbers we
* pick a fixed, artificial one. We use (uint32_t) -1 rather
* than (uint64_t) -1 since dbus1 only had 32bit identifiers,
* pick a fixed, artificial one. We use UINT32_MAX rather
* than UINT64_MAX since dbus1 only had 32bit identifiers,
* even though kdbus can do 64bit. */
return sd_bus_message_seal(m, 0xFFFFFFFFULL, 0);
}
@@ -2332,7 +2332,7 @@ int bus_ensure_running(sd_bus *bus) {
if (r > 0)
continue;
r = sd_bus_wait(bus, (uint64_t) -1);
r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0)
return r;
}
@@ -2460,7 +2460,7 @@ _public_ int sd_bus_call(
left = timeout - n;
} else
left = (uint64_t) -1;
left = UINT64_MAX;
r = bus_poll(bus, true, left);
if (r < 0)
@@ -2580,12 +2580,12 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
c = prioq_peek(bus->reply_callbacks_prioq);
if (!c) {
*timeout_usec = (uint64_t) -1;
*timeout_usec = UINT64_MAX;
return 0;
}
if (c->timeout_usec == 0) {
*timeout_usec = (uint64_t) -1;
*timeout_usec = UINT64_MAX;
return 0;
}
@@ -2598,7 +2598,7 @@ _public_ int sd_bus_get_timeout(sd_bus *bus, uint64_t *timeout_usec) {
case BUS_WATCH_BIND:
case BUS_OPENING:
*timeout_usec = (uint64_t) -1;
*timeout_usec = UINT64_MAX;
return 0;
default:
@@ -3310,7 +3310,7 @@ static int bus_poll(sd_bus *bus, bool need_more, uint64_t timeout_usec) {
}
}
if (timeout_usec != (uint64_t) -1 && (m == USEC_INFINITY || timeout_usec < m))
if (timeout_usec != UINT64_MAX && (m == USEC_INFINITY || timeout_usec < m))
m = timeout_usec;
r = ppoll_usec(p, n, m);
@@ -3376,7 +3376,7 @@ _public_ int sd_bus_flush(sd_bus *bus) {
if (bus->wqueue_size <= 0)
return 0;
r = bus_poll(bus, false, (uint64_t) -1);
r = bus_poll(bus, false, UINT64_MAX);
if (r < 0)
return r;
}
+2 -2
View File
@@ -127,7 +127,7 @@ static int server(sd_bus *bus) {
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) {
log_error_errno(r, "Failed to wait: %m");
goto fail;
@@ -472,7 +472,7 @@ static void* client2(void *p) {
goto finish;
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) {
log_error_errno(r, "Failed to wait: %m");
goto finish;
+1 -1
View File
@@ -255,7 +255,7 @@ static void *server(void *p) {
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) {
log_error_errno(r, "Failed to wait: %m");
goto fail;
+1 -1
View File
@@ -47,7 +47,7 @@ static void *server(void *p) {
}
if (r == 0) {
r = sd_bus_wait(bus, (uint64_t) -1);
r = sd_bus_wait(bus, UINT64_MAX);
if (r < 0) {
log_error_errno(r, "Failed to wait: %m");
goto fail;
+3 -3
View File
@@ -98,7 +98,7 @@ int device_get_devnode_mode(sd_device *device, mode_t *mode) {
if (r < 0)
return r;
if (device->devmode == (mode_t) -1)
if (device->devmode == MODE_INVALID)
return -ENOENT;
if (mode)
@@ -116,7 +116,7 @@ int device_get_devnode_uid(sd_device *device, uid_t *uid) {
if (r < 0)
return r;
if (device->devuid == (uid_t) -1)
if (device->devuid == UID_INVALID)
return -ENOENT;
if (uid)
@@ -154,7 +154,7 @@ int device_get_devnode_gid(sd_device *device, gid_t *gid) {
if (r < 0)
return r;
if (device->devgid == (gid_t) -1)
if (device->devgid == GID_INVALID)
return -ENOENT;
if (gid)
+4 -3
View File
@@ -26,6 +26,7 @@
#include "string-util.h"
#include "strv.h"
#include "strxcpyx.h"
#include "user-util.h"
#include "util.h"
int device_new_aux(sd_device **ret) {
@@ -40,9 +41,9 @@ int device_new_aux(sd_device **ret) {
*device = (sd_device) {
.n_ref = 1,
.watch_handle = -1,
.devmode = (mode_t) -1,
.devuid = (uid_t) -1,
.devgid = (gid_t) -1,
.devmode = MODE_INVALID,
.devuid = UID_INVALID,
.devgid = GID_INVALID,
.action = _SD_DEVICE_ACTION_INVALID,
};
+3 -3
View File
@@ -1236,7 +1236,7 @@ _public_ int sd_event_add_time(
assert_return(e, -EINVAL);
assert_return(e = event_resolve(e), -ENOPKG);
assert_return(accuracy != (uint64_t) -1, -EINVAL);
assert_return(accuracy != UINT64_MAX, -EINVAL);
assert_return(e->state != SD_EVENT_FINISHED, -ESTALE);
assert_return(!event_pid_changed(e), -ECHILD);
@@ -2615,7 +2615,7 @@ _public_ int sd_event_source_set_time_accuracy(sd_event_source *s, uint64_t usec
int r;
assert_return(s, -EINVAL);
assert_return(usec != (uint64_t) -1, -EINVAL);
assert_return(usec != UINT64_MAX, -EINVAL);
assert_return(EVENT_SOURCE_IS_TIME(s->type), -EDOM);
assert_return(s->event->state != SD_EVENT_FINISHED, -ESTALE);
assert_return(!event_pid_changed(s->event), -ECHILD);
@@ -4083,7 +4083,7 @@ _public_ int sd_event_loop(sd_event *e) {
_unused_ _cleanup_(sd_event_unrefp) sd_event *ref = NULL;
while (e->state != SD_EVENT_FINISHED) {
r = sd_event_run(e, (uint64_t) -1);
r = sd_event_run(e, UINT64_MAX);
if (r < 0)
return r;
}
+10 -10
View File
@@ -217,7 +217,7 @@ static void test_basic(bool with_pidfd) {
got_unref = false;
assert_se(sd_event_add_io(e, &t, k[0], EPOLLIN, unref_handler, NULL) >= 0);
assert_se(write(k[1], &ch, 1) == 1);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(got_unref);
got_a = false, got_b = false, got_c = false, got_d = 0;
@@ -227,10 +227,10 @@ static void test_basic(bool with_pidfd) {
assert_se(sd_event_add_io(e, &w, d[0], EPOLLIN, io_handler, INT_TO_PTR('d')) >= 0);
assert_se(sd_event_source_set_enabled(w, SD_EVENT_ONESHOT) >= 0);
assert_se(write(d[1], &ch, 1) >= 0);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(got_d == 1);
assert_se(write(d[1], &ch, 1) >= 0);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(got_d == 2);
assert_se(sd_event_add_io(e, &x, a[0], EPOLLIN, io_handler, INT_TO_PTR('a')) >= 0);
@@ -258,15 +258,15 @@ static void test_basic(bool with_pidfd) {
assert_se(!got_a && !got_b && !got_c);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(!got_a && got_b && !got_c);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(!got_a && got_b && got_c);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(got_a && got_b && got_c);
@@ -357,19 +357,19 @@ static void test_rtqueue(void) {
assert_se(n_rtqueue == 0);
assert_se(last_rtqueue_sigval == 0);
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(n_rtqueue == 1);
assert_se(last_rtqueue_sigval == 2); /* first SIGRTMIN+3 */
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(n_rtqueue == 2);
assert_se(last_rtqueue_sigval == 4); /* second SIGRTMIN+3 */
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(n_rtqueue == 3);
assert_se(last_rtqueue_sigval == 3); /* first SIGUSR2 */
assert_se(sd_event_run(e, (uint64_t) -1) >= 1);
assert_se(sd_event_run(e, UINT64_MAX) >= 1);
assert_se(n_rtqueue == 4);
assert_se(last_rtqueue_sigval == 1); /* SIGRTMIN+2 */
+7 -7
View File
@@ -176,7 +176,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
if (ret != LZMA_OK)
return -ENOMEM;
space = MIN(src_size * 2, dst_max ?: (size_t) -1);
space = MIN(src_size * 2, dst_max ?: SIZE_MAX);
if (!greedy_realloc(dst, dst_alloc_size, space, 1))
return -ENOMEM;
@@ -202,7 +202,7 @@ int decompress_blob_xz(const void *src, uint64_t src_size,
return -ENOBUFS;
used = space - s.avail_out;
space = MIN(2 * space, dst_max ?: (size_t) -1);
space = MIN(2 * space, dst_max ?: SIZE_MAX);
if (!greedy_realloc(dst, dst_alloc_size, space, 1))
return -ENOMEM;
@@ -554,7 +554,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
size_t m = sizeof(buf);
ssize_t n;
if (max_bytes != (uint64_t) -1 && (uint64_t) m > max_bytes)
if (max_bytes != UINT64_MAX && (uint64_t) m > max_bytes)
m = (size_t) max_bytes;
n = read(fdf, buf, m);
@@ -566,7 +566,7 @@ int compress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
s.next_in = buf;
s.avail_in = n;
if (max_bytes != (uint64_t) -1) {
if (max_bytes != UINT64_MAX) {
assert(max_bytes >= (uint64_t) n);
max_bytes -= n;
}
@@ -664,7 +664,7 @@ int compress_stream_lz4(int fdf, int fdt, uint64_t max_bytes) {
offset += n;
total_out += n;
if (max_bytes != (uint64_t) -1 && total_out > (size_t) max_bytes) {
if (max_bytes != UINT64_MAX && total_out > (size_t) max_bytes) {
r = log_debug_errno(SYNTHETIC_ERRNO(EFBIG),
"Compressed stream longer than %" PRIu64 " bytes", max_bytes);
goto cleanup;
@@ -752,7 +752,7 @@ int decompress_stream_xz(int fdf, int fdt, uint64_t max_bytes) {
n = sizeof(out) - s.avail_out;
if (max_bytes != (uint64_t) -1) {
if (max_bytes != UINT64_MAX) {
if (max_bytes < (uint64_t) n)
return -EFBIG;
@@ -816,7 +816,7 @@ int decompress_stream_lz4(int in, int out, uint64_t max_bytes) {
total_in += used;
total_out += produced;
if (max_bytes != (uint64_t) -1 && total_out > (size_t) max_bytes) {
if (max_bytes != UINT64_MAX && total_out > (size_t) max_bytes) {
log_debug("Decompressed stream longer than %"PRIu64" bytes", max_bytes);
r = -EFBIG;
goto cleanup;
+18 -18
View File
@@ -1561,7 +1561,7 @@ bool journal_field_valid(const char *p, size_t l, bool allow_protected) {
http://pubs.opengroup.org/onlinepubs/000095399/basedefs/xbd_chap08.html */
if (l == (size_t) -1)
if (l == SIZE_MAX)
l = strlen(p);
/* No empty field names */
@@ -2352,7 +2352,7 @@ static int generic_array_bisect(
uint64_t *ret_offset,
uint64_t *ret_idx) {
uint64_t a, p, t = 0, i = 0, last_p = 0, last_index = (uint64_t) -1;
uint64_t a, p, t = 0, i = 0, last_p = 0, last_index = UINT64_MAX;
bool subtract_one = false;
Object *o, *array = NULL;
int r;
@@ -2422,7 +2422,7 @@ static int generic_array_bisect(
left = 0;
right -= 1;
if (last_index != (uint64_t) -1) {
if (last_index != UINT64_MAX) {
assert(last_index <= right);
/* If we cached the last index we
@@ -2522,7 +2522,7 @@ static int generic_array_bisect(
n -= k;
t += k;
last_index = (uint64_t) -1;
last_index = UINT64_MAX;
a = le64toh(array->entry_array.next_entry_array_offset);
}
@@ -2533,7 +2533,7 @@ found:
return 0;
/* Let's cache this item for the next invocation */
chain_cache_put(f->chain_cache, ci, first, a, le64toh(array->entry_array.items[0]), t, subtract_one ? (i > 0 ? i-1 : (uint64_t) -1) : i);
chain_cache_put(f->chain_cache, ci, first, a, le64toh(array->entry_array.items[0]), t, subtract_one ? (i > 0 ? i-1 : UINT64_MAX) : i);
if (subtract_one && i == 0)
p = last_p;
@@ -3447,7 +3447,7 @@ int journal_file_open(
#elif HAVE_XZ
.compress_xz = compress,
#endif
.compress_threshold_bytes = compress_threshold_bytes == (uint64_t) -1 ?
.compress_threshold_bytes = compress_threshold_bytes == UINT64_MAX ?
DEFAULT_COMPRESS_THRESHOLD :
MAX(MIN_COMPRESS_THRESHOLD, compress_threshold_bytes),
#if HAVE_GCRYPT
@@ -3964,12 +3964,12 @@ void journal_reset_metrics(JournalMetrics *m) {
/* Set everything to "pick automatic values". */
*m = (JournalMetrics) {
.min_use = (uint64_t) -1,
.max_use = (uint64_t) -1,
.min_size = (uint64_t) -1,
.max_size = (uint64_t) -1,
.keep_free = (uint64_t) -1,
.n_max_files = (uint64_t) -1,
.min_use = UINT64_MAX,
.max_use = UINT64_MAX,
.min_size = UINT64_MAX,
.max_size = UINT64_MAX,
.keep_free = UINT64_MAX,
.n_max_files = UINT64_MAX,
};
}
@@ -3986,7 +3986,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
else
log_debug_errno(errno, "Failed to determine disk size: %m");
if (m->max_use == (uint64_t) -1) {
if (m->max_use == UINT64_MAX) {
if (fs_size > 0)
m->max_use = CLAMP(PAGE_ALIGN(fs_size / 10), /* 10% of file system size */
@@ -4000,7 +4000,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
m->max_use = JOURNAL_FILE_SIZE_MIN*2;
}
if (m->min_use == (uint64_t) -1) {
if (m->min_use == UINT64_MAX) {
if (fs_size > 0)
m->min_use = CLAMP(PAGE_ALIGN(fs_size / 50), /* 2% of file system size */
MIN_USE_LOW, MIN_USE_HIGH);
@@ -4011,7 +4011,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
if (m->min_use > m->max_use)
m->min_use = m->max_use;
if (m->max_size == (uint64_t) -1)
if (m->max_size == UINT64_MAX)
m->max_size = MIN(PAGE_ALIGN(m->max_use / 8), /* 8 chunks */
MAX_SIZE_UPPER);
else
@@ -4025,14 +4025,14 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
m->max_use = m->max_size*2;
}
if (m->min_size == (uint64_t) -1)
if (m->min_size == UINT64_MAX)
m->min_size = JOURNAL_FILE_SIZE_MIN;
else
m->min_size = CLAMP(PAGE_ALIGN(m->min_size),
JOURNAL_FILE_SIZE_MIN,
m->max_size ?: UINT64_MAX);
if (m->keep_free == (uint64_t) -1) {
if (m->keep_free == UINT64_MAX) {
if (fs_size > 0)
m->keep_free = MIN(PAGE_ALIGN(fs_size / 20), /* 5% of file system size */
KEEP_FREE_UPPER);
@@ -4040,7 +4040,7 @@ void journal_default_metrics(JournalMetrics *m, int fd) {
m->keep_free = DEFAULT_KEEP_FREE;
}
if (m->n_max_files == (uint64_t) -1)
if (m->n_max_files == UINT64_MAX)
m->n_max_files = DEFAULT_N_MAX_FILES;
log_debug("Fixed min_use=%s max_use=%s max_size=%s min_size=%s keep_free=%s n_max_files=%" PRIu64,
+3 -3
View File
@@ -2542,7 +2542,7 @@ _public_ int sd_journal_get_timeout(sd_journal *j, uint64_t *timeout_usec) {
return fd;
if (!j->on_network) {
*timeout_usec = (uint64_t) -1;
*timeout_usec = UINT64_MAX;
return 0;
}
@@ -2724,10 +2724,10 @@ _public_ int sd_journal_wait(sd_journal *j, uint64_t timeout_usec) {
if (r < 0)
return r;
if (t != (uint64_t) -1) {
if (t != UINT64_MAX) {
t = usec_sub_unsigned(t, now(CLOCK_MONOTONIC));
if (timeout_usec == (uint64_t) -1 || timeout_usec > t)
if (timeout_usec == UINT64_MAX || timeout_usec > t)
timeout_usec = t;
}
@@ -35,7 +35,7 @@ _noreturn_ static void log_assert_errno(const char *text, int error, const char
static JournalFile *test_open(const char *name) {
JournalFile *f;
assert_ret(journal_file_open(-1, name, O_RDWR|O_CREAT, 0644, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f));
assert_ret(journal_file_open(-1, name, O_RDWR|O_CREAT, 0644, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f));
return f;
}
@@ -206,7 +206,7 @@ static void test_sequence_numbers(void) {
mkdtemp_chdir_chattr(t);
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0644,
true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0);
true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &one) == 0);
append_number(one, 1, &seqnum);
printf("seqnum=%"PRIu64"\n", seqnum);
@@ -223,7 +223,7 @@ static void test_sequence_numbers(void) {
memcpy(&seqnum_id, &one->header->seqnum_id, sizeof(sd_id128_t));
assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0644,
true, (uint64_t) -1, false, NULL, NULL, NULL, one, &two) == 0);
true, UINT64_MAX, false, NULL, NULL, NULL, one, &two) == 0);
assert_se(two->header->state == STATE_ONLINE);
assert_se(!sd_id128_equal(two->header->file_id, one->header->file_id));
@@ -254,7 +254,7 @@ static void test_sequence_numbers(void) {
seqnum = 0;
assert_se(journal_file_open(-1, "two.journal", O_RDWR, 0,
true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &two) == 0);
true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &two) == 0);
assert_se(sd_id128_equal(two->header->seqnum_id, seqnum_id));
@@ -73,9 +73,9 @@ static void run_test(void) {
assert_se(chdir(t) >= 0);
(void) chattr_path(t, FS_NOCOW_FL, FS_NOCOW_FL, NULL);
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &one) == 0);
assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &two) == 0);
assert_se(journal_file_open(-1, "three.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &three) == 0);
assert_se(journal_file_open(-1, "one.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &one) == 0);
assert_se(journal_file_open(-1, "two.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &two) == 0);
assert_se(journal_file_open(-1, "three.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &three) == 0);
for (i = 0; i < N_ENTRIES; i++) {
char *p, *q;
@@ -41,7 +41,7 @@ static int raw_verify(const char *fn, const char *verification_key) {
JournalFile *f;
int r;
r = journal_file_open(-1, fn, O_RDONLY, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f);
r = journal_file_open(-1, fn, O_RDONLY, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f);
if (r < 0)
return r;
@@ -75,7 +75,7 @@ int main(int argc, char *argv[]) {
log_info("Generating...");
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
for (n = 0; n < N_ENTRIES; n++) {
struct iovec iovec;
@@ -97,7 +97,7 @@ int main(int argc, char *argv[]) {
log_info("Verifying...");
assert_se(journal_file_open(-1, "test.journal", O_RDONLY, 0666, true, (uint64_t) -1, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
assert_se(journal_file_open(-1, "test.journal", O_RDONLY, 0666, true, UINT64_MAX, !!verification_key, NULL, NULL, NULL, NULL, &f) == 0);
/* journal_file_print_header(f); */
journal_file_dump(f);
+9 -9
View File
@@ -37,7 +37,7 @@ static void test_non_empty(void) {
mkdtemp_chdir_chattr(t);
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f) == 0);
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f) == 0);
assert_se(dual_timestamp_get(&ts));
assert_se(sd_id128_randomize(&fake_boot_id) == 0);
@@ -98,8 +98,8 @@ static void test_non_empty(void) {
assert_se(journal_file_move_to_entry_by_seqnum(f, 10, DIRECTION_DOWN, &o, NULL) == 0);
journal_file_rotate(&f, true, (uint64_t) -1, true, NULL);
journal_file_rotate(&f, true, (uint64_t) -1, true, NULL);
journal_file_rotate(&f, true, UINT64_MAX, true, NULL);
journal_file_rotate(&f, true, UINT64_MAX, true, NULL);
(void) journal_file_close(f);
@@ -124,13 +124,13 @@ static void test_empty(void) {
mkdtemp_chdir_chattr(t);
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, false, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f1) == 0);
assert_se(journal_file_open(-1, "test.journal", O_RDWR|O_CREAT, 0666, false, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f1) == 0);
assert_se(journal_file_open(-1, "test-compress.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, false, NULL, NULL, NULL, NULL, &f2) == 0);
assert_se(journal_file_open(-1, "test-compress.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, false, NULL, NULL, NULL, NULL, &f2) == 0);
assert_se(journal_file_open(-1, "test-seal.journal", O_RDWR|O_CREAT, 0666, false, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f3) == 0);
assert_se(journal_file_open(-1, "test-seal.journal", O_RDWR|O_CREAT, 0666, false, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f3) == 0);
assert_se(journal_file_open(-1, "test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, (uint64_t) -1, true, NULL, NULL, NULL, NULL, &f4) == 0);
assert_se(journal_file_open(-1, "test-seal-compress.journal", O_RDWR|O_CREAT, 0666, true, UINT64_MAX, true, NULL, NULL, NULL, NULL, &f4) == 0);
journal_file_print_header(f1);
puts("");
@@ -224,8 +224,8 @@ static void test_min_compress_size(void) {
* carefully */
/* DEFAULT_MIN_COMPRESS_SIZE is 512 */
assert_se(!check_compressed((uint64_t) -1, 255));
assert_se(check_compressed((uint64_t) -1, 513));
assert_se(!check_compressed(UINT64_MAX, 255));
assert_se(check_compressed(UINT64_MAX, 513));
/* compress everything */
assert_se(check_compressed(0, 96));
+2 -2
View File
@@ -1043,9 +1043,9 @@ _public_ int sd_login_monitor_get_timeout(sd_login_monitor *m, uint64_t *timeout
assert_return(m, -EINVAL);
assert_return(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;
}
+1 -1
View File
@@ -277,7 +277,7 @@ static void test_monitor(void) {
nw = now(CLOCK_MONOTONIC);
r = poll(&pollfd, 1,
timeout == (uint64_t) -1 ? -1 :
timeout == UINT64_MAX ? -1 :
timeout > nw ? (int) ((timeout - nw) / 1000) :
0);
+5 -5
View File
@@ -512,7 +512,7 @@ int sd_netlink_process(sd_netlink *rtnl, sd_netlink_message **ret) {
}
static usec_t calc_elapse(uint64_t usec) {
if (usec == (uint64_t) -1)
if (usec == UINT64_MAX)
return 0;
if (usec == 0)
@@ -550,7 +550,7 @@ static int rtnl_poll(sd_netlink *rtnl, bool need_more, uint64_t timeout_usec) {
}
}
if (timeout_usec != (uint64_t) -1 && (m == USEC_INFINITY || timeout_usec < m))
if (timeout_usec != UINT64_MAX && (m == USEC_INFINITY || timeout_usec < m))
m = timeout_usec;
r = fd_wait_for_event(rtnl->fd, e, m);
@@ -606,7 +606,7 @@ int sd_netlink_call_async(
if (r < 0)
return r;
if (usec != (uint64_t) -1) {
if (usec != UINT64_MAX) {
r = prioq_ensure_allocated(&nl->reply_callbacks_prioq, timeout_compare);
if (r < 0)
return r;
@@ -714,7 +714,7 @@ int sd_netlink_read(sd_netlink *rtnl,
left = timeout - n;
} else
left = (uint64_t) -1;
left = UINT64_MAX;
r = rtnl_poll(rtnl, true, left);
if (r < 0)
@@ -766,7 +766,7 @@ int sd_netlink_get_timeout(const sd_netlink *rtnl, uint64_t *timeout_usec) {
c = prioq_peek(rtnl->reply_callbacks_prioq);
if (!c) {
*timeout_usec = (uint64_t) -1;
*timeout_usec = UINT64_MAX;
return 0;
}
+2 -2
View File
@@ -461,9 +461,9 @@ _public_ int sd_network_monitor_get_timeout(sd_network_monitor *m, uint64_t *tim
assert_return(m, -EINVAL);
assert_return(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;
}
+1 -1
View File
@@ -621,7 +621,7 @@ _public_ int sd_resolve_get_timeout(sd_resolve *resolve, uint64_t *usec) {
assert_return(usec, -EINVAL);
assert_return(!resolve_pid_changed(resolve), -ECHILD);
*usec = (uint64_t) -1;
*usec = UINT64_MAX;
return 0;
}