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
+19 -19
View File
@@ -308,7 +308,7 @@ static int oci_capability_array(const char *name, JsonVariant *v, JsonDispatchFl
m |= UINT64_C(1) << cap;
}
if (*mask == (uint64_t) -1)
if (*mask == UINT64_MAX)
*mask = m;
else
*mask |= m;
@@ -336,7 +336,7 @@ static int oci_capabilities(const char *name, JsonVariant *v, JsonDispatchFlags
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;
}
@@ -704,7 +704,7 @@ static int oci_uid_gid_range(const char *name, JsonVariant *v, JsonDispatchFlags
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);
@@ -880,8 +880,8 @@ static int oci_devices(const char *name, JsonVariant *v, JsonDispatchFlags flags
*node = (DeviceNode) {
.uid = UID_INVALID,
.gid = GID_INVALID,
.major = (unsigned) -1,
.minor = (unsigned) -1,
.major = UINT_MAX,
.minor = UINT_MAX,
.mode = 0644,
};
@@ -892,7 +892,7 @@ static int oci_devices(const char *name, JsonVariant *v, JsonDispatchFlags flags
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;
@@ -1026,8 +1026,8 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
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[] = {
@@ -1052,7 +1052,7 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
* 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 */
@@ -1064,11 +1064,11 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
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.");
@@ -1116,7 +1116,7 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
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)
@@ -1126,7 +1126,7 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
t = "char";
}
if (list[i].major == (unsigned) -1) {
if (list[i].major == UINT_MAX) {
pattern = strjoin(t, "-*");
if (!pattern)
return log_oom();
@@ -1136,7 +1136,7 @@ static int oci_cgroup_devices(const char *name, JsonVariant *v, JsonDispatchFlag
}
} 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)
@@ -1416,8 +1416,8 @@ static int oci_cgroup_block_io_weight_device(const char *name, JsonVariant *v, J
unsigned minor;
uintmax_t weight;
} data = {
.major = (unsigned) -1,
.minor = (unsigned) -1,
.major = UINT_MAX,
.minor = UINT_MAX,
.weight = UINTMAX_MAX,
};
@@ -1477,8 +1477,8 @@ static int oci_cgroup_block_io_throttle(const char *name, JsonVariant *v, JsonDi
unsigned minor;
uintmax_t rate;
} data = {
.major = (unsigned) -1,
.minor = (unsigned) -1,
.major = UINT_MAX,
.minor = UINT_MAX,
};
static const JsonDispatch table[] = {
@@ -1890,7 +1890,7 @@ static int oci_seccomp_syscalls(const char *name, JsonVariant *v, JsonDispatchFl
{ "args", JSON_VARIANT_ARRAY, oci_seccomp_args, 0, 0 },
};
struct syscall_rule rule = {
.action = (uint32_t) -1,
.action = UINT32_MAX,
};
char **i;
+4 -4
View File
@@ -51,10 +51,10 @@ Settings *settings_new(void) {
.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,
};
@@ -274,7 +274,7 @@ int config_parse_capability(
break;
if (streq(word, "all"))
u = (uint64_t) -1;
u = UINT64_MAX;
else {
r = capability_from_name(word);
if (r < 0) {
+13 -13
View File
@@ -217,7 +217,7 @@ static bool arg_oom_score_adjust_set = false;
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;
@@ -549,7 +549,7 @@ static int parse_capability_spec(const char *spec, uint64_t *ret_mask) {
}
if (streq(t, "all"))
mask = (uint64_t) -1;
mask = UINT64_MAX;
else {
r = capability_from_name(t);
if (r < 0)
@@ -1768,7 +1768,7 @@ static int verify_arguments(void) {
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)
@@ -2640,19 +2640,19 @@ static int drop_capabilities(uid_t uid) {
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))
@@ -2664,7 +2664,7 @@ static int drop_capabilities(uid_t uid) {
.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)
@@ -3045,7 +3045,7 @@ static int determine_uid_shift(const char *directory) {
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.");
@@ -4336,7 +4336,7 @@ static int merge_settings(Settings *settings, const char *path) {
}
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);
@@ -4931,7 +4931,7 @@ static int run_container(
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);
@@ -5552,7 +5552,7 @@ finish:
/* 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);
}