Cleanup: various non functional changes

- Use const arguments.
- Quiet unused assignment warnings.
- Use explicit cast to suppress CPPCHECK's truncLongCastReturn warning.
This commit is contained in:
Campbell Barton
2024-09-23 11:00:51 +10:00
parent a74ad65e8e
commit 7feccafbb0
8 changed files with 16 additions and 11 deletions

View File

@@ -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];

View File

@@ -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);
}

View File

@@ -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();
}

View File

@@ -161,8 +161,8 @@ class ConstPatchCoordWrapperBuffer : public RawDataWrapperVertexBuffer<const Pat
// Discriminators used in FaceVaryingVolatileEval in order to detect whether we are using adaptive
// patches as the CPU and OpenGL PatchTable have different APIs.
bool is_adaptive(CpuPatchTable *patch_table);
bool is_adaptive(GLPatchTable *patch_table);
bool is_adaptive(const CpuPatchTable *patch_table);
bool is_adaptive(const GLPatchTable *patch_table);
template<typename EVAL_VERTEX_BUFFER,
typename STENCIL_TABLE,

View File

@@ -293,7 +293,9 @@ static void *studiolight_multilayer_addlayer(void *base, const char * /*layer_na
/* Convert a multilayer pass to ImBuf channel 4 float buffer.
* NOTE: Parameter rect will become invalid. Do not use rect after calling this
* function */
static float *studiolight_multilayer_convert_pass(ImBuf *ibuf, float *rect, const uint channels)
static float *studiolight_multilayer_convert_pass(const ImBuf *ibuf,
float *rect,
const uint channels)
{
if (channels == 4) {
return rect;
@@ -487,7 +489,7 @@ static void studiolight_create_matcap_specular_gputexture(StudioLight *sl)
sl->flag |= 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);

View File

@@ -144,7 +144,8 @@ TRIVIAL_DEFAULT_INT_HASH(uint64_t);
template<> struct DefaultHash<float> {
uint64_t operator()(float value) const
{
return *reinterpret_cast<uint32_t *>(&value);
/* Explicit `uint64_t` cast to suppress CPPCHECK warning. */
return uint64_t(*reinterpret_cast<uint32_t *>(&value));
}
};

View File

@@ -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);

View File

@@ -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");
}