summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2019-07-26 15:49:09 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2019-07-26 15:49:09 +0200
commit37645e9b47493d3a07ca59549fa830e5c1e0a637 (patch)
tree0dee3a0116e6d191e718c1614e71e837257d4c76
parentb2708ce81d25ab08e42a4bf8a4a9b0e8c550a44a (diff)
cynadm: fix empty list bug
Change-Id: I3f64af57796dfc6b38f4cd51ab838e820e6cbb9c Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/main-cynadm.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/main-cynadm.c b/src/main-cynadm.c
index bb51c25..4be5bae 100644
--- a/src/main-cynadm.c
+++ b/src/main-cynadm.c
@@ -417,16 +417,18 @@ int do_list(int ac, char **av)
if (rc < 0)
fprintf(stderr, "error %s\n", strerror(-rc));
else {
- it = lr.head = listresult_sort(lr.count, lr.head);
- while(it) {
- fprintf(stdout, "%-*s %-*s %-*s %-*s %-*s %-*s\n",
- (int)lr.lengths[0], it->items[0],
- (int)lr.lengths[1], it->items[1],
- (int)lr.lengths[2], it->items[2],
- (int)lr.lengths[3], it->items[3],
- (int)lr.lengths[4], it->items[4],
- (int)lr.lengths[5], it->items[5]);
- it = it->next;
+ if (lr.count) {
+ it = lr.head = listresult_sort(lr.count, lr.head);
+ while(it) {
+ fprintf(stdout, "%-*s %-*s %-*s %-*s %-*s %-*s\n",
+ (int)lr.lengths[0], it->items[0],
+ (int)lr.lengths[1], it->items[1],
+ (int)lr.lengths[2], it->items[2],
+ (int)lr.lengths[3], it->items[3],
+ (int)lr.lengths[4], it->items[4],
+ (int)lr.lengths[5], it->items[5]);
+ it = it->next;
+ }
}
fprintf(stdout, "%d entries found\n", lr.count);
}