Skip to content

Commit 77dbf34

Browse files
committed
fix warning
1 parent 6f5bc6e commit 77dbf34

File tree

1 file changed

+119
-117
lines changed

1 file changed

+119
-117
lines changed

include/libstored/util.h

Lines changed: 119 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@
3838
*/
3939
#ifndef likely
4040
# ifdef __GNUC__
41-
# define likely(expr) __builtin_expect(!!(expr), 1)
41+
# define likely(expr) \
42+
__builtin_expect( \
43+
!!(expr), /* NOLINT(readability-simplify-boolean-expr) */ \
44+
1)
4245
# else
4346
# define likely(expr) (expr)
4447
# endif
@@ -52,10 +55,10 @@
5255
*/
5356
#ifndef unlikely
5457
# ifdef __GNUC__
55-
# define unlikely(expr) \
56-
__builtin_expect( \
57-
!!(expr), /* NOLINT(readability-simplify-boolean-expr) */ \
58-
0)
58+
# define unlikely(expr) \
59+
__builtin_expect( \
60+
!!(expr), /* NOLINT(readability-simplify-boolean-expr) */ \
61+
0)
5962
# else
6063
# define unlikely(expr) (expr)
6164
# endif
@@ -73,9 +76,9 @@
7376
# define stored_yield() zth_yield()
7477
# endif
7578
# else
76-
# define stored_yield() \
77-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
78-
} while(false)
79+
# define stored_yield() \
80+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
81+
} while(false)
7982
# endif
8083
#endif
8184

@@ -125,11 +128,11 @@
125128

126129
#ifdef STORED_HAVE_VALGRIND
127130
# define STORED_MAKE_MEM_NOACCESS_VALGRIND(buffer, size) \
128-
(void)VALGRIND_MAKE_MEM_NOACCESS(buffer, size)
131+
(void)VALGRIND_MAKE_MEM_NOACCESS(buffer, size)
129132
# define STORED_MAKE_MEM_UNDEFINED_VALGRIND(buffer, size) \
130-
(void)VALGRIND_MAKE_MEM_UNDEFINED(buffer, size)
133+
(void)VALGRIND_MAKE_MEM_UNDEFINED(buffer, size)
131134
# define STORED_MAKE_MEM_DEFINED_VALGRIND(buffer, size) \
132-
(void)VALGRIND_MAKE_MEM_DEFINED(buffer, size)
135+
(void)VALGRIND_MAKE_MEM_DEFINED(buffer, size)
133136
#else // !STORED_HAVE_VALGRIND
134137
# define STORED_MAKE_MEM_NOACCESS_VALGRIND(buffer, size) (void)0
135138
# define STORED_MAKE_MEM_UNDEFINED_VALGRIND(buffer, size) (void)0
@@ -151,40 +154,40 @@
151154

152155
#if !defined(NDEBUG) \
153156
&& ((defined(STORED_HAVE_VALGRIND) && !defined(NVALGRIND)) || defined(STORED_ENABLE_ASAN))
154-
# define STORED_MAKE_MEM_NOACCESS(buffer, size) \
155-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
156-
void* b_ = (void*)(buffer); \
157-
size_t s_ = (size_t)(size); \
158-
STORED_MAKE_MEM_NOACCESS_VALGRIND(b_, s_); \
159-
STORED_MAKE_MEM_NOACCESS_ASAN(b_, s_); \
160-
} while(0)
161-
162-
# define STORED_MAKE_MEM_UNDEFINED(buffer, size) \
163-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
164-
void* b_ = (void*)(buffer); \
165-
size_t s_ = (size_t)(size); \
166-
STORED_MAKE_MEM_UNDEFINED_VALGRIND(b_, s_); \
167-
STORED_MAKE_MEM_UNDEFINED_ASAN(b_, s_); \
168-
if(Config::Debug && !RUNNING_ON_VALGRIND && b_) \
169-
memset(b_, 0xef, s_); \
170-
} while(0)
171-
# define STORED_MAKE_MEM_DEFINED(buffer, size) \
172-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
173-
void* b_ = (void*)(buffer); \
174-
size_t s_ = (size_t)(size); \
175-
STORED_MAKE_MEM_DEFINED_VALGRIND(b_, s_); \
176-
STORED_MAKE_MEM_DEFINED_ASAN(b_, s_); \
177-
} while(0)
157+
# define STORED_MAKE_MEM_NOACCESS(buffer, size) \
158+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
159+
void* b_ = (void*)(buffer); \
160+
size_t s_ = (size_t)(size); \
161+
STORED_MAKE_MEM_NOACCESS_VALGRIND(b_, s_); \
162+
STORED_MAKE_MEM_NOACCESS_ASAN(b_, s_); \
163+
} while(0)
164+
165+
# define STORED_MAKE_MEM_UNDEFINED(buffer, size) \
166+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
167+
void* b_ = (void*)(buffer); \
168+
size_t s_ = (size_t)(size); \
169+
STORED_MAKE_MEM_UNDEFINED_VALGRIND(b_, s_); \
170+
STORED_MAKE_MEM_UNDEFINED_ASAN(b_, s_); \
171+
if(Config::Debug && !RUNNING_ON_VALGRIND && b_) \
172+
memset(b_, 0xef, s_); \
173+
} while(0)
174+
# define STORED_MAKE_MEM_DEFINED(buffer, size) \
175+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
176+
void* b_ = (void*)(buffer); \
177+
size_t s_ = (size_t)(size); \
178+
STORED_MAKE_MEM_DEFINED_VALGRIND(b_, s_); \
179+
STORED_MAKE_MEM_DEFINED_ASAN(b_, s_); \
180+
} while(0)
178181
#else
179-
# define STORED_MAKE_MEM_NOACCESS(buffer, size) \
180-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
181-
} while(0)
182-
# define STORED_MAKE_MEM_UNDEFINED(buffer, size) \
183-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
184-
} while(0)
185-
# define STORED_MAKE_MEM_DEFINED(buffer, size) \
186-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
187-
} while(0)
182+
# define STORED_MAKE_MEM_NOACCESS(buffer, size) \
183+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
184+
} while(0)
185+
# define STORED_MAKE_MEM_UNDEFINED(buffer, size) \
186+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
187+
} while(0)
188+
# define STORED_MAKE_MEM_DEFINED(buffer, size) \
189+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
190+
} while(0)
188191
#endif
189192

190193

@@ -208,7 +211,7 @@
208211
*/
209212
# ifndef DOXYGEN
210213
# define SFINAE_IS_FUNCTION(T, F, T_OK) \
211-
typename std::enable_if<std::is_assignable<std::function<F>, T>::value, T_OK>::type
214+
typename std::enable_if<std::is_assignable<std::function<F>, T>::value, T_OK>::type
212215
# else
213216
# define SFINAE_IS_FUNCTION(T, F, T_OK) T_OK
214217
# endif
@@ -218,10 +221,10 @@
218221

219222
# if defined(STORED_cplusplus) && STORED_cplusplus < 201103L && !defined(static_assert) \
220223
&& !defined(STORED_COMPILER_MSVC)
221-
# define static_assert(expr, msg) \
222-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
223-
typedef __attribute__((unused)) int static_assert_[(expr) ? 1 : -1]; \
224-
} while(0)
224+
# define static_assert(expr, msg) \
225+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
226+
typedef __attribute__((unused)) int static_assert_[(expr) ? 1 : -1]; \
227+
} while(0)
225228
# endif
226229

227230
# ifndef STORED_CLASS_NOCOPY
@@ -236,35 +239,35 @@
236239
* \param Class the class this macro is embedded in
237240
*/
238241
# if STORED_cplusplus >= 201103L
239-
# define STORED_CLASS_NOCOPY(Class) \
240-
public: \
241-
/*! \brief Deleted copy constructor. */ \
242-
Class(Class const&) = delete; \
243-
/*! \brief Default move constructor. */ \
244-
Class(Class&&) noexcept = default; /* NOLINT */ \
245-
/*! \brief Deleted assignment operator. */ \
246-
void operator=(Class const&) = delete; \
247-
/*! \brief Default move assignment operator. */ \
248-
Class& operator=(Class&&) noexcept = default; /* NOLINT */
242+
# define STORED_CLASS_NOCOPY(Class) \
243+
public: \
244+
/*! \brief Deleted copy constructor. */ \
245+
Class(Class const&) = delete; \
246+
/*! \brief Default move constructor. */ \
247+
Class(Class&&) noexcept = default; /* NOLINT */ \
248+
/*! \brief Deleted assignment operator. */ \
249+
void operator=(Class const&) = delete; \
250+
/*! \brief Default move assignment operator. */ \
251+
Class& operator=(Class&&) noexcept = default; /* NOLINT */
249252
# else
250-
# define STORED_CLASS_NOCOPY(Class) \
251-
private: \
252-
/*! \brief Deleted copy constructor. */ \
253-
Class(Class const&); \
254-
/*! \brief Deleted assignment operator. */ \
255-
void operator=(Class const&);
253+
# define STORED_CLASS_NOCOPY(Class) \
254+
private: \
255+
/*! \brief Deleted copy constructor. */ \
256+
Class(Class const&); \
257+
/*! \brief Deleted assignment operator. */ \
258+
void operator=(Class const&);
256259
# endif
257260
# endif
258261

259262
# if STORED_cplusplus >= 201103L && !defined(STORED_CLASS_DEFAULT_COPY_MOVE)
260-
# define STORED_CLASS_DEFAULT_COPY_MOVE(type) \
261-
public: \
262-
type(type const&) = default; \
263-
type(type&&) noexcept = default; \
264-
type& operator=(type const&) = default; \
265-
type& operator=(type&&) noexcept = default; \
266-
\
267-
private:
263+
# define STORED_CLASS_DEFAULT_COPY_MOVE(type) \
264+
public: \
265+
type(type const&) = default; \
266+
type(type&&) noexcept = default; \
267+
type& operator=(type const&) = default; \
268+
type& operator=(type&&) noexcept = default; \
269+
\
270+
private:
268271
# endif
269272

270273
# ifndef CLASS_NO_WEAK_VTABLE
@@ -273,19 +276,19 @@
273276
* \details Use CLASS_NO_WEAK_VTABLE_DEF() in one .cpp file.
274277
*/
275278
# define CLASS_NO_WEAK_VTABLE \
276-
protected: \
277-
void force_to_translation_unit();
279+
protected: \
280+
void force_to_translation_unit();
278281
/*!
279282
* \see CLASS_NO_WEAK_VTABLE
280283
*/
281284
// cppcheck-suppress-macro duplInheritedMember
282-
# define CLASS_NO_WEAK_VTABLE_DEF(Class) \
283-
/*! \brief Dummy function to force the vtable of this \
284-
* class to this translation unit. Don't call. */ \
285-
void Class::force_to_translation_unit() \
286-
{ \
287-
abort(); \
288-
}
285+
# define CLASS_NO_WEAK_VTABLE_DEF(Class) \
286+
/*! \brief Dummy function to force the vtable of this \
287+
* class to this translation unit. Don't call. */ \
288+
void Class::force_to_translation_unit() \
289+
{ \
290+
abort(); \
291+
}
289292
# endif
290293

291294
namespace stored {
@@ -294,19 +297,19 @@ namespace stored {
294297
* \brief Like \c assert(), but only emits code when #stored::Config::EnableAssert.
295298
*/
296299
# ifdef STORED_HAVE_ZTH
297-
# define stored_assert(expr) \
298-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
299-
if(::stored::Config::EnableAssert) { \
300-
zth_assert(expr); \
301-
} \
302-
} while(false)
300+
# define stored_assert(expr) \
301+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
302+
if(::stored::Config::EnableAssert) { \
303+
zth_assert(expr); \
304+
} \
305+
} while(false)
303306
# else
304-
# define stored_assert(expr) \
305-
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
306-
if(::stored::Config::EnableAssert) { \
307-
assert(expr); \
308-
} \
309-
} while(false)
307+
# define stored_assert(expr) \
308+
do { /* NOLINT(cppcoreguidelines-avoid-do-while) */ \
309+
if(::stored::Config::EnableAssert) { \
310+
assert(expr); \
311+
} \
312+
} while(false)
310313
# endif
311314

312315
void swap_endian(void* buffer, size_t len) noexcept;
@@ -835,10 +838,10 @@ using store_t = typename store<Impl, Base...>::type;
835838
*
836839
* \hideinitializer
837840
*/
838-
# define STORE_T(Impl, ...) \
839-
EXPAND(STORED_GET_MACRO_ARGN( \
840-
Impl, ##__VA_ARGS__, STORE_T_9, STORE_T_8, STORE_T_7, STORE_T_6, STORE_T_5, \
841-
STORE_T_4, STORE_T_3, STORE_T_2, STORE_T_1)(Impl, ##__VA_ARGS__))
841+
# define STORE_T(Impl, ...) \
842+
EXPAND(STORED_GET_MACRO_ARGN( \
843+
Impl, ##__VA_ARGS__, STORE_T_9, STORE_T_8, STORE_T_7, STORE_T_6, STORE_T_5, STORE_T_4, \
844+
STORE_T_3, STORE_T_2, STORE_T_1)(Impl, ##__VA_ARGS__))
842845

843846
// Make sure to match the number of template arguments of stored::store.
844847
# define STORE_BASE_CLASS_1(x) x
@@ -851,12 +854,11 @@ using store_t = typename store<Impl, Base...>::type;
851854
# define STORE_BASE_CLASS_8(x, ...) EXPAND(STORE_BASE_CLASS_7(__VA_ARGS__))
852855
# define STORE_BASE_CLASS_9(x, ...) EXPAND(STORE_BASE_CLASS_8(__VA_ARGS__))
853856

854-
# define STORE_CLASS_BASE(Impl, ...) \
855-
EXPAND(STORED_GET_MACRO_ARGN( \
856-
0, Impl, ##__VA_ARGS__, STORE_BASE_CLASS_9, STORE_BASE_CLASS_8, \
857-
STORE_BASE_CLASS_7, STORE_BASE_CLASS_6, STORE_BASE_CLASS_5, STORE_BASE_CLASS_4, \
858-
STORE_BASE_CLASS_3, STORE_BASE_CLASS_2, \
859-
STORE_BASE_CLASS_1)(Impl, ##__VA_ARGS__))<Impl /**/>
857+
# define STORE_CLASS_BASE(Impl, ...) \
858+
EXPAND(STORED_GET_MACRO_ARGN( \
859+
0, Impl, ##__VA_ARGS__, STORE_BASE_CLASS_9, STORE_BASE_CLASS_8, STORE_BASE_CLASS_7, \
860+
STORE_BASE_CLASS_6, STORE_BASE_CLASS_5, STORE_BASE_CLASS_4, STORE_BASE_CLASS_3, \
861+
STORE_BASE_CLASS_2, STORE_BASE_CLASS_1)(Impl, ##__VA_ARGS__))<Impl /**/>
860862

861863
# ifdef STORED_COMPILER_MSVC
862864
// https://developercommunity.visualstudio.com/t/compile-error-when-using-using-declaration-referen/486683
@@ -866,25 +868,25 @@ using store_t = typename store<Impl, Base...>::type;
866868
# define STORE_CLASS_USING_BASE_TYPE(type, ...) using typename __VA_ARGS__::type;
867869
# endif
868870

869-
# define STORE_CLASS_(Impl, ...) \
870-
STORED_CLASS_NOCOPY(Impl) \
871-
STORED_CLASS_NEW_DELETE(Impl) \
872-
public: \
873-
typedef Impl self; \
874-
typedef __VA_ARGS__ base; \
875-
STORE_CLASS_USING_BASE_TYPE(root, __VA_ARGS__) \
876-
STORE_CLASS_USING_BASE_TYPE(Implementation, __VA_ARGS__) \
877-
\
878-
private:
871+
# define STORE_CLASS_(Impl, ...) \
872+
STORED_CLASS_NOCOPY(Impl) \
873+
STORED_CLASS_NEW_DELETE(Impl) \
874+
public: \
875+
typedef Impl self; \
876+
typedef __VA_ARGS__ base; \
877+
STORE_CLASS_USING_BASE_TYPE(root, __VA_ARGS__) \
878+
STORE_CLASS_USING_BASE_TYPE(Implementation, __VA_ARGS__) \
879+
\
880+
private:
879881

880882
/*!
881883
* \brief Class helper macro to get a store implementation class right.
882884
* \see #stored::store
883885
* \hideinitializer
884886
*/
885-
# define STORE_CLASS(Impl, ...) \
886-
STORE_CLASS_(Impl, STORE_T(Impl, __VA_ARGS__)) \
887-
friend class STORE_CLASS_BASE(Impl, ##__VA_ARGS__);
887+
# define STORE_CLASS(Impl, ...) \
888+
STORE_CLASS_(Impl, STORE_T(Impl, __VA_ARGS__)) \
889+
friend class STORE_CLASS_BASE(Impl, ##__VA_ARGS__);
888890

889891
/*!
890892
* \brief Class helper macro to get a store wrapper class right.

0 commit comments

Comments
 (0)