summaryrefslogtreecommitdiffstats
path: root/src/shared/format-table.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-15 17:09:39 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-15 17:09:39 +0200
commitba99f19c0d3313d1828d751b441bea4e0b7dfc12 (patch)
tree4210e279f136796c319dc494c66eaa0ed763aafe /src/shared/format-table.c
parentsystemctl: do not suggest passing --all if the user passed --state= (diff)
downloadsystemd-ba99f19c0d3313d1828d751b441bea4e0b7dfc12.tar.xz
systemd-ba99f19c0d3313d1828d751b441bea4e0b7dfc12.zip
format-table: add TABLE_TIMESPAN_MSEC
Diffstat (limited to 'src/shared/format-table.c')
-rw-r--r--src/shared/format-table.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/shared/format-table.c b/src/shared/format-table.c
index 54ca1972bd..90c80568ac 100644
--- a/src/shared/format-table.c
+++ b/src/shared/format-table.c
@@ -231,6 +231,7 @@ static size_t table_data_size(TableDataType type, const void *data) {
case TABLE_TIMESTAMP:
case TABLE_TIMESPAN:
+ case TABLE_TIMESPAN_MSEC:
return sizeof(usec_t);
case TABLE_SIZE:
@@ -720,6 +721,7 @@ int table_add_many_internal(Table *t, TableDataType first_type, ...) {
case TABLE_TIMESTAMP:
case TABLE_TIMESPAN:
+ case TABLE_TIMESPAN_MSEC:
buffer.usec = va_arg(ap, usec_t);
data = &buffer.usec;
break;
@@ -885,6 +887,7 @@ static int cell_data_compare(TableData *a, size_t index_a, TableData *b, size_t
return CMP(a->timestamp, b->timestamp);
case TABLE_TIMESPAN:
+ case TABLE_TIMESPAN_MSEC:
return CMP(a->timespan, b->timespan);
case TABLE_SIZE:
@@ -999,14 +1002,16 @@ static const char *table_data_format(TableData *d) {
break;
}
- case TABLE_TIMESPAN: {
+ case TABLE_TIMESPAN:
+ case TABLE_TIMESPAN_MSEC: {
_cleanup_free_ char *p;
p = new(char, FORMAT_TIMESPAN_MAX);
if (!p)
return NULL;
- if (!format_timespan(p, FORMAT_TIMESPAN_MAX, d->timespan, 0))
+ if (!format_timespan(p, FORMAT_TIMESPAN_MAX, d->timespan,
+ d->type == TABLE_TIMESPAN ? 0 : USEC_PER_MSEC))
return "n/a";
d->formatted = TAKE_PTR(p);
@@ -1638,6 +1643,7 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
return json_variant_new_unsigned(ret, d->timestamp);
case TABLE_TIMESPAN:
+ case TABLE_TIMESPAN_MSEC:
if (d->timespan == USEC_INFINITY)
return json_variant_new_null(ret);