mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-08 12:24:09 +00:00
libobs: Calm stringop-overflow warning on GCC
Those warnings appeared with GCC 12 with -O2, those are potentially created by regression from GCC.
This commit is contained in:
parent
c648222332
commit
678b0287e6
|
@ -55,20 +55,25 @@
|
|||
#define PRAGMA_WARN_PUSH __pragma(warning(push))
|
||||
#define PRAGMA_WARN_POP __pragma(warning(pop))
|
||||
#define PRAGMA_WARN_DEPRECATION
|
||||
#define PRAGMA_WARN_STRINGOP_OVERFLOW
|
||||
#elif defined(__clang__)
|
||||
#define PRAGMA_WARN_PUSH _Pragma("clang diagnostic push")
|
||||
#define PRAGMA_WARN_POP _Pragma("clang diagnostic pop")
|
||||
#define PRAGMA_WARN_DEPRECATION \
|
||||
_Pragma("clang diagnostic warning \"-Wdeprecated-declarations\"")
|
||||
#define PRAGMA_WARN_STRINGOP_OVERFLOW
|
||||
#elif defined(__GNUC__)
|
||||
#define PRAGMA_WARN_PUSH _Pragma("GCC diagnostic push")
|
||||
#define PRAGMA_WARN_POP _Pragma("GCC diagnostic pop")
|
||||
#define PRAGMA_WARN_DEPRECATION \
|
||||
_Pragma("GCC diagnostic warning \"-Wdeprecated-declarations\"")
|
||||
#define PRAGMA_WARN_STRINGOP_OVERFLOW \
|
||||
_Pragma("GCC diagnostic warning \"-Wstringop-overflow\"")
|
||||
#else
|
||||
#define PRAGMA_WARN_PUSH
|
||||
#define PRAGMA_WARN_POP
|
||||
#define PRAGMA_WARN_DEPRECATION
|
||||
#define PRAGMA_WARN_STRINGOP_OVERFLOW
|
||||
#endif
|
||||
|
||||
#include <stddef.h>
|
||||
|
|
|
@ -207,7 +207,11 @@ static inline void *darray_push_back_new(const size_t element_size,
|
|||
darray_ensure_capacity(element_size, dst, ++dst->num);
|
||||
|
||||
last = darray_end(element_size, dst);
|
||||
PRAGMA_WARN_PUSH
|
||||
// NOTE: Those warning could be false positive from GCC 12 with -O2
|
||||
PRAGMA_WARN_STRINGOP_OVERFLOW
|
||||
memset(last, 0, element_size);
|
||||
PRAGMA_WARN_POP
|
||||
return last;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue