tree-wide: various Coccinelle-suggested tweaks and related fixes (#40950)

This commit is contained in:
Mike Yuan
2026-03-05 17:07:39 +01:00
committed by GitHub
39 changed files with 155 additions and 173 deletions
+5
View File
@@ -81,3 +81,8 @@
* let's help it a little here by providing simplified one-line versions. */
#define CMSG_BUFFER_TYPE(x) union { uint8_t align_check[(size) >= CMSG_SPACE(0) && (size) == CMSG_ALIGN(size) ? 1 : -1]; }
#define SD_ID128_MAKE(...) ((const sd_id128) {})
/* Work around a bug in zlib.h parsing on Fedora (and possibly others)
* See: https://github.com/coccinelle/coccinelle/issues/413 */
#define Z_EXPORT
#define Z_EXTERN
+4 -2
View File
@@ -4,11 +4,13 @@ set -e
# Exclude following paths from the Coccinelle transformations
EXCLUDED_PATHS=(
"src/boot/efi/*"
"src/basic/include/linux/*"
"src/boot/*"
"src/include/uapi/*"
# Symlinked to test-bus-vtable-cc.cc, which causes issues with the IN_SET macro
"src/libsystemd/sd-bus/test-bus-vtable.c"
"src/libsystemd/sd-journal/lookup3.c"
# Our BPF programs don't have access to systemd stuff
"src/network/bpf/*"
# Ignore man examples, as they redefine some macros we use internally, which makes Coccinelle complain
# and ignore code that tries to use the redefined stuff
"man/*"
+13 -17
View File
@@ -1,26 +1,22 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
@@
/* Disable this transformation on test-json.c */
position p : script:python() { p[0].file != "src/test/test-json.c" };
expression key, val;
@@
- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_BOOLEAN(val))
(
- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_BOOLEAN(val))
+ SD_JSON_BUILD_PAIR_BOOLEAN(key, val)
@@
expression key, val;
@@
- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_INTEGER(val))
|
- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_INTEGER(val))
+ SD_JSON_BUILD_PAIR_INTEGER(key, val)
@@
expression key, val;
@@
- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_STRING(val))
|
- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_STRING(val))
+ SD_JSON_BUILD_PAIR_STRING(key, val)
@@
expression key, val;
@@
- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_UNSIGNED(val))
|
- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_UNSIGNED(val))
+ SD_JSON_BUILD_PAIR_UNSIGNED(key, val)
@@
expression key, val;
@@
- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_VARIANT(val))
|
- SD_JSON_BUILD_PAIR@p(key, SD_JSON_BUILD_VARIANT(val))
+ SD_JSON_BUILD_PAIR_VARIANT(key, val)
)
+1 -3
View File
@@ -1150,10 +1150,8 @@ int flush_accept(int fd) {
r = fd_wait_for_event(fd, POLLIN, 0);
if (r == -EINTR)
continue;
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
if (iteration >= MAX_FLUSH_ITERATIONS)
return log_debug_errno(SYNTHETIC_ERRNO(EBUSY),
+5 -7
View File
@@ -408,13 +408,11 @@ static void unit_lookup_parameters_done(UnitLookupParameters *p) {
}
static int varlink_error_conflict_lookup_parameters(sd_varlink *v, const UnitLookupParameters *p) {
log_debug_errno(
ESRCH,
"Searching unit by lookup parameters name='%s' pid="PID_FMT" cgroup='%s' invocationID='%s' resulted in multiple different units",
p->name,
p->pidref.pid,
p->cgroup,
sd_id128_is_null(p->invocation_id) ? "" : SD_ID128_TO_UUID_STRING(p->invocation_id));
log_debug("Searching unit by lookup parameters name='%s' pid='"PID_FMT"' cgroup='%s' invocationID='%s' resulted in multiple different units",
strnull(p->name),
pidref_is_set(&p->pidref) ? p->pidref.pid : 0,
strnull(p->cgroup),
sd_id128_is_null(p->invocation_id) ? "" : SD_ID128_TO_UUID_STRING(p->invocation_id));
return varlink_error_no_such_unit(v, /* name= */ NULL);
}
+1 -1
View File
@@ -2690,7 +2690,7 @@ int home_augment_status(
r = sd_json_buildo(&status,
SD_JSON_BUILD_PAIR_STRING("state", home_state_to_string(state)),
SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Home")),
SD_JSON_BUILD_PAIR("useFallback", SD_JSON_BUILD_BOOLEAN(!HOME_STATE_IS_ACTIVE(state))),
SD_JSON_BUILD_PAIR_BOOLEAN("useFallback", !HOME_STATE_IS_ACTIVE(state)),
SD_JSON_BUILD_PAIR("fallbackShell", JSON_BUILD_CONST_STRING(BINDIR "/systemd-home-fallback-shell")),
SD_JSON_BUILD_PAIR("fallbackHomeDirectory", JSON_BUILD_CONST_STRING("/")),
SD_JSON_BUILD_PAIR_CONDITION(disk_size != UINT64_MAX, "diskSize", SD_JSON_BUILD_UNSIGNED(disk_size)),
+1 -1
View File
@@ -159,7 +159,7 @@ int group_record_synthesize(GroupRecord *g, UserRecord *h) {
SD_JSON_BUILD_PAIR_STRING("description", description),
SD_JSON_BUILD_PAIR("binding", SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(user_record_gid(h))))))),
SD_JSON_BUILD_PAIR_UNSIGNED("gid", user_record_gid(h)))))),
SD_JSON_BUILD_PAIR_CONDITION(h->disposition >= 0, "disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(user_record_disposition(h)))),
SD_JSON_BUILD_PAIR("status", SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), SD_JSON_BUILD_OBJECT(
+4 -4
View File
@@ -209,13 +209,13 @@ static int parse_pull_expression(const char *v) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *j = NULL;
r = sd_json_buildo(
&j,
SD_JSON_BUILD_PAIR("remote", SD_JSON_BUILD_STRING(remote)),
SD_JSON_BUILD_PAIR("local", SD_JSON_BUILD_STRING(local)),
SD_JSON_BUILD_PAIR_STRING("remote", remote),
SD_JSON_BUILD_PAIR_STRING("local", local),
SD_JSON_BUILD_PAIR("class", JSON_BUILD_STRING_UNDERSCORIFY(image_class_to_string(class))),
SD_JSON_BUILD_PAIR("type", JSON_BUILD_STRING_UNDERSCORIFY(import_type_to_string(type))),
SD_JSON_BUILD_PAIR("readOnly", SD_JSON_BUILD_BOOLEAN(ro)),
SD_JSON_BUILD_PAIR_BOOLEAN("readOnly", ro),
SD_JSON_BUILD_PAIR("verify", JSON_BUILD_STRING_UNDERSCORIFY(import_verify_to_string(verify))),
SD_JSON_BUILD_PAIR("imageRoot", SD_JSON_BUILD_STRING(image_root)));
SD_JSON_BUILD_PAIR_STRING("imageRoot", image_root));
if (r < 0)
return log_error_errno(r, "Failed to build import JSON object: %m");
+1 -2
View File
@@ -454,8 +454,7 @@ static int parse_argv(int argc, char *argv[]) {
"64 hex character SHA256 hash required when specifying explicit checksum, %zu specified", n * 2);
iovec_done(&arg_checksum);
arg_checksum.iov_base = TAKE_PTR(h);
arg_checksum.iov_len = n;
arg_checksum = IOVEC_MAKE(TAKE_PTR(h), n);
arg_import_flags &= ~(IMPORT_PULL_SETTINGS|IMPORT_PULL_ROOTHASH|IMPORT_PULL_ROOTHASH_SIGNATURE|IMPORT_PULL_VERITY);
arg_verify = _IMPORT_VERIFY_INVALID;
+1 -1
View File
@@ -68,7 +68,7 @@ static int test_basic(bool bind_to_interface) {
r = sd_dhcp_server_start(server);
/* skip test if running in an environment with no full networking support, CONFIG_PACKET not
* compiled in kernel, nor af_packet module available. */
if (r == -EPERM || r == -EAFNOSUPPORT)
if (IN_SET(r, -EPERM, -EAFNOSUPPORT))
return r;
ASSERT_OK(r);
+11 -11
View File
@@ -57,8 +57,8 @@ static int json_transform_variant(sd_bus_message *m, const char *contents, sd_js
return sd_json_buildo(
ret,
SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(contents)),
SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(value)));
SD_JSON_BUILD_PAIR_STRING("type", contents),
SD_JSON_BUILD_PAIR_VARIANT("data", value));
}
static int json_transform_dict_array(sd_bus_message *m, sd_json_variant **ret) {
@@ -287,8 +287,8 @@ static int json_transform_message(sd_bus_message *m, const char *type, sd_json_v
return sd_json_buildo(
ret,
SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(type)),
SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_VARIANT(v)));
SD_JSON_BUILD_PAIR_STRING("type", type),
SD_JSON_BUILD_PAIR_VARIANT("data", v));
}
_public_ int sd_bus_message_dump_json(sd_bus_message *m, uint64_t flags, sd_json_variant **ret) {
@@ -325,13 +325,13 @@ _public_ int sd_bus_message_dump_json(sd_bus_message *m, uint64_t flags, sd_json
return sd_json_buildo(
ret,
SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_STRING(bus_message_type_to_string(m->header->type))),
SD_JSON_BUILD_PAIR("endian", SD_JSON_BUILD_STRING(CHAR_TO_STR(m->header->endian))),
SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_INTEGER(m->header->flags)),
SD_JSON_BUILD_PAIR("version", SD_JSON_BUILD_INTEGER(m->header->version)),
SD_JSON_BUILD_PAIR("cookie", SD_JSON_BUILD_INTEGER(BUS_MESSAGE_COOKIE(m))),
SD_JSON_BUILD_PAIR_STRING("type", bus_message_type_to_string(m->header->type)),
SD_JSON_BUILD_PAIR_STRING("endian", CHAR_TO_STR(m->header->endian)),
SD_JSON_BUILD_PAIR_INTEGER("flags", m->header->flags),
SD_JSON_BUILD_PAIR_INTEGER("version", m->header->version),
SD_JSON_BUILD_PAIR_INTEGER("cookie", BUS_MESSAGE_COOKIE(m)),
SD_JSON_BUILD_PAIR_CONDITION(m->reply_cookie != 0, "reply_cookie", SD_JSON_BUILD_INTEGER(m->reply_cookie)),
SD_JSON_BUILD_PAIR("timestamp-realtime", SD_JSON_BUILD_UNSIGNED(ts)),
SD_JSON_BUILD_PAIR_UNSIGNED("timestamp-realtime", ts),
SD_JSON_BUILD_PAIR_CONDITION(!!m->sender, "sender", SD_JSON_BUILD_STRING(m->sender)),
SD_JSON_BUILD_PAIR_CONDITION(!!m->destination, "destination", SD_JSON_BUILD_STRING(m->destination)),
SD_JSON_BUILD_PAIR_CONDITION(!!m->path, "path", SD_JSON_BUILD_STRING(m->path)),
@@ -341,5 +341,5 @@ _public_ int sd_bus_message_dump_json(sd_bus_message *m, uint64_t flags, sd_json
SD_JSON_BUILD_PAIR_CONDITION(m->realtime != 0, "realtime", SD_JSON_BUILD_INTEGER(m->realtime)),
SD_JSON_BUILD_PAIR_CONDITION(m->seqnum != 0, "seqnum", SD_JSON_BUILD_INTEGER(m->seqnum)),
SD_JSON_BUILD_PAIR_CONDITION(!!m->error.name, "error_name", SD_JSON_BUILD_STRING(m->error.name)),
SD_JSON_BUILD_PAIR("payload", SD_JSON_BUILD_VARIANT(v)));
SD_JSON_BUILD_PAIR_VARIANT("payload", v));
}
+6 -6
View File
@@ -4182,8 +4182,8 @@ _public_ int sd_json_buildv(sd_json_variant **ret, va_list ap) {
if (ratelimit_configured(rl)) {
r = sd_json_buildo(
&add,
SD_JSON_BUILD_PAIR("intervalUSec", SD_JSON_BUILD_UNSIGNED(rl->interval)),
SD_JSON_BUILD_PAIR("burst", SD_JSON_BUILD_UNSIGNED(rl->burst)));
SD_JSON_BUILD_PAIR_UNSIGNED("intervalUSec", rl->interval),
SD_JSON_BUILD_PAIR_UNSIGNED("burst", rl->burst));
if (r < 0)
goto finish;
} else
@@ -4805,8 +4805,8 @@ _public_ int sd_json_buildv(sd_json_variant **ret, va_list ap) {
goto finish;
r = sd_json_buildo(&add_more,
SD_JSON_BUILD_PAIR("realtime", SD_JSON_BUILD_UNSIGNED(ts->realtime)),
SD_JSON_BUILD_PAIR("monotonic", SD_JSON_BUILD_UNSIGNED(ts->monotonic)));
SD_JSON_BUILD_PAIR_UNSIGNED("realtime", ts->realtime),
SD_JSON_BUILD_PAIR_UNSIGNED("monotonic", ts->monotonic));
if (r < 0)
goto finish;
}
@@ -4835,8 +4835,8 @@ _public_ int sd_json_buildv(sd_json_variant **ret, va_list ap) {
goto finish;
r = sd_json_buildo(&add_more,
SD_JSON_BUILD_PAIR("intervalUSec", SD_JSON_BUILD_UNSIGNED(rl->interval)),
SD_JSON_BUILD_PAIR("burst", SD_JSON_BUILD_UNSIGNED(rl->burst)));
SD_JSON_BUILD_PAIR_UNSIGNED("intervalUSec", rl->interval),
SD_JSON_BUILD_PAIR_UNSIGNED("burst", rl->burst));
if (r < 0)
goto finish;
}
+1 -1
View File
@@ -3411,7 +3411,7 @@ _public_ int sd_varlink_set_allow_fd_passing_output(sd_varlink *v, int b) {
if (r < 0)
return r;
v->allow_fd_passing_output = !!b;
v->allow_fd_passing_output = b;
return 1;
}
+1 -2
View File
@@ -105,9 +105,8 @@ static void sd_eviocrevoke(int fd) {
if (errno == EINVAL) {
log_warning_errno(errno, "Kernel does not support evdev-revocation, continuing without revoking device access: %m");
warned = true;
} else if (errno != ENODEV) {
} else if (errno != ENODEV)
log_warning_errno(errno, "Failed to revoke evdev device, continuing without revoking device access: %m");
}
}
}
+2 -4
View File
@@ -316,10 +316,8 @@ static int machine_add_from_params(
details,
&manager->polkit_registry,
error);
if (r < 0)
return r;
if (r == 0)
return 0; /* Will call us back */
if (r <= 0)
return r; /* 0 means Polkit will call us back, see method_create_machine() */
}
r = manager_add_machine(manager, name, &m);
+2 -2
View File
@@ -476,9 +476,9 @@ static int list_machine_one_and_maybe_read_metadata(sd_varlink *link, Machine *m
r = sd_json_buildo(
&v,
SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(m->name)),
SD_JSON_BUILD_PAIR_STRING("name", m->name),
SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(m->id), "id", SD_JSON_BUILD_ID128(m->id)),
SD_JSON_BUILD_PAIR("class", SD_JSON_BUILD_STRING(machine_class_to_string(m->class))),
SD_JSON_BUILD_PAIR_STRING("class", machine_class_to_string(m->class)),
JSON_BUILD_PAIR_STRING_NON_EMPTY("service", m->service),
JSON_BUILD_PAIR_STRING_NON_EMPTY("rootDirectory", m->root_directory),
JSON_BUILD_PAIR_STRING_NON_EMPTY("unit", m->unit),
+1 -3
View File
@@ -1321,10 +1321,8 @@ static int acquire_removable(sd_device *d) {
return r;
r = device_in_subsystem(d, "block");
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
}
if (parse_boolean(v) <= 0)
+1 -2
View File
@@ -1439,12 +1439,11 @@ void netdev_dump(NetDev *netdev, FILE *f) {
if (netdev->mtu > 0)
fprintf(f, "MTUBytes=%" PRIu32 "\n", netdev->mtu);
if (streq(netdev->kind, "vlan")) {
if (streq(netdev->kind, "vlan"))
fprintf(f,
"\n[VLAN]\n"
"Id=%u\n",
netdev->vlan_id);
}
}
void link_dump(Link *link, FILE *f) {
+2 -5
View File
@@ -152,11 +152,8 @@ Modem* modem_free(Modem *modem) {
if (!modem)
return NULL;
if (modem->bearers_by_name)
hashmap_free(modem->bearers_by_name);
if (modem->bearers_by_path)
hashmap_free(modem->bearers_by_path);
hashmap_free(modem->bearers_by_name);
hashmap_free(modem->bearers_by_path);
if (modem->manager)
hashmap_remove_value(modem->manager->modems_by_path, modem->path, modem);
+1 -2
View File
@@ -422,7 +422,7 @@ static int monitor_swap_contexts_handler(sd_event_source *s, uint64_t usec, void
if (r < 0)
log_error_errno(r, "Failed to select any cgroups based on swap: %m");
else {
if (selected && r > 0) {
if (selected && r > 0)
log_notice("Marked %s for killing due to memory used (%"PRIu64") / total (%"PRIu64") and "
"swap used (%"PRIu64") / total (%"PRIu64") being more than "
PERMYRIAD_AS_PERCENT_FORMAT_STR,
@@ -430,7 +430,6 @@ static int monitor_swap_contexts_handler(sd_event_source *s, uint64_t usec, void
m->system_context.mem_used, m->system_context.mem_total,
m->system_context.swap_used, m->system_context.swap_total,
PERMYRIAD_AS_PERCENT_FORMAT_VAL(m->swap_used_limit_permyriad));
}
return 0;
}
}
+22 -22
View File
@@ -2785,15 +2785,15 @@ static int make_pcrlock_record(
r = sd_json_variant_append_arraybo(
&digests,
SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_usize)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
}
r = sd_json_buildo(ret_record,
SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(pcr)),
SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
SD_JSON_BUILD_PAIR_UNSIGNED("pcr", pcr),
SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to build record object: %m");
@@ -2867,7 +2867,7 @@ static int make_pcrlock_record_from_stream(
r = sd_json_variant_append_arraybo(
&digests,
SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_usize)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
@@ -2881,8 +2881,8 @@ static int make_pcrlock_record_from_stream(
r = sd_json_buildo(
&record,
SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(i)),
SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
SD_JSON_BUILD_PAIR_UNSIGNED("pcr", i),
SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to build record object: %m");
@@ -2914,7 +2914,7 @@ static int write_pcrlock(sd_json_variant *array, const char *default_pcrlock_pat
r = sd_json_buildo(
&v,
SD_JSON_BUILD_PAIR("records", SD_JSON_BUILD_VARIANT(array)));
SD_JSON_BUILD_PAIR_VARIANT("records", array));
if (r < 0)
return log_error_errno(r, "Failed to build JSON object: %m");
@@ -3238,7 +3238,7 @@ static int verb_lock_secureboot_authority(int argc, char *argv[], void *userdata
LIST_FOREACH(banks, bank, rec->banks) {
r = sd_json_variant_append_arraybo(
&digests,
SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(bank->algorithm))),
SD_JSON_BUILD_PAIR_STRING("hashAlg", tpm2_hash_alg_to_string(bank->algorithm)),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(bank->hash.buffer, bank->hash.size)));
if (r < 0)
return log_error_errno(r, "Failed to build digests array: %m");
@@ -3246,8 +3246,8 @@ static int verb_lock_secureboot_authority(int argc, char *argv[], void *userdata
r = sd_json_variant_append_arraybo(
&array,
SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(rec->pcr)),
SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
SD_JSON_BUILD_PAIR_UNSIGNED("pcr", rec->pcr),
SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to build record array: %m");
}
@@ -3529,7 +3529,7 @@ static int verb_lock_firmware(int argc, char *argv[], void *userdata) {
LIST_FOREACH(banks, bank, rec->banks) {
r = sd_json_variant_append_arraybo(
&digests,
SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(tpm2_hash_alg_to_string(bank->algorithm))),
SD_JSON_BUILD_PAIR_STRING("hashAlg", tpm2_hash_alg_to_string(bank->algorithm)),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(bank->hash.buffer, bank->hash.size)));
if (r < 0)
return log_error_errno(r, "Failed to build digests array: %m");
@@ -3537,8 +3537,8 @@ static int verb_lock_firmware(int argc, char *argv[], void *userdata) {
r = sd_json_variant_append_arraybo(
FLAGS_SET(separator_seen_mask, bit) ? &array_late : &array_early,
SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(rec->pcr)),
SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
SD_JSON_BUILD_PAIR_UNSIGNED("pcr", rec->pcr),
SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to build record array: %m");
}
@@ -3748,7 +3748,7 @@ static int verb_lock_pe(int argc, char *argv[], void *userdata) {
r = sd_json_variant_append_arraybo(
&digests,
SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_size)));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
@@ -3756,8 +3756,8 @@ static int verb_lock_pe(int argc, char *argv[], void *userdata) {
r = sd_json_variant_append_arraybo(
&array,
SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(i)),
SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(digests)));
SD_JSON_BUILD_PAIR_UNSIGNED("pcr", i),
SD_JSON_BUILD_PAIR_VARIANT("digests", digests));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
}
@@ -3804,7 +3804,7 @@ static int verb_lock_uki(int argc, char *argv[], void *userdata) {
r = sd_json_variant_append_arraybo(
&pe_digests,
SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(peh, hash_sizes[i])));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
@@ -3816,8 +3816,8 @@ static int verb_lock_uki(int argc, char *argv[], void *userdata) {
r = sd_json_variant_append_arraybo(
&array,
SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(TPM2_PCR_BOOT_LOADER_CODE)),
SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(pe_digests)));
SD_JSON_BUILD_PAIR_UNSIGNED("pcr", TPM2_PCR_BOOT_LOADER_CODE),
SD_JSON_BUILD_PAIR_VARIANT("digests", pe_digests));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
@@ -3839,7 +3839,7 @@ static int verb_lock_uki(int argc, char *argv[], void *userdata) {
r = sd_json_variant_append_arraybo(
&section_digests,
SD_JSON_BUILD_PAIR("hashAlg", SD_JSON_BUILD_STRING(a)),
SD_JSON_BUILD_PAIR_STRING("hashAlg", a),
SD_JSON_BUILD_PAIR("digest", SD_JSON_BUILD_HEX(hash, hash_sizes[i])));
if (r < 0)
return log_error_errno(r, "Failed to build JSON digest object: %m");
@@ -3860,8 +3860,8 @@ static int verb_lock_uki(int argc, char *argv[], void *userdata) {
/* And then append a record for the section contents digests as well */
r = sd_json_variant_append_arraybo(
&array,
SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_UNSIGNED(TPM2_PCR_KERNEL_BOOT /* =11 */)),
SD_JSON_BUILD_PAIR("digests", SD_JSON_BUILD_VARIANT(section_digests)));
SD_JSON_BUILD_PAIR_UNSIGNED("pcr", TPM2_PCR_KERNEL_BOOT),
SD_JSON_BUILD_PAIR_VARIANT("digests", section_digests));
if (r < 0)
return log_error_errno(r, "Failed to append record object: %m");
}
+3 -3
View File
@@ -441,9 +441,9 @@ int mdns_manage_services_answer(DnsServiceBrowser *sb, DnsAnswer *answer, int ow
browse_service_update_event_to_string(
BROWSE_SERVICE_UPDATE_REMOVED)),
SD_JSON_BUILD_PAIR_INTEGER("family", owner_family),
SD_JSON_BUILD_PAIR_STRING("name", name ?: ""),
SD_JSON_BUILD_PAIR_STRING("type", type ?: ""),
SD_JSON_BUILD_PAIR_STRING("domain", domain ?: ""),
SD_JSON_BUILD_PAIR_STRING("name", strempty(name)),
SD_JSON_BUILD_PAIR_STRING("type", strempty(type)),
SD_JSON_BUILD_PAIR_STRING("domain", strempty(domain)),
SD_JSON_BUILD_PAIR_INTEGER("ifindex", ifindex));
if (r < 0) {
log_error_errno(r, "Failed to build JSON for removed service: %m");
+1 -1
View File
@@ -49,7 +49,7 @@ static Hook* hook_free(Hook *h) {
if (!h)
return NULL;
mfree(h->socket_path);
free(h->socket_path);
sd_varlink_unref(h->filter_link);
set_free(h->idle_links);
+1 -1
View File
@@ -1180,7 +1180,7 @@ static DnsSvcParam* add_svcb_param(DnsResourceRecord *rr, uint16_t key, const ch
param->key = key;
param->length = len;
if (value != NULL)
if (value)
memcpy(param->value, value, len);
LIST_APPEND(params, rr->svcb.params, param);
+1 -1
View File
@@ -3902,7 +3902,7 @@ static DnsSvcParam* add_svcb_param(DnsResourceRecord *rr, uint16_t key, const ch
param->key = key;
param->length = len;
if (value != NULL)
if (value)
memcpy(param->value, value, len);
LIST_APPEND(params, rr->svcb.params, param);
+1 -1
View File
@@ -858,7 +858,7 @@ static void exercise_dns_query_go(GoConfig *cfg, void (*check_query)(DnsQuery *q
ASSERT_NOT_NULL(query);
ASSERT_TRUE(dns_query_go(query));
if (check_query != NULL)
if (check_query)
check_query(query);
}
+1 -1
View File
@@ -2043,7 +2043,7 @@ static DnsSvcParam* add_svcb_param(DnsResourceRecord *rr, uint16_t key, const ch
param->key = key;
param->length = len;
if (value != NULL)
if (value)
memcpy(param->value, value, len);
LIST_APPEND(params, rr->svcb.params, param);
+1 -3
View File
@@ -2187,10 +2187,8 @@ int image_setup_pool(RuntimeScope scope, ImageClass class, bool use_btrfs_subvol
return r;
r = check_btrfs(pool);
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
if (!use_btrfs_subvol)
return 0;
+2 -2
View File
@@ -284,8 +284,8 @@ int hostname_substitute_wildcards(char *name) {
struct siphash state;
siphash24_init(&state, key.bytes);
siphash24_compress(&mid, sizeof(mid), &state);
siphash24_compress(&counter, sizeof(counter), &state); /* counter mode */
siphash24_compress_typesafe(mid, &state);
siphash24_compress_typesafe(counter, &state); /* counter mode */
h = siphash24_finalize(&state);
left_bits = sizeof(h) * 8;
counter++;
+1 -1
View File
@@ -1244,7 +1244,7 @@ int fido2_list_devices(void) {
goto finish;
}
if (table_get_rows(t) > 1)
if (!table_isempty(t))
printf("\n"
"%1$sLegend: RK %2$s Resident key%3$s\n"
"%1$s CLIENTPIN %2$s PIN request%3$s\n"
+1 -1
View File
@@ -163,7 +163,7 @@ static int metric_build_send(MetricFamilyContext *context, const char *object, s
return sd_varlink_replybo(context->link,
SD_JSON_BUILD_PAIR_STRING("name", context->metric_family->name),
JSON_BUILD_PAIR_STRING_NON_EMPTY("object", object),
SD_JSON_BUILD_PAIR("value", SD_JSON_BUILD_VARIANT(value)),
SD_JSON_BUILD_PAIR_VARIANT("value", value),
JSON_BUILD_PAIR_VARIANT_NON_NULL("fields", fields));
}
+1 -1
View File
@@ -95,7 +95,7 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_ISSUE_PATH:
if (isempty(optarg) || streq(optarg, "-")) {
if (empty_or_dash(optarg)) {
arg_issue_path = mfree(arg_issue_path);
arg_issue_stdout = true;
break;
+1 -2
View File
@@ -108,14 +108,13 @@ static int parse_shutdown_time_spec(const char *t, usec_t *ret) {
if (r < 0)
return r;
if (tm.tm_hour != requested_hour || tm.tm_min != requested_min) {
if (tm.tm_hour != requested_hour || tm.tm_min != requested_min)
log_warning("Requested shutdown time %02d:%02d does not exist. "
"Rescheduling to %02d:%02d.",
requested_hour,
requested_min,
tm.tm_hour,
tm.tm_min);
}
}
*ret = s;
+1 -2
View File
@@ -397,13 +397,12 @@ static int context_discover_update_sets_by_flag(Context *c, UpdateSetFlags flags
assert(flags == UPDATE_INSTALLED);
match = resource_find_instance(&t->target, cursor);
if (!match && !(extra_flags & (UPDATE_PARTIAL|UPDATE_PENDING))) {
if (!match && !(extra_flags & (UPDATE_PARTIAL|UPDATE_PENDING)))
/* When we're looking for installed versions, let's be robust and treat
* an incomplete installation as an installation. Otherwise, there are
* situations that can lead to sysupdate wiping the currently booted OS.
* See https://github.com/systemd/systemd/issues/33339 */
extra_flags |= UPDATE_INCOMPLETE;
}
}
cursor_instances[k] = match;
+36 -36
View File
@@ -395,13 +395,13 @@ TEST(json) {
SD_JSON_BUILD_ARRAY(
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("foo_bar", JSON_BUILD_CONST_STRING("v1")),
SD_JSON_BUILD_PAIR("quux", SD_JSON_BUILD_UNSIGNED(4711)),
SD_JSON_BUILD_PAIR("zzz", SD_JSON_BUILD_BOOLEAN(true)),
SD_JSON_BUILD_PAIR_UNSIGNED("quux", 4711),
SD_JSON_BUILD_PAIR_BOOLEAN("zzz", true),
SD_JSON_BUILD_PAIR("asdf-custom", SD_JSON_BUILD_NULL)),
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("foo_bar", SD_JSON_BUILD_STRV(STRV_MAKE("a", "b", "c"))),
SD_JSON_BUILD_PAIR("quux", SD_JSON_BUILD_NULL),
SD_JSON_BUILD_PAIR("zzz", SD_JSON_BUILD_UNSIGNED(0755)),
SD_JSON_BUILD_PAIR_UNSIGNED("zzz", 0755),
SD_JSON_BUILD_PAIR("asdf-custom", SD_JSON_BUILD_NULL)))));
ASSERT_TRUE(sd_json_variant_equal(v, w));
@@ -624,23 +624,23 @@ TEST(signed_integers) {
ASSERT_OK(sd_json_build(&b,
SD_JSON_BUILD_ARRAY(
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("int", SD_JSON_BUILD_INTEGER(-1)),
SD_JSON_BUILD_PAIR("int8", SD_JSON_BUILD_INTEGER(-1)),
SD_JSON_BUILD_PAIR("int16", SD_JSON_BUILD_INTEGER(-1)),
SD_JSON_BUILD_PAIR("int32", SD_JSON_BUILD_INTEGER(-1)),
SD_JSON_BUILD_PAIR("int64", SD_JSON_BUILD_INTEGER(-1))),
SD_JSON_BUILD_PAIR_INTEGER("int", -1),
SD_JSON_BUILD_PAIR_INTEGER("int8", -1),
SD_JSON_BUILD_PAIR_INTEGER("int16", -1),
SD_JSON_BUILD_PAIR_INTEGER("int32", -1),
SD_JSON_BUILD_PAIR_INTEGER("int64", -1)),
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("int", SD_JSON_BUILD_INTEGER(INT_MAX)),
SD_JSON_BUILD_PAIR("int8", SD_JSON_BUILD_INTEGER(INT8_MAX)),
SD_JSON_BUILD_PAIR("int16", SD_JSON_BUILD_INTEGER(INT16_MAX)),
SD_JSON_BUILD_PAIR("int32", SD_JSON_BUILD_INTEGER(INT32_MAX)),
SD_JSON_BUILD_PAIR("int64", SD_JSON_BUILD_INTEGER(INT64_MAX))),
SD_JSON_BUILD_PAIR_INTEGER("int", INT_MAX),
SD_JSON_BUILD_PAIR_INTEGER("int8", INT8_MAX),
SD_JSON_BUILD_PAIR_INTEGER("int16", INT16_MAX),
SD_JSON_BUILD_PAIR_INTEGER("int32", INT32_MAX),
SD_JSON_BUILD_PAIR_INTEGER("int64", INT64_MAX)),
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("int", SD_JSON_BUILD_INTEGER(INT_MIN)),
SD_JSON_BUILD_PAIR("int8", SD_JSON_BUILD_INTEGER(INT8_MIN)),
SD_JSON_BUILD_PAIR("int16", SD_JSON_BUILD_INTEGER(INT16_MIN)),
SD_JSON_BUILD_PAIR("int32", SD_JSON_BUILD_INTEGER(INT32_MIN)),
SD_JSON_BUILD_PAIR("int64", SD_JSON_BUILD_INTEGER(INT64_MIN))))));
SD_JSON_BUILD_PAIR_INTEGER("int", INT_MIN),
SD_JSON_BUILD_PAIR_INTEGER("int8", INT8_MIN),
SD_JSON_BUILD_PAIR_INTEGER("int16", INT16_MIN),
SD_JSON_BUILD_PAIR_INTEGER("int32", INT32_MIN),
SD_JSON_BUILD_PAIR_INTEGER("int64", INT64_MIN)))));
sd_json_variant_dump(b, SD_JSON_FORMAT_NEWLINE, stdout, NULL);
ASSERT_TRUE(sd_json_variant_equal(a, b));
@@ -686,21 +686,21 @@ TEST(unsigned_integers) {
ASSERT_OK(sd_json_build(&b,
SD_JSON_BUILD_ARRAY(
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("uint", SD_JSON_BUILD_UNSIGNED(0)),
SD_JSON_BUILD_PAIR("uint8", SD_JSON_BUILD_UNSIGNED(0)),
SD_JSON_BUILD_PAIR("uint16", SD_JSON_BUILD_UNSIGNED(0)),
SD_JSON_BUILD_PAIR("uint32", SD_JSON_BUILD_UNSIGNED(0)),
SD_JSON_BUILD_PAIR("uhex32", SD_JSON_BUILD_UNSIGNED(0)),
SD_JSON_BUILD_PAIR("uint64", SD_JSON_BUILD_UNSIGNED(0)),
SD_JSON_BUILD_PAIR("uhex64", SD_JSON_BUILD_UNSIGNED(0))),
SD_JSON_BUILD_PAIR_UNSIGNED("uint", 0),
SD_JSON_BUILD_PAIR_UNSIGNED("uint8", 0),
SD_JSON_BUILD_PAIR_UNSIGNED("uint16", 0),
SD_JSON_BUILD_PAIR_UNSIGNED("uint32", 0),
SD_JSON_BUILD_PAIR_UNSIGNED("uhex32", 0),
SD_JSON_BUILD_PAIR_UNSIGNED("uint64", 0),
SD_JSON_BUILD_PAIR_UNSIGNED("uhex64", 0)),
SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("uint", SD_JSON_BUILD_UNSIGNED(UINT_MAX)),
SD_JSON_BUILD_PAIR("uint8", SD_JSON_BUILD_UNSIGNED(UINT8_MAX)),
SD_JSON_BUILD_PAIR("uint16", SD_JSON_BUILD_UNSIGNED(UINT16_MAX)),
SD_JSON_BUILD_PAIR("uint32", SD_JSON_BUILD_UNSIGNED(UINT32_MAX)),
SD_JSON_BUILD_PAIR("uhex32", SD_JSON_BUILD_UNSIGNED(UINT32_MAX)),
SD_JSON_BUILD_PAIR("uint64", SD_JSON_BUILD_UNSIGNED(UINT64_MAX)),
SD_JSON_BUILD_PAIR("uhex64", SD_JSON_BUILD_UNSIGNED(UINT64_MAX))))));
SD_JSON_BUILD_PAIR_UNSIGNED("uint", UINT_MAX),
SD_JSON_BUILD_PAIR_UNSIGNED("uint8", UINT8_MAX),
SD_JSON_BUILD_PAIR_UNSIGNED("uint16", UINT16_MAX),
SD_JSON_BUILD_PAIR_UNSIGNED("uint32", UINT32_MAX),
SD_JSON_BUILD_PAIR_UNSIGNED("uhex32", UINT32_MAX),
SD_JSON_BUILD_PAIR_UNSIGNED("uint64", UINT64_MAX),
SD_JSON_BUILD_PAIR_UNSIGNED("uhex64", UINT64_MAX)))));
sd_json_variant_dump(b, SD_JSON_FORMAT_NEWLINE, stdout, NULL);
ASSERT_TRUE(sd_json_variant_equal(a, b));
@@ -734,10 +734,10 @@ TEST(vertical) {
ASSERT_OK(table_to_json(t, &a));
ASSERT_OK(sd_json_build(&b, SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("pfft_aa", SD_JSON_BUILD_STRING("foo")),
SD_JSON_BUILD_PAIR("dimpfelmoser", SD_JSON_BUILD_UNSIGNED(1024)),
SD_JSON_BUILD_PAIR("custom-quux", SD_JSON_BUILD_STRING("asdf")),
SD_JSON_BUILD_PAIR("lllllllllllo", SD_JSON_BUILD_STRING("jjjjjjjjjjjjjjjjj")))));
SD_JSON_BUILD_PAIR_STRING("pfft_aa", "foo"),
SD_JSON_BUILD_PAIR_UNSIGNED("dimpfelmoser", 1024),
SD_JSON_BUILD_PAIR_STRING("custom-quux", "asdf"),
SD_JSON_BUILD_PAIR_STRING("lllllllllllo", "jjjjjjjjjjjjjjjjj"))));
ASSERT_TRUE(sd_json_variant_equal(a, b));
}
+2 -2
View File
@@ -334,8 +334,8 @@ TEST(validate_json) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *v = NULL;
assert_se(sd_json_build(&v, SD_JSON_BUILD_OBJECT(
SD_JSON_BUILD_PAIR("a", SD_JSON_BUILD_STRING("x")),
SD_JSON_BUILD_PAIR("b", SD_JSON_BUILD_UNSIGNED(44)),
SD_JSON_BUILD_PAIR_STRING("a", "x"),
SD_JSON_BUILD_PAIR_UNSIGNED("b", 44),
SD_JSON_BUILD_PAIR("d", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_UNSIGNED(5), SD_JSON_BUILD_UNSIGNED(7), SD_JSON_BUILD_UNSIGNED(107))),
SD_JSON_BUILD_PAIR("g", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("f", SD_JSON_BUILD_REAL(0.5f)))))) >= 0);
+13 -13
View File
@@ -45,7 +45,7 @@ static int method_something(sd_varlink *link, sd_json_variant *parameters, sd_va
y = sd_json_variant_integer(b);
r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("sum", SD_JSON_BUILD_INTEGER(x + y))));
r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("sum", x + y)));
if (r < 0)
return r;
@@ -75,7 +75,7 @@ static int method_something_more(sd_varlink *link, sd_json_variant *parameters,
for (int i = 0; i < 5; i++) {
_cleanup_(sd_json_variant_unrefp) sd_json_variant *w = NULL;
r = sd_json_build(&w, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("sum", SD_JSON_BUILD_INTEGER(s.x + (s.y * i)))));
r = sd_json_build(&w, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("sum", s.x + (s.y * i))));
if (r < 0)
return r;
@@ -84,7 +84,7 @@ static int method_something_more(sd_varlink *link, sd_json_variant *parameters,
return r;
}
r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("sum", SD_JSON_BUILD_INTEGER(s.x + (s.y * 5)))));
r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("sum", s.x + (s.y * 5))));
if (r < 0)
return r;
@@ -125,7 +125,7 @@ static int method_passfd(sd_varlink *link, sd_json_variant *parameters, sd_varli
ASSERT_OK(vv = memfd_new_and_seal_string("data", "miau"));
ASSERT_OK(ww = memfd_new_and_seal_string("data", "wuff"));
r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("yo", SD_JSON_BUILD_INTEGER(88))));
r = sd_json_build(&ret, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("yo", 88)));
if (r < 0)
return r;
@@ -222,7 +222,7 @@ static void flood_test(const char *address) {
ASSERT_OK(asprintf(&t, "flood-%zu", k));
ASSERT_OK(sd_varlink_set_description(connections[k], t));
ASSERT_OK(sd_varlink_attach_event(connections[k], e, k));
ASSERT_OK(sd_varlink_sendb(connections[k], "io.test.Rubbish", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_INTEGER(k)))));
ASSERT_OK(sd_varlink_sendb(connections[k], "io.test.Rubbish", SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("id", k))));
}
/* Then, create one more, which should fail */
@@ -253,8 +253,8 @@ static void *thread(void *arg) {
const char *error_id, *e;
int x = 0;
ASSERT_OK(sd_json_build(&i, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("a", SD_JSON_BUILD_INTEGER(88)),
SD_JSON_BUILD_PAIR("b", SD_JSON_BUILD_INTEGER(99)))));
ASSERT_OK(sd_json_build(&i, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("a", 88),
SD_JSON_BUILD_PAIR_INTEGER("b", 99))));
ASSERT_OK(sd_varlink_connect_address(&c, arg));
ASSERT_OK(sd_varlink_set_description(c, "thread-client"));
@@ -262,8 +262,8 @@ static void *thread(void *arg) {
ASSERT_OK(sd_varlink_set_allow_fd_passing_output(c, true));
/* Test that client is able to perform two sequential sd_varlink_collect calls if first resulted in an error */
ASSERT_OK(sd_json_build(&wrong, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("a", SD_JSON_BUILD_INTEGER(88)),
SD_JSON_BUILD_PAIR("c", SD_JSON_BUILD_INTEGER(99)))));
ASSERT_OK(sd_json_build(&wrong, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("a", 88),
SD_JSON_BUILD_PAIR_INTEGER("c", 99))));
ASSERT_OK(sd_varlink_collect(c, "io.test.DoSomethingMore", wrong, &j, &error_id));
ASSERT_STREQ(error_id, "org.varlink.service.InvalidParameter");
@@ -292,7 +292,7 @@ static void *thread(void *arg) {
ASSERT_OK_EQ(sd_varlink_push_fd(c, fd2), 1);
ASSERT_OK_EQ(sd_varlink_push_fd(c, fd3), 2);
ASSERT_OK(sd_varlink_callb(c, "io.test.PassFD", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("fd", SD_JSON_BUILD_STRING("whoop")))));
ASSERT_OK(sd_varlink_callb(c, "io.test.PassFD", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_STRING("fd", "whoop"))));
ASSERT_NULL(e);
int fd4, fd5;
@@ -302,7 +302,7 @@ static void *thread(void *arg) {
test_fd(fd4, "miau", 4);
test_fd(fd5, "wuff", 4);
ASSERT_OK(sd_varlink_callb(c, "io.test.PassFD", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("fdx", SD_JSON_BUILD_STRING("whoopx")))));
ASSERT_OK(sd_varlink_callb(c, "io.test.PassFD", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_STRING("fdx", "whoopx"))));
ASSERT_TRUE(sd_varlink_error_is_invalid_parameter(e, o, "fd"));
ASSERT_OK(sd_varlink_callb(c, "io.test.IDontExist", &o, &e, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("x", SD_JSON_BUILD_REAL(5.5)))));
@@ -371,8 +371,8 @@ TEST(chat) {
ASSERT_OK(sd_varlink_server_attach_event(s, e, 0));
ASSERT_OK(sd_varlink_server_set_connections_max(s, OVERLOAD_CONNECTIONS));
ASSERT_OK(sd_json_build(&v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("a", SD_JSON_BUILD_INTEGER(7)),
SD_JSON_BUILD_PAIR("b", SD_JSON_BUILD_INTEGER(22)))));
ASSERT_OK(sd_json_build(&v, SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_INTEGER("a", 7),
SD_JSON_BUILD_PAIR_INTEGER("b", 22))));
ASSERT_OK(sd_varlink_connect_address(&c, sp));
ASSERT_OK(sd_varlink_set_description(c, "main-client"));
+1 -1
View File
@@ -192,7 +192,7 @@ static int verb_probe(UdevEvent *event, sd_device *dev) {
(void) image_policy_to_string(image_policy, /* simplify= */ false, &a);
(void) image_policy_to_string(image_policy_mangled, /* simplify= */ false, &b);
log_device_debug_errno(dev, ERFKILL, "Couldn't dissect block device with regular policy '%s', retrying with policy where root/usr are set to ignore '%s'.", a, b);
log_device_debug_errno(dev, SYNTHETIC_ERRNO(ERFKILL), "Couldn't dissect block device with regular policy '%s', retrying with policy where root/usr are set to ignore '%s'.", a, b);
}
r = dissect_loop_device(
+1 -3
View File
@@ -157,10 +157,8 @@ static int worker_mark_block_device_read_only(sd_device *dev) {
return 0;
r = device_in_subsystem(dev, "block");
if (r < 0)
if (r <= 0)
return r;
if (r == 0)
return 0;
/* Exclude synthetic devices for now, this is supposed to be a safety feature to avoid modification
* of physical devices, and what sits on top of those doesn't really matter if we don't allow the