diff --git a/source/blender/animrig/intern/action.cc b/source/blender/animrig/intern/action.cc index 75d71fe8c87..e96f6a62e06 100644 --- a/source/blender/animrig/intern/action.cc +++ b/source/blender/animrig/intern/action.cc @@ -172,7 +172,7 @@ static void array_shift_range( BLI_assert(to <= num + range_start - range_end); UNUSED_VARS_NDEBUG(num); - if (range_start == range_end || range_start == to) { + if (ELEM(range_start, range_end, to)) { return; } @@ -1928,7 +1928,7 @@ ID *action_slot_get_id_best_guess(Main &bmain, Slot &slot, ID *primary_id) { blender::Span users = slot.users(bmain); if (users.is_empty()) { - return 0; + return nullptr; } if (users.contains(primary_id)) { return primary_id; diff --git a/source/blender/blenloader/BLO_read_write.hh b/source/blender/blenloader/BLO_read_write.hh index 5bbd36a2ab2..56d6d5443fb 100644 --- a/source/blender/blenloader/BLO_read_write.hh +++ b/source/blender/blenloader/BLO_read_write.hh @@ -86,7 +86,7 @@ struct Main; /** * Mapping between names and ids. */ -int BLO_get_struct_id_by_name(BlendWriter *writer, const char *struct_name); +int BLO_get_struct_id_by_name(const BlendWriter *writer, const char *struct_name); #define BLO_get_struct_id(writer, struct_name) SDNA_TYPE_FROM_STRUCT(struct_name) /** @@ -146,7 +146,7 @@ void BLO_write_struct_array_at_address_by_id( * Write struct list. */ void BLO_write_struct_list_by_name(BlendWriter *writer, const char *struct_name, ListBase *list); -void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, ListBase *list); +void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, const ListBase *list); #define BLO_write_struct_list(writer, struct_name, list_ptr) \ BLO_write_struct_list_by_id(writer, BLO_get_struct_id(writer, struct_name), list_ptr) diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index d433f2e91b6..b5cedc1d1ab 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -1874,7 +1874,7 @@ void BLO_write_struct_array_at_address_by_id( writestruct_at_address_nr(writer->wd, BLO_CODE_DATA, struct_id, array_size, address, data_ptr); } -void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, ListBase *list) +void BLO_write_struct_list_by_id(BlendWriter *writer, int struct_id, const ListBase *list) { writelist_nr(writer->wd, BLO_CODE_DATA, struct_id, list); } @@ -1894,7 +1894,7 @@ void blo_write_id_struct(BlendWriter *writer, int struct_id, const void *id_addr writestruct_at_address_nr(writer->wd, GS(id->name), struct_id, 1, id_address, id); } -int BLO_get_struct_id_by_name(BlendWriter *writer, const char *struct_name) +int BLO_get_struct_id_by_name(const BlendWriter *writer, const char *struct_name) { int struct_id = DNA_struct_find_with_alias(writer->wd->sdna, struct_name); return struct_id; diff --git a/source/blender/editors/animation/anim_filter_test.cc b/source/blender/editors/animation/anim_filter_test.cc index 1aae9892912..20e456972de 100644 --- a/source/blender/editors/animation/anim_filter_test.cc +++ b/source/blender/editors/animation/anim_filter_test.cc @@ -95,12 +95,12 @@ TEST_F(ActionFilterTest, slots_expanded_or_not) ASSERT_NE(nullptr, fcu_cube_loc_y); /* Mock an bAnimContext for the Animation editor, with the above Animation showing. */ - SpaceAction saction = {0}; + SpaceAction saction = {nullptr}; saction.action = action; saction.action_slot_handle = slot_cube.handle; saction.ads.filterflag = ADS_FILTER_ALL_SLOTS; - bAnimContext ac = {0}; + bAnimContext ac = {nullptr}; ac.bmain = bmain; ac.datatype = ANIMCONT_ACTION; ac.data = action; @@ -249,12 +249,12 @@ TEST_F(ActionFilterTest, layered_action_active_fcurves) fcurve_other->flag &= ~FCURVE_ACTIVE; /* Mock an bAnimContext for the Action editor. */ - SpaceAction saction = {0}; + SpaceAction saction = {nullptr}; saction.action = action; saction.action_slot_handle = slot_cube.handle; saction.ads.filterflag = ADS_FILTER_ALL_SLOTS; - bAnimContext ac = {0}; + bAnimContext ac = {nullptr}; ac.bmain = bmain; ac.datatype = ANIMCONT_ACTION; ac.data = action; diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_image_render.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_image_render.cc index b2ea0652608..59dec75d0cb 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_image_render.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_image_render.cc @@ -551,7 +551,7 @@ void draw_grease_pencil_strokes(const RegionView3D &rv3d, mat->gp_style->mode) : GP_MATERIAL_MODE_LINE; - if (mat == 0 || (mat->gp_style->flag & GP_MATERIAL_HIDE)) { + if (mat == nullptr || (mat->gp_style->flag & GP_MATERIAL_HIDE)) { return; } diff --git a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc index a8f38c18782..e19638a71be 100644 --- a/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc +++ b/source/blender/editors/grease_pencil/intern/grease_pencil_utils.cc @@ -68,9 +68,7 @@ DrawingPlacement::DrawingPlacement(const Scene &scene, } /* Account for layer transform. */ - if (scene.toolsettings->gp_sculpt.lock_axis != GP_LOCKAXIS_VIEW && - scene.toolsettings->gp_sculpt.lock_axis != GP_LOCKAXIS_CURSOR) - { + if (!ELEM(scene.toolsettings->gp_sculpt.lock_axis, GP_LOCKAXIS_VIEW, GP_LOCKAXIS_CURSOR)) { /* Use the transpose inverse for normal. */ placement_normal_ = math::transform_direction(math::transpose(world_space_to_layer_space_), placement_normal_); @@ -154,7 +152,7 @@ DrawingPlacement::DrawingPlacement(const Scene &scene, } /* Account for layer transform. */ - if (reproject_mode != ReprojectMode::View && reproject_mode != ReprojectMode::Cursor) { + if (!ELEM(reproject_mode, ReprojectMode::View, ReprojectMode::Cursor)) { /* Use the transpose inverse for normal. */ placement_normal_ = math::transform_direction(math::transpose(world_space_to_layer_space_), placement_normal_); diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_grease_pencil_color.cc b/source/blender/editors/interface/eyedroppers/eyedropper_grease_pencil_color.cc index b720975f3c6..737bd7df500 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_grease_pencil_color.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_grease_pencil_color.cc @@ -323,7 +323,7 @@ static void eyedropper_gpencil_color_set(bContext *C, /* Convert from linear rgb space to display space because palette and brush colors are in display * space, and this conversion is needed to undo the conversion to linear performed by * eyedropper_color_sample_fl. */ - if ((eye->display) && (eye->mode == EyeMode::Palette || eye->mode == EyeMode::Brush)) { + if (eye->display && ELEM(eye->mode, EyeMode::Palette, EyeMode::Brush)) { IMB_colormanagement_scene_linear_to_display_v3(col_conv, eye->display); } diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 544e84b77a6..4b5a0ca0977 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -1976,7 +1976,7 @@ void ui_draw_but_CURVEPROFILE(ARegion *region, BLI_polyfill_calc(table_coords, tot_points, -1, tri_indices); /* Draw the triangles for the profile fill. */ - immUniformColor3ubvAlpha((const uchar *)wcol->item, 128); + immUniformColor3ubvAlpha(wcol->item, 128); GPU_blend(GPU_BLEND_ALPHA); GPU_polygon_smooth(false); immBegin(GPU_PRIM_TRIS, 3 * tot_triangles); diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index 25d2ec7e914..51142620c7f 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -1378,7 +1378,7 @@ static void svg_replace_color_attributes(std::string &svg, "{:02x}{:02x}{:02x}{:02x}", color[0], color[1], color[2], color[3]); size_t att_start = start; - while (1) { + while (true) { constexpr static blender::StringRef key = "fill=\""; att_start = svg.find(key, att_start); if (att_start == std::string::npos || att_start > end) { @@ -1392,7 +1392,7 @@ static void svg_replace_color_attributes(std::string &svg, } att_start = start; - while (1) { + while (true) { constexpr static blender::StringRef key = "fill:"; att_start = svg.find(key, att_start); if (att_start == std::string::npos || att_start > end) { @@ -1413,7 +1413,7 @@ static void icon_source_edit_cb(std::string &svg) /* Scan string, processing only groups with our keyword ids. */ - while (1) { + while (true) { /* Look for a blender id, quick exit if not found. */ constexpr static blender::StringRef key = "id=\""; const size_t id_start = svg.find(key + "blender_", g_start); diff --git a/source/blender/editors/sculpt_paint/grease_pencil_fill.cc b/source/blender/editors/sculpt_paint/grease_pencil_fill.cc index 0a224f98fd3..23f58e9648b 100644 --- a/source/blender/editors/sculpt_paint/grease_pencil_fill.cc +++ b/source/blender/editors/sculpt_paint/grease_pencil_fill.cc @@ -884,7 +884,7 @@ static rctf get_boundary_bounds(const ARegion ®ion, /* Check if the color is visible. */ const int material_index = materials[curve_i]; Material *mat = BKE_object_material_get(const_cast(&object), material_index + 1); - if (mat == 0 || (mat->gp_style->flag & GP_MATERIAL_HIDE)) { + if (mat == nullptr || (mat->gp_style->flag & GP_MATERIAL_HIDE)) { return; } diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 8250d127cba..eb24fa2511f 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -1321,7 +1321,7 @@ void restore_position_from_undo_step(const Depsgraph &depsgraph, Object &object) /* Because brush deformation is calculated for the evaluated deformed positions, * the translations have to be transformed to the original space. */ apply_crazyspace_to_translations(ss.deform_imats, verts, tls.translations); - if (active_key == nullptr || mesh.key->refkey == active_key) { + if (ELEM(active_key, nullptr, mesh.key->refkey)) { /* We only ever want to propagate changes back to the base mesh if we either have * no shape key active, or we are working on the basis shape key. * See #126199 for more information. */ diff --git a/source/blender/gpu/GPU_batch.hh b/source/blender/gpu/GPU_batch.hh index f80d1e954d7..d4fa6216edc 100644 --- a/source/blender/gpu/GPU_batch.hh +++ b/source/blender/gpu/GPU_batch.hh @@ -425,7 +425,7 @@ void GPU_batch_draw_parameter_get(blender::gpu::Batch *batch, /** * Return vertex range for this #blender::gpu::Batch when using primitive expansions. */ -blender::IndexRange GPU_batch_draw_expanded_parameter_get(blender::gpu::Batch *batch, +blender::IndexRange GPU_batch_draw_expanded_parameter_get(const blender::gpu::Batch *batch, GPUPrimType expanded_prim_type, int vertex_count, int vertex_first); diff --git a/source/blender/gpu/intern/gpu_batch.cc b/source/blender/gpu/intern/gpu_batch.cc index f3e63f67481..3bcda577f25 100644 --- a/source/blender/gpu/intern/gpu_batch.cc +++ b/source/blender/gpu/intern/gpu_batch.cc @@ -343,7 +343,7 @@ void GPU_batch_draw_parameter_get(Batch *gpu_batch, *r_instance_count = i_count; } -blender::IndexRange GPU_batch_draw_expanded_parameter_get(blender::gpu::Batch *batch, +blender::IndexRange GPU_batch_draw_expanded_parameter_get(const blender::gpu::Batch *batch, GPUPrimType expanded_prim_type, int vertex_count, int vertex_first) diff --git a/source/blender/gpu/opengl/gl_storage_buffer.cc b/source/blender/gpu/opengl/gl_storage_buffer.cc index e97bbd452e5..9acc67c3a04 100644 --- a/source/blender/gpu/opengl/gl_storage_buffer.cc +++ b/source/blender/gpu/opengl/gl_storage_buffer.cc @@ -232,7 +232,7 @@ void GLStorageBuf::read(void *data) /* Repeat until the data is ready. */ } glDeleteSync(read_fence_); - read_fence_ = 0; + read_fence_ = nullptr; memcpy(data, persistent_ptr_, size_in_bytes_); } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index fa5c7dc35b8..70bfcae2c43 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -1567,7 +1567,7 @@ static int imb_exr_split_channel_name(ExrChannel *echan, return 1; } -static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname) +static ExrLayer *imb_exr_get_layer(ListBase *lb, const char *layname) { ExrLayer *lay = (ExrLayer *)BLI_findstring(lb, layname, offsetof(ExrLayer, name)); @@ -1580,7 +1580,7 @@ static ExrLayer *imb_exr_get_layer(ListBase *lb, char *layname) return lay; } -static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname) +static ExrPass *imb_exr_get_pass(ListBase *lb, const char *passname) { ExrPass *pass = (ExrPass *)BLI_findstring(lb, passname, offsetof(ExrPass, name)); diff --git a/source/blender/imbuf/intern/scaling.cc b/source/blender/imbuf/intern/scaling.cc index fa4851e00ee..dcd2248828f 100644 --- a/source/blender/imbuf/intern/scaling.cc +++ b/source/blender/imbuf/intern/scaling.cc @@ -776,8 +776,7 @@ static void scale_bilinear_func( }); } -bool IMB_scale( - ImBuf *ibuf, unsigned int newx, unsigned int newy, IMBScaleFilter filter, bool threaded) +bool IMB_scale(ImBuf *ibuf, uint newx, uint newy, IMBScaleFilter filter, bool threaded) { BLI_assert_msg(newx > 0 && newy > 0, "Images must be at least 1 on both dimensions!"); if (ibuf == nullptr) { diff --git a/source/blender/imbuf/tests/performance/IMB_scaling_performance_test.cc b/source/blender/imbuf/tests/performance/IMB_scaling_performance_test.cc index 8542190db03..850187a3451 100644 --- a/source/blender/imbuf/tests/performance/IMB_scaling_performance_test.cc +++ b/source/blender/imbuf/tests/performance/IMB_scaling_performance_test.cc @@ -15,11 +15,11 @@ using namespace blender; static constexpr int SRC_X = 5123; static constexpr int SRC_Y = 4091; -static constexpr int DST_SMALLER_X = (int)(SRC_X * 0.21f); -static constexpr int DST_SMALLER_Y = (int)(SRC_Y * 0.67f); +static constexpr int DST_SMALLER_X = int(SRC_X * 0.21f); +static constexpr int DST_SMALLER_Y = int(SRC_Y * 0.67f); -static constexpr int DST_LARGER_X = (int)(SRC_X * 1.19f); -static constexpr int DST_LARGER_Y = (int)(SRC_Y * 2.13f); +static constexpr int DST_LARGER_X = int(SRC_X * 1.19f); +static constexpr int DST_LARGER_Y = int(SRC_Y * 2.13f); static ImBuf *create_src_image(bool use_float) { diff --git a/source/blender/io/grease_pencil/intern/grease_pencil_io.cc b/source/blender/io/grease_pencil/intern/grease_pencil_io.cc index 6391cb1e7d0..df3e6ccabd2 100644 --- a/source/blender/io/grease_pencil/intern/grease_pencil_io.cc +++ b/source/blender/io/grease_pencil/intern/grease_pencil_io.cc @@ -52,7 +52,7 @@ static float get_average(const Span values) static ColorGeometry4f get_average(const Span values) { if (values.is_empty()) { - return ColorGeometry4f(0); + return ColorGeometry4f(nullptr); } /* ColorGeometry4f does not support arithmetic directly. */ Span rgba_values = values.cast(); diff --git a/source/blender/io/grease_pencil/intern/grease_pencil_io_import_svg.cc b/source/blender/io/grease_pencil/intern/grease_pencil_io_import_svg.cc index b8c2242f493..a271023e7e1 100644 --- a/source/blender/io/grease_pencil/intern/grease_pencil_io_import_svg.cc +++ b/source/blender/io/grease_pencil/intern/grease_pencil_io_import_svg.cc @@ -286,7 +286,7 @@ bool SVGImporter::read(StringRefNull filepath) constexpr float svg_dpi = 96.0f; char abs_filepath[FILE_MAX]; - BLI_strncpy(abs_filepath, filepath.c_str(), sizeof(abs_filepath)); + STRNCPY(abs_filepath, filepath.c_str()); BLI_path_abs(abs_filepath, BKE_main_blendfile_path_from_global()); NSVGimage *svg_data = nullptr; diff --git a/source/blender/makesdna/intern/dna_genfile.cc b/source/blender/makesdna/intern/dna_genfile.cc index 537e7e68c58..62b3576442a 100644 --- a/source/blender/makesdna/intern/dna_genfile.cc +++ b/source/blender/makesdna/intern/dna_genfile.cc @@ -550,7 +550,7 @@ static bool init_structDNA(SDNA *sdna, bool do_endian_swap, const char **r_error const int mat4x4f_struct_index = DNA_struct_find_index_without_alias_ex( sdna, "mat4x4f", &dummy_index); if (mat4x4f_struct_index > 0) { - SDNA_Struct *struct_info = sdna->structs[mat4x4f_struct_index]; + const SDNA_Struct *struct_info = sdna->structs[mat4x4f_struct_index]; const int mat4x4f_type_index = struct_info->type_index; sdna->types_alignment[mat4x4f_type_index] = alignof(blender::float4x4); } diff --git a/source/blender/sequencer/intern/disk_cache.cc b/source/blender/sequencer/intern/disk_cache.cc index 61ad8b834e3..c1769066ef0 100644 --- a/source/blender/sequencer/intern/disk_cache.cc +++ b/source/blender/sequencer/intern/disk_cache.cc @@ -478,7 +478,9 @@ static size_t seq_disk_cache_write_header(FILE *file, const DiskCacheHeader *hea return fwrite(header, sizeof(*header), 1, file); } -static int seq_disk_cache_add_header_entry(SeqCacheKey *key, ImBuf *ibuf, DiskCacheHeader *header) +static int seq_disk_cache_add_header_entry(const SeqCacheKey *key, + ImBuf *ibuf, + DiskCacheHeader *header) { int i; uint64_t offset = sizeof(*header); @@ -528,7 +530,7 @@ static int seq_disk_cache_add_header_entry(SeqCacheKey *key, ImBuf *ibuf, DiskCa return i; } -static int seq_disk_cache_get_header_entry(SeqCacheKey *key, const DiskCacheHeader *header) +static int seq_disk_cache_get_header_entry(const SeqCacheKey *key, const DiskCacheHeader *header) { for (int i = 0; i < DCACHE_IMAGES_PER_FILE; i++) { if (header->entry[i].frameno == key->frame_index) { diff --git a/source/blender/sequencer/intern/effects.cc b/source/blender/sequencer/intern/effects.cc index 9c830c09223..36558619c88 100644 --- a/source/blender/sequencer/intern/effects.cc +++ b/source/blender/sequencer/intern/effects.cc @@ -960,7 +960,7 @@ static void do_blend_effect_float( } static void do_blend_effect_byte( - float fac, int x, int y, uchar *rect1, uchar *rect2, int btype, uchar *out) + float fac, int x, int y, const uchar *rect1, uchar *rect2, int btype, uchar *out) { switch (btype) { case SEQ_TYPE_ADD: diff --git a/source/blender/sequencer/intern/strip_retiming.cc b/source/blender/sequencer/intern/strip_retiming.cc index 0ad00e20253..6ce77fb31e0 100644 --- a/source/blender/sequencer/intern/strip_retiming.cc +++ b/source/blender/sequencer/intern/strip_retiming.cc @@ -415,7 +415,7 @@ void SEQ_retiming_remove_multiple_keys(Sequence *seq, } /* Sanitize keys to be removed. */ - keys_to_remove.remove_if([&](SeqRetimingKey *key) { + keys_to_remove.remove_if([&](const SeqRetimingKey *key) { return key->strip_frame_index == 0 || SEQ_retiming_is_last_key(seq, key) || SEQ_retiming_key_is_transition_type(key); });