]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
treewide: prefer using SD_JSON_BUILD_PAIR_* over SD_JSON_BUILD_PAIR()
authorJelle van der Waa <jelle@vdwaa.nl>
Sat, 22 Nov 2025 13:45:04 +0000 (14:45 +0100)
committerJelle van der Waa <jelle@vdwaa.nl>
Mon, 24 Nov 2025 20:05:10 +0000 (21:05 +0100)
Include a coccinelle script that patches this automatically.

12 files changed:
coccinelle/sd_build_pair.cocci [new file with mode: 0644]
src/ask-password/ask-password.c
src/dissect/dissect.c
src/import/importd.c
src/libsystemd/sd-varlink/sd-varlink.c
src/machine/machined-varlink.c
src/measure/measure-tool.c
src/mountfsd/mountwork.c
src/nsresourced/nsresourcework.c
src/nsresourced/userns-registry.c
src/nss-resolve/nss-resolve.c
src/resolve/resolved-varlink.c

diff --git a/coccinelle/sd_build_pair.cocci b/coccinelle/sd_build_pair.cocci
new file mode 100644 (file)
index 0000000..f0724ef
--- /dev/null
@@ -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)
index c56dfc23468c0ff043e7cba76b367c0ffee6e993..b712b8b3c0e9c884676557bb1f6cff12144b2eb7 100644 (file)
@@ -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) {
index d244822c133de376776a77ff9909ef532e32f2b6..ec2110a4ce9c655bdfee3c2f70e25d1742bd3696 100644 (file)
@@ -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();
         }
index 91cd7ce6488183ea710ea37f401885e4a2da9a07..2ffdc3a4aa685fe42154bb8842b8f9f46651b6b4 100644 (file)
@@ -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;
 
index 18b26f657da8b5d080d33dfefdbc285463545e5f..4e294e56b3834017263e5c013ada64da6daba4e2 100644 (file)
@@ -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(&parameters_obj,SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_VARIANT(parameters)));
+                r = sd_json_buildo(&parameters_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(&parameters_obj, SD_JSON_BUILD_PAIR("parameter", SD_JSON_BUILD_VARIANT(sd_json_variant_by_index(parameters, 0))));
+                r = sd_json_buildo(&parameters_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");
 
index 8188aeb4b134c143424583e25a4f0db7a9bd2ec4..77cc5849414fe75771ae42c81fb4ba953f700c35 100644 (file)
@@ -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")))));
index 0d5ceb9faff57294092397bd4302df1bd8ec549d..a14cd9ad69e29a07f558b0bc8625224a83ed6d8c 100644 (file)
@@ -771,8 +771,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");
 
@@ -973,9 +973,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");
@@ -1134,8 +1134,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");
 
index 2f12f02e7ba9a45d738c4ea34eab484d63d7ba89..7e4c5063fa3492c65350045337d2cda3fdc4130c 100644 (file)
@@ -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);
index 0fc8d1cb0105816c46a170bd68fcbe0097415377..15aaca61fc26ef7791826eb38a7ce74b5bd8d062 100644 (file)
@@ -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
index e576f02c38a74db6ea3899016d75018159d705d0..97a222cfc40529a17e2690d0935d904eec071ea8 100644 (file)
@@ -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)),
index 48606d75c78f61f7d7be53b109fbf4a2d9c7fd01..f842e0cf579c692c3a7ce31c1896b91077aa662b 100644 (file)
@@ -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;
 
index 24280a84bd654b5904bcfb30e3d0dd73ec5b8cae..f6ecc982208f305744949f59c38d981ddeb40d5b 100644 (file)
@@ -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");