fixup service_dump logic
authorJohn Crispin <blogic@openwrt.org>
Tue, 3 Sep 2013 14:03:29 +0000 (16:03 +0200)
committerJohn Crispin <blogic@openwrt.org>
Tue, 3 Sep 2013 17:44:57 +0000 (19:44 +0200)
Signed-off-by: John Crispin <blogic@openwrt.org>
service.c

index c80402c809aa854bc314071693f5a1b1b82e2eb8..e485c534bf151e8338bfc442211065d90688c7cf 100644 (file)
--- a/service.c
+++ b/service.c
@@ -220,16 +220,19 @@ service_dump(struct service *s, int verbose)
        struct service_instance *in;
        void *c, *i;
 
-       if (avl_is_empty(&s->instances.avl) && !verbose)
+       c = blobmsg_open_table(&b, s->name);
+
+       if (avl_is_empty(&s->instances.avl)) {
+               blobmsg_close_table(&b, c);
                return;
+       }
 
-       c = blobmsg_open_table(&b, s->name);
-       if (verbose && s->trigger)
-               blobmsg_add_blob(&b, s->trigger);
        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);
        blobmsg_close_table(&b, c);
 }