Cleanup: various cppcheck warnings

Avoid shadowing, use const args & match function & declaration args.
This commit is contained in:
Campbell Barton 2024-07-22 09:58:43 +10:00
parent f85c29dc5c
commit d3fbc56021
10 changed files with 25 additions and 18 deletions

View File

@ -949,7 +949,7 @@ void assert_baklava_phase_1_invariants(const Strip &strip);
* Creates a new `Action` that matches the old action but is converted to have layers.
* Returns a nullptr if the action is empty or already layered.
*/
Action *convert_to_layered_action(Main &bmain, const Action &action);
Action *convert_to_layered_action(Main &bmain, const Action &legacy_action);
/**
* Deselect the keys of all actions in the Span. Duplicate entries are only visited once.

View File

@ -84,7 +84,7 @@ static float from_16dot16(FT_Fixed value)
static GlyphCacheBLF *blf_glyph_cache_find(FontBLF *font)
{
for (std::unique_ptr<GlyphCacheBLF> &gc : font->cache) {
for (const std::unique_ptr<GlyphCacheBLF> &gc : font->cache) {
if (gc->size == font->size && (gc->bold == ((font->flags & BLF_BOLD) != 0)) &&
(gc->italic == ((font->flags & BLF_ITALIC) != 0)) &&
(gc->char_weight == font->char_weight) && (gc->char_slant == font->char_slant) &&

View File

@ -90,7 +90,7 @@ void BKE_camera_params_compute_viewplane(
/**
* Crop `viewplane` given the current resolution and a pixel region inside the view plane.
*/
void BKE_camera_params_crop_viewplane(rctf *viewplane, int winx, int winy, rcti *region);
void BKE_camera_params_crop_viewplane(rctf *viewplane, int winx, int winy, const rcti *region);
/**
* View-plane is assumed to be already computed.
*/

View File

@ -341,12 +341,12 @@ void BKE_libblock_free_data_py(ID *id);
* \param bmain: #Main database containing the freed #ID,
* can be NULL in case it's a temp ID outside of any #Main.
* \param idv: Pointer to ID to be freed.
* \param flag: Set of \a LIB_ID_FREE_... flags controlling/overriding usual freeing process,
* \param flag_orig: Set of \a LIB_ID_FREE_... flags controlling/overriding usual freeing process,
* 0 to get default safe behavior.
* \param use_flag_from_idtag: Still use freeing info flags from given #ID data-block,
* even if some overriding ones are passed in \a flag parameter.
*/
void BKE_id_free_ex(Main *bmain, void *idv, int flag, bool use_flag_from_idtag);
void BKE_id_free_ex(Main *bmain, void *idv, int flag_orig, bool use_flag_from_idtag);
/**
* Complete ID freeing, should be usable in most cases (even for out-of-Main IDs).
*

View File

@ -485,7 +485,7 @@ void BKE_camera_params_compute_viewplane(
params->viewplane = viewplane;
}
void BKE_camera_params_crop_viewplane(rctf *viewplane, int winx, int winy, rcti *region)
void BKE_camera_params_crop_viewplane(rctf *viewplane, int winx, int winy, const rcti *region)
{
float pix_size_x = BLI_rctf_size_x(viewplane) / winx;
float pix_size_y = BLI_rctf_size_y(viewplane) / winy;

View File

@ -4974,7 +4974,7 @@ blender::ImplicitSharingInfoAndData blo_read_shared_impl(
if (BLO_read_data_is_undo(reader)) {
if (reader->fd->flags & FD_FLAGS_IS_MEMFILE) {
UndoReader *undo_reader = reinterpret_cast<UndoReader *>(reader->fd->file);
MemFile &memfile = *undo_reader->memfile;
const MemFile &memfile = *undo_reader->memfile;
if (memfile.shared_storage) {
/* Check if the data was saved with sharing-info. */
if (const blender::ImplicitSharingInfo *sharing_info =

View File

@ -879,7 +879,6 @@ static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
if ((ob->adt) && (ob->adt->action)) {
AnimData *adt = ob->adt;
bAction *act = adt->action;
FCurve *fcu, *fcn;
const float cfra_unmap = BKE_nla_tweakedit_remap(adt, cfra, NLATIME_CONVERT_UNMAP);
Action &action = act->wrap();
@ -892,7 +891,8 @@ static int delete_key_v3d_without_keying_set(bContext *C, wmOperator *op)
}
}
else {
for (fcu = static_cast<FCurve *>(act->curves.first); fcu; fcu = fcn) {
FCurve *fcn;
for (FCurve *fcu = static_cast<FCurve *>(act->curves.first); fcu; fcu = fcn) {
fcn = fcu->next;
if (!can_delete_key(fcu, ob, op->reports)) {
continue;

View File

@ -237,12 +237,19 @@ static void screen_draw_area_icon(
if (bg_color) {
const float bg_width = UI_SCALE_FAC * 50.0f;
const float bg_height = UI_SCALE_FAC * 40.0f;
rctf rect = {center_x - (bg_width / 2.0f),
center_x + bg_width - (bg_width / 2.0f),
center_y - (bg_height / 2.0f),
center_y + bg_height - (bg_height / 2.0f)};
UI_draw_roundbox_4fv_ex(
&rect, bg_color, nullptr, 1.0f, outline ? outline : nullptr, U.pixelsize, 6 * U.pixelsize);
const rctf bg_rect = {
/*xmin*/ center_x - (bg_width / 2.0f),
/*xmax*/ center_x + bg_width - (bg_width / 2.0f),
/*ymin*/ center_y - (bg_height / 2.0f),
/*ymax*/ center_y + bg_height - (bg_height / 2.0f),
};
UI_draw_roundbox_4fv_ex(&bg_rect,
bg_color,
nullptr,
1.0f,
outline ? outline : nullptr,
U.pixelsize,
6 * U.pixelsize);
}
const float icon_size = 32.0f * UI_SCALE_FAC;

View File

@ -406,8 +406,8 @@ void AnimationImporter::Assign_transform_animations(
fcurve_deg_to_rad(fcu);
}
}
COLLADAFW::Rotate *rot = (COLLADAFW::Rotate *)transform;
COLLADABU::Math::Vector3 &axis = rot->getRotationAxis();
const COLLADAFW::Rotate *rot = (COLLADAFW::Rotate *)transform;
const COLLADABU::Math::Vector3 &axis = rot->getRotationAxis();
switch (binding->animationClass) {
case COLLADAFW::AnimationList::ANGLE: {

View File

@ -1106,7 +1106,7 @@ blender::Map<SeqRetimingKey *, Sequence *> SEQ_retiming_selection_get(const Edit
bool SEQ_retiming_selection_contains(const Editing *ed, const SeqRetimingKey *key)
{
LISTBASE_FOREACH (Sequence *, seq, ed->seqbasep) {
for (SeqRetimingKey &key_iter : SEQ_retiming_keys_get(seq)) {
for (const SeqRetimingKey &key_iter : SEQ_retiming_keys_get(seq)) {
if ((key_iter.flag & SEQ_KEY_SELECTED) != 0 && &key_iter == key) {
return true;
}