Merge pull request #18852 from yuwata/tree-wide-use-UINT64_MAX
tree-wide: use UINT64_MAX or friends
This commit is contained in:
@@ -204,7 +204,7 @@ static int backspace_string(int ttyfd, const char *str) {
|
||||
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,
|
||||
@@ -583,9 +583,9 @@ int ask_password_tty(
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -595,7 +595,7 @@ int ask_password_tty(
|
||||
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)) {
|
||||
@@ -632,7 +632,7 @@ int ask_password_tty(
|
||||
|
||||
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);
|
||||
|
||||
+1
-1
@@ -18,7 +18,7 @@
|
||||
#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))
|
||||
|
||||
@@ -142,9 +142,9 @@ int bus_property_get_rlimit(
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -180,18 +180,18 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
|
||||
} 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);
|
||||
|
||||
@@ -1193,7 +1193,7 @@ static int bus_append_execute_property(sd_bus_message *m, const char *field, con
|
||||
_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);
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ int bus_event_loop_with_idle(
|
||||
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;
|
||||
|
||||
|
||||
@@ -133,7 +133,7 @@ static int bus_process_wait(sd_bus *bus) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -414,7 +414,7 @@ int bus_wait_for_units_run(BusWaitForUnits *d) {
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -2331,7 +2331,7 @@ int dissected_image_acquire_metadata(DissectedImage *m) {
|
||||
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);
|
||||
|
||||
+35
-35
@@ -122,7 +122,7 @@ static size_t TABLE_CELL_TO_INDEX(TableCell *cell) {
|
||||
}
|
||||
|
||||
static TableCell* TABLE_INDEX_TO_CELL(size_t index) {
|
||||
assert(index != (size_t) -1);
|
||||
assert(index != SIZE_MAX);
|
||||
return SIZE_TO_PTR(index + 1);
|
||||
}
|
||||
|
||||
@@ -131,9 +131,9 @@ struct Table {
|
||||
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;
|
||||
@@ -161,8 +161,8 @@ Table *table_new_raw(size_t n_columns) {
|
||||
*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);
|
||||
@@ -427,16 +427,16 @@ int table_add_cell_full(
|
||||
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);
|
||||
@@ -591,7 +591,7 @@ int table_set_minimum_width(Table *t, TableCell *cell, size_t minimum_width) {
|
||||
assert(t);
|
||||
assert(cell);
|
||||
|
||||
if (minimum_width == (size_t) -1)
|
||||
if (minimum_width == SIZE_MAX)
|
||||
minimum_width = 1;
|
||||
|
||||
r = table_dedup_cell(t, cell);
|
||||
@@ -622,7 +622,7 @@ int table_set_weight(Table *t, TableCell *cell, unsigned weight) {
|
||||
assert(t);
|
||||
assert(cell);
|
||||
|
||||
if (weight == (unsigned) -1)
|
||||
if (weight == UINT_MAX)
|
||||
weight = DEFAULT_WEIGHT;
|
||||
|
||||
r = table_dedup_cell(t, cell);
|
||||
@@ -639,7 +639,7 @@ int table_set_align_percent(Table *t, TableCell *cell, unsigned percent) {
|
||||
assert(t);
|
||||
assert(cell);
|
||||
|
||||
if (percent == (unsigned) -1)
|
||||
if (percent == UINT_MAX)
|
||||
percent = 0;
|
||||
|
||||
assert(percent <= 100);
|
||||
@@ -658,7 +658,7 @@ int table_set_ellipsize_percent(Table *t, TableCell *cell, unsigned percent) {
|
||||
assert(t);
|
||||
assert(cell);
|
||||
|
||||
if (percent == (unsigned) -1)
|
||||
if (percent == UINT_MAX)
|
||||
percent = 100;
|
||||
|
||||
assert(percent <= 100);
|
||||
@@ -1067,7 +1067,7 @@ void table_set_width(Table *t, size_t width) {
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -1094,7 +1094,7 @@ int table_set_display_all(Table *t) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int table_set_display(Table *t, size_t first_column, ...) {
|
||||
int table_set_display_internal(Table *t, size_t first_column, ...) {
|
||||
size_t allocated, column;
|
||||
va_list ap;
|
||||
|
||||
@@ -1115,7 +1115,7 @@ int table_set_display(Table *t, size_t first_column, ...) {
|
||||
t->display_map[t->n_display_map++] = column;
|
||||
|
||||
column = va_arg(ap, size_t);
|
||||
if (column == (size_t) -1)
|
||||
if (column == SIZE_MAX)
|
||||
break;
|
||||
|
||||
}
|
||||
@@ -1124,7 +1124,7 @@ int table_set_display(Table *t, size_t first_column, ...) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int table_set_sort(Table *t, size_t first_column, ...) {
|
||||
int table_set_sort_internal(Table *t, size_t first_column, ...) {
|
||||
size_t allocated, column;
|
||||
va_list ap;
|
||||
|
||||
@@ -1145,7 +1145,7 @@ int table_set_sort(Table *t, size_t first_column, ...) {
|
||||
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);
|
||||
@@ -1758,7 +1758,7 @@ static int console_width_height(
|
||||
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;
|
||||
@@ -1794,7 +1794,7 @@ static int table_data_requested_width_height(
|
||||
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;
|
||||
@@ -1808,7 +1808,7 @@ static int table_data_requested_width_height(
|
||||
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)
|
||||
@@ -1965,14 +1965,14 @@ int table_print(Table *t, FILE *f) {
|
||||
|
||||
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;
|
||||
|
||||
@@ -2020,7 +2020,7 @@ int table_print(Table *t, FILE *f) {
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -2029,8 +2029,8 @@ int table_print(Table *t, FILE *f) {
|
||||
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;
|
||||
|
||||
@@ -2049,8 +2049,8 @@ int table_print(Table *t, FILE *f) {
|
||||
|
||||
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];
|
||||
|
||||
@@ -2058,7 +2058,7 @@ int table_print(Table *t, FILE *f) {
|
||||
}
|
||||
|
||||
/* 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))))
|
||||
@@ -2066,7 +2066,7 @@ int table_print(Table *t, FILE *f) {
|
||||
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)
|
||||
@@ -2091,7 +2091,7 @@ int table_print(Table *t, FILE *f) {
|
||||
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])
|
||||
@@ -2119,7 +2119,7 @@ int table_print(Table *t, FILE *f) {
|
||||
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;
|
||||
@@ -2128,7 +2128,7 @@ int table_print(Table *t, FILE *f) {
|
||||
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)
|
||||
@@ -2210,7 +2210,7 @@ int table_print(Table *t, FILE *f) {
|
||||
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;
|
||||
@@ -2445,7 +2445,7 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
|
||||
|
||||
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);
|
||||
|
||||
@@ -73,7 +73,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Table*, table_unref);
|
||||
|
||||
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);
|
||||
|
||||
@@ -101,8 +101,10 @@ void table_set_width(Table *t, size_t width);
|
||||
void table_set_cell_height_max(Table *t, size_t height);
|
||||
int table_set_empty_string(Table *t, const char *empty);
|
||||
int table_set_display_all(Table *t);
|
||||
int table_set_display(Table *t, size_t first_column, ...);
|
||||
int table_set_sort(Table *t, size_t first_column, ...);
|
||||
int table_set_display_internal(Table *t, size_t first_column, ...);
|
||||
#define table_set_display(...) table_set_display_internal(__VA_ARGS__, (size_t) SIZE_MAX)
|
||||
int table_set_sort_internal(Table *t, size_t first_column, ...);
|
||||
#define table_set_sort(...) table_set_sort_internal(__VA_ARGS__, (size_t) SIZE_MAX)
|
||||
int table_set_reverse(Table *t, size_t column, bool b);
|
||||
int table_hide_column_from_display(Table *t, size_t column);
|
||||
|
||||
|
||||
+12
-12
@@ -393,10 +393,10 @@ int json_variant_new_stringn(JsonVariant **ret, const char *s, size_t n) {
|
||||
|
||||
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;
|
||||
@@ -2508,7 +2508,7 @@ static int json_parse_string(const char **p, char **ret) {
|
||||
continue;
|
||||
}
|
||||
|
||||
len = utf8_encoded_valid_unichar(c, (size_t) -1);
|
||||
len = utf8_encoded_valid_unichar(c, SIZE_MAX);
|
||||
if (len < 0)
|
||||
return len;
|
||||
|
||||
@@ -2828,7 +2828,7 @@ typedef struct JsonStack {
|
||||
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) {
|
||||
@@ -3532,7 +3532,7 @@ int json_buildv(JsonVariant **ret, va_list ap) {
|
||||
|
||||
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 */
|
||||
@@ -3729,7 +3729,7 @@ int json_buildv(JsonVariant **ret, va_list ap) {
|
||||
|
||||
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 */
|
||||
@@ -3801,7 +3801,7 @@ int json_buildv(JsonVariant **ret, va_list ap) {
|
||||
|
||||
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;
|
||||
@@ -3819,9 +3819,9 @@ int json_buildv(JsonVariant **ret, va_list ap) {
|
||||
}
|
||||
|
||||
/* 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
|
||||
@@ -4233,7 +4233,7 @@ int json_dispatch_uid_gid(const char *name, JsonVariant *variant, JsonDispatchFl
|
||||
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)) {
|
||||
@@ -4448,7 +4448,7 @@ int json_variant_unbase64(JsonVariant *v, void **ret, size_t *ret_size) {
|
||||
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) {
|
||||
@@ -4456,7 +4456,7 @@ 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] = {
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ int json_variant_new_null(JsonVariant **ret);
|
||||
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);
|
||||
|
||||
@@ -1323,7 +1323,7 @@ int show_journal(
|
||||
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 */
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
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);
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ static bool stderr_redirected = false;
|
||||
_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);
|
||||
|
||||
+6
-6
@@ -646,24 +646,24 @@ int pty_forward_set_width_height(PTYForward *f, unsigned width, unsigned height)
|
||||
|
||||
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) {
|
||||
|
||||
@@ -458,7 +458,7 @@ size_t udev_replace_chars(char *str, const char *allow) {
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
@@ -570,7 +570,7 @@ static int json_dispatch_umask(const char *name, JsonVariant *variant, JsonDispa
|
||||
uintmax_t k;
|
||||
|
||||
if (json_variant_is_null(variant)) {
|
||||
*m = (mode_t) -1;
|
||||
*m = MODE_INVALID;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -590,7 +590,7 @@ static int json_dispatch_access_mode(const char *name, JsonVariant *variant, Jso
|
||||
uintmax_t k;
|
||||
|
||||
if (json_variant_is_null(variant)) {
|
||||
*m = (mode_t) -1;
|
||||
*m = MODE_INVALID;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -866,7 +866,7 @@ static int dispatch_pkcs11_key_data(const char *name, JsonVariant *variant, Json
|
||||
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");
|
||||
|
||||
@@ -933,7 +933,7 @@ static int dispatch_fido2_hmac_credential(const char *name, JsonVariant *variant
|
||||
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");
|
||||
|
||||
@@ -963,7 +963,7 @@ static int dispatch_fido2_hmac_credential_array(const char *name, JsonVariant *v
|
||||
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");
|
||||
|
||||
@@ -993,7 +993,7 @@ static int dispatch_fido2_hmac_salt_value(const char *name, JsonVariant *variant
|
||||
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");
|
||||
|
||||
@@ -1754,7 +1754,7 @@ const char *user_record_skeleton_directory(UserRecord *h) {
|
||||
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) {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
|
||||
#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 */
|
||||
|
||||
Reference in New Issue
Block a user