From a82d3f85c689056681ba608624e8326c09415293 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Wed, 18 Jun 2014 14:00:58 +1000 Subject: Correct casts for IS_EQ and other macro tweaks - ensure GET_INT_FROM_POINTER us only used to get values - rename STACK_POP_ELSE -> STACK_POP_DEFAULT --- source/blender/blenkernel/BKE_mesh_mapping.h | 3 ++- source/blender/blenlib/BLI_ghash.h | 2 +- source/blender/blenlib/BLI_linklist_stack.h | 4 ++-- source/blender/blenlib/BLI_utildefines.h | 14 +++++++------- 4 files changed, 12 insertions(+), 11 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/BKE_mesh_mapping.h b/source/blender/blenkernel/BKE_mesh_mapping.h index f3f6b556a07..ed7e506941c 100644 --- a/source/blender/blenkernel/BKE_mesh_mapping.h +++ b/source/blender/blenkernel/BKE_mesh_mapping.h @@ -131,7 +131,8 @@ int *BKE_mesh_calc_smoothgroups( /* No good (portable) way to have exported inlined functions... */ #define BKE_MESH_TESSFACE_VINDEX_ORDER(_mf, _v) ( \ - (CHECK_TYPE_INLINE(_mf, MFace *), CHECK_TYPE_INLINE(_v, unsigned int)), \ + (CHECK_TYPE_INLINE(_mf, MFace *), \ + CHECK_TYPE_INLINE(&(_v), unsigned int *)), \ ((_mf->v1 == _v) ? 0 : \ (_mf->v2 == _v) ? 1 : \ (_mf->v3 == _v) ? 2 : \ diff --git a/source/blender/blenlib/BLI_ghash.h b/source/blender/blenlib/BLI_ghash.h index 947386dc934..a59023d4f9b 100644 --- a/source/blender/blenlib/BLI_ghash.h +++ b/source/blender/blenlib/BLI_ghash.h @@ -130,7 +130,7 @@ unsigned int BLI_ghashutil_strhash_p(const void *key); int BLI_ghashutil_strcmp(const void *a, const void *b); #define BLI_ghashutil_inthash(key) ( \ - CHECK_TYPE_INLINE(key, int), \ + CHECK_TYPE_INLINE(&(key), int *), \ BLI_ghashutil_uinthash((unsigned int)key)) unsigned int BLI_ghashutil_uinthash(unsigned int key); #define BLI_ghashutil_inthash_v4(key) ( \ diff --git a/source/blender/blenlib/BLI_linklist_stack.h b/source/blender/blenlib/BLI_linklist_stack.h index 5f4f98c5a4f..d3d1924628c 100644 --- a/source/blender/blenlib/BLI_linklist_stack.h +++ b/source/blender/blenlib/BLI_linklist_stack.h @@ -69,14 +69,14 @@ BLI_linklist_prepend_pool(&(var), ptr, _##var##_pool)) #define BLI_LINKSTACK_POP(var) \ (var ? (typeof(_##var##_type))BLI_linklist_pop_pool(&(var), _##var##_pool) : NULL) -#define BLI_LINKSTACK_POP_ELSE(var, r) \ +#define BLI_LINKSTACK_POP_DEFAULT(var, r) \ (var ? (typeof(_##var##_type))BLI_linklist_pop_pool(&(var), _##var##_pool) : r) #else /* non gcc */ #define BLI_LINKSTACK_PUSH(var, ptr) ( \ BLI_linklist_prepend_pool(&(var), ptr, _##var##_pool)) #define BLI_LINKSTACK_POP(var) \ (var ? BLI_linklist_pop_pool(&(var), _##var##_pool) : NULL) -#define BLI_LINKSTACK_POP_ELSE(var, r) \ +#define BLI_LINKSTACK_POP_DEFAULT(var, r) \ (var ? BLI_linklist_pop_pool(&(var), _##var##_pool) : r) #endif /* gcc check */ diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index c8cdfdb60fa..600476b9038 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -313,11 +313,11 @@ #define IS_EQ(a, b) ( \ CHECK_TYPE_INLINE(a, double), CHECK_TYPE_INLINE(b, double), \ - ((fabs((double)(a) - (b)) >= (double) FLT_EPSILON) ? false : true)) + ((fabs((double)((a) - (b))) >= (double) FLT_EPSILON) ? false : true)) #define IS_EQF(a, b) ( \ CHECK_TYPE_INLINE(a, float), CHECK_TYPE_INLINE(b, float), \ - ((fabsf((float)(a) - (b)) >= (float) FLT_EPSILON) ? false : true)) + ((fabsf((float)((a) - (b))) >= (float) FLT_EPSILON) ? false : true)) #define IS_EQT(a, b, c) ((a > b) ? (((a - b) <= c) ? 1 : 0) : ((((b - a) <= c) ? 1 : 0))) #define IN_RANGE(a, b, c) ((b < c) ? ((b < a && a < c) ? 1 : 0) : ((c < a && a < b) ? 1 : 0)) @@ -339,9 +339,9 @@ #define STACK_PUSH(stack, val) (void)((stack)[(_##stack##_index)++] = val) #define STACK_PUSH_RET(stack) ((void)stack, ((stack)[(_##stack##_index)++])) #define STACK_PUSH_RET_PTR(stack) ((void)stack, &((stack)[(_##stack##_index)++])) -#define STACK_POP(stack) ((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : NULL) -#define STACK_POP_PTR(stack) ((_##stack##_index) ? &((stack)[--(_##stack##_index)]) : NULL) -#define STACK_POP_ELSE(stack, r) ((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : r) +#define STACK_POP(stack) ((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : NULL) +#define STACK_POP_PTR(stack) ((_##stack##_index) ? &((stack)[--(_##stack##_index)]) : NULL) +#define STACK_POP_DEFAULT(stack, r) ((_##stack##_index) ? ((stack)[--(_##stack##_index)]) : r) #define STACK_FREE(stack) ((void)stack) #ifdef __GNUC__ #define STACK_SWAP(stack_a, stack_b) { \ @@ -382,10 +382,10 @@ /* Warning-free macros for storing ints in pointers. Use these _only_ * for storing an int in a pointer, not a pointer in an int (64bit)! */ #define SET_INT_IN_POINTER(i) ((void *)(intptr_t)(i)) -#define GET_INT_FROM_POINTER(i) ((int)(intptr_t)(i)) +#define GET_INT_FROM_POINTER(i) ((void)0, ((int)(intptr_t)(i))) #define SET_UINT_IN_POINTER(i) ((void *)(uintptr_t)(i)) -#define GET_UINT_FROM_POINTER(i) ((unsigned int)(uintptr_t)(i)) +#define GET_UINT_FROM_POINTER(i) ((void)0, ((unsigned int)(uintptr_t)(i))) /* Macro to convert a value to string in the preprocessor -- cgit v1.2.3