diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh index 19ae59e4e5..ecefbf5302 100755 --- a/coccinelle/run-coccinelle.sh +++ b/coccinelle/run-coccinelle.sh @@ -33,6 +33,11 @@ case "$1" in ;; esac +if ! command -v spatch >/dev/null; then + echo 'Please install spatch (package "coccinelle")' + exit 1 +fi + if ! parallel -h >/dev/null; then echo 'Please install GNU parallel (package "parallel")' exit 1 diff --git a/coccinelle/sd_build_pair.cocci b/coccinelle/sd_build_pair.cocci new file mode 100644 index 0000000000..f0724ef824 --- /dev/null +++ b/coccinelle/sd_build_pair.cocci @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +@@ +expression key, val; +@@ +- SD_JSON_BUILD_PAIR(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_INTEGER(key, val) +@@ +expression key, val; +@@ +- SD_JSON_BUILD_PAIR(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_UNSIGNED(key, val) +@@ +expression key, val; +@@ +- SD_JSON_BUILD_PAIR(key, SD_JSON_BUILD_VARIANT(val)) ++ SD_JSON_BUILD_PAIR_VARIANT(key, val) diff --git a/src/ask-password/ask-password.c b/src/ask-password/ask-password.c index c56dfc2346..b712b8b3c0 100644 --- a/src/ask-password/ask-password.c +++ b/src/ask-password/ask-password.c @@ -371,7 +371,7 @@ static int vl_method_ask(sd_varlink *link, sd_json_variant *parameters, sd_varli sd_json_variant_sensitive(vl); - return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("passwords", SD_JSON_BUILD_VARIANT(vl))); + return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR_VARIANT("passwords", vl)); } static int vl_server(void) { diff --git a/src/core/varlink-dynamic-user.c b/src/core/varlink-dynamic-user.c index 6be6091b3b..cdf5fa8693 100644 --- a/src/core/varlink-dynamic-user.c +++ b/src/core/varlink-dynamic-user.c @@ -26,13 +26,13 @@ static int build_user_json(const char *user_name, uid_t uid, sd_json_variant **r assert(ret); return sd_json_buildo(ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)), - SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(uid)), + SD_JSON_BUILD_PAIR_STRING("userName", user_name), + SD_JSON_BUILD_PAIR_UNSIGNED("uid", uid), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", uid), SD_JSON_BUILD_PAIR("realName", JSON_BUILD_CONST_STRING("Dynamic User")), SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")), SD_JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)), - SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)), + SD_JSON_BUILD_PAIR_BOOLEAN("locked", true), SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")), SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic"))))); } @@ -136,9 +136,9 @@ static int build_group_json(const char *group_name, gid_t gid, sd_json_variant * assert(ret); return sd_json_buildo(ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(group_name)), + SD_JSON_BUILD_PAIR_STRING("groupName", group_name), SD_JSON_BUILD_PAIR("description", JSON_BUILD_CONST_STRING("Dynamic Group")), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", gid), SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.DynamicUser")), SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("dynamic"))))); } diff --git a/src/core/varlink-execute.c b/src/core/varlink-execute.c index 116d77e006..afba470e46 100644 --- a/src/core/varlink-execute.c +++ b/src/core/varlink-execute.c @@ -365,7 +365,7 @@ static int exec_dir_build_json(sd_json_variant **ret, const char *name, void *us return sd_json_buildo( ret, - SD_JSON_BUILD_PAIR("paths", SD_JSON_BUILD_VARIANT(v)), + SD_JSON_BUILD_PAIR_VARIANT("paths", v), SD_JSON_BUILD_PAIR_UNSIGNED("mode", exec_dir->mode), SD_JSON_BUILD_PAIR("quota", SD_JSON_BUILD_OBJECT( diff --git a/src/core/varlink.c b/src/core/varlink.c index 99f12c59e5..d133b6a640 100644 --- a/src/core/varlink.c +++ b/src/core/varlink.c @@ -61,9 +61,9 @@ static int build_managed_oom_json_array_element(Unit *u, const char *property, s return -EINVAL; return sd_json_buildo(ret_v, - SD_JSON_BUILD_PAIR("mode", SD_JSON_BUILD_STRING(mode)), - SD_JSON_BUILD_PAIR("path", SD_JSON_BUILD_STRING(crt->cgroup_path)), - SD_JSON_BUILD_PAIR("property", SD_JSON_BUILD_STRING(property)), + SD_JSON_BUILD_PAIR_STRING("mode", mode), + SD_JSON_BUILD_PAIR_STRING("path", crt->cgroup_path), + SD_JSON_BUILD_PAIR_STRING("property", property), SD_JSON_BUILD_PAIR_CONDITION(use_limit, "limit", SD_JSON_BUILD_UNSIGNED(c->moom_mem_pressure_limit)), SD_JSON_BUILD_PAIR_CONDITION(use_duration, "duration", SD_JSON_BUILD_UNSIGNED(c->moom_mem_pressure_duration_usec))); } @@ -126,7 +126,7 @@ static int build_managed_oom_cgroups_json(Manager *m, bool allow_empty, sd_json_ return 0; } - r = sd_json_buildo(ret, SD_JSON_BUILD_PAIR("cgroups", SD_JSON_BUILD_VARIANT(arr))); + r = sd_json_buildo(ret, SD_JSON_BUILD_PAIR_VARIANT("cgroups", arr)); if (r < 0) return r; @@ -281,7 +281,7 @@ int manager_varlink_send_managed_oom_update(Unit *u) { return 0; } - r = sd_json_buildo(&v, SD_JSON_BUILD_PAIR("cgroups", SD_JSON_BUILD_VARIANT(arr))); + r = sd_json_buildo(&v, SD_JSON_BUILD_PAIR_VARIANT("cgroups", arr)); if (r < 0) return r; diff --git a/src/cryptenroll/cryptenroll-fido2.c b/src/cryptenroll/cryptenroll-fido2.c index 3e23a0e47c..822cf26c89 100644 --- a/src/cryptenroll/cryptenroll-fido2.c +++ b/src/cryptenroll/cryptenroll-fido2.c @@ -160,9 +160,9 @@ int enroll_fido2( SD_JSON_BUILD_PAIR("fido2-credential", SD_JSON_BUILD_BASE64(cid, cid_size)), SD_JSON_BUILD_PAIR("fido2-salt", JSON_BUILD_IOVEC_BASE64(&salt)), SD_JSON_BUILD_PAIR("fido2-rp", JSON_BUILD_CONST_STRING("io.systemd.cryptsetup")), - SD_JSON_BUILD_PAIR("fido2-clientPin-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN))), - SD_JSON_BUILD_PAIR("fido2-up-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))), - SD_JSON_BUILD_PAIR("fido2-uv-required", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV)))); + SD_JSON_BUILD_PAIR_BOOLEAN("fido2-clientPin-required", FLAGS_SET(lock_with, FIDO2ENROLL_PIN)), + SD_JSON_BUILD_PAIR_BOOLEAN("fido2-up-required", FLAGS_SET(lock_with, FIDO2ENROLL_UP)), + SD_JSON_BUILD_PAIR_BOOLEAN("fido2-uv-required", FLAGS_SET(lock_with, FIDO2ENROLL_UV))); if (r < 0) return log_error_errno(r, "Failed to prepare FIDO2 JSON token object: %m"); diff --git a/src/cryptenroll/cryptenroll-pkcs11.c b/src/cryptenroll/cryptenroll-pkcs11.c index 656246afc0..18ffb2edc3 100644 --- a/src/cryptenroll/cryptenroll-pkcs11.c +++ b/src/cryptenroll/cryptenroll-pkcs11.c @@ -101,8 +101,8 @@ int enroll_pkcs11(struct crypt_device *cd, const struct iovec *volume_key,const r = sd_json_buildo(&v, SD_JSON_BUILD_PAIR("type", JSON_BUILD_CONST_STRING("systemd-pkcs11")), SD_JSON_BUILD_PAIR("keyslots", SD_JSON_BUILD_ARRAY(SD_JSON_BUILD_STRING(keyslot_as_string))), - SD_JSON_BUILD_PAIR("pkcs11-uri", SD_JSON_BUILD_STRING(private_uri ?: uri)), - SD_JSON_BUILD_PAIR("pkcs11-key", SD_JSON_BUILD_BASE64(saved_key, saved_key_size))); + SD_JSON_BUILD_PAIR_STRING("pkcs11-uri", private_uri ?: uri), + SD_JSON_BUILD_PAIR_BASE64("pkcs11-key", saved_key, saved_key_size)); if (r < 0) return log_error_errno(r, "Failed to prepare PKCS#11 JSON token object: %m"); diff --git a/src/dissect/dissect.c b/src/dissect/dissect.c index 45e98855d3..b991acab75 100644 --- a/src/dissect/dissect.c +++ b/src/dissect/dissect.c @@ -1105,9 +1105,9 @@ static int action_dissect( r = sd_json_buildo( &v, - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(bn)), + SD_JSON_BUILD_PAIR_STRING("name", bn), SD_JSON_BUILD_PAIR_CONDITION(size != UINT64_MAX, "size", SD_JSON_BUILD_INTEGER(size)), - SD_JSON_BUILD_PAIR("sectorSize", SD_JSON_BUILD_INTEGER(m->sector_size)), + SD_JSON_BUILD_PAIR_INTEGER("sectorSize", m->sector_size), SD_JSON_BUILD_PAIR_CONDITION(a >= 0, "architecture", SD_JSON_BUILD_STRING(architecture_to_string(a))), SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(m->image_uuid), "imageUuid", SD_JSON_BUILD_UUID(m->image_uuid)), SD_JSON_BUILD_PAIR_CONDITION(!!m->hostname, "hostname", SD_JSON_BUILD_STRING(m->hostname)), @@ -1117,16 +1117,16 @@ static int action_dissect( SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->initrd_release), "initrdRelease", JSON_BUILD_STRV_ENV_PAIR(m->initrd_release)), SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->sysext_release), "sysextRelease", JSON_BUILD_STRV_ENV_PAIR(m->sysext_release)), SD_JSON_BUILD_PAIR_CONDITION(!strv_isempty(m->confext_release), "confextRelease", JSON_BUILD_STRV_ENV_PAIR(m->confext_release)), - SD_JSON_BUILD_PAIR("useBootableUefi", SD_JSON_BUILD_BOOLEAN(dissected_image_is_bootable_uefi(m))), - SD_JSON_BUILD_PAIR("useBootableContainer", SD_JSON_BUILD_BOOLEAN(dissected_image_is_bootable_os(m))), - SD_JSON_BUILD_PAIR("useInitrd", SD_JSON_BUILD_BOOLEAN(dissected_image_is_initrd(m))), - SD_JSON_BUILD_PAIR("usePortableService", SD_JSON_BUILD_BOOLEAN(dissected_image_is_portable(m))), - SD_JSON_BUILD_PAIR("useSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "system"))), - SD_JSON_BUILD_PAIR("useInitRDSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "initrd"))), - SD_JSON_BUILD_PAIR("usePortableSystemExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(sysext_scopes, "portable"))), - SD_JSON_BUILD_PAIR("useConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "system"))), - SD_JSON_BUILD_PAIR("useInitRDConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "initrd"))), - SD_JSON_BUILD_PAIR("usePortableConfigurationExtension", SD_JSON_BUILD_BOOLEAN(strv_contains(confext_scopes, "portable")))); + SD_JSON_BUILD_PAIR_BOOLEAN("useBootableUefi", dissected_image_is_bootable_uefi(m)), + SD_JSON_BUILD_PAIR_BOOLEAN("useBootableContainer", dissected_image_is_bootable_os(m)), + SD_JSON_BUILD_PAIR_BOOLEAN("useInitrd", dissected_image_is_initrd(m)), + SD_JSON_BUILD_PAIR_BOOLEAN("usePortableService", dissected_image_is_portable(m)), + SD_JSON_BUILD_PAIR_BOOLEAN("useSystemExtension", strv_contains(sysext_scopes, "system")), + SD_JSON_BUILD_PAIR_BOOLEAN("useInitRDSystemExtension", strv_contains(sysext_scopes, "initrd")), + SD_JSON_BUILD_PAIR_BOOLEAN("usePortableSystemExtension", strv_contains(sysext_scopes, "portable")), + SD_JSON_BUILD_PAIR_BOOLEAN("useConfigurationExtension", strv_contains(confext_scopes, "system")), + SD_JSON_BUILD_PAIR_BOOLEAN("useInitRDConfigurationExtension", strv_contains(confext_scopes, "initrd")), + SD_JSON_BUILD_PAIR_BOOLEAN("usePortableConfigurationExtension", strv_contains(confext_scopes, "portable"))); if (r < 0) return log_oom(); } diff --git a/src/home/homectl-fido2.c b/src/home/homectl-fido2.c index 41f8f206db..d351b1db5e 100644 --- a/src/home/homectl-fido2.c +++ b/src/home/homectl-fido2.c @@ -89,12 +89,12 @@ static int add_fido2_salt( return log_error_errno(errno_or_else(EINVAL), "Failed to UNIX hash secret key: %m"); r = sd_json_buildo(&e, - SD_JSON_BUILD_PAIR("credential", SD_JSON_BUILD_BASE64(cid, cid_size)), + SD_JSON_BUILD_PAIR_BASE64("credential", cid, cid_size), SD_JSON_BUILD_PAIR("salt", JSON_BUILD_IOVEC_BASE64(salt)), - SD_JSON_BUILD_PAIR("hashedPassword", SD_JSON_BUILD_STRING(hashed)), - SD_JSON_BUILD_PAIR("up", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UP))), - SD_JSON_BUILD_PAIR("uv", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_UV))), - SD_JSON_BUILD_PAIR("clientPin", SD_JSON_BUILD_BOOLEAN(FLAGS_SET(lock_with, FIDO2ENROLL_PIN)))); + SD_JSON_BUILD_PAIR_STRING("hashedPassword", hashed), + SD_JSON_BUILD_PAIR_BOOLEAN("up", FLAGS_SET(lock_with, FIDO2ENROLL_UP)), + SD_JSON_BUILD_PAIR_BOOLEAN("uv", FLAGS_SET(lock_with, FIDO2ENROLL_UV)), + SD_JSON_BUILD_PAIR_BOOLEAN("clientPin", FLAGS_SET(lock_with, FIDO2ENROLL_PIN))); if (r < 0) return log_error_errno(r, "Failed to build FIDO2 salt JSON key object: %m"); diff --git a/src/home/homed-varlink.c b/src/home/homed-varlink.c index 9cae051cf9..d4015de622 100644 --- a/src/home/homed-varlink.c +++ b/src/home/homed-varlink.c @@ -330,8 +330,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_ if (last) { r = sd_varlink_notifybo( link, - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)), - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name))); + SD_JSON_BUILD_PAIR_STRING("userName", last), + SD_JSON_BUILD_PAIR_STRING("groupName", p.group_name)); if (r < 0) return r; } @@ -342,8 +342,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_ if (last) return sd_varlink_replybo( link, - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)), - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(p.group_name))); + SD_JSON_BUILD_PAIR_STRING("userName", last), + SD_JSON_BUILD_PAIR_STRING("groupName", p.group_name)); } else { const char *last = NULL; @@ -352,8 +352,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_ if (last) { r = sd_varlink_notifybo( link, - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)), - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last))); + SD_JSON_BUILD_PAIR_STRING("userName", last), + SD_JSON_BUILD_PAIR_STRING("groupName", last)); if (r < 0) return r; @@ -362,8 +362,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_ r = sd_varlink_notifybo( link, - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(h->user_name)), - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(*j))); + SD_JSON_BUILD_PAIR_STRING("userName", h->user_name), + SD_JSON_BUILD_PAIR_STRING("groupName", *j)); if (r < 0) return r; } @@ -374,8 +374,8 @@ int vl_method_get_memberships(sd_varlink *link, sd_json_variant *parameters, sd_ if (last) return sd_varlink_replybo( link, - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(last)), - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(last))); + SD_JSON_BUILD_PAIR_STRING("userName", last), + SD_JSON_BUILD_PAIR_STRING("groupName", last)); } return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL); diff --git a/src/home/user-record-sign.c b/src/home/user-record-sign.c index 46e5ea7c99..7a80ef1e7a 100644 --- a/src/home/user-record-sign.c +++ b/src/home/user-record-sign.c @@ -58,8 +58,8 @@ int user_record_sign(UserRecord *ur, EVP_PKEY *private_key, UserRecord **ret) { &v, "signature", SD_JSON_BUILD_ARRAY( - SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR("data", SD_JSON_BUILD_BASE64(signature, signature_size)), - SD_JSON_BUILD_PAIR("key", SD_JSON_BUILD_STRING(key))))); + SD_JSON_BUILD_OBJECT(SD_JSON_BUILD_PAIR_BASE64("data", signature, signature_size), + SD_JSON_BUILD_PAIR_STRING("key", key)))); if (r < 0) return r; diff --git a/src/import/importd.c b/src/import/importd.c index 91cd7ce648..2ffdc3a4aa 100644 --- a/src/import/importd.c +++ b/src/import/importd.c @@ -1764,12 +1764,12 @@ static int make_transfer_json(Transfer *t, sd_json_variant **ret) { assert(t); r = sd_json_buildo(ret, - SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_UNSIGNED(t->id)), + SD_JSON_BUILD_PAIR_UNSIGNED("id", t->id), SD_JSON_BUILD_PAIR("type", JSON_BUILD_STRING_UNDERSCORIFY(transfer_type_to_string(t->type))), - SD_JSON_BUILD_PAIR("remote", SD_JSON_BUILD_STRING(t->remote)), - SD_JSON_BUILD_PAIR("local", SD_JSON_BUILD_STRING(t->local)), + SD_JSON_BUILD_PAIR_STRING("remote", t->remote), + SD_JSON_BUILD_PAIR_STRING("local", t->local), SD_JSON_BUILD_PAIR("class", JSON_BUILD_STRING_UNDERSCORIFY(image_class_to_string(t->class))), - SD_JSON_BUILD_PAIR("percent", SD_JSON_BUILD_REAL(transfer_percent_as_double(t)))); + SD_JSON_BUILD_PAIR_REAL("percent", transfer_percent_as_double(t))); if (r < 0) return log_error_errno(r, "Failed to build transfer JSON data: %m"); @@ -1945,7 +1945,7 @@ static int vl_method_pull(sd_varlink *link, sd_json_variant *parameters, sd_varl /* If more was not set, just return the download id, and be done with it */ if (!FLAGS_SET(flags, SD_VARLINK_METHOD_MORE)) - return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_UNSIGNED(t->id))); + return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR_UNSIGNED("id", t->id)); /* Otherwise add this connection to the set of subscriptions, return the id, but keep the thing running */ r = set_ensure_put(&t->varlink_subscribed, &varlink_hash_ops, link); @@ -1954,7 +1954,7 @@ static int vl_method_pull(sd_varlink *link, sd_json_variant *parameters, sd_varl sd_varlink_ref(link); - r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR("id", SD_JSON_BUILD_UNSIGNED(t->id))); + r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR_UNSIGNED("id", t->id)); if (r < 0) return r; diff --git a/src/libsystemd/sd-varlink/sd-varlink.c b/src/libsystemd/sd-varlink/sd-varlink.c index 18b26f657d..4e294e56b3 100644 --- a/src/libsystemd/sd-varlink/sd-varlink.c +++ b/src/libsystemd/sd-varlink/sd-varlink.c @@ -1413,7 +1413,7 @@ static int varlink_dispatch_method(sd_varlink *v) { } } } else if (VARLINK_STATE_WANTS_REPLY(v->state)) { - r = sd_varlink_errorbo(v, SD_VARLINK_ERROR_METHOD_NOT_FOUND, SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method))); + r = sd_varlink_errorbo(v, SD_VARLINK_ERROR_METHOD_NOT_FOUND, SD_JSON_BUILD_PAIR_STRING("method", method)); /* If we didn't manage to enqueue an error response, then fail the connection completely. */ if (r < 0 && VARLINK_STATE_WANTS_REPLY(v->state)) goto fail; @@ -2049,9 +2049,9 @@ _public_ int sd_varlink_send(sd_varlink *v, const char *method, sd_json_variant r = sd_json_buildo( &m, - SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)), + SD_JSON_BUILD_PAIR_STRING("method", method), JSON_BUILD_PAIR_VARIANT_NON_EMPTY("parameters", parameters), - SD_JSON_BUILD_PAIR("oneway", SD_JSON_BUILD_BOOLEAN(true))); + SD_JSON_BUILD_PAIR_BOOLEAN("oneway", true)); if (r < 0) return varlink_log_errno(v, r, "Failed to build json message: %m"); @@ -2097,7 +2097,7 @@ _public_ int sd_varlink_invoke(sd_varlink *v, const char *method, sd_json_varian r = sd_json_buildo( &m, - SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)), + SD_JSON_BUILD_PAIR_STRING("method", method), JSON_BUILD_PAIR_VARIANT_NON_EMPTY("parameters", parameters)); if (r < 0) return varlink_log_errno(v, r, "Failed to build json message: %m"); @@ -2147,9 +2147,9 @@ _public_ int sd_varlink_observe(sd_varlink *v, const char *method, sd_json_varia r = sd_json_buildo( &m, - SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)), + SD_JSON_BUILD_PAIR_STRING("method", method), JSON_BUILD_PAIR_VARIANT_NON_EMPTY("parameters", parameters), - SD_JSON_BUILD_PAIR("more", SD_JSON_BUILD_BOOLEAN(true))); + SD_JSON_BUILD_PAIR_BOOLEAN("more", true)); if (r < 0) return varlink_log_errno(v, r, "Failed to build json message: %m"); @@ -2208,7 +2208,7 @@ _public_ int sd_varlink_call_full( r = sd_json_buildo( &m, - SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)), + SD_JSON_BUILD_PAIR_STRING("method", method), JSON_BUILD_PAIR_VARIANT_NON_EMPTY("parameters", parameters)); if (r < 0) return varlink_log_errno(v, r, "Failed to build json message: %m"); @@ -2362,9 +2362,9 @@ _public_ int sd_varlink_collect_full( r = sd_json_buildo( &m, - SD_JSON_BUILD_PAIR("method", SD_JSON_BUILD_STRING(method)), + SD_JSON_BUILD_PAIR_STRING("method", method), JSON_BUILD_PAIR_VARIANT_NON_EMPTY("parameters", parameters), - SD_JSON_BUILD_PAIR("more", SD_JSON_BUILD_BOOLEAN(true))); + SD_JSON_BUILD_PAIR_BOOLEAN("more", true)); if (r < 0) return varlink_log_errno(v, r, "Failed to build json message: %m"); @@ -2613,7 +2613,7 @@ _public_ int sd_varlink_error(sd_varlink *v, const char *error_id, sd_json_varia r = sd_json_buildo( &m, - SD_JSON_BUILD_PAIR("error", SD_JSON_BUILD_STRING(error_id)), + SD_JSON_BUILD_PAIR_STRING("error", error_id), JSON_BUILD_PAIR_VARIANT_NON_EMPTY("parameters", parameters)); if (r < 0) return varlink_log_errno(v, r, "Failed to build json message: %m"); @@ -2669,7 +2669,7 @@ _public_ int sd_varlink_error_invalid_parameter(sd_varlink *v, sd_json_variant * if (sd_json_variant_is_string(parameters)) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *parameters_obj = NULL; - r = sd_json_buildo(¶meters_obj,SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_VARIANT(parameters))); + r = sd_json_buildo(¶meters_obj,SD_JSON_BUILD_PAIR_VARIANT("parameter", parameters)); if (r < 0) return r; @@ -2680,7 +2680,7 @@ _public_ int sd_varlink_error_invalid_parameter(sd_varlink *v, sd_json_variant * sd_json_variant_elements(parameters) > 0) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *parameters_obj = NULL; - r = sd_json_buildo(¶meters_obj, SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_VARIANT(sd_json_variant_by_index(parameters, 0)))); + r = sd_json_buildo(¶meters_obj, SD_JSON_BUILD_PAIR_VARIANT("parameter", sd_json_variant_by_index(parameters, 0))); if (r < 0) return r; @@ -2694,7 +2694,7 @@ _public_ int sd_varlink_error_invalid_parameter_name(sd_varlink *v, const char * return sd_varlink_errorbo( v, SD_VARLINK_ERROR_INVALID_PARAMETER, - SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_STRING(name))); + SD_JSON_BUILD_PAIR_STRING("parameter", name)); } _public_ int sd_varlink_error_errno(sd_varlink *v, int error) { @@ -2749,7 +2749,7 @@ _public_ int sd_varlink_notify(sd_varlink *v, sd_json_variant *parameters) { r = sd_json_buildo( &m, JSON_BUILD_PAIR_VARIANT_NON_EMPTY("parameters", parameters), - SD_JSON_BUILD_PAIR("continues", SD_JSON_BUILD_BOOLEAN(true))); + SD_JSON_BUILD_PAIR_BOOLEAN("continues", true)); if (r < 0) return varlink_log_errno(v, r, "Failed to build json message: %m"); diff --git a/src/machine/machined-varlink.c b/src/machine/machined-varlink.c index dd02bf9dd1..f4714c545d 100644 --- a/src/machine/machined-varlink.c +++ b/src/machine/machined-varlink.c @@ -49,13 +49,13 @@ static int build_user_json(const char *user_name, uid_t uid, const char *real_na return sd_json_buildo( ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(user_name)), - SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(uid)), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(GID_NOBODY)), + SD_JSON_BUILD_PAIR_STRING("userName", user_name), + SD_JSON_BUILD_PAIR_UNSIGNED("uid", uid), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", GID_NOBODY), SD_JSON_BUILD_PAIR_CONDITION(!isempty(real_name), "realName", SD_JSON_BUILD_STRING(real_name)), SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")), SD_JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)), - SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)), + SD_JSON_BUILD_PAIR_BOOLEAN("locked", true), SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Machine")), SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("container"))))); } @@ -221,8 +221,8 @@ static int build_group_json(const char *group_name, gid_t gid, const char *descr return sd_json_buildo( ret, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_OBJECT( - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(group_name)), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(gid)), + SD_JSON_BUILD_PAIR_STRING("groupName", group_name), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", gid), SD_JSON_BUILD_PAIR_CONDITION(!isempty(description), "description", SD_JSON_BUILD_STRING(description)), SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.Machine")), SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("container"))))); diff --git a/src/measure/measure-tool.c b/src/measure/measure-tool.c index 3c8acf6417..1cc681f973 100644 --- a/src/measure/measure-tool.c +++ b/src/measure/measure-tool.c @@ -770,8 +770,8 @@ static int verb_calculate(int argc, char *argv[], void *userdata) { r = sd_json_variant_append_arraybo( &array, SD_JSON_BUILD_PAIR_CONDITION(!isempty(*phase), "phase", SD_JSON_BUILD_STRING(*phase)), - SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_INTEGER(TPM2_PCR_KERNEL_BOOT)), - SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_HEX(pcr_states[i].value, pcr_states[i].value_size))); + SD_JSON_BUILD_PAIR_INTEGER("pcr", TPM2_PCR_KERNEL_BOOT), + SD_JSON_BUILD_PAIR_HEX("hash", pcr_states[i].value, pcr_states[i].value_size)); if (r < 0) return log_error_errno(r, "Failed to append JSON object to array: %m"); @@ -957,9 +957,9 @@ static int build_policy_digest(bool sign) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *bv = NULL; r = sd_json_buildo(&bv, - SD_JSON_BUILD_PAIR("pcrs", SD_JSON_BUILD_VARIANT(a)), /* PCR mask */ + SD_JSON_BUILD_PAIR_VARIANT("pcrs", a), /* PCR mask */ SD_JSON_BUILD_PAIR_CONDITION(pubkey_fp_size > 0, "pkfp", SD_JSON_BUILD_HEX(pubkey_fp, pubkey_fp_size)), /* SHA256 fingerprint of public key (DER) used for the signature */ - SD_JSON_BUILD_PAIR("pol", SD_JSON_BUILD_HEX(pcr_policy_digest.buffer, pcr_policy_digest.size)), /* TPM2 policy hash that is signed */ + SD_JSON_BUILD_PAIR_HEX("pol", pcr_policy_digest.buffer, pcr_policy_digest.size), /* TPM2 policy hash that is signed */ SD_JSON_BUILD_PAIR_CONDITION(ss > 0, "sig", SD_JSON_BUILD_BASE64(sig, ss))); /* signature data */ if (r < 0) return log_error_errno(r, "Failed to build JSON object: %m"); @@ -1118,8 +1118,8 @@ static int verb_status(int argc, char *argv[], void *userdata) { r = sd_json_buildo( &bv, - SD_JSON_BUILD_PAIR("pcr", SD_JSON_BUILD_INTEGER(TPM2_PCR_KERNEL_BOOT)), - SD_JSON_BUILD_PAIR("hash", SD_JSON_BUILD_HEX(h, l))); + SD_JSON_BUILD_PAIR_INTEGER("pcr", TPM2_PCR_KERNEL_BOOT), + SD_JSON_BUILD_PAIR_HEX("hash", h, l)); if (r < 0) return log_error_errno(r, "Failed to build JSON object: %m"); diff --git a/src/mountfsd/mountwork.c b/src/mountfsd/mountwork.c index 2f12f02e7b..7e4c5063fa 100644 --- a/src/mountfsd/mountwork.c +++ b/src/mountfsd/mountwork.c @@ -596,17 +596,17 @@ static int vl_method_mount_image( r = sd_json_variant_append_arraybo( &aj, - SD_JSON_BUILD_PAIR("designator", SD_JSON_BUILD_STRING(partition_designator_to_string(d))), - SD_JSON_BUILD_PAIR("writable", SD_JSON_BUILD_BOOLEAN(pp->rw)), - SD_JSON_BUILD_PAIR("growFileSystem", SD_JSON_BUILD_BOOLEAN(pp->growfs)), + SD_JSON_BUILD_PAIR_STRING("designator", partition_designator_to_string(d)), + SD_JSON_BUILD_PAIR_BOOLEAN("writable", pp->rw), + SD_JSON_BUILD_PAIR_BOOLEAN("growFileSystem", pp->growfs), SD_JSON_BUILD_PAIR_CONDITION(pp->partno > 0, "partitionNumber", SD_JSON_BUILD_INTEGER(pp->partno)), SD_JSON_BUILD_PAIR_CONDITION(pp->architecture > 0, "architecture", SD_JSON_BUILD_STRING(architecture_to_string(pp->architecture))), SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(pp->uuid), "partitionUuid", SD_JSON_BUILD_UUID(pp->uuid)), - SD_JSON_BUILD_PAIR("fileSystemType", SD_JSON_BUILD_STRING(dissected_partition_fstype(pp))), + SD_JSON_BUILD_PAIR_STRING("fileSystemType", dissected_partition_fstype(pp)), SD_JSON_BUILD_PAIR_CONDITION(!!pp->label, "partitionLabel", SD_JSON_BUILD_STRING(pp->label)), - SD_JSON_BUILD_PAIR("size", SD_JSON_BUILD_UNSIGNED(pp->size)), - SD_JSON_BUILD_PAIR("offset", SD_JSON_BUILD_UNSIGNED(pp->offset)), - SD_JSON_BUILD_PAIR("mountFileDescriptor", SD_JSON_BUILD_INTEGER(fd_idx)), + SD_JSON_BUILD_PAIR_UNSIGNED("size", pp->size), + SD_JSON_BUILD_PAIR_UNSIGNED("offset", pp->offset), + SD_JSON_BUILD_PAIR_INTEGER("mountFileDescriptor", fd_idx), JSON_BUILD_PAIR_STRV_NON_EMPTY("mountPoint", l)); if (r < 0) return r; @@ -616,10 +616,10 @@ static int vl_method_mount_image( return sd_varlink_replybo( link, - SD_JSON_BUILD_PAIR("partitions", SD_JSON_BUILD_VARIANT(aj)), - SD_JSON_BUILD_PAIR("imagePolicy", SD_JSON_BUILD_STRING(ps)), - SD_JSON_BUILD_PAIR("imageSize", SD_JSON_BUILD_UNSIGNED(di->image_size)), - SD_JSON_BUILD_PAIR("sectorSize", SD_JSON_BUILD_UNSIGNED(di->sector_size)), + SD_JSON_BUILD_PAIR_VARIANT("partitions", aj), + SD_JSON_BUILD_PAIR_STRING("imagePolicy", ps), + SD_JSON_BUILD_PAIR_UNSIGNED("imageSize", di->image_size), + SD_JSON_BUILD_PAIR_UNSIGNED("sectorSize", di->sector_size), SD_JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(di->image_uuid), "imageUuid", SD_JSON_BUILD_UUID(di->image_uuid))); } @@ -997,7 +997,7 @@ static int vl_method_mount_directory( return sd_varlink_replybo( link, - SD_JSON_BUILD_PAIR("mountFileDescriptor", SD_JSON_BUILD_INTEGER(fd_idx))); + SD_JSON_BUILD_PAIR_INTEGER("mountFileDescriptor", fd_idx)); } typedef struct MakeDirectoryParameters { @@ -1117,7 +1117,7 @@ static int vl_method_make_directory( return sd_varlink_replybo( link, - SD_JSON_BUILD_PAIR("directoryFileDescriptor", SD_JSON_BUILD_INTEGER(fd_idx))); + SD_JSON_BUILD_PAIR_INTEGER("directoryFileDescriptor", fd_idx)); fail: (void) unlinkat(parent_fd, t ?: p.name, AT_REMOVEDIR); diff --git a/src/nsresourced/nsresourcework.c b/src/nsresourced/nsresourcework.c index 0fc8d1cb01..15aaca61fc 100644 --- a/src/nsresourced/nsresourcework.c +++ b/src/nsresourced/nsresourcework.c @@ -98,15 +98,15 @@ static int build_user_json(UserNamespaceInfo *userns_info, uid_t offset, sd_json return sd_json_buildo( ret, - SD_JSON_BUILD_PAIR("userName", SD_JSON_BUILD_STRING(name)), - SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(userns_info->start_uid + offset)), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(GID_NOBODY)), - SD_JSON_BUILD_PAIR("realName", SD_JSON_BUILD_STRING(realname)), + SD_JSON_BUILD_PAIR_STRING("userName", name), + SD_JSON_BUILD_PAIR_UNSIGNED("uid", userns_info->start_uid + offset), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", GID_NOBODY), + SD_JSON_BUILD_PAIR_STRING("realName", realname), SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/")), - SD_JSON_BUILD_PAIR("shell", SD_JSON_BUILD_STRING(NOLOGIN)), - SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)), + SD_JSON_BUILD_PAIR_STRING("shell", NOLOGIN), + SD_JSON_BUILD_PAIR_BOOLEAN("locked", true), SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NamespaceResource")), - SD_JSON_BUILD_PAIR("disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(disposition)))); + SD_JSON_BUILD_PAIR_STRING("disposition", user_disposition_to_string(disposition))); } static int vl_method_get_user_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { @@ -200,7 +200,7 @@ static int vl_method_get_user_record(sd_varlink *link, sd_json_variant *paramete if (r < 0) return r; - return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v))); + return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR_VARIANT("record", v)); not_found: return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL); @@ -229,11 +229,11 @@ static int build_group_json(UserNamespaceInfo *userns_info, gid_t offset, sd_jso return sd_json_buildo( ret, - SD_JSON_BUILD_PAIR("groupName", SD_JSON_BUILD_STRING(name)), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(userns_info->start_gid + offset)), - SD_JSON_BUILD_PAIR("description", SD_JSON_BUILD_STRING(description)), + SD_JSON_BUILD_PAIR_STRING("groupName", name), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", userns_info->start_gid + offset), + SD_JSON_BUILD_PAIR_STRING("description", description), SD_JSON_BUILD_PAIR("service", JSON_BUILD_CONST_STRING("io.systemd.NamespaceResource")), - SD_JSON_BUILD_PAIR("disposition", SD_JSON_BUILD_STRING(user_disposition_to_string(disposition)))); + SD_JSON_BUILD_PAIR_STRING("disposition", user_disposition_to_string(disposition))); } static int vl_method_get_group_record(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) { @@ -327,7 +327,7 @@ static int vl_method_get_group_record(sd_varlink *link, sd_json_variant *paramet if (r < 0) return r; - return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR("record", SD_JSON_BUILD_VARIANT(v))); + return sd_varlink_replybo(link, SD_JSON_BUILD_PAIR_VARIANT("record", v)); not_found: return sd_varlink_error(link, "io.systemd.UserDatabase.NoRecordFound", NULL); @@ -1900,8 +1900,8 @@ static int vl_method_add_netif_to_user_namespace(sd_varlink *link, sd_json_varia return sd_varlink_replybo( link, - SD_JSON_BUILD_PAIR("hostInterfaceName", SD_JSON_BUILD_STRING(ifname_host)), - SD_JSON_BUILD_PAIR("namespaceInterfaceName", SD_JSON_BUILD_STRING(ifname_namespace))); + SD_JSON_BUILD_PAIR_STRING("hostInterfaceName", ifname_host), + SD_JSON_BUILD_PAIR_STRING("namespaceInterfaceName", ifname_namespace)); } else if (streq(p.mode, "tap")) { /* NB: when we do the "tap" stuff we do not actually do any namespace operation here, neither diff --git a/src/nsresourced/userns-registry.c b/src/nsresourced/userns-registry.c index e576f02c38..97a222cfc4 100644 --- a/src/nsresourced/userns-registry.c +++ b/src/nsresourced/userns-registry.c @@ -446,9 +446,9 @@ int userns_registry_store(int dir_fd, UserNamespaceInfo *info) { _cleanup_(sd_json_variant_unrefp) sd_json_variant *def = NULL; r = sd_json_buildo( &def, - SD_JSON_BUILD_PAIR("owner", SD_JSON_BUILD_UNSIGNED(info->owner)), - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(info->name)), - SD_JSON_BUILD_PAIR("userns", SD_JSON_BUILD_UNSIGNED(info->userns_inode)), + SD_JSON_BUILD_PAIR_UNSIGNED("owner", info->owner), + SD_JSON_BUILD_PAIR_STRING("name", info->name), + SD_JSON_BUILD_PAIR_UNSIGNED("userns", info->userns_inode), SD_JSON_BUILD_PAIR_CONDITION(info->size > 0, "size", SD_JSON_BUILD_UNSIGNED(info->size)), SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(info->start_uid), "start", SD_JSON_BUILD_UNSIGNED(info->start_uid)), SD_JSON_BUILD_PAIR_CONDITION(uid_is_valid(info->target_uid), "target", SD_JSON_BUILD_UNSIGNED(info->target_uid)), diff --git a/src/nss-resolve/nss-resolve.c b/src/nss-resolve/nss-resolve.c index 48606d75c7..f842e0cf57 100644 --- a/src/nss-resolve/nss-resolve.c +++ b/src/nss-resolve/nss-resolve.c @@ -216,8 +216,8 @@ enum nss_status _nss_resolve_gethostbyname4_r( r = sd_json_buildo( &cparams, - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags()))); + SD_JSON_BUILD_PAIR_STRING("name", name), + SD_JSON_BUILD_PAIR_UNSIGNED("flags", query_flags())); if (r < 0) goto fail; @@ -384,9 +384,9 @@ enum nss_status _nss_resolve_gethostbyname3_r( r = sd_json_buildo( &cparams, - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(name)), - SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(af)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags()))); + SD_JSON_BUILD_PAIR_STRING("name", name), + SD_JSON_BUILD_PAIR_INTEGER("family", af), + SD_JSON_BUILD_PAIR_UNSIGNED("flags", query_flags())); if (r < 0) goto fail; @@ -604,9 +604,9 @@ enum nss_status _nss_resolve_gethostbyaddr2_r( r = sd_json_buildo( &cparams, - SD_JSON_BUILD_PAIR("address", SD_JSON_BUILD_BYTE_ARRAY(addr, len)), - SD_JSON_BUILD_PAIR("family", SD_JSON_BUILD_INTEGER(af)), - SD_JSON_BUILD_PAIR("flags", SD_JSON_BUILD_UNSIGNED(query_flags()))); + SD_JSON_BUILD_PAIR_BYTE_ARRAY("address", addr, len), + SD_JSON_BUILD_PAIR_INTEGER("family", af), + SD_JSON_BUILD_PAIR_UNSIGNED("flags", query_flags())); if (r < 0) goto fail; diff --git a/src/resolve/resolved-varlink.c b/src/resolve/resolved-varlink.c index 24280a84bd..f6ecc98220 100644 --- a/src/resolve/resolved-varlink.c +++ b/src/resolve/resolved-varlink.c @@ -110,7 +110,7 @@ static int reply_query_state(DnsQuery *q) { case DNS_TRANSACTION_DNSSEC_FAILED: return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSSECValidationFailed", - SD_JSON_BUILD_PAIR("result", SD_JSON_BUILD_STRING(dnssec_result_to_string(q->answer_dnssec_result))), + SD_JSON_BUILD_PAIR_STRING("result", dnssec_result_to_string(q->answer_dnssec_result)), SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0, "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg), @@ -135,11 +135,11 @@ static int reply_query_state(DnsQuery *q) { /* We return this as NXDOMAIN. This is only generated when a host doesn't implement LLMNR/TCP, and we * thus quickly know that we cannot resolve an in-addr.arpa or ip6.arpa address. */ return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError", - SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(DNS_RCODE_NXDOMAIN))); + SD_JSON_BUILD_PAIR_INTEGER("rcode", DNS_RCODE_NXDOMAIN)); case DNS_TRANSACTION_RCODE_FAILURE: return sd_varlink_errorbo(q->varlink_request, "io.systemd.Resolve.DNSError", - SD_JSON_BUILD_PAIR("rcode", SD_JSON_BUILD_INTEGER(q->answer_rcode)), + SD_JSON_BUILD_PAIR_INTEGER("rcode", q->answer_rcode), SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0, "extendedDNSErrorCode", SD_JSON_BUILD_INTEGER(q->answer_ede_rcode)), SD_JSON_BUILD_PAIR_CONDITION(q->answer_ede_rcode >= 0 && !isempty(q->answer_ede_msg), @@ -1249,7 +1249,7 @@ static int vl_method_subscribe_query_results(sd_varlink *link, sd_json_variant * /* Send a ready message to the connecting client, to indicate that we are now listinening, and all * queries issued after the point the client sees this will also be reported to the client. */ - r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR("ready", SD_JSON_BUILD_BOOLEAN(true))); + r = sd_varlink_notifybo(link, SD_JSON_BUILD_PAIR_BOOLEAN("ready", true)); if (r < 0) return log_error_errno(r, "Failed to report monitor to be established: %m"); diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 12f67fbce1..46143020fe 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -1770,8 +1770,8 @@ static int json_addon( r = sd_json_variant_append_arraybo( array, - SD_JSON_BUILD_PAIR(addon_str, SD_JSON_BUILD_STRING(addon->location)), - SD_JSON_BUILD_PAIR("options", SD_JSON_BUILD_STRING(addon->cmdline))); + SD_JSON_BUILD_PAIR_STRING(addon_str, addon->location), + SD_JSON_BUILD_PAIR_STRING("options", addon->cmdline)); if (r < 0) return log_oom(); diff --git a/src/shared/dns-rr.c b/src/shared/dns-rr.c index fa9aedb5c3..0fa730c13b 100644 --- a/src/shared/dns-rr.c +++ b/src/shared/dns-rr.c @@ -2183,9 +2183,9 @@ int dns_resource_key_to_json(DnsResourceKey *key, sd_json_variant **ret) { return sd_json_buildo( ret, - SD_JSON_BUILD_PAIR("class", SD_JSON_BUILD_INTEGER(key->class)), - SD_JSON_BUILD_PAIR("type", SD_JSON_BUILD_INTEGER(key->type)), - SD_JSON_BUILD_PAIR("name", SD_JSON_BUILD_STRING(dns_resource_key_name(key)))); + SD_JSON_BUILD_PAIR_INTEGER("class", key->class), + SD_JSON_BUILD_PAIR_INTEGER("type", key->type), + SD_JSON_BUILD_PAIR_STRING("name", dns_resource_key_name(key))); } int dns_resource_key_from_json(sd_json_variant *v, DnsResourceKey **ret) { diff --git a/src/shared/userdb.c b/src/shared/userdb.c index 18a13a1e7a..9891e0e733 100644 --- a/src/shared/userdb.c +++ b/src/shared/userdb.c @@ -701,8 +701,8 @@ static int synthetic_root_user_build(UserRecord **ret) { return user_record_buildo( ret, SD_JSON_BUILD_PAIR("userName", JSON_BUILD_CONST_STRING("root")), - SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(0)), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(0)), + SD_JSON_BUILD_PAIR_UNSIGNED("uid", 0), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", 0), SD_JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_CONST_STRING("/root")), SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("intrinsic"))); } @@ -711,10 +711,10 @@ static int synthetic_nobody_user_build(UserRecord **ret) { return user_record_buildo( ret, SD_JSON_BUILD_PAIR("userName", JSON_BUILD_CONST_STRING(NOBODY_USER_NAME)), - SD_JSON_BUILD_PAIR("uid", SD_JSON_BUILD_UNSIGNED(UID_NOBODY)), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(GID_NOBODY)), + SD_JSON_BUILD_PAIR_UNSIGNED("uid", UID_NOBODY), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", GID_NOBODY), SD_JSON_BUILD_PAIR("shell", JSON_BUILD_CONST_STRING(NOLOGIN)), - SD_JSON_BUILD_PAIR("locked", SD_JSON_BUILD_BOOLEAN(true)), + SD_JSON_BUILD_PAIR_BOOLEAN("locked", true), SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("intrinsic"))); } @@ -1228,7 +1228,7 @@ static int synthetic_root_group_build(GroupRecord **ret) { return group_record_buildo( ret, SD_JSON_BUILD_PAIR("groupName", JSON_BUILD_CONST_STRING("root")), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(0)), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", 0), SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("intrinsic"))); } @@ -1236,7 +1236,7 @@ static int synthetic_nobody_group_build(GroupRecord **ret) { return group_record_buildo( ret, SD_JSON_BUILD_PAIR("groupName", JSON_BUILD_CONST_STRING(NOBODY_GROUP_NAME)), - SD_JSON_BUILD_PAIR("gid", SD_JSON_BUILD_UNSIGNED(GID_NOBODY)), + SD_JSON_BUILD_PAIR_UNSIGNED("gid", GID_NOBODY), SD_JSON_BUILD_PAIR("disposition", JSON_BUILD_CONST_STRING("intrinsic"))); }