fix the dump logic to show validators and triggers even if no instances exist
authorJohn Crispin <blogic@openwrt.org>
Wed, 29 Jan 2014 17:33:50 +0000 (17:33 +0000)
committerJohn Crispin <blogic@openwrt.org>
Wed, 29 Jan 2014 17:33:50 +0000 (17:33 +0000)
Signed-off-by: John Crispin <blogic@openwrt.org>
service/service.c

index 3ec24c392c9a85e88f19b7cd4b36583bcd31b4f4..3fc84245280cf158f9773416d8d3828dfa538c85 100644 (file)
@@ -259,15 +259,12 @@ service_dump(struct service *s, int verbose)
 
        c = blobmsg_open_table(&b, s->name);
 
-       if (avl_is_empty(&s->instances.avl)) {
-               blobmsg_close_table(&b, c);
-               return;
+       if (!avl_is_empty(&s->instances.avl)) {
+               i = blobmsg_open_table(&b, "instances");
+               vlist_for_each_element(&s->instances, in, node)
+                       instance_dump(&b, in, verbose);
+               blobmsg_close_table(&b, i);
        }
-
-       i = blobmsg_open_table(&b, "instances");
-       vlist_for_each_element(&s->instances, in, node)
-               instance_dump(&b, in, verbose);
-       blobmsg_close_table(&b, i);
        if (verbose && s->trigger)
                blobmsg_add_blob(&b, s->trigger);
        if (verbose && !list_empty(&s->validators))