Merge pull request #6602 from SachinVin/wall
Chore: enable `-Werror` on GCC and clang
This commit is contained in:
commit
35d1b67fd4
25 changed files with 124 additions and 114 deletions
|
@ -31,7 +31,7 @@ av_hwframe_ctx_init_func av_hwframe_ctx_init;
|
|||
av_hwframe_get_buffer_func av_hwframe_get_buffer;
|
||||
av_hwframe_transfer_data_func av_hwframe_transfer_data;
|
||||
av_int_list_length_for_size_func av_int_list_length_for_size;
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 59
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 53, 100) // lavu 56.53.100
|
||||
av_opt_child_class_iterate_func av_opt_child_class_iterate;
|
||||
#else
|
||||
av_opt_child_class_next_func av_opt_child_class_next;
|
||||
|
@ -166,7 +166,7 @@ static bool LoadAVUtil() {
|
|||
LOAD_SYMBOL(avutil, av_hwframe_get_buffer);
|
||||
LOAD_SYMBOL(avutil, av_hwframe_transfer_data);
|
||||
LOAD_SYMBOL(avutil, av_int_list_length_for_size);
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 59
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 53, 100) // lavu 56.53.100
|
||||
LOAD_SYMBOL(avutil, av_opt_child_class_iterate);
|
||||
#else
|
||||
LOAD_SYMBOL(avutil, av_opt_child_class_next);
|
||||
|
|
|
@ -47,7 +47,7 @@ typedef int (*av_hwframe_ctx_init_func)(AVBufferRef*);
|
|||
typedef int (*av_hwframe_get_buffer_func)(AVBufferRef*, AVFrame*, int);
|
||||
typedef int (*av_hwframe_transfer_data_func)(AVFrame*, const AVFrame*, int);
|
||||
typedef unsigned (*av_int_list_length_for_size_func)(unsigned, const void*, uint64_t);
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 59
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 53, 100) // lavu 56.53.100
|
||||
typedef const AVClass* (*av_opt_child_class_iterate_func)(const AVClass*, void**);
|
||||
#else
|
||||
typedef const AVClass* (*av_opt_child_class_next_func)(const AVClass*, const AVClass*);
|
||||
|
@ -85,7 +85,7 @@ extern av_hwframe_ctx_init_func av_hwframe_ctx_init;
|
|||
extern av_hwframe_get_buffer_func av_hwframe_get_buffer;
|
||||
extern av_hwframe_transfer_data_func av_hwframe_transfer_data;
|
||||
extern av_int_list_length_for_size_func av_int_list_length_for_size;
|
||||
#if LIBAVCODEC_VERSION_MAJOR >= 59
|
||||
#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(56, 53, 100) // lavu 56.53.100
|
||||
extern av_opt_child_class_iterate_func av_opt_child_class_iterate;
|
||||
#else
|
||||
extern av_opt_child_class_next_func av_opt_child_class_next;
|
||||
|
|
|
@ -102,12 +102,11 @@ static void StripTailDirSlashes(std::string& fname) {
|
|||
}
|
||||
|
||||
bool Exists(const std::string& filename) {
|
||||
struct stat file_info;
|
||||
|
||||
std::string copy(filename);
|
||||
StripTailDirSlashes(copy);
|
||||
|
||||
#ifdef _WIN32
|
||||
struct stat file_info;
|
||||
// Windows needs a slash to identify a driver root
|
||||
if (copy.size() != 0 && copy.back() == ':')
|
||||
copy += DIR_SEP_CHR;
|
||||
|
@ -116,6 +115,7 @@ bool Exists(const std::string& filename) {
|
|||
#elif ANDROID
|
||||
int result = AndroidStorage::FileExists(filename) ? 0 : -1;
|
||||
#else
|
||||
struct stat file_info;
|
||||
int result = stat(copy.c_str(), &file_info);
|
||||
#endif
|
||||
|
||||
|
@ -699,7 +699,7 @@ static const std::string& GetHomeDirectory() {
|
|||
* @return The directory path
|
||||
* @sa http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
*/
|
||||
static const std::string GetUserDirectory(const std::string& envvar) {
|
||||
[[maybe_unused]] static const std::string GetUserDirectory(const std::string& envvar) {
|
||||
const char* directory = getenv(envvar.c_str());
|
||||
|
||||
std::string user_dir;
|
||||
|
|
|
@ -16,19 +16,33 @@
|
|||
// Call directly after the command or use the error num.
|
||||
// This function might change the error code.
|
||||
std::string GetLastErrorMsg() {
|
||||
constexpr std::size_t buff_size = 255;
|
||||
char err_str[buff_size];
|
||||
std::size_t msg_len;
|
||||
|
||||
#ifdef _WIN32
|
||||
msg_len =
|
||||
FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(),
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), err_str, buff_size, nullptr);
|
||||
LPSTR err_str;
|
||||
|
||||
DWORD res = FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
nullptr, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
reinterpret_cast<LPSTR>(&err_str), 1, nullptr);
|
||||
if (!res) {
|
||||
return "(FormatMessageA failed to format error)";
|
||||
}
|
||||
std::string ret(err_str);
|
||||
LocalFree(err_str);
|
||||
return ret;
|
||||
#else
|
||||
char err_str[255];
|
||||
#if (defined(__GLIBC__) || __ANDROID_API__ >= 23) && \
|
||||
(_GNU_SOURCE || (_POSIX_C_SOURCE < 200112L && _XOPEN_SOURCE < 600))
|
||||
// Thread safe (GNU-specific)
|
||||
const char* str = strerror_r(errno, err_str, sizeof(err_str));
|
||||
return std::string(str);
|
||||
#else
|
||||
// Thread safe (XSI-compliant)
|
||||
strerror_r(errno, err_str, buff_size);
|
||||
msg_len = strnlen(err_str, buff_size);
|
||||
#endif
|
||||
|
||||
return std::string(err_str, msg_len);
|
||||
int second_err = strerror_r(errno, err_str, sizeof(err_str));
|
||||
if (second_err != 0) {
|
||||
return "(strerror_r failed to format error)";
|
||||
}
|
||||
return std::string(err_str);
|
||||
#endif // GLIBC etc.
|
||||
#endif // _WIN32
|
||||
}
|
||||
|
|
|
@ -170,7 +170,7 @@ static std::wstring CPToUTF16(u32 code_page, const std::string& input) {
|
|||
MultiByteToWideChar(code_page, 0, input.data(), static_cast<int>(input.size()), nullptr, 0);
|
||||
|
||||
if (size == 0) {
|
||||
return L"";
|
||||
return {};
|
||||
}
|
||||
|
||||
std::wstring output(size, L'\0');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue