Fix warnings reported by CLANG,
the C warning generator.
This commit is contained in:
1 parent
690fd72c8b
commit
d9401371a6
5 files changed
+16
-7
No files matched your search
@@ -332,4 +332,11 @@ M_END_PROTECTED_CODE
|
||||
|
||||
#endif
|
||||
|
||||
// C17 deprecated ATOMIC_VAR_INIT
|
||||
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201710L
|
||||
# define M_ATOMIC_VAR_INIT(x) (x)
|
||||
#else
|
||||
# define M_ATOMIC_VAR_INIT(x) ATOMIC_VAR_INIT(x)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+2
-2
@@ -48,11 +48,11 @@ M_BEGIN_PROTECTED_CODE
|
||||
|
||||
/* Value of the interface field for static intialization (Uses C99 designated element). */
|
||||
#define M_ISHARED_PTR_STATIC_DESIGNATED_INIT(name, type) \
|
||||
.M_F(name, _cpt) = ATOMIC_VAR_INIT(0)
|
||||
.M_F(name, _cpt) = M_ATOMIC_VAR_INIT(0)
|
||||
|
||||
/* Value of the interface field for static intialization (Uses C89 designated element). */
|
||||
#define M_ISHARED_PTR_STATIC_INIT(name, type) \
|
||||
ATOMIC_VAR_INIT(0)
|
||||
M_ATOMIC_VAR_INIT(0)
|
||||
|
||||
|
||||
/* Define the intrusive shared pointer type and its M_INLINE functions.
|
||||
|
||||
+1
-1
@@ -681,7 +681,7 @@ typedef struct {
|
||||
} m_once_t[1];
|
||||
|
||||
// Initial value for m_once_t
|
||||
#define M_ONCE_INIT_VALUE { { ATOMIC_VAR_INIT(0) } }
|
||||
#define M_ONCE_INIT_VALUE { { M_ATOMIC_VAR_INIT(0) } }
|
||||
|
||||
// Call the function exactly once
|
||||
M_INLINE void m_once_call(m_once_t o, void (*func)(void))
|
||||
|
||||
+5
-3
@@ -887,13 +887,15 @@ static void test_M_CSTR(void)
|
||||
#undef M_USE_CSTR_ALLOC
|
||||
#define M_USE_CSTR_ALLOC 8
|
||||
// Disable GNUC warning as we want to test this behavior.
|
||||
// this warning is not supported by CLANG
|
||||
#if defined (__GNUC__) && __GNUC__ >= 7 && !defined(__clang__)
|
||||
// this warning is supported by CLANG
|
||||
#if (defined (__GNUC__) && __GNUC__ >= 7 && !defined(__clang__)) \
|
||||
||(defined(__clang__) && __clang_major__ >= 18)
|
||||
_Pragma("GCC diagnostic push")
|
||||
_Pragma("GCC diagnostic ignored \"-Wformat-truncation\"")
|
||||
#endif
|
||||
r = strcmp(M_CSTR("Hello %s %c", "World", '!'), "Hello W");
|
||||
#if defined(__GNUC__) && __GNUC__ >= 7 && !defined(__clang__)
|
||||
#if (defined (__GNUC__) && __GNUC__ >= 7 && !defined(__clang__)) \
|
||||
||(defined(__clang__) && __clang_major__ >= 18)
|
||||
_Pragma("GCC diagnostic pop")
|
||||
#endif
|
||||
assert (r == 0);
|
||||
|
||||
@@ -31,7 +31,7 @@ static int fib(int n);
|
||||
struct fib2_s {
|
||||
int x, n;
|
||||
};
|
||||
atomic_bool resetFunc_called = ATOMIC_VAR_INIT(false);
|
||||
atomic_bool resetFunc_called = M_ATOMIC_VAR_INIT(false);
|
||||
static void resetFunc(void)
|
||||
{
|
||||
atomic_store(&resetFunc_called, true);
|
||||
|
||||
Reference in new issue
Block a user