From 7feccafbb0d68bd53c4bbdfe8e153055e3cfb38a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Mon, 23 Sep 2024 11:00:51 +1000 Subject: [PATCH] Cleanup: various non functional changes - Use const arguments. - Quiet unused assignment warnings. - Use explicit cast to suppress CPPCHECK's truncLongCastReturn warning. --- intern/dualcon/intern/dualcon_c_api.cpp | 4 ++-- intern/ghost/intern/GHOST_SystemWayland.cc | 2 +- intern/opensubdiv/internal/evaluator/eval_output.cc | 4 ++-- intern/opensubdiv/internal/evaluator/eval_output.h | 4 ++-- source/blender/blenkernel/intern/studiolight.cc | 6 ++++-- source/blender/blenlib/BLI_hash.hh | 3 ++- source/blender/blenlib/intern/array_store.cc | 2 ++ source/blender/blenlib/intern/buffer.c | 2 +- 8 files changed, 16 insertions(+), 11 deletions(-) diff --git a/intern/dualcon/intern/dualcon_c_api.cpp b/intern/dualcon/intern/dualcon_c_api.cpp index a9cf590cb18..73b582600c4 100644 --- a/intern/dualcon/intern/dualcon_c_api.cpp +++ b/intern/dualcon/intern/dualcon_c_api.cpp @@ -79,7 +79,7 @@ class DualConInputReader : public ModelReader { Triangle *t = new Triangle(); - unsigned int *tr = GET_TRI(input_mesh, curtri); + const unsigned int *tr = GET_TRI(input_mesh, curtri); veccopy(t->vt[0], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[0]))); veccopy(t->vt[1], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[1]))); veccopy(t->vt[2], GET_CO(input_mesh, GET_LOOP(input_mesh, tr[2]))); @@ -104,7 +104,7 @@ class DualConInputReader : public ModelReader { return 0; } - unsigned int *tr = GET_TRI(input_mesh, curtri); + const unsigned int *tr = GET_TRI(input_mesh, curtri); t[0] = tr[0]; t[1] = tr[1]; t[2] = tr[2]; diff --git a/intern/ghost/intern/GHOST_SystemWayland.cc b/intern/ghost/intern/GHOST_SystemWayland.cc index f9a04ca2882..1d6cc37bf19 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cc +++ b/intern/ghost/intern/GHOST_SystemWayland.cc @@ -4305,7 +4305,7 @@ static void gesture_pinch_handle_begin(void *data, /* Reset defaults. */ seat->pointer_gesture_pinch = GWL_SeatStatePointerGesture_Pinch{}; - GHOST_WindowWayland *win = nullptr; + const GHOST_WindowWayland *win = nullptr; if (wl_surface *wl_surface_focus = seat->pointer.wl.surface_window) { win = ghost_wl_surface_user_data(wl_surface_focus); } diff --git a/intern/opensubdiv/internal/evaluator/eval_output.cc b/intern/opensubdiv/internal/evaluator/eval_output.cc index 5efc13b3f39..86ea03e67fa 100644 --- a/intern/opensubdiv/internal/evaluator/eval_output.cc +++ b/intern/opensubdiv/internal/evaluator/eval_output.cc @@ -7,12 +7,12 @@ #include "internal/evaluator/eval_output.h" namespace blender::opensubdiv { -bool is_adaptive(CpuPatchTable *patch_table) +bool is_adaptive(const CpuPatchTable *patch_table) { return patch_table->GetPatchArrayBuffer()[0].GetDescriptor().IsAdaptive(); } -bool is_adaptive(GLPatchTable *patch_table) +bool is_adaptive(const GLPatchTable *patch_table) { return patch_table->GetPatchArrays()[0].GetDescriptor().IsAdaptive(); } diff --git a/intern/opensubdiv/internal/evaluator/eval_output.h b/intern/opensubdiv/internal/evaluator/eval_output.h index dd3fc11c61c..168d461d90b 100644 --- a/intern/opensubdiv/internal/evaluator/eval_output.h +++ b/intern/opensubdiv/internal/evaluator/eval_output.h @@ -161,8 +161,8 @@ class ConstPatchCoordWrapperBuffer : public RawDataWrapperVertexBufferflag |= STUDIOLIGHT_MATCAP_SPECULAR_GPUTEXTURE; } -static float4 studiolight_calculate_radiance(ImBuf *ibuf, const float direction[3]) +static float4 studiolight_calculate_radiance(const ImBuf *ibuf, const float direction[3]) { float uv[2]; direction_to_equirect(uv, direction); diff --git a/source/blender/blenlib/BLI_hash.hh b/source/blender/blenlib/BLI_hash.hh index f582a89fb1c..d16328cc819 100644 --- a/source/blender/blenlib/BLI_hash.hh +++ b/source/blender/blenlib/BLI_hash.hh @@ -144,7 +144,8 @@ TRIVIAL_DEFAULT_INT_HASH(uint64_t); template<> struct DefaultHash { uint64_t operator()(float value) const { - return *reinterpret_cast(&value); + /* Explicit `uint64_t` cast to suppress CPPCHECK warning. */ + return uint64_t(*reinterpret_cast(&value)); } }; diff --git a/source/blender/blenlib/intern/array_store.cc b/source/blender/blenlib/intern/array_store.cc index babc30b41ca..9902072ef7a 100644 --- a/source/blender/blenlib/intern/array_store.cc +++ b/source/blender/blenlib/intern/array_store.cc @@ -1452,6 +1452,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info, } BLI_assert(i_prev == data_len); + UNUSED_VARS_NDEBUG(i_prev); #ifdef USE_FASTPATH_CHUNKS_LAST if (chunk_list_reference_last != nullptr) { @@ -1472,6 +1473,7 @@ static BChunkList *bchunk_list_from_data_merge(const BArrayInfo *info, #undef data_len_original BLI_assert(i_prev == data_len_original); + UNUSED_VARS_NDEBUG(i_prev); /* Check we're the correct size and that we didn't accidentally modify the reference. */ ASSERT_CHUNKLIST_SIZE(chunk_list, data_len_original); diff --git a/source/blender/blenlib/intern/buffer.c b/source/blender/blenlib/intern/buffer.c index 5519a5bc418..04013063115 100644 --- a/source/blender/blenlib/intern/buffer.c +++ b/source/blender/blenlib/intern/buffer.c @@ -38,7 +38,7 @@ #include "BLI_strict_flags.h" /* Keep last. */ -static void *buffer_alloc(BLI_Buffer *buffer, const size_t len) +static void *buffer_alloc(const BLI_Buffer *buffer, const size_t len) { return MEM_mallocN(buffer->elem_size * len, "BLI_Buffer.data"); }