From 14b2a35c8bfd6d77f6357f929ddd82845436725f Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 19 Sep 2020 16:01:32 +1000 Subject: [PATCH] Cleanup: use parenthesis for if statements in macros --- intern/cycles/blender/blender_sync.cpp | 18 ++++-- intern/cycles/device/opencl/device_opencl.h | 6 +- intern/guardedalloc/MEM_guardedalloc.h | 6 +- source/blender/blenkernel/BKE_pbvh.h | 15 +++-- source/blender/blenkernel/intern/anim_data.c | 9 ++- source/blender/blenkernel/intern/brush.c | 24 +++++--- source/blender/blenkernel/intern/constraint.c | 7 ++- .../blender/blenkernel/intern/mesh_validate.c | 6 +- source/blender/blenkernel/intern/particle.c | 3 +- source/blender/blenlib/BLI_bitmap.h | 6 +- source/blender/blenlib/BLI_utildefines.h | 60 ++++++++++++------- source/blender/blenlib/intern/task_iterator.c | 6 +- .../editors/animation/anim_channels_defines.c | 18 ++++-- .../blender/editors/animation/anim_filter.c | 3 +- .../editors/animation/keyframes_edit.c | 16 +++-- .../blender/editors/gpencil/gpencil_intern.h | 12 ++-- .../editors/interface/interface_handlers.c | 3 +- .../freestyle/intern/geometry/GeomUtils.cpp | 30 ++++++---- source/blender/makesdna/DNA_ID.h | 6 +- source/blender/makesdna/DNA_userdef_types.h | 3 +- source/blender/makesrna/intern/makesrna.c | 15 +++-- source/blender/makesrna/intern/rna_mesh.c | 6 +- source/blender/makesrna/intern/rna_test.c | 4 +- .../nodes/texture/nodes/node_texture_proc.c | 6 +- source/blender/python/intern/bpy_props.c | 3 +- .../blender/render/intern/include/texture.h | 18 ++++-- .../render/intern/source/render_result.c | 6 +- .../blender/windowmanager/intern/wm_keymap.c | 3 +- 28 files changed, 210 insertions(+), 108 deletions(-) diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index bb2240142b0..ec62fa63f73 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -482,8 +482,10 @@ PassType BlenderSync::get_pass_type(BL::RenderPass &b_pass) { string name = b_pass.name(); #define MAP_PASS(passname, passtype) \ - if (name == passname) \ - return passtype; + if (name == passname) { \ + return passtype; \ + } \ + ((void)0) /* NOTE: Keep in sync with defined names from DNA_scene_types.h */ MAP_PASS("Combined", PASS_COMBINED); MAP_PASS("Depth", PASS_DEPTH); @@ -546,8 +548,10 @@ int BlenderSync::get_denoising_pass(BL::RenderPass &b_pass) name = name.substr(10); #define MAP_PASS(passname, offset) \ - if (name == passname) \ - return offset; + if (name == passname) { \ + return offset; \ + } \ + ((void)0) MAP_PASS("Normal", DENOISING_PASS_PREFILTERED_NORMAL); MAP_PASS("Albedo", DENOISING_PASS_PREFILTERED_ALBEDO); MAP_PASS("Depth", DENOISING_PASS_PREFILTERED_DEPTH); @@ -586,8 +590,10 @@ vector BlenderSync::sync_render_passes(BL::RenderLayer &b_rlay, if (denoising.use || denoising.store_passes) { if (denoising.type == DENOISER_NLM) { #define MAP_OPTION(name, flag) \ - if (!get_boolean(crl, name)) \ - scene->film->denoising_flags |= flag; + if (!get_boolean(crl, name)) { \ + scene->film->denoising_flags |= flag; \ + } \ + ((void)0) MAP_OPTION("denoising_diffuse_direct", DENOISING_CLEAN_DIFFUSE_DIR); MAP_OPTION("denoising_diffuse_indirect", DENOISING_CLEAN_DIFFUSE_IND); MAP_OPTION("denoising_glossy_direct", DENOISING_CLEAN_GLOSSY_DIR); diff --git a/intern/cycles/device/opencl/device_opencl.h b/intern/cycles/device/opencl/device_opencl.h index e0140996cf0..4fd3c27f17e 100644 --- a/intern/cycles/device/opencl/device_opencl.h +++ b/intern/cycles/device/opencl/device_opencl.h @@ -230,8 +230,9 @@ class OpenCLCache { if (err != CL_SUCCESS) { \ string message = string_printf( \ "OpenCL error: %s in %s (%s:%d)", clewErrorString(err), #stmt, __FILE__, __LINE__); \ - if ((device)->error_message() == "") \ + if ((device)->error_message() == "") { \ (device)->set_error(message); \ + } \ fprintf(stderr, "%s\n", message.c_str()); \ } \ } \ @@ -244,8 +245,9 @@ class OpenCLCache { if (err != CL_SUCCESS) { \ string message = string_printf( \ "OpenCL error: %s in %s (%s:%d)", clewErrorString(err), #stmt, __FILE__, __LINE__); \ - if (error_msg == "") \ + if (error_msg == "") { \ error_msg = message; \ + } \ fprintf(stderr, "%s\n", message.c_str()); \ } \ } \ diff --git a/intern/guardedalloc/MEM_guardedalloc.h b/intern/guardedalloc/MEM_guardedalloc.h index 78e629a6971..f12eb0ac340 100644 --- a/intern/guardedalloc/MEM_guardedalloc.h +++ b/intern/guardedalloc/MEM_guardedalloc.h @@ -243,8 +243,9 @@ void MEM_use_guarded_allocator(void); } \ void operator delete(void *mem) \ { \ - if (mem) \ + if (mem) { \ MEM_freeN(mem); \ + } \ } \ void *operator new[](size_t num_bytes) \ { \ @@ -252,8 +253,9 @@ void MEM_use_guarded_allocator(void); } \ void operator delete[](void *mem) \ { \ - if (mem) \ + if (mem) { \ MEM_freeN(mem); \ + } \ } \ void *operator new(size_t /*count*/, void *ptr) \ { \ diff --git a/source/blender/blenkernel/BKE_pbvh.h b/source/blender/blenkernel/BKE_pbvh.h index c3d107105a9..cd213b49c5b 100644 --- a/source/blender/blenkernel/BKE_pbvh.h +++ b/source/blender/blenkernel/BKE_pbvh.h @@ -390,8 +390,9 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m vi.height = vi.gridsize; \ vi.index = vi.grid_indices[vi.g] * vi.key.grid_area - 1; \ vi.grid = vi.grids[vi.grid_indices[vi.g]]; \ - if (mode == PBVH_ITER_UNIQUE) \ + if (mode == PBVH_ITER_UNIQUE) { \ vi.gh = vi.grid_hidden[vi.grid_indices[vi.g]]; \ + } \ } \ else { \ vi.width = vi.totvert; \ @@ -408,8 +409,9 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m vi.index++; \ vi.visible = true; \ if (vi.gh) { \ - if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) \ + if (BLI_BITMAP_TEST(vi.gh, vi.gy * vi.gridsize + vi.gx)) { \ continue; \ + } \ } \ } \ else if (vi.mverts) { \ @@ -426,10 +428,12 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m vi.co = vi.mvert->co; \ vi.no = vi.mvert->no; \ vi.index = vi.vert_indices[vi.i]; \ - if (vi.vmask) \ + if (vi.vmask) { \ vi.mask = &vi.vmask[vi.index]; \ - if (vi.vcol) \ + } \ + if (vi.vcol) { \ vi.col = vi.vcol[vi.index].color; \ + } \ } \ else { \ if (!BLI_gsetIterator_done(&vi.bm_unique_verts)) { \ @@ -441,8 +445,9 @@ void pbvh_vertex_iter_init(PBVH *pbvh, PBVHNode *node, PBVHVertexIter *vi, int m BLI_gsetIterator_step(&vi.bm_other_verts); \ } \ vi.visible = !BM_elem_flag_test_bool(vi.bm_vert, BM_ELEM_HIDDEN); \ - if (mode == PBVH_ITER_UNIQUE && !vi.visible) \ + if (mode == PBVH_ITER_UNIQUE && !vi.visible) { \ continue; \ + } \ vi.co = vi.bm_vert->co; \ vi.fno = vi.bm_vert->no; \ vi.index = BM_elem_index_get(vi.bm_vert); \ diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index 5ce449c5000..6f36b6ee99b 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -1287,8 +1287,9 @@ void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *use #define ANIMDATA_IDS_CB(first) \ for (id = first; id; id = id->next) { \ AnimData *adt = BKE_animdata_from_id(id); \ - if (adt) \ + if (adt) { \ func(id, adt, user_data); \ + } \ } \ (void)0 @@ -1299,11 +1300,13 @@ void BKE_animdata_main_cb(Main *bmain, ID_AnimData_Edit_Callback func, void *use NtId_Type *ntp = (NtId_Type *)id; \ if (ntp->nodetree) { \ AnimData *adt2 = BKE_animdata_from_id((ID *)ntp->nodetree); \ - if (adt2) \ + if (adt2) { \ func(id, adt2, user_data); \ + } \ } \ - if (adt) \ + if (adt) { \ func(id, adt, user_data); \ + } \ } \ (void)0 diff --git a/source/blender/blenkernel/intern/brush.c b/source/blender/blenkernel/intern/brush.c index a816e4354b8..7eea911f515 100644 --- a/source/blender/blenkernel/intern/brush.c +++ b/source/blender/blenkernel/intern/brush.c @@ -1545,20 +1545,28 @@ void BKE_brush_debug_print_state(Brush *br) brush_defaults(&def); #define BR_TEST(field, t) \ - if (br->field != def.field) \ - printf("br->" #field " = %" #t ";\n", br->field) + if (br->field != def.field) { \ + printf("br->" #field " = %" #t ";\n", br->field); \ + } \ + ((void)0) #define BR_TEST_FLAG(_f) \ - if ((br->flag & _f) && !(def.flag & _f)) \ + if ((br->flag & _f) && !(def.flag & _f)) { \ printf("br->flag |= " #_f ";\n"); \ - else if (!(br->flag & _f) && (def.flag & _f)) \ - printf("br->flag &= ~" #_f ";\n") + } \ + else if (!(br->flag & _f) && (def.flag & _f)) { \ + printf("br->flag &= ~" #_f ";\n"); \ + } \ + ((void)0) #define BR_TEST_FLAG_OVERLAY(_f) \ - if ((br->overlay_flags & _f) && !(def.overlay_flags & _f)) \ + if ((br->overlay_flags & _f) && !(def.overlay_flags & _f)) { \ printf("br->overlay_flags |= " #_f ";\n"); \ - else if (!(br->overlay_flags & _f) && (def.overlay_flags & _f)) \ - printf("br->overlay_flags &= ~" #_f ";\n") + } \ + else if (!(br->overlay_flags & _f) && (def.overlay_flags & _f)) { \ + printf("br->overlay_flags &= ~" #_f ";\n"); \ + } \ + ((void)0) /* print out any non-default brush state */ BR_TEST(normal_weight, f); diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 9411f937f08..601704fc8c5 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -788,9 +788,9 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph), ct->space = con->tarspace; \ ct->flag = CONSTRAINT_TAR_TEMP; \ \ - if (ct->tar) \ + if (ct->tar) { \ ct->type = CONSTRAINT_OBTYPE_OBJECT; \ -\ + } \ BLI_addtail(list, ct); \ } \ (void)0 @@ -2645,7 +2645,8 @@ static void actcon_get_tarmat(struct Depsgraph *depsgraph, /* Skip targets if we're using local float property to set action time */ if (data->flag & ACTCON_USE_EVAL_TIME) { s = data->eval_time; - } else { + } + else { /* get the transform matrix of the target */ constraint_target_to_mat4(ct->tar, ct->subtarget, diff --git a/source/blender/blenkernel/intern/mesh_validate.c b/source/blender/blenkernel/intern/mesh_validate.c index 338420641cf..990d99e5ec4 100644 --- a/source/blender/blenkernel/intern/mesh_validate.c +++ b/source/blender/blenkernel/intern/mesh_validate.c @@ -198,8 +198,10 @@ static int search_polyloop_cmp(const void *v1, const void *v2) * \{ */ #define PRINT_MSG(...) \ - if (do_verbose) \ - CLOG_INFO(&LOG, 1, __VA_ARGS__) + if (do_verbose) { \ + CLOG_INFO(&LOG, 1, __VA_ARGS__); \ + } \ + ((void)0) #define PRINT_ERR(...) \ do { \ diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index e837c57400a..0fa665a3424 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3997,8 +3997,9 @@ static int get_particle_uv(Mesh *mesh, #define CLAMP_WARP_PARTICLE_TEXTURE_POS(type, pvalue) \ if (event & type) { \ - if (pvalue < 0.0f) \ + if (pvalue < 0.0f) { \ pvalue = 1.0f + pvalue; \ + } \ CLAMP(pvalue, 0.0f, 1.0f); \ } \ (void)0 diff --git a/source/blender/blenlib/BLI_bitmap.h b/source/blender/blenlib/BLI_bitmap.h index 61a50662d79..960ce44c58c 100644 --- a/source/blender/blenlib/BLI_bitmap.h +++ b/source/blender/blenlib/BLI_bitmap.h @@ -93,10 +93,12 @@ typedef unsigned int BLI_bitmap; #define BLI_BITMAP_SET(_bitmap, _index, _set) \ { \ CHECK_TYPE(_bitmap, BLI_bitmap *); \ - if (_set) \ + if (_set) { \ BLI_BITMAP_ENABLE(_bitmap, _index); \ - else \ + } \ + else { \ BLI_BITMAP_DISABLE(_bitmap, _index); \ + } \ } \ (void)0 diff --git a/source/blender/blenlib/BLI_utildefines.h b/source/blender/blenlib/BLI_utildefines.h index acfa77ecf31..326015e8d80 100644 --- a/source/blender/blenlib/BLI_utildefines.h +++ b/source/blender/blenlib/BLI_utildefines.h @@ -136,50 +136,66 @@ extern "C" { (void)0 #define DO_MIN(vec, min) \ { \ - if ((min)[0] > (vec)[0]) \ + if ((min)[0] > (vec)[0]) { \ (min)[0] = (vec)[0]; \ - if ((min)[1] > (vec)[1]) \ + } \ + if ((min)[1] > (vec)[1]) { \ (min)[1] = (vec)[1]; \ - if ((min)[2] > (vec)[2]) \ + } \ + if ((min)[2] > (vec)[2]) { \ (min)[2] = (vec)[2]; \ + } \ } \ (void)0 #define DO_MAX(vec, max) \ { \ - if ((max)[0] < (vec)[0]) \ + if ((max)[0] < (vec)[0]) { \ (max)[0] = (vec)[0]; \ - if ((max)[1] < (vec)[1]) \ + } \ + if ((max)[1] < (vec)[1]) { \ (max)[1] = (vec)[1]; \ - if ((max)[2] < (vec)[2]) \ + } \ + if ((max)[2] < (vec)[2]) { \ (max)[2] = (vec)[2]; \ + } \ } \ (void)0 #define DO_MINMAX(vec, min, max) \ { \ - if ((min)[0] > (vec)[0]) \ + if ((min)[0] > (vec)[0]) { \ (min)[0] = (vec)[0]; \ - if ((min)[1] > (vec)[1]) \ + } \ + if ((min)[1] > (vec)[1]) { \ (min)[1] = (vec)[1]; \ - if ((min)[2] > (vec)[2]) \ + } \ + if ((min)[2] > (vec)[2]) { \ (min)[2] = (vec)[2]; \ - if ((max)[0] < (vec)[0]) \ + } \ + if ((max)[0] < (vec)[0]) { \ (max)[0] = (vec)[0]; \ - if ((max)[1] < (vec)[1]) \ + } \ + if ((max)[1] < (vec)[1]) { \ (max)[1] = (vec)[1]; \ - if ((max)[2] < (vec)[2]) \ + } \ + if ((max)[2] < (vec)[2]) { \ (max)[2] = (vec)[2]; \ + } \ } \ (void)0 #define DO_MINMAX2(vec, min, max) \ { \ - if ((min)[0] > (vec)[0]) \ + if ((min)[0] > (vec)[0]) { \ (min)[0] = (vec)[0]; \ - if ((min)[1] > (vec)[1]) \ + } \ + if ((min)[1] > (vec)[1]) { \ (min)[1] = (vec)[1]; \ - if ((max)[0] < (vec)[0]) \ + } \ + if ((max)[0] < (vec)[0]) { \ (max)[0] = (vec)[0]; \ - if ((max)[1] < (vec)[1]) \ + } \ + if ((max)[1] < (vec)[1]) { \ (max)[1] = (vec)[1]; \ + } \ } \ (void)0 @@ -330,24 +346,28 @@ extern "C" { #define CLAMP(a, b, c) \ { \ - if ((a) < (b)) \ + if ((a) < (b)) { \ (a) = (b); \ - else if ((a) > (c)) \ + } \ + else if ((a) > (c)) { \ (a) = (c); \ + } \ } \ (void)0 #define CLAMP_MAX(a, c) \ { \ - if ((a) > (c)) \ + if ((a) > (c)) { \ (a) = (c); \ + } \ } \ (void)0 #define CLAMP_MIN(a, b) \ { \ - if ((a) < (b)) \ + if ((a) < (b)) { \ (a) = (b); \ + } \ } \ (void)0 diff --git a/source/blender/blenlib/intern/task_iterator.c b/source/blender/blenlib/intern/task_iterator.c index ee459ac2548..38271e5823f 100644 --- a/source/blender/blenlib/intern/task_iterator.c +++ b/source/blender/blenlib/intern/task_iterator.c @@ -37,8 +37,10 @@ /* Allows to avoid using malloc for userdata_chunk in tasks, when small enough. */ #define MALLOCA(_size) ((_size) <= 8192) ? alloca((_size)) : MEM_mallocN((_size), __func__) #define MALLOCA_FREE(_mem, _size) \ - if (((_mem) != NULL) && ((_size) > 8192)) \ - MEM_freeN((_mem)) + if (((_mem) != NULL) && ((_size) > 8192)) { \ + MEM_freeN((_mem)); \ + } \ + ((void)0) BLI_INLINE void task_parallel_calc_chunk_size(const TaskParallelSettings *settings, const int tot_items, diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index b7aa150ea7a..cebf807d346 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4254,20 +4254,26 @@ short ANIM_channel_setting_get(bAnimContext *ac, bAnimListElem *ale, eAnimChanne #define ACF_SETTING_SET(sval, sflag, smode) \ { \ if (negflag) { \ - if (smode == ACHANNEL_SETFLAG_INVERT) \ + if (smode == ACHANNEL_SETFLAG_INVERT) { \ (sval) ^= (sflag); \ - else if (smode == ACHANNEL_SETFLAG_ADD) \ + } \ + else if (smode == ACHANNEL_SETFLAG_ADD) { \ (sval) &= ~(sflag); \ - else \ + } \ + else { \ (sval) |= (sflag); \ + } \ } \ else { \ - if (smode == ACHANNEL_SETFLAG_INVERT) \ + if (smode == ACHANNEL_SETFLAG_INVERT) { \ (sval) ^= (sflag); \ - else if (smode == ACHANNEL_SETFLAG_ADD) \ + } \ + else if (smode == ACHANNEL_SETFLAG_ADD) { \ (sval) |= (sflag); \ - else \ + } \ + else { \ (sval) &= ~(sflag); \ + } \ } \ } \ (void)0 diff --git a/source/blender/editors/animation/anim_filter.c b/source/blender/editors/animation/anim_filter.c index a17f1950be0..9d450496f33 100644 --- a/source/blender/editors/animation/anim_filter.c +++ b/source/blender/editors/animation/anim_filter.c @@ -570,8 +570,9 @@ bool ANIM_animdata_get_context(const bContext *C, bAnimContext *ac) // XXX: ale_statement stuff is really a hack for one special case. It shouldn't really be needed... #define ANIMCHANNEL_NEW_CHANNEL_FULL( \ channel_data, channel_type, owner_id, fcurve_owner_id, ale_statement) \ - if (filter_mode & ANIMFILTER_TMP_PEEK) \ + if (filter_mode & ANIMFILTER_TMP_PEEK) { \ return 1; \ + } \ { \ bAnimListElem *ale = make_new_animlistelem( \ channel_data, channel_type, (ID *)owner_id, fcurve_owner_id); \ diff --git a/source/blender/editors/animation/keyframes_edit.c b/source/blender/editors/animation/keyframes_edit.c index 6f6b5232fa7..299aa1db4f5 100644 --- a/source/blender/editors/animation/keyframes_edit.c +++ b/source/blender/editors/animation/keyframes_edit.c @@ -515,19 +515,21 @@ void ANIM_editkeyframes_refresh(bAnimContext *ac) #define KEYFRAME_OK_CHECKS(check) \ { \ CHECK_TYPE(ok, short); \ - if (check(1)) \ + if (check(1)) { \ ok |= KEYFRAME_OK_KEY; \ -\ + } \ if (ked && (ked->iterflags & KEYFRAME_ITER_INCL_HANDLES)) { \ /* Only act on visible items, so check handle visibility state. */ \ const bool handles_visible = ((ked->iterflags & KEYFRAME_ITER_HANDLES_DEFAULT_INVISIBLE) ? \ (BEZT_ISSEL_ANY(bezt)) : \ true); \ if (handles_visible) { \ - if (check(0)) \ + if (check(0)) { \ ok |= KEYFRAME_OK_H1; \ - if (check(2)) \ + } \ + if (check(2)) { \ ok |= KEYFRAME_OK_H2; \ + } \ } \ } \ } \ @@ -1054,10 +1056,12 @@ KeyframeEditFunc ANIM_editkeyframes_mirror(short mode) */ #define ENSURE_HANDLES_MATCH(bezt) \ if (bezt->h1 != bezt->h2) { \ - if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) \ + if (ELEM(bezt->h1, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) { \ bezt->h1 = HD_FREE; \ - if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) \ + } \ + if (ELEM(bezt->h2, HD_ALIGN, HD_AUTO, HD_AUTO_ANIM)) { \ bezt->h2 = HD_FREE; \ + } \ } \ (void)0 diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h index e6fdbf1ad17..f45321b6b20 100644 --- a/source/blender/editors/gpencil/gpencil_intern.h +++ b/source/blender/editors/gpencil/gpencil_intern.h @@ -670,11 +670,13 @@ struct GP_EditableStrokes_Iter { for (bGPDstroke *gps = gpf_->strokes.first; gps; gps = gpsn_) { \ gpsn_ = gps->next; \ /* skip strokes that are invalid for current view */ \ - if (ED_gpencil_stroke_can_use(C, gps) == false) \ + if (ED_gpencil_stroke_can_use(C, gps) == false) { \ continue; \ + } \ /* check if the color is editable */ \ - if (ED_gpencil_stroke_color_use(obact_, gpl, gps) == false) \ + if (ED_gpencil_stroke_color_use(obact_, gpl, gps) == false) { \ continue; \ + } \ /* ... Do Stuff With Strokes ... */ #define GP_EDITABLE_STROKES_END(gpstroke_iter) \ @@ -717,11 +719,13 @@ struct GP_EditableStrokes_Iter { /* loop over strokes */ \ LISTBASE_FOREACH (bGPDstroke *, gps, &gpf_->strokes) { \ /* skip strokes that are invalid for current view */ \ - if (ED_gpencil_stroke_can_use(C, gps) == false) \ + if (ED_gpencil_stroke_can_use(C, gps) == false) { \ continue; \ + } \ /* check if the color is editable */ \ - if (ED_gpencil_stroke_color_use(obact_, gpl, gps) == false) \ + if (ED_gpencil_stroke_color_use(obact_, gpl, gps) == false) { \ continue; \ + } \ /* ... Do Stuff With Strokes ... */ #define GP_EVALUATED_STROKES_END(gpstroke_iter) \ diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index cd78b61b8c5..19261bd3db6 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -10486,8 +10486,9 @@ static int ui_pie_handler(bContext *C, const wmEvent *event, uiPopupBlockHandle #define CASE_NUM_TO_DIR(n, d) \ case (EVT_ZEROKEY + n): \ case (EVT_PAD0 + n): { \ - if (num_dir == UI_RADIAL_NONE) \ + if (num_dir == UI_RADIAL_NONE) { \ num_dir = d; \ + } \ } \ (void)0 diff --git a/source/blender/freestyle/intern/geometry/GeomUtils.cpp b/source/blender/freestyle/intern/geometry/GeomUtils.cpp index 89a89d095ea..925bc3c9f94 100644 --- a/source/blender/freestyle/intern/geometry/GeomUtils.cpp +++ b/source/blender/freestyle/intern/geometry/GeomUtils.cpp @@ -219,14 +219,18 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1, #define FINDMINMAX(x0, x1, x2, min, max) \ { \ min = max = x0; \ - if (x1 < min) \ + if (x1 < min) { \ min = x1; \ - if (x1 > max) \ + } \ + if (x1 > max) { \ max = x1; \ - if (x2 < min) \ + } \ + if (x2 < min) { \ min = x2; \ - if (x2 > max) \ + } \ + if (x2 > max) { \ max = x2; \ + } \ } \ (void)0 @@ -244,8 +248,9 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1, max = p0; \ } \ rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; \ - if (min > rad || max < -rad) \ + if (min > rad || max < -rad) { \ return 0; \ + } \ } \ (void)0 @@ -262,8 +267,9 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1, max = p0; \ } \ rad = fa * boxhalfsize[Y] + fb * boxhalfsize[Z]; \ - if (min > rad || max < -rad) \ + if (min > rad || max < -rad) { \ return 0; \ + } \ } \ (void)0 @@ -281,8 +287,9 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1, max = p0; \ } \ rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; \ - if (min > rad || max < -rad) \ + if (min > rad || max < -rad) { \ return 0; \ + } \ } \ (void)0 @@ -299,8 +306,9 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1, max = p0; \ } \ rad = fa * boxhalfsize[X] + fb * boxhalfsize[Z]; \ - if (min > rad || max < -rad) \ + if (min > rad || max < -rad) { \ return 0; \ + } \ } \ (void)0 @@ -318,8 +326,9 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1, max = p2; \ } \ rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; \ - if (min > rad || max < -rad) \ + if (min > rad || max < -rad) { \ return 0; \ + } \ } \ (void)0 @@ -336,8 +345,9 @@ intersection_test intersect2dSeg2dSegParametric(const Vec2r &p1, max = p0; \ } \ rad = fa * boxhalfsize[X] + fb * boxhalfsize[Y]; \ - if (min > rad || max < -rad) \ + if (min > rad || max < -rad) { \ return 0; \ + } \ } \ (void)0 diff --git a/source/blender/makesdna/DNA_ID.h b/source/blender/makesdna/DNA_ID.h index e16a22f5459..1e24ec24dc2 100644 --- a/source/blender/makesdna/DNA_ID.h +++ b/source/blender/makesdna/DNA_ID.h @@ -511,8 +511,10 @@ typedef enum ID_Type { ((ID *)(_id))->newid->tag |= LIB_TAG_NEW, \ (void *)((ID *)(_id))->newid) #define ID_NEW_REMAP(a) \ - if ((a) && (a)->id.newid) \ - (a) = (void *)(a)->id.newid + if ((a) && (a)->id.newid) { \ + (a) = (void *)(a)->id.newid; \ + } \ + ((void)0) /** id->flag (persitent). */ enum { diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index b60dcb67224..e83353e04df 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -985,8 +985,9 @@ typedef enum ePathCompare_Flag { /* Helper macro for checking frame clamping */ #define FRAMENUMBER_MIN_CLAMP(cfra) \ { \ - if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) \ + if ((U.flag & USER_NONEGFRAMES) && (cfra < 0)) { \ cfra = 0; \ + } \ } \ (void)0 diff --git a/source/blender/makesrna/intern/makesrna.c b/source/blender/makesrna/intern/makesrna.c index f1086ab69bc..269db1990b8 100644 --- a/source/blender/makesrna/intern/makesrna.c +++ b/source/blender/makesrna/intern/makesrna.c @@ -4629,8 +4629,9 @@ static const char *cpp_classes = " ++i; \\\n" " } \\\n" " sname##_##identifier##_end(&iter); \\\n" - " if (!found) \\\n" + " if (!found) { \\\n" " memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" + " } \\\n" " return found; \\\n" " } \n" "#define COLLECTION_PROPERTY_LOOKUP_INT_true(sname, identifier) \\\n" @@ -4638,8 +4639,9 @@ static const char *cpp_classes = "PointerRNA *r_ptr) \\\n" " { \\\n" " int found = sname##_##identifier##_lookup_int(ptr, key, r_ptr); \\\n" - " if (!found) \\\n" + " if (!found) { \\\n" " memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" + " } \\\n" " return found; \\\n" " } \n" "#define COLLECTION_PROPERTY_LOOKUP_STRING_false(sname, identifier) \\\n" @@ -4660,13 +4662,15 @@ static const char *cpp_classes = " *r_ptr = iter.ptr; \\\n" " found = 1; \\\n" " } \\\n" - " if (name_fixed != name) \\\n" + " if (name_fixed != name) { \\\n" " MEM_freeN((void *) name); \\\n" + " } \\\n" " sname##_##identifier##_next(&iter); \\\n" " } \\\n" " sname##_##identifier##_end(&iter); \\\n" - " if (!found) \\\n" + " if (!found) { \\\n" " memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" + " } \\\n" " return found; \\\n" " } \n" "#define COLLECTION_PROPERTY_LOOKUP_STRING_true(sname, identifier) \\\n" @@ -4674,8 +4678,9 @@ static const char *cpp_classes = "*key, PointerRNA *r_ptr) \\\n" " { \\\n" " int found = sname##_##identifier##_lookup_string(ptr, key, r_ptr); \\\n" - " if (!found) \\\n" + " if (!found) { \\\n" " memset(r_ptr, 0, sizeof(*r_ptr)); \\\n" + " } \\\n" " return found; \\\n" " } \n" "#define COLLECTION_PROPERTY(collection_funcs, type, sname, identifier, has_length, " diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index b69d6b40590..4afb17fe0b9 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -157,8 +157,10 @@ static CustomData *rna_cd_from_layer(PointerRNA *ptr, CustomDataLayer *cdl) /* rely on negative values wrapping */ # define TEST_CDL(cmd) \ - if ((void)(cd = cmd(me)), ARRAY_HAS_ITEM(cdl, cd->layers, cd->totlayer)) \ - return cd + if ((void)(cd = cmd(me)), ARRAY_HAS_ITEM(cdl, cd->layers, cd->totlayer)) { \ + return cd; \ + } \ + ((void)0) TEST_CDL(rna_mesh_vdata_helper); TEST_CDL(rna_mesh_edata_helper); diff --git a/source/blender/makesrna/intern/rna_test.c b/source/blender/makesrna/intern/rna_test.c index f7b9779279d..39c1623352d 100644 --- a/source/blender/makesrna/intern/rna_test.c +++ b/source/blender/makesrna/intern/rna_test.c @@ -73,9 +73,9 @@ \ static int rna_Test_##arr##_set_length(PointerRNA *ptr, int length) \ { \ - if (length > max) \ + if (length > max) { \ return 0; \ -\ + } \ arr##_len = length; \ \ return 1; \ diff --git a/source/blender/nodes/texture/nodes/node_texture_proc.c b/source/blender/nodes/texture/nodes/node_texture_proc.c index bb7ee5f5bff..2cd4e31feb3 100644 --- a/source/blender/nodes/texture/nodes/node_texture_proc.c +++ b/source/blender/nodes/texture/nodes/node_texture_proc.c @@ -137,10 +137,12 @@ static int count_outputs(bNode *node) bNodeStack **out) \ { \ int outs = count_outputs(node); \ - if (outs >= 1) \ + if (outs >= 1) { \ tex_output(node, execdata, in, out[0], &name##_colorfn, data); \ - if (outs >= 2) \ + } \ + if (outs >= 2) { \ tex_output(node, execdata, in, out[1], &name##_normalfn, data); \ + } \ } /* --- VORONOI -- */ diff --git a/source/blender/python/intern/bpy_props.c b/source/blender/python/intern/bpy_props.c index bc708bd4a89..587f143e5f6 100644 --- a/source/blender/python/intern/bpy_props.c +++ b/source/blender/python/intern/bpy_props.c @@ -1986,8 +1986,9 @@ static void bpy_prop_callback_assign_enum(struct PropertyRNA *prop, } \ srna = srna_from_self(self, #_func "(...):"); \ if (srna == NULL) { \ - if (PyErr_Occurred()) \ + if (PyErr_Occurred()) { \ return NULL; \ + } \ return bpy_prop_deferred_return(pymeth_##_func, kw); \ } \ (void)0 diff --git a/source/blender/render/intern/include/texture.h b/source/blender/render/intern/include/texture.h index 22023baab95..44ad508fe33 100644 --- a/source/blender/render/intern/include/texture.h +++ b/source/blender/render/intern/include/texture.h @@ -44,12 +44,15 @@ extern "C" { texres->tg = tex->gfac * ((texres->tg - 0.5f) * tex->contrast + tex->bright - 0.5f); \ texres->tb = tex->bfac * ((texres->tb - 0.5f) * tex->contrast + tex->bright - 0.5f); \ if (!(tex->flag & TEX_NO_CLAMP)) { \ - if (texres->tr < 0.0f) \ + if (texres->tr < 0.0f) { \ texres->tr = 0.0f; \ - if (texres->tg < 0.0f) \ + } \ + if (texres->tg < 0.0f) { \ texres->tg = 0.0f; \ - if (texres->tb < 0.0f) \ + } \ + if (texres->tb < 0.0f) { \ texres->tb = 0.0f; \ + } \ } \ if (tex->saturation != 1.0f) { \ float _hsv[3]; \ @@ -57,12 +60,15 @@ extern "C" { _hsv[1] *= tex->saturation; \ hsv_to_rgb(_hsv[0], _hsv[1], _hsv[2], &texres->tr, &texres->tg, &texres->tb); \ if ((tex->saturation > 1.0f) && !(tex->flag & TEX_NO_CLAMP)) { \ - if (texres->tr < 0.0f) \ + if (texres->tr < 0.0f) { \ texres->tr = 0.0f; \ - if (texres->tg < 0.0f) \ + } \ + if (texres->tg < 0.0f) { \ texres->tg = 0.0f; \ - if (texres->tb < 0.0f) \ + } \ + if (texres->tb < 0.0f) { \ texres->tb = 0.0f; \ + } \ } \ } \ ((void)0) diff --git a/source/blender/render/intern/source/render_result.c b/source/blender/render/intern/source/render_result.c index ef88584974a..d2f21ab035c 100644 --- a/source/blender/render/intern/source/render_result.c +++ b/source/blender/render/intern/source/render_result.c @@ -579,8 +579,10 @@ static int passtype_from_name(const char *name) int len = BLI_str_partition(name, delim, &sep, &suf); #define CHECK_PASS(NAME) \ - if (STREQLEN(name, RE_PASSNAME_##NAME, len)) \ - return SCE_PASS_##NAME + if (STREQLEN(name, RE_PASSNAME_##NAME, len)) { \ + return SCE_PASS_##NAME; \ + } \ + ((void)0) CHECK_PASS(COMBINED); CHECK_PASS(Z); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index a39b10434e8..3d9ca281897 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -1176,8 +1176,9 @@ int WM_keymap_item_raw_to_string(const short shift, const int result_len) { #define ADD_SEP \ - if (p != buf) \ + if (p != buf) { \ *p++ = ' '; \ + } \ (void)0 char buf[128];