mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
Merge pull request #12188 from poettering/coccinelle-fixlets
tree-wide: let's run coccinelle again
This commit is contained in:
commit
33ca308f38
@ -297,10 +297,8 @@ static int assess_root_directory(
|
||||
assert(ret_description);
|
||||
|
||||
*ret_badness =
|
||||
(isempty(info->root_directory) ||
|
||||
path_equal(info->root_directory, "/")) &&
|
||||
(isempty(info->root_image) ||
|
||||
path_equal(info->root_image, "/"));
|
||||
empty_or_root(info->root_directory) ||
|
||||
empty_or_root(info->root_image);
|
||||
*ret_description = NULL;
|
||||
|
||||
return 0;
|
||||
|
@ -1411,9 +1411,9 @@ int open_parent(const char *path, int flags, mode_t mode) {
|
||||
/* Let's insist on O_DIRECTORY since the parent of a file or directory is a directory. Except if we open an
|
||||
* O_TMPFILE file, because in that case we are actually create a regular file below the parent directory. */
|
||||
|
||||
if ((flags & O_PATH) == O_PATH)
|
||||
if (FLAGS_SET(flags, O_PATH))
|
||||
flags |= O_DIRECTORY;
|
||||
else if ((flags & O_TMPFILE) != O_TMPFILE)
|
||||
else if (!FLAGS_SET(flags, O_TMPFILE))
|
||||
flags |= O_DIRECTORY|O_RDONLY;
|
||||
|
||||
fd = open(parent, flags, mode);
|
||||
|
@ -675,7 +675,7 @@ static int insert_into_order(uint16_t slot, bool first) {
|
||||
}
|
||||
|
||||
/* extend array */
|
||||
t = realloc(order, (n + 1) * sizeof(uint16_t));
|
||||
t = reallocarray(order, n + 1, sizeof(uint16_t));
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
order = t;
|
||||
|
@ -269,10 +269,8 @@ static BOOLEAN line_edit(
|
||||
|
||||
case KEYPRESS(0, 0, CHAR_LINEFEED):
|
||||
case KEYPRESS(0, 0, CHAR_CARRIAGE_RETURN):
|
||||
if (StrCmp(line, line_in) != 0) {
|
||||
*line_out = line;
|
||||
line = NULL;
|
||||
}
|
||||
if (StrCmp(line, line_in) != 0)
|
||||
*line_out = TAKE_PTR(line);
|
||||
enter = TRUE;
|
||||
exit = TRUE;
|
||||
break;
|
||||
@ -1258,8 +1256,7 @@ static VOID config_entry_bump_counters(
|
||||
/* If the file we just renamed is the loader path, then let's update that. */
|
||||
if (StrCmp(entry->loader, old_path) == 0) {
|
||||
FreePool(entry->loader);
|
||||
entry->loader = new_path;
|
||||
new_path = NULL;
|
||||
entry->loader = TAKE_PTR(new_path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1360,10 +1357,8 @@ static VOID config_entry_add_from_file(
|
||||
s = PoolPrint(L"%s %s", entry->options, new);
|
||||
FreePool(entry->options);
|
||||
entry->options = s;
|
||||
} else {
|
||||
entry->options = new;
|
||||
new = NULL;
|
||||
}
|
||||
} else
|
||||
entry->options = TAKE_PTR(new);
|
||||
|
||||
continue;
|
||||
}
|
||||
@ -1382,10 +1377,8 @@ static VOID config_entry_add_from_file(
|
||||
s = PoolPrint(L"%s %s", initrd, entry->options);
|
||||
FreePool(entry->options);
|
||||
entry->options = s;
|
||||
} else {
|
||||
entry->options = initrd;
|
||||
initrd = NULL;
|
||||
}
|
||||
} else
|
||||
entry->options = TAKE_PTR(initrd);
|
||||
}
|
||||
|
||||
entry->device = device;
|
||||
|
@ -122,8 +122,7 @@ EFI_STATUS efivar_get(const CHAR16 *name, CHAR16 **value) {
|
||||
|
||||
/* Return buffer directly if it happens to be NUL terminated already */
|
||||
if (size >= 2 && buf[size-2] == 0 && buf[size-1] == 0) {
|
||||
*value = (CHAR16*) buf;
|
||||
buf = NULL;
|
||||
*value = (CHAR16*) TAKE_PTR(buf);
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -922,10 +922,9 @@ static int run(int argc, char *argv[]) {
|
||||
|
||||
arg_count = (mask & CGROUP_MASK_PIDS) ? COUNT_PIDS : COUNT_USERSPACE_PROCESSES;
|
||||
|
||||
if (arg_recursive_unset && arg_count == COUNT_PIDS) {
|
||||
log_error("Non-recursive counting is only supported when counting processes, not tasks. Use -P or -k.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (arg_recursive_unset && arg_count == COUNT_PIDS)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Non-recursive counting is only supported when counting processes, not tasks. Use -P or -k.");
|
||||
|
||||
r = show_cgroup_get_path_and_warn(arg_machine, arg_root, &root);
|
||||
if (r < 0)
|
||||
|
@ -237,7 +237,7 @@ _public_ int sd_device_new_from_devnum(sd_device **ret, char type, dev_t devnum)
|
||||
assert_return(IN_SET(type, 'b', 'c'), -EINVAL);
|
||||
|
||||
/* use /sys/dev/{block,char}/<maj>:<min> link */
|
||||
snprintf(id, sizeof(id), "%u:%u", major(devnum), minor(devnum));
|
||||
xsprintf(id, "%u:%u", major(devnum), minor(devnum));
|
||||
|
||||
syspath = strjoina("/sys/dev/", (type == 'b' ? "block" : "char"), "/", id);
|
||||
|
||||
|
@ -3116,7 +3116,7 @@ _public_ int sd_event_wait(sd_event *e, uint64_t timeout) {
|
||||
timeout = 0;
|
||||
|
||||
m = epoll_wait(e->epoll_fd, ev_queue, ev_queue_max,
|
||||
timeout == (uint64_t) -1 ? -1 : (int) ((timeout + USEC_PER_MSEC - 1) / USEC_PER_MSEC));
|
||||
timeout == (uint64_t) -1 ? -1 : (int) DIV_ROUND_UP(timeout, USEC_PER_MSEC));
|
||||
if (m < 0) {
|
||||
if (errno == EINTR) {
|
||||
e->state = SD_EVENT_PENDING;
|
||||
|
@ -818,7 +818,7 @@ _public_ int sd_get_uids(uid_t **users) {
|
||||
uid_t *t;
|
||||
|
||||
n = MAX(16, 2*r);
|
||||
t = realloc(l, sizeof(uid_t) * n);
|
||||
t = reallocarray(l, sizeof(uid_t), n);
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -949,10 +949,8 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
|
||||
case ARG_LINK_JOURNAL:
|
||||
r = parse_link_journal(optarg, &arg_link_journal, &arg_link_journal_try);
|
||||
if (r < 0) {
|
||||
log_error_errno(r, "Failed to parse link journal mode %s", optarg);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse link journal mode %s", optarg);
|
||||
|
||||
arg_settings_mask |= SETTING_LINK_JOURNAL;
|
||||
break;
|
||||
@ -1243,9 +1241,8 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to parse root hash: %s", optarg);
|
||||
if (l < sizeof(sd_id128_t)) {
|
||||
log_error("Root hash must be at least 128bit long: %s", optarg);
|
||||
free(k);
|
||||
return -EINVAL;
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Root hash must be at least 128bit long: %s", optarg);
|
||||
}
|
||||
|
||||
free(arg_root_hash);
|
||||
@ -1389,10 +1386,8 @@ static int parse_argv(int argc, char *argv[]) {
|
||||
"read-only\n"
|
||||
"passive\n"
|
||||
"pipe");
|
||||
else {
|
||||
log_error("Unknown console mode: %s", optarg);
|
||||
return -EINVAL;
|
||||
}
|
||||
else
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Unknown console mode: %s", optarg);
|
||||
|
||||
arg_settings_mask |= SETTING_CONSOLE_MODE;
|
||||
break;
|
||||
@ -2618,10 +2613,8 @@ static int determine_names(void) {
|
||||
return log_error_errno(r, "Failed to determine current directory: %m");
|
||||
}
|
||||
|
||||
if (!arg_directory && !arg_image) {
|
||||
log_error("Failed to determine path, please use -D or -i.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!arg_directory && !arg_image)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to determine path, please use -D or -i.");
|
||||
}
|
||||
|
||||
if (!arg_machine) {
|
||||
@ -2644,10 +2637,8 @@ static int determine_names(void) {
|
||||
return log_oom();
|
||||
|
||||
hostname_cleanup(arg_machine);
|
||||
if (!machine_name_is_valid(arg_machine)) {
|
||||
log_error("Failed to determine machine name automatically, please use -M.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!machine_name_is_valid(arg_machine))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Failed to determine machine name automatically, please use -M.");
|
||||
|
||||
if (arg_ephemeral) {
|
||||
char *b;
|
||||
@ -2774,10 +2765,8 @@ static int patch_sysctl(void) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!good) {
|
||||
log_error("Refusing to write to sysctl '%s', as it is not safe in the selected namespaces.", *k);
|
||||
return -EPERM;
|
||||
}
|
||||
if (!good)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EPERM), "Refusing to write to sysctl '%s', as it is not safe in the selected namespaces.", *k);
|
||||
|
||||
r = sysctl_write(*k, *v);
|
||||
if (r < 0)
|
||||
@ -4162,10 +4151,9 @@ static int run_container(int master,
|
||||
log_debug_errno(r, "Cannot determine if passed network namespace path '%s' really refers to a network namespace, assuming it does.", arg_network_namespace_path);
|
||||
else if (r < 0)
|
||||
return log_error_errno(r, "Failed to check %s fs type: %m", arg_network_namespace_path);
|
||||
else if (r == 0) {
|
||||
log_error("Path %s doesn't refer to a network namespace, refusing.", arg_network_namespace_path);
|
||||
return -EINVAL;
|
||||
}
|
||||
else if (r == 0)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
|
||||
"Path %s doesn't refer to a network namespace, refusing.", arg_network_namespace_path);
|
||||
}
|
||||
|
||||
*pid = raw_clone(SIGCHLD|CLONE_NEWNS);
|
||||
@ -4228,10 +4216,8 @@ static int run_container(int master,
|
||||
l = recv(uid_shift_socket_pair[0], &arg_uid_shift, sizeof arg_uid_shift, 0);
|
||||
if (l < 0)
|
||||
return log_error_errno(errno, "Failed to read UID shift: %m");
|
||||
if (l != sizeof arg_uid_shift) {
|
||||
log_error("Short read while reading UID shift.");
|
||||
return -EIO;
|
||||
}
|
||||
if (l != sizeof arg_uid_shift)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read while reading UID shift.");
|
||||
|
||||
if (arg_userns_mode == USER_NAMESPACE_PICK) {
|
||||
/* If we are supposed to pick the UID shift, let's try to use the shift read from the
|
||||
@ -4245,10 +4231,8 @@ static int run_container(int master,
|
||||
l = send(uid_shift_socket_pair[0], &arg_uid_shift, sizeof arg_uid_shift, MSG_NOSIGNAL);
|
||||
if (l < 0)
|
||||
return log_error_errno(errno, "Failed to send UID shift: %m");
|
||||
if (l != sizeof arg_uid_shift) {
|
||||
log_error("Short write while writing UID shift.");
|
||||
return -EIO;
|
||||
}
|
||||
if (l != sizeof arg_uid_shift)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short write while writing UID shift.");
|
||||
}
|
||||
}
|
||||
|
||||
@ -4257,11 +4241,9 @@ static int run_container(int master,
|
||||
l = recv(unified_cgroup_hierarchy_socket_pair[0], &arg_unified_cgroup_hierarchy, sizeof(arg_unified_cgroup_hierarchy), 0);
|
||||
if (l < 0)
|
||||
return log_error_errno(errno, "Failed to read cgroup mode: %m");
|
||||
if (l != sizeof(arg_unified_cgroup_hierarchy)) {
|
||||
log_error("Short read while reading cgroup mode (%zu bytes).%s",
|
||||
l, l == 0 ? " The child is most likely dead." : "");
|
||||
return -EIO;
|
||||
}
|
||||
if (l != sizeof(arg_unified_cgroup_hierarchy))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read while reading cgroup mode (%zu bytes).%s",
|
||||
l, l == 0 ? " The child is most likely dead." : "");
|
||||
}
|
||||
|
||||
/* Wait for the outer child. */
|
||||
@ -4275,19 +4257,15 @@ static int run_container(int master,
|
||||
l = recv(pid_socket_pair[0], pid, sizeof *pid, 0);
|
||||
if (l < 0)
|
||||
return log_error_errno(errno, "Failed to read inner child PID: %m");
|
||||
if (l != sizeof *pid) {
|
||||
log_error("Short read while reading inner child PID.");
|
||||
return -EIO;
|
||||
}
|
||||
if (l != sizeof *pid)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read while reading inner child PID.");
|
||||
|
||||
/* We also retrieve container UUID in case it was generated by outer child */
|
||||
l = recv(uuid_socket_pair[0], &arg_uuid, sizeof arg_uuid, 0);
|
||||
if (l < 0)
|
||||
return log_error_errno(errno, "Failed to read container machine ID: %m");
|
||||
if (l != sizeof(arg_uuid)) {
|
||||
log_error("Short read while reading container machined ID.");
|
||||
return -EIO;
|
||||
}
|
||||
if (l != sizeof(arg_uuid))
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EIO), "Short read while reading container machined ID.");
|
||||
|
||||
/* We also retrieve the socket used for notifications generated by outer child */
|
||||
notify_socket = receive_one_fd(notify_socket_pair[0], 0);
|
||||
@ -4298,10 +4276,8 @@ static int run_container(int master,
|
||||
log_debug("Init process invoked as PID "PID_FMT, *pid);
|
||||
|
||||
if (arg_userns_mode != USER_NAMESPACE_NO) {
|
||||
if (!barrier_place_and_sync(&barrier)) { /* #1 */
|
||||
log_error("Child died too early.");
|
||||
return -ESRCH;
|
||||
}
|
||||
if (!barrier_place_and_sync(&barrier)) /* #1 */
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ESRCH), "Child died too early.");
|
||||
|
||||
r = setup_uid_map(*pid);
|
||||
if (r < 0)
|
||||
@ -4313,10 +4289,8 @@ static int run_container(int master,
|
||||
if (arg_private_network) {
|
||||
if (!arg_network_namespace_path) {
|
||||
/* Wait until the child has unshared its network namespace. */
|
||||
if (!barrier_place_and_sync(&barrier)) { /* #3 */
|
||||
log_error("Child died too early");
|
||||
return -ESRCH;
|
||||
}
|
||||
if (!barrier_place_and_sync(&barrier)) /* #3 */
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ESRCH), "Child died too early");
|
||||
}
|
||||
|
||||
r = move_network_interfaces(*pid, arg_network_interfaces);
|
||||
@ -4472,10 +4446,8 @@ static int run_container(int master,
|
||||
return r;
|
||||
|
||||
/* Let the child know that we are ready and wait that the child is completely ready now. */
|
||||
if (!barrier_place_and_sync(&barrier)) { /* #5 */
|
||||
log_error("Child died too early.");
|
||||
return -ESRCH;
|
||||
}
|
||||
if (!barrier_place_and_sync(&barrier)) /* #5 */
|
||||
return log_error_errno(SYNTHETIC_ERRNO(ESRCH), "Child died too early.");
|
||||
|
||||
/* At this point we have made use of the UID we picked, and thus nss-mymachines
|
||||
* will make them appear in getpwuid(), thus we can release the /etc/passwd lock. */
|
||||
|
@ -119,10 +119,8 @@ int ifname_mangle(const char *s) {
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_ifindex > 0 && arg_ifindex != ifi) {
|
||||
log_error("Specified multiple different interfaces. Refusing.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (arg_ifindex > 0 && arg_ifindex != ifi)
|
||||
return log_error_errno(SYNTHETIC_ERRNO(EINVAL), "Specified multiple different interfaces. Refusing.");
|
||||
|
||||
arg_ifindex = ifi;
|
||||
free_and_replace(arg_ifname, iface);
|
||||
|
@ -756,7 +756,7 @@ static int bus_print_property(const char *name, const char *expected_value, sd_b
|
||||
|
||||
if ((u & NAMESPACE_FLAGS_ALL) == 0)
|
||||
result = "yes";
|
||||
else if ((u & NAMESPACE_FLAGS_ALL) == NAMESPACE_FLAGS_ALL)
|
||||
else if (FLAGS_SET(u, NAMESPACE_FLAGS_ALL))
|
||||
result = "no";
|
||||
else {
|
||||
r = namespace_flags_to_string(u, &s);
|
||||
|
@ -3297,10 +3297,8 @@ int json_dispatch_boolean(const char *name, JsonVariant *variant, JsonDispatchFl
|
||||
assert(variant);
|
||||
assert(b);
|
||||
|
||||
if (!json_variant_is_boolean(variant)) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' is not a boolean.", strna(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_boolean(variant))
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a boolean.", strna(name));
|
||||
|
||||
*b = json_variant_boolean(variant);
|
||||
return 0;
|
||||
@ -3312,10 +3310,8 @@ int json_dispatch_tristate(const char *name, JsonVariant *variant, JsonDispatchF
|
||||
assert(variant);
|
||||
assert(b);
|
||||
|
||||
if (!json_variant_is_boolean(variant)) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' is not a boolean.", strna(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_boolean(variant))
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a boolean.", strna(name));
|
||||
|
||||
*b = json_variant_boolean(variant);
|
||||
return 0;
|
||||
@ -3327,10 +3323,8 @@ int json_dispatch_integer(const char *name, JsonVariant *variant, JsonDispatchFl
|
||||
assert(variant);
|
||||
assert(i);
|
||||
|
||||
if (!json_variant_is_integer(variant)) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' is not an integer.", strna(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_integer(variant))
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name));
|
||||
|
||||
*i = json_variant_integer(variant);
|
||||
return 0;
|
||||
@ -3342,10 +3336,8 @@ int json_dispatch_unsigned(const char *name, JsonVariant *variant, JsonDispatchF
|
||||
assert(variant);
|
||||
assert(u);
|
||||
|
||||
if (!json_variant_is_unsigned(variant)) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' is not an unsigned integer.", strna(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_unsigned(variant))
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an unsigned integer.", strna(name));
|
||||
|
||||
*u = json_variant_unsigned(variant);
|
||||
return 0;
|
||||
@ -3357,15 +3349,11 @@ int json_dispatch_uint32(const char *name, JsonVariant *variant, JsonDispatchFla
|
||||
assert(variant);
|
||||
assert(u);
|
||||
|
||||
if (!json_variant_is_unsigned(variant)) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' is not an unsigned integer.", strna(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_unsigned(variant))
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an unsigned integer.", strna(name));
|
||||
|
||||
if (json_variant_unsigned(variant) > UINT32_MAX) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' out of bounds.", strna(name));
|
||||
return -ERANGE;
|
||||
}
|
||||
if (json_variant_unsigned(variant) > UINT32_MAX)
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(ERANGE), "JSON field '%s' out of bounds.", strna(name));
|
||||
|
||||
*u = (uint32_t) json_variant_unsigned(variant);
|
||||
return 0;
|
||||
@ -3377,15 +3365,11 @@ int json_dispatch_int32(const char *name, JsonVariant *variant, JsonDispatchFlag
|
||||
assert(variant);
|
||||
assert(i);
|
||||
|
||||
if (!json_variant_is_integer(variant)) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' is not an integer.", strna(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_integer(variant))
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not an integer.", strna(name));
|
||||
|
||||
if (json_variant_integer(variant) < INT32_MIN || json_variant_integer(variant) > INT32_MAX) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' out of bounds.", strna(name));
|
||||
return -ERANGE;
|
||||
}
|
||||
if (json_variant_integer(variant) < INT32_MIN || json_variant_integer(variant) > INT32_MAX)
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(ERANGE), "JSON field '%s' out of bounds.", strna(name));
|
||||
|
||||
*i = (int32_t) json_variant_integer(variant);
|
||||
return 0;
|
||||
@ -3403,10 +3387,8 @@ int json_dispatch_string(const char *name, JsonVariant *variant, JsonDispatchFla
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!json_variant_is_string(variant)) {
|
||||
json_log(variant, flags, 0, "JSON field '%s' is not a string.", strna(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_string(variant))
|
||||
return json_log(variant, flags, SYNTHETIC_ERRNO(EINVAL), "JSON field '%s' is not a string.", strna(name));
|
||||
|
||||
r = free_and_strdup(s, json_variant_string(variant));
|
||||
if (r < 0)
|
||||
@ -3429,20 +3411,16 @@ int json_dispatch_strv(const char *name, JsonVariant *variant, JsonDispatchFlags
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!json_variant_is_array(variant)) {
|
||||
json_log(variant, 0, flags, "JSON field '%s' is not an array.", strna(name));
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_array(variant))
|
||||
return json_log(variant, SYNTHETIC_ERRNO(EINVAL), flags, "JSON field '%s' is not an array.", strna(name));
|
||||
|
||||
for (i = 0; i < json_variant_elements(variant); i++) {
|
||||
JsonVariant *e;
|
||||
|
||||
assert_se(e = json_variant_by_index(variant, i));
|
||||
|
||||
if (!json_variant_is_string(e)) {
|
||||
json_log(e, 0, flags, "JSON array element is not a string.");
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!json_variant_is_string(e))
|
||||
return json_log(e, flags, SYNTHETIC_ERRNO(EINVAL), "JSON array element is not a string.");
|
||||
|
||||
r = strv_extend(&l, json_variant_string(e));
|
||||
if (r < 0)
|
||||
|
@ -1645,8 +1645,7 @@ static bool match_key(UdevRules *rules, struct token *token, const char *val) {
|
||||
char *pos;
|
||||
bool match = false;
|
||||
|
||||
if (!val)
|
||||
val = "";
|
||||
val = strempty(val);
|
||||
|
||||
switch (token->key.glob) {
|
||||
case GL_PLAIN:
|
||||
|
Loading…
Reference in New Issue
Block a user