Bypass 0 byte allocation when no domains are enabled
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Nov 2014 21:10:46 +0000 (16:10 -0500)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 7 Nov 2014 21:10:46 +0000 (16:10 -0500)
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
src/bin/lttng-sessiond/cmd.c
src/bin/lttng-sessiond/main.c

index d882b074d54cd4f0348365ab4adb218ce263c48b..98e090539af0ecf7755abc2dfe1332b2f116f3fa 100644 (file)
@@ -2388,6 +2388,10 @@ ssize_t cmd_list_domains(struct ltt_session *session,
                }
        }
 
+       if (!nb_dom) {
+               goto end;
+       }
+
        *domains = zmalloc(nb_dom * sizeof(struct lttng_domain));
        if (*domains == NULL) {
                ret = LTTNG_ERR_FATAL;
@@ -2413,7 +2417,7 @@ ssize_t cmd_list_domains(struct ltt_session *session,
                        }
                }
        }
-
+end:
        return nb_dom;
 
 error:
index 699d53323dd3b7eefe313d006f3b0e0605941336..c8484b93cb8a7006b708f562466cffc75aa4c767 100644 (file)
@@ -3474,7 +3474,7 @@ skip_domain:
        case LTTNG_LIST_DOMAINS:
        {
                ssize_t nb_dom;
-               struct lttng_domain *domains;
+               struct lttng_domain *domains = NULL;
 
                nb_dom = cmd_list_domains(cmd_ctx->session, &domains);
                if (nb_dom < 0) {
This page took 0.03006 seconds and 4 git commands to generate.