From fae0b004343641dc0e304012fe631479a15b6677 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 19 Sep 2024 01:21:42 +0900 Subject: [PATCH] creds-util: make sd_json_dispatch_field table static --- src/shared/creds-util.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/shared/creds-util.c b/src/shared/creds-util.c index c7a50267374..180ab560fa7 100644 --- a/src/shared/creds-util.c +++ b/src/shared/creds-util.c @@ -1582,14 +1582,12 @@ int ipc_encrypt_credential(const char *name, usec_t timestamp, usec_t not_after, return log_error_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to encrypt: %s", error_id); } - r = sd_json_dispatch( - reply, - (const sd_json_dispatch_field[]) { - { "blob", SD_JSON_VARIANT_STRING, json_dispatch_unbase64_iovec, PTR_TO_SIZE(ret), SD_JSON_MANDATORY }, - {}, - }, - SD_JSON_LOG|SD_JSON_ALLOW_EXTENSIONS, - /* userdata= */ NULL); + static const sd_json_dispatch_field dispatch_table[] = { + { "blob", SD_JSON_VARIANT_STRING, json_dispatch_unbase64_iovec, 0, SD_JSON_MANDATORY }, + {}, + }; + + r = sd_json_dispatch(reply, dispatch_table, SD_JSON_LOG|SD_JSON_ALLOW_EXTENSIONS, ret); if (r < 0) return r; @@ -1649,14 +1647,12 @@ int ipc_decrypt_credential(const char *validate_name, usec_t validate_timestamp, return log_error_errno(sd_varlink_error_to_errno(error_id, reply), "Failed to decrypt: %s", error_id); } - r = sd_json_dispatch( - reply, - (const sd_json_dispatch_field[]) { - { "data", SD_JSON_VARIANT_STRING, json_dispatch_unbase64_iovec, PTR_TO_SIZE(ret), SD_JSON_MANDATORY }, - {}, - }, - SD_JSON_LOG|SD_JSON_ALLOW_EXTENSIONS, - /* userdata= */ NULL); + static const sd_json_dispatch_field dispatch_table[] = { + { "data", SD_JSON_VARIANT_STRING, json_dispatch_unbase64_iovec, 0, SD_JSON_MANDATORY }, + {}, + }; + + r = sd_json_dispatch(reply, dispatch_table, SD_JSON_LOG|SD_JSON_ALLOW_EXTENSIONS, ret); if (r < 0) return r; -- 2.47.3