From b7826c42df5bc049b93b636b0ef81d5cca8397e4 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Fri, 19 Jul 2013 10:39:25 +0000 Subject: enable type limits warning when compiling with gcc. --- CMakeLists.txt | 2 ++ source/blender/blenkernel/intern/implicit.c | 4 ++++ source/blender/blenkernel/intern/mask_rasterize.c | 8 ++++---- source/blender/bmesh/intern/bmesh_operators.c | 3 --- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b1a7830434e..17ae5b3857d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1977,6 +1977,7 @@ if(CMAKE_COMPILER_IS_GNUCC) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_NULL -Wnonnull) # C only ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs) ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero) + ADD_CHECK_C_COMPILER_FLAG(C_WARNINGS C_WARN_TYPE_LIMITS -Wtype-limits) # gcc 4.2 gives annoying warnings on every file with this if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3") @@ -2003,6 +2004,7 @@ if(CMAKE_COMPILER_IS_GNUCC) ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_INIT_SELF -Winit-self) # needs -Wuninitialized ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_MISSING_INCLUDE_DIRS -Wmissing-include-dirs) ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_NO_DIV_BY_ZERO -Wno-div-by-zero) + ADD_CHECK_CXX_COMPILER_FLAG(CXX_WARNINGS CXX_WARN_TYPE_LIMITS -Wtype-limits) # gcc 4.2 gives annoying warnings on every file with this if(NOT "${CMAKE_C_COMPILER_VERSION}" VERSION_LESS "4.3") diff --git a/source/blender/blenkernel/intern/implicit.c b/source/blender/blenkernel/intern/implicit.c index b9064fe8ba3..c8e18bc3dee 100644 --- a/source/blender/blenkernel/intern/implicit.c +++ b/source/blender/blenkernel/intern/implicit.c @@ -48,6 +48,10 @@ #include "BKE_global.h" +#ifdef __GNUC__ +# pragma GCC diagnostic ignored "-Wtype-limits" +#endif + #ifdef _OPENMP # define CLOTH_OPENMP_LIMIT 512 #endif diff --git a/source/blender/blenkernel/intern/mask_rasterize.c b/source/blender/blenkernel/intern/mask_rasterize.c index e68f87211eb..ac48eaa3185 100644 --- a/source/blender/blenkernel/intern/mask_rasterize.c +++ b/source/blender/blenkernel/intern/mask_rasterize.c @@ -496,10 +496,10 @@ static void layer_bucket_init(MaskRasterLayer *layer, const float pixel_size) /* this should _almost_ never happen but since it can in extreme cases, * we have to clamp the values or we overrun the buffer and crash */ - CLAMP(xi_min, 0, layer->buckets_x - 1); - CLAMP(xi_max, 0, layer->buckets_x - 1); - CLAMP(yi_min, 0, layer->buckets_y - 1); - CLAMP(yi_max, 0, layer->buckets_y - 1); + if (xi_min >= layer->buckets_x) xi_min = layer->buckets_x - 1; + if (xi_max >= layer->buckets_x) xi_max = layer->buckets_x - 1; + if (yi_min >= layer->buckets_y) yi_min = layer->buckets_y - 1; + if (yi_max >= layer->buckets_y) yi_max = layer->buckets_y - 1; for (yi = yi_min; yi <= yi_max; yi++) { unsigned int bucket_index = (layer->buckets_x * yi) + xi_min; diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 7f8b40d85dc..63c00d5b545 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -561,8 +561,6 @@ static int bmo_mesh_flag_count(BMesh *bm, const char htype, const short oflag, BMElemF *ele_f; int i; - BLI_assert((unsigned int)test_for_enabled <= 1); - for (i = 0; i < 3; i++) { if (htype & flag_types[i]) { BM_ITER_MESH (ele_f, &iter, bm, iter_types[i]) { @@ -937,7 +935,6 @@ static void bmo_slot_buffer_from_flag(BMesh *bm, BMOperator *op, int totelement, i = 0; BLI_assert(op->slots_in == slot_args || op->slots_out == slot_args); - BLI_assert((unsigned int)test_for_enabled <= 1); if (test_for_enabled) totelement = BMO_mesh_enabled_flag_count(bm, htype, oflag); -- cgit v1.2.3