From: Michael Jeanson Date: Tue, 18 Apr 2023 15:29:21 +0000 (-0400) Subject: Build fix: missing error_get_str on non-glibc builds X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=2441eac381265b25aac9eb2cf4e4e793a3ffab5a;p=lttng-tools.git Build fix: missing error_get_str on non-glibc builds The function declaration was erroneously moved inside this ifdef. This breaks non glibc builds. Introduced in : commit 003f455dab0204dd3f066ecdbea0470035f8181f Author: Jérémie Galarneau Date: Thu Apr 13 14:31:33 2023 -0400 Fix: logging: unhandled error in *_FMT macros Coverity reports: 1508779 Uncaught exception If the exception is ever thrown, the program will crash. In lttng::​sessiond::​rotation_thread::​_thread_function(): A C++ exception is thrown but never caught (CWE-248) The *_FMT macros, which use fmtlib, don't handle the case where fmt::format throws. This can happen, in particular, when an invalid format string is used. The macros are modified to log the exception and abort. Change-Id: I5eb3b2a673e224f3c99cae7faece31175084db9d Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/src/common/error.hpp b/src/common/error.hpp index d1996384d..d00f41309 100644 --- a/src/common/error.hpp +++ b/src/common/error.hpp @@ -243,7 +243,6 @@ static inline void __lttng_print_check_abort(enum lttng_error_level type) /* * Version using GNU strerror_r, for linux with appropriate defines. */ -const char *error_get_str(int32_t code); #define PERROR(call, args...) \ do { \ char *_perror_buf; \ @@ -253,6 +252,8 @@ const char *error_get_str(int32_t code); } while (0); #endif +const char *error_get_str(int32_t code); + namespace lttng { namespace logging { namespace details {