summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2020-02-04 21:33:08 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2020-02-07 10:41:57 +0100
commit384f2e70fe4bc5bdfd9f35c4347351a985f23d14 (patch)
tree15361337e34260164a27ff72b1c8c53721398f88
parent1685b6a3370f944e30c9ea9cc078d3fc4c243934 (diff)
Fix bug on unknown commands
Unknow commands were leading to infinite loop. This fixes. Bug-AGL: SPEC-3166 Change-Id: If1529526c5779951b8e2e30d999f3fc037eae9d4 Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/cynagora.c2
-rw-r--r--src/main-cynagora-admin.c37
2 files changed, 19 insertions, 20 deletions
diff --git a/src/cynagora.c b/src/cynagora.c
index 16d953f..609ab84 100644
--- a/src/cynagora.c
+++ b/src/cynagora.c
@@ -383,7 +383,7 @@ get_reply(
* @param block
*
* @return the count of fields greater than 0 or a negative -errno value
- * or -EAGAIN if nothing and block == 0
+ * or -EAGAIN if nothing and block == false
* or -EPIPE if broken link
*/
static
diff --git a/src/main-cynagora-admin.c b/src/main-cynagora-admin.c
index c6a9535..8f28db5 100644
--- a/src/main-cynagora-admin.c
+++ b/src/main-cynagora-admin.c
@@ -459,24 +459,23 @@ int do_list(int ac, char **av)
if (rc == 0) {
memset(&lr, 0, sizeof lr);
last_status = rc = cynagora_get(cynagora, &key, listcb, &lr);
- if (rc < 0)
- fprintf(stderr, "error %s\n", strerror(-rc));
- else {
- 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;
- }
+ 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);
}
+ if (rc < 0)
+ fprintf(stderr, "error %d: %s\n", -rc, strerror(-rc));
+ else
+ fprintf(stdout, "%d entries found\n", lr.count);
/* free list */
while(lr.head) {
it = lr.head;
@@ -679,13 +678,13 @@ int do_any(int ac, char **av)
}
if (!strcmp(av[0], "quit"))
- return 0;
+ exit(0);
if (!strcmp(av[0], "help") || !strcmp(av[0], "?"))
return do_help(ac, av);
- fprintf(stderr, "unknown command %s\n", av[0]);
- return 0;
+ fprintf(stderr, "unknown command %s (try help)\n", av[0]);
+ return 1;
}
void do_all(int ac, char **av, int quit)