From 8346beb68a50caf0b63edaca526250c0068f66d3 Mon Sep 17 00:00:00 2001 From: Philippe Proulx Date: Tue, 13 Jul 2021 10:48:19 -0400 Subject: [PATCH] lttng_strerror(): accept positive and negative codes MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Some functions return positive `lttng_error_code` enumerator values while other return negative values. Make lttng_strerror() accept positive and negative codes. This improves the API UX and will make the documentation less complex. Signed-off-by: Philippe Proulx Signed-off-by: Jérémie Galarneau Change-Id: I359cef98ae32991d1a01b7f2cd484ece7bab2df9 --- src/lib/lttng-ctl/lttng-ctl.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lib/lttng-ctl/lttng-ctl.cpp b/src/lib/lttng-ctl/lttng-ctl.cpp index d4ec1c81b..63841df40 100644 --- a/src/lib/lttng-ctl/lttng-ctl.cpp +++ b/src/lib/lttng-ctl/lttng-ctl.cpp @@ -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); } -- 2.34.1