Move lttng_ust_strerror to liblttng-ust
authorMichael Jeanson <mjeanson@efficios.com>
Thu, 22 Apr 2021 00:17:56 +0000 (20:17 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 23 Apr 2021 19:43:58 +0000 (15:43 -0400)
Move the implementation of lttng_ust_strerror to liblttng-ust, it's part
of its public ABI and should not be copied in multiples libraries.

Change-Id: I825769d6c62b25e3e21b71abd18241998c6dde85
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
src/common/ustcomm.c
src/lib/lttng-ust/Makefile.am
src/lib/lttng-ust/strerror.c [new file with mode: 0644]

index 0c46fe5e2d945a20a302efd82aea891fd751be54..00cbf5a73bae82b0a30568490eb9923706036125 100644 (file)
 #include "common/ustcomm.h"
 #include "common/ust-fd.h"
 #include "common/macros.h"
-#include <lttng/ust-error.h>
 #include "common/dynamic-type.h"
 #include "common/logging.h"
 
 #include "common/events.h"
 #include "common/compat/pthread.h"
 
-#define USTCOMM_CODE_OFFSET(code)      \
-       (code == LTTNG_UST_OK ? 0 : (code - LTTNG_UST_ERR + 1))
-
 #define USTCOMM_MAX_SEND_FDS   4
 
 static
@@ -48,43 +44,6 @@ int serialize_fields(struct lttng_ust_session *session,
                size_t *iter_output, size_t nr_lttng_fields,
                const struct lttng_ust_event_field * const *lttng_fields);
 
-/*
- * Human readable error message.
- */
-static const char *ustcomm_readable_code[] = {
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_OK) ] = "Success",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR) ] = "Unknown error",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_NOENT) ] = "No entry",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_EXIST) ] = "Object already exists",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_INVAL) ] = "Invalid argument",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_PERM) ] = "Permission denied",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_NOSYS) ] = "Not implemented",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_EXITING) ] = "Process is exiting",
-
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_INVAL_MAGIC) ] = "Invalid magic number",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_INVAL_SOCKET_TYPE) ] = "Invalid socket type",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_UNSUP_MAJOR) ] = "Unsupported major version",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_PEERCRED) ] = "Cannot get unix socket peer credentials",
-       [ USTCOMM_CODE_OFFSET(LTTNG_UST_ERR_PEERCRED_PID) ] = "Peer credentials PID is invalid. Socket appears to belong to a distinct, non-nested pid namespace.",
-};
-
-/*
- * lttng_ust_strerror
- * @code: must be a negative value of enum lttng_ust_error_code (or 0).
- *
- * Returns a ptr to a string representing a human readable error code from the
- * ustcomm_return_code enum.
- */
-const char *lttng_ust_strerror(int code)
-{
-       code = -code;
-
-       if (code < LTTNG_UST_OK || code >= LTTNG_UST_ERR_NR)
-               code = LTTNG_UST_ERR;
-
-       return ustcomm_readable_code[USTCOMM_CODE_OFFSET(code)];
-}
-
 /*
  * ustcomm_connect_unix_sock
  *
index 7f82ebdec00758ae4677c4a56f47f49c91d476aa..2b22471a0558ff6da2aa598a64ffaee7d3d74fa0 100644 (file)
@@ -61,7 +61,8 @@ liblttng_ust_runtime_la_SOURCES = \
        rculfhash-internal.h \
        rculfhash-mm-chunk.c \
        rculfhash-mm-mmap.c \
-       rculfhash-mm-order.c
+       rculfhash-mm-order.c \
+       strerror.c
 
 if HAVE_PERF_EVENT
 liblttng_ust_runtime_la_SOURCES += \
diff --git a/src/lib/lttng-ust/strerror.c b/src/lib/lttng-ust/strerror.c
new file mode 100644 (file)
index 0000000..1fa7fc3
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * SPDX-License-Identifier: LGPL-2.1-only
+ *
+ * Copyright (C) 2011 David Goulet <david.goulet@polymtl.ca>
+ * Copyright (C) 2011-2013 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ */
+
+#include <lttng/ust-error.h>
+
+#define CODE_OFFSET(code)      \
+       (code == LTTNG_UST_OK ? 0 : (code - LTTNG_UST_ERR + 1))
+
+/*
+ * Human readable error message.
+ */
+static const char *ustcomm_readable_code[] = {
+       [ CODE_OFFSET(LTTNG_UST_OK) ] = "Success",
+       [ CODE_OFFSET(LTTNG_UST_ERR) ] = "Unknown error",
+       [ CODE_OFFSET(LTTNG_UST_ERR_NOENT) ] = "No entry",
+       [ CODE_OFFSET(LTTNG_UST_ERR_EXIST) ] = "Object already exists",
+       [ CODE_OFFSET(LTTNG_UST_ERR_INVAL) ] = "Invalid argument",
+       [ CODE_OFFSET(LTTNG_UST_ERR_PERM) ] = "Permission denied",
+       [ CODE_OFFSET(LTTNG_UST_ERR_NOSYS) ] = "Not implemented",
+       [ CODE_OFFSET(LTTNG_UST_ERR_EXITING) ] = "Process is exiting",
+
+       [ CODE_OFFSET(LTTNG_UST_ERR_INVAL_MAGIC) ] = "Invalid magic number",
+       [ CODE_OFFSET(LTTNG_UST_ERR_INVAL_SOCKET_TYPE) ] = "Invalid socket type",
+       [ CODE_OFFSET(LTTNG_UST_ERR_UNSUP_MAJOR) ] = "Unsupported major version",
+       [ CODE_OFFSET(LTTNG_UST_ERR_PEERCRED) ] = "Cannot get unix socket peer credentials",
+       [ CODE_OFFSET(LTTNG_UST_ERR_PEERCRED_PID) ] = "Peer credentials PID is invalid. Socket appears to belong to a distinct, non-nested pid namespace.",
+};
+
+/*
+ * lttng_ust_strerror
+ * @code: must be a negative value of enum lttng_ust_error_code (or 0).
+ *
+ * Returns a ptr to a string representing a human readable error code from the
+ * ustcomm_return_code enum.
+ */
+const char *lttng_ust_strerror(int code)
+{
+       code = -code;
+
+       if (code < LTTNG_UST_OK || code >= LTTNG_UST_ERR_NR)
+               code = LTTNG_UST_ERR;
+
+       return ustcomm_readable_code[CODE_OFFSET(code)];
+}
This page took 0.028457 seconds and 4 git commands to generate.