summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIronicallySerious <wtwarit@gmail.com>2019-01-31 01:08:57 +0530
committerIronicallySerious <wtwarit@gmail.com>2019-02-18 22:08:42 +0530
commit4121df235ee49471f30089a2d6b6e081536852ba (patch)
treef4da4d68866cc1a0143616d6249819b1cfa60f2d
parentc21ca98e4c6e6228adefcc696b3ff6a1104c678e (diff)
Fix parameterised macros in core. Addresses #25488
This adds the saves the programmer of doing something like SWAP(x++, y--) and getting the wrong result unless the parameters are evaluated before use.
-rw-r--r--core/io/logger.cpp2
-rw-r--r--core/math/geometry.cpp2
-rw-r--r--core/typedefs.h2
3 files changed, 3 insertions, 3 deletions
diff --git a/core/io/logger.cpp b/core/io/logger.cpp
index eeb82bfce4..9175f6a262 100644
--- a/core/io/logger.cpp
+++ b/core/io/logger.cpp
@@ -39,7 +39,7 @@
// va_copy, otherwise you have to use the internal version (__va_copy).
#if !defined(va_copy)
#if defined(__GNUC__)
-#define va_copy(d, s) __va_copy(d, s)
+#define va_copy(d, s) __va_copy((d), (s))
#else
#define va_copy(d, s) ((d) = (s))
#endif
diff --git a/core/math/geometry.cpp b/core/math/geometry.cpp
index 12c88f43b3..95399fb0c6 100644
--- a/core/math/geometry.cpp
+++ b/core/math/geometry.cpp
@@ -514,7 +514,7 @@ static inline void _build_faces(uint8_t ***p_cell_status, int x, int y, int z, i
Vector3(1,1,1),
};
*/
-#define vert(m_idx) Vector3((m_idx & 4) >> 2, (m_idx & 2) >> 1, m_idx & 1)
+#define vert(m_idx) Vector3(((m_idx)&4) >> 2, ((m_idx)&2) >> 1, (m_idx)&1)
static const uint8_t indices[6][4] = {
{ 7, 6, 4, 5 },
diff --git a/core/typedefs.h b/core/typedefs.h
index 0005e5e6ee..433c97d8d2 100644
--- a/core/typedefs.h
+++ b/core/typedefs.h
@@ -135,7 +135,7 @@ T *_nullptr() {
/** Generic swap template */
#ifndef SWAP
-#define SWAP(m_x, m_y) __swap_tmpl(m_x, m_y)
+#define SWAP(m_x, m_y) __swap_tmpl((m_x), (m_y))
template <class T>
inline void __swap_tmpl(T &x, T &y) {