]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
format-table: when generating json, synthesize "null" for invalid ifindex
authorLennart Poettering <lennart@poettering.net>
Tue, 9 Feb 2021 15:39:49 +0000 (16:39 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 10 Feb 2021 11:21:56 +0000 (12:21 +0100)
This matches what we do for other cell types that have an invalid value.

src/shared/format-table.c

index 92f82dd5b251198d7861f4c09408940a5252393f..05bcff00956b9fea31fa0ca4a26640a9c2c4aa17 100644 (file)
@@ -2478,6 +2478,9 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
                 return json_variant_new_integer(ret, d->percent);
 
         case TABLE_IFINDEX:
+                if (d->ifindex <= 0)
+                        return json_variant_new_null(ret);
+
                 return json_variant_new_integer(ret, d->ifindex);
 
         case TABLE_IN_ADDR: