tree-wide: use JSON_BUILD_PAIR_ENUM() more often
This commit is contained in:
committed by
Lennart Poettering
parent
3dd09ccea2
commit
1b53324959
@@ -211,10 +211,10 @@ static int parse_pull_expression(const char *v) {
|
||||
&j,
|
||||
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))),
|
||||
JSON_BUILD_PAIR_ENUM("class", image_class_to_string(class)),
|
||||
JSON_BUILD_PAIR_ENUM("type", import_type_to_string(type)),
|
||||
SD_JSON_BUILD_PAIR_BOOLEAN("readOnly", ro),
|
||||
SD_JSON_BUILD_PAIR("verify", JSON_BUILD_STRING_UNDERSCORIFY(import_verify_to_string(verify))),
|
||||
JSON_BUILD_PAIR_ENUM("verify", import_verify_to_string(verify)),
|
||||
SD_JSON_BUILD_PAIR_STRING("imageRoot", image_root));
|
||||
if (r < 0)
|
||||
return log_error_errno(r, "Failed to build import JSON object: %m");
|
||||
|
||||
@@ -1804,10 +1804,10 @@ static int make_transfer_json(Transfer *t, sd_json_variant **ret) {
|
||||
|
||||
r = sd_json_buildo(ret,
|
||||
SD_JSON_BUILD_PAIR_UNSIGNED("id", t->id),
|
||||
SD_JSON_BUILD_PAIR("type", JSON_BUILD_STRING_UNDERSCORIFY(transfer_type_to_string(t->type))),
|
||||
JSON_BUILD_PAIR_ENUM("type", transfer_type_to_string(t->type)),
|
||||
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))),
|
||||
JSON_BUILD_PAIR_ENUM("class", image_class_to_string(t->class)),
|
||||
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");
|
||||
|
||||
@@ -130,8 +130,8 @@ int session_send_create_reply_varlink(Session *s, const sd_bus_error *error) {
|
||||
SD_JSON_BUILD_PAIR_UNSIGNED("UID", s->user->user_record->uid),
|
||||
SD_JSON_BUILD_PAIR_CONDITION(!!s->seat, "Seat", SD_JSON_BUILD_STRING(s->seat ? s->seat->id : NULL)),
|
||||
SD_JSON_BUILD_PAIR_CONDITION(s->vtnr > 0, "VTNr", SD_JSON_BUILD_UNSIGNED(s->vtnr)),
|
||||
SD_JSON_BUILD_PAIR("Class", JSON_BUILD_STRING_UNDERSCORIFY(session_class_to_string(s->class))),
|
||||
SD_JSON_BUILD_PAIR("Type", JSON_BUILD_STRING_UNDERSCORIFY(session_type_to_string(s->type))));
|
||||
JSON_BUILD_PAIR_ENUM("Class", session_class_to_string(s->class)),
|
||||
JSON_BUILD_PAIR_ENUM("Type", session_type_to_string(s->type)));
|
||||
}
|
||||
|
||||
static JSON_DISPATCH_ENUM_DEFINE(json_dispatch_session_class, SessionClass, session_class_from_string);
|
||||
|
||||
@@ -1144,8 +1144,8 @@ static int register_session(
|
||||
SD_JSON_BUILD_PAIR_UNSIGNED("UID", ur->uid),
|
||||
JSON_BUILD_PAIR_PIDREF("PID", &pidref),
|
||||
JSON_BUILD_PAIR_STRING_NON_EMPTY("Service", c->service),
|
||||
SD_JSON_BUILD_PAIR("Type", JSON_BUILD_STRING_UNDERSCORIFY(c->type)),
|
||||
SD_JSON_BUILD_PAIR("Class", JSON_BUILD_STRING_UNDERSCORIFY(c->class)),
|
||||
JSON_BUILD_PAIR_ENUM("Type", c->type),
|
||||
JSON_BUILD_PAIR_ENUM("Class", c->class),
|
||||
JSON_BUILD_PAIR_STRING_NON_EMPTY("Desktop", c->desktop),
|
||||
JSON_BUILD_PAIR_STRING_NON_EMPTY("Seat", c->seat),
|
||||
SD_JSON_BUILD_PAIR_CONDITION(c->vtnr > 0, "VTNr", SD_JSON_BUILD_UNSIGNED(c->vtnr)),
|
||||
|
||||
+1
-1
@@ -2837,7 +2837,7 @@ static int context_notify(
|
||||
if (c->link) {
|
||||
r = sd_varlink_notifybo(
|
||||
c->link,
|
||||
SD_JSON_BUILD_PAIR("phase", JSON_BUILD_STRING_UNDERSCORIFY(progress_phase_to_string(phase))),
|
||||
JSON_BUILD_PAIR_ENUM("phase", progress_phase_to_string(phase)),
|
||||
JSON_BUILD_PAIR_STRING_NON_EMPTY("object", object),
|
||||
JSON_BUILD_PAIR_UNSIGNED_NOT_EQUAL("progress", percent, UINT_MAX));
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user