Cleanup: use const pointers, quiet cppcheck unreadVariable warning

This commit is contained in:
Campbell Barton
2024-04-17 11:36:38 +10:00
parent 8680976dc9
commit cf37424203
16 changed files with 24 additions and 20 deletions

View File

@@ -7900,7 +7900,7 @@ GHOST_TSuccess GHOST_SystemWayland::getCursorPositionClientRelative(const GHOST_
if (UNLIKELY(!seat)) {
return GHOST_kFailure;
}
GWL_SeatStatePointer *seat_state_pointer = gwl_seat_state_pointer_active(seat);
const GWL_SeatStatePointer *seat_state_pointer = gwl_seat_state_pointer_active(seat);
if (!seat_state_pointer || !seat_state_pointer->wl.surface_window) {
return GHOST_kFailure;
}
@@ -7934,7 +7934,7 @@ GHOST_TSuccess GHOST_SystemWayland::getCursorPosition(int32_t &x, int32_t &y) co
if (UNLIKELY(!seat)) {
return GHOST_kFailure;
}
GWL_SeatStatePointer *seat_state_pointer = gwl_seat_state_pointer_active(seat);
const GWL_SeatStatePointer *seat_state_pointer = gwl_seat_state_pointer_active(seat);
if (!seat_state_pointer) {
return GHOST_kFailure;
}

View File

@@ -2056,7 +2056,7 @@ GHOST_TSuccess GHOST_WindowWayland::setWindowCursorGrab(GHOST_TGrabCursorMode mo
#endif
GHOST_Rect bounds_buf;
GHOST_Rect *bounds = nullptr;
const GHOST_Rect *bounds = nullptr;
if (m_cursorGrab == GHOST_kGrabWrap) {
if (getCursorGrabBounds(bounds_buf) == GHOST_kFailure) {
getClientBounds(bounds_buf);

View File

@@ -150,7 +150,7 @@ static void addtail(volatile localListBase *listbase, void *vlink);
static void remlink(volatile localListBase *listbase, void *vlink);
static void rem_memblock(MemHead *memh);
static void MemorY_ErroR(const char *block, const char *error);
static const char *check_memlist(MemHead *memh);
static const char *check_memlist(const MemHead *memh);
/* --------------------------------------------------------------------- */
/* locally used defines */
@@ -235,7 +235,7 @@ static void mem_unlock_thread()
bool MEM_guarded_consistency_check()
{
const char *err_val = nullptr;
MemHead *listend;
const MemHead *listend;
/* check_memlist starts from the front, and runs until it finds
* the requested chunk. For this test, that's the last one. */
listend = static_cast<MemHead *>(membase->last);
@@ -1100,7 +1100,7 @@ static void MemorY_ErroR(const char *block, const char *error)
#endif
}
static const char *check_memlist(MemHead *memh)
static const char *check_memlist(const MemHead *memh)
{
MemHead *forw, *back, *forwok, *backok;
const char *name;

View File

@@ -1412,7 +1412,7 @@ static int ptcache_filepath(PTCacheID *pid,
const bool do_ext)
{
int len = 0;
char *idname;
const char *idname;
char *newname;
filepath[0] = '\0';
newname = filepath;
@@ -1444,6 +1444,7 @@ static int ptcache_filepath(PTCacheID *pid,
newname += temp;
len += temp;
}
UNUSED_VARS(newname);
if (do_ext) {
len += ptcache_filepath_ext_append(pid, filepath, size_t(len), true, cfra);

View File

@@ -88,7 +88,7 @@ size_t BLI_array_store_state_size_get(BArrayState *state);
/**
* Fill in existing allocated memory with the contents of \a state.
*/
void BLI_array_store_state_data_get(BArrayState *state, void *data);
void BLI_array_store_state_data_get(const BArrayState *state, void *data);
/**
* Allocate an array for \a state and return it.
*/

View File

@@ -1687,7 +1687,7 @@ size_t BLI_array_store_state_size_get(BArrayState *state)
return state->chunk_list->total_expanded_size;
}
void BLI_array_store_state_data_get(BArrayState *state, void *data)
void BLI_array_store_state_data_get(const BArrayState *state, void *data)
{
#ifdef USE_PARANOID_CHECKS
size_t data_test_len = 0;

View File

@@ -1971,7 +1971,7 @@ void sub_eul_euleul(float r_eul[3], float a[3], float b[3], const short order)
void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4])
{
float *t, *q, dscale[3], scale[3], basequat[4], mat3[3][3];
float dscale[3], scale[3], basequat[4], mat3[3][3];
float baseRS[4][4], baseinv[4][4], baseR[4][4], baseRinv[4][4];
float R[4][4], S[4][4];
@@ -2020,8 +2020,8 @@ void mat4_to_dquat(DualQuat *dq, const float basemat[4][4], const float mat[4][4
mat4_to_quat(dq->quat, R);
/* dual part */
t = R[3];
q = dq->quat;
const float *t = R[3];
const float *q = dq->quat;
dq->trans[0] = -0.5f * (t[0] * q[1] + t[1] * q[2] + t[2] * q[3]);
dq->trans[1] = 0.5f * (t[0] * q[0] + t[1] * q[3] - t[2] * q[2]);
dq->trans[2] = 0.5f * (-t[0] * q[3] + t[1] * q[0] + t[2] * q[1]);

View File

@@ -260,6 +260,7 @@ char *BLI_sprintfN_with_buffer(
retval = vsnprintf(result, size, format, args);
va_end(args);
BLI_assert((size_t)(retval + 1) == size);
UNUSED_VARS_NDEBUG(retval);
return result;
}

View File

@@ -1385,7 +1385,7 @@ BlendThumbnail *BLO_thumbnail_from_file(const char *filepath)
{
FileData *fd;
BlendThumbnail *data = nullptr;
int *fd_data;
const int *fd_data;
fd = blo_filedata_from_file_minimal(filepath);
fd_data = fd ? read_file_thumbnail(fd) : nullptr;

View File

@@ -5338,7 +5338,7 @@ void ui_draw_pie_center(uiBlock *block)
const float cx = block->pie_data.pie_center_spawned[0];
const float cy = block->pie_data.pie_center_spawned[1];
float *pie_dir = block->pie_data.pie_dir;
const float *pie_dir = block->pie_data.pie_dir;
const float pie_radius_internal = UI_SCALE_FAC * U.pie_menu_threshold;
const float pie_radius_external = UI_SCALE_FAC * (U.pie_menu_threshold + 7.0f);

View File

@@ -1514,7 +1514,7 @@ void UI_ThemeClearColor(int colorid)
int UI_ThemeMenuShadowWidth()
{
bTheme *btheme = UI_GetTheme();
const bTheme *btheme = UI_GetTheme();
return int(btheme->tui.menu_shadow_width * UI_SCALE_FAC);
}

View File

@@ -298,7 +298,7 @@ static void sequencer_sample_apply(bContext *C, wmOperator *op, const wmEvent *e
if (fx >= 0.0f && fy >= 0.0f && fx < ibuf->x && fy < ibuf->y) {
const float *fp;
uchar *cp;
const uchar *cp;
int x = int(fx), y = int(fy);
info->x = x;

View File

@@ -735,7 +735,7 @@ static int p_face_exists(ParamHandle *handle, const ParamKey *pvkeys, int i1, in
static bool p_edge_implicit_seam(PEdge *e, PEdge *ep)
{
float *uv1, *uv2, *uvp1, *uvp2;
const float *uv1, *uv2, *uvp1, *uvp2;
float limit[2];
limit[0] = 0.00001;
@@ -771,7 +771,7 @@ static bool p_edge_has_pair(ParamHandle *handle, PEdge *e, bool topology_from_uv
{
PHashKey key;
PEdge *pe;
PVert *v1, *v2;
const PVert *v1, *v2;
PHashKey key1 = e->vert->u.key;
PHashKey key2 = e->next->vert->u.key;

View File

@@ -70,7 +70,7 @@ static int imb_save_dpx_cineon(ImBuf *ibuf, const char *filepath, int use_cineon
LogImageFile *logImage;
float *fbuf;
float *fbuf_ptr;
uchar *rect_ptr;
const uchar *rect_ptr;
int x, y, depth, bitspersample, rvalue;
if (flags & IB_mem) {

View File

@@ -158,6 +158,7 @@ char *DNA_elem_id_rename(MemArena *mem_arena,
i += elem_full_tail_len;
}
BLI_assert((strlen(elem_dst_full) == elem_final_len) && (i == elem_final_len));
UNUSED_VARS_NDEBUG(i);
return elem_dst_full;
}

View File

@@ -310,7 +310,8 @@ static PyObject *bpyunits_to_string(PyObject * /*self*/, PyObject *args, PyObjec
* (spaces, trailing '\0'...).
* So in practice, 64 should be more than enough.
*/
char buf1[64], buf2[64], *str;
char buf1[64], buf2[64];
const char *str;
PyObject *result;
BKE_unit_value_as_string_adaptive(