Coverity reports:
1502349 Uncaught exception If the exception is ever thrown, the
program will crash.
In lttng::file_descriptor::~file_descriptor(): A C++ exception is
thrown but never caught (CWE-248)
and
1502348 Uncaught exception If the exception is ever thrown, the
program will crash.
In main: A C++ exception is thrown but never caught (CWE-248)
Both have the same cause: libfmt should not be used in "final" catch
blocks before returning to non exception-safe code in order to contain
all exceptions.
As we add custom formaters, it could be interesting to revisit this and
provide a noexcept wrapper for fmt::format. For the moment not much is
lost (beyond format string type safety) from using the existing logging
macros directly.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: Ia70505517678ae182f6479feeb264c9402aa1381
const auto ret = ::close(_raw_fd);
if (ret) {
- PERROR("%s",
- fmt::format("Failed to close file descriptor: fd = {}",
- _raw_fd)
- .c_str());
+ PERROR("Failed to close file descriptor: fd=%i", _raw_fd);
}
}
int _raw_fd;
};
-} /* namespace lttng */
\ No newline at end of file
+} /* namespace lttng */
try {
srand(lttng::random::produce_best_effort_random_seed());
} catch (std::exception& e) {
- ERR("%s",
- fmt::format("Failed to initialize random seed during generation of UUID: {}",
- e.what())
- .c_str());
+ ERR("Failed to initialize random seed during generation of UUID: %s",
+ e.what());
ret = -1;
goto end;
}