Files
openal-soft/core/except.cpp
Chris Robinson 069985e1e8 Avoid implicit array-to-pointer decay
Note that GCC's va_list seems to be implemented as some type with an array size
of 1 (__va_list_tag[1]), which is expected to implicitly decay to a pointer
when passed as a parameter. This unfortunately necessitates NOLINTBEGIN/END
where it's used to silence clang-tidy.
2024-01-24 20:31:02 -08:00

33 lines
673 B
C++

#include "config.h"
#include "except.h"
#include <cstdio>
#include <cstdarg>
#include "opthelpers.h"
namespace al {
base_exception::~base_exception() = default;
void base_exception::setMessage(const char *msg, std::va_list args)
{
/* NOLINTBEGIN(*-array-to-pointer-decay) */
std::va_list args2;
va_copy(args2, args);
int msglen{std::vsnprintf(nullptr, 0, msg, args)};
if(msglen > 0) LIKELY
{
mMessage.resize(static_cast<size_t>(msglen)+1);
std::vsnprintf(mMessage.data(), mMessage.length(), msg, args2);
mMessage.pop_back();
}
va_end(args2);
/* NOLINTEND(*-array-to-pointer-decay) */
}
} // namespace al