Merge pull request #29937 from yuwata/network-fix-json-format
network: fix json output
This commit is contained in:
+12
-12
@@ -1057,7 +1057,7 @@ static int dhcp6_client_vendor_options_append_json(Link *link, JsonVariant **v)
|
||||
JSON_BUILD_PAIR_UNSIGNED("SubOptionCode", (*option)->option),
|
||||
JSON_BUILD_PAIR_HEX("SubOptionData", (*option)->data, (*option)->length)));
|
||||
if (r < 0)
|
||||
return 0;
|
||||
return r;
|
||||
}
|
||||
|
||||
return json_variant_set_field_non_null(v, "VendorSpecificOptions", array);
|
||||
@@ -1065,7 +1065,7 @@ static int dhcp6_client_vendor_options_append_json(Link *link, JsonVariant **v)
|
||||
|
||||
static int dhcp6_client_lease_append_json(Link *link, JsonVariant **v) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *w = NULL;
|
||||
usec_t ts, t1, t2;
|
||||
usec_t ts = USEC_INFINITY, t1 = USEC_INFINITY, t2 = USEC_INFINITY;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
@@ -1075,15 +1075,15 @@ static int dhcp6_client_lease_append_json(Link *link, JsonVariant **v) {
|
||||
return 0;
|
||||
|
||||
r = sd_dhcp6_lease_get_timestamp(link->dhcp6_lease, CLOCK_BOOTTIME, &ts);
|
||||
if (r < 0)
|
||||
if (r < 0 && r != -ENODATA)
|
||||
return r;
|
||||
|
||||
r = sd_dhcp6_lease_get_t1_timestamp(link->dhcp6_lease, CLOCK_BOOTTIME, &t1);
|
||||
if (r < 0)
|
||||
if (r < 0 && r != -ENODATA)
|
||||
return r;
|
||||
|
||||
r = sd_dhcp6_lease_get_t2_timestamp(link->dhcp6_lease, CLOCK_BOOTTIME, &t2);
|
||||
if (r < 0)
|
||||
if (r < 0 && r != -ENODATA)
|
||||
return r;
|
||||
|
||||
r = json_build(&w, JSON_BUILD_OBJECT(
|
||||
@@ -1161,7 +1161,7 @@ static int dhcp6_client_append_json(Link *link, JsonVariant **v) {
|
||||
|
||||
static int dhcp_client_lease_append_json(Link *link, JsonVariant **v) {
|
||||
_cleanup_(json_variant_unrefp) JsonVariant *w = NULL;
|
||||
usec_t lease_timestamp_usec, t1, t2;
|
||||
usec_t lease_timestamp_usec = USEC_INFINITY, t1 = USEC_INFINITY, t2 = USEC_INFINITY;
|
||||
int r;
|
||||
|
||||
assert(link);
|
||||
@@ -1171,16 +1171,16 @@ static int dhcp_client_lease_append_json(Link *link, JsonVariant **v) {
|
||||
return 0;
|
||||
|
||||
r = sd_dhcp_lease_get_timestamp(link->dhcp_lease, CLOCK_BOOTTIME, &lease_timestamp_usec);
|
||||
if (r < 0)
|
||||
return 0;
|
||||
if (r < 0 && r != -ENODATA)
|
||||
return r;
|
||||
|
||||
r = sd_dhcp_lease_get_t1_timestamp(link->dhcp_lease, CLOCK_BOOTTIME, &t1);
|
||||
if (r < 0)
|
||||
return 0;
|
||||
if (r < 0 && r != -ENODATA)
|
||||
return r;
|
||||
|
||||
r = sd_dhcp_lease_get_t2_timestamp(link->dhcp_lease, CLOCK_BOOTTIME, &t2);
|
||||
if (r < 0)
|
||||
return 0;
|
||||
if (r < 0 && r != -ENODATA)
|
||||
return r;
|
||||
|
||||
r = json_build(&w, JSON_BUILD_OBJECT(
|
||||
JSON_BUILD_PAIR_FINITE_USEC("LeaseTimestampUSec", lease_timestamp_usec),
|
||||
|
||||
Reference in New Issue
Block a user