/*
* 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);
}
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;
if (ret % session_size) {
ret = -LTTNG_ERR_UNK;
free(sessions);
- *out_sessions = NULL;
goto end;
}
session_count = (size_t) ret / session_size;