Copyright ownership transfer
[lttng-tools.git] / src / lib / lttng-ctl / lttng-ctl.cpp
index 3622987183c5db8c4bdf8e0f48b70b7bd63b5366..684cf466984eabc6fdd973a24a581f7cabaf28e9 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Linux Trace Toolkit Control Library
  *
- * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011 EfficiOS Inc.
  * Copyright (C) 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  *
  * SPDX-License-Identifier: LGPL-2.1-only
@@ -47,7 +47,7 @@
 
 #include "lttng-ctl-helper.h"
 #include <common/filter/filter-ast.h>
-#include <common/filter/filter-parser.h>
+#include <common/filter/filter-parser.hpp>
 #include <common/filter/memstream.h>
 
 #define COPY_DOMAIN_PACKED(dst, src)                           \
@@ -1769,10 +1769,14 @@ int lttng_list_syscalls(struct lttng_event **events)
 
 /*
  * Returns a human readable string describing
- * the error code (a negative value).
+ * the error code (positive or negative value).
  */
 const char *lttng_strerror(int code)
 {
+       if (code > 0) {
+               code = -code;
+       }
+
        return error_get_str(code);
 }
 
@@ -2098,6 +2102,12 @@ int lttng_list_sessions(struct lttng_session **out_sessions)
 
        memset(&lsm, 0, sizeof(lsm));
        lsm.cmd_type = LTTNG_LIST_SESSIONS;
+       /*
+        * Initialize out_sessions to NULL so it is initialized when
+        * lttng_list_sessions returns 0, thus allowing *out_sessions to
+        * be subsequently freed.
+        */
+       *out_sessions = NULL;
        ret = lttng_ctl_ask_sessiond(&lsm, (void**) &sessions);
        if (ret <= 0) {
                goto end;
@@ -2110,7 +2120,6 @@ int lttng_list_sessions(struct lttng_session **out_sessions)
        if (ret % session_size) {
                ret = -LTTNG_ERR_UNK;
                free(sessions);
-               *out_sessions = NULL;
                goto end;
        }
        session_count = (size_t) ret / session_size;
This page took 0.02439 seconds and 4 git commands to generate.