From 4a6268e09221b0dc521b5c676b34c7918961258b Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 20 Sep 2025 16:26:42 +1000 Subject: [PATCH] Cleanup: various non functional changes for C++ --- intern/ghost/intern/GHOST_SystemWayland.cc | 3 +-- intern/guardedalloc/intern/mallocn_lockfree_impl.cc | 2 +- source/blender/blenkernel/intern/node.cc | 2 +- source/blender/blenloader/intern/versioning_500.cc | 2 +- source/blender/bmesh/tools/bmesh_bevel.cc | 4 ++-- source/blender/editors/mesh/editmesh_select.cc | 6 +++--- source/blender/imbuf/intern/openexr/openexr_api.cpp | 4 +--- source/blender/imbuf/movie/intern/movie_write.cc | 2 +- .../opencolorio/intern/libocio/libocio_colorspace.cc | 4 ++-- .../nodes/composite/nodes/node_composite_file_output.cc | 6 +++--- .../nodes/function/nodes/node_fn_string_to_value.cc | 2 +- source/blender/windowmanager/intern/wm_event_system.cc | 2 +- source/blender/windowmanager/intern/wm_window.cc | 8 ++++---- 13 files changed, 22 insertions(+), 25 deletions(-) diff --git a/intern/ghost/intern/GHOST_SystemWayland.cc b/intern/ghost/intern/GHOST_SystemWayland.cc index 494e46d9b7b..0ae5191ec3b 100644 --- a/intern/ghost/intern/GHOST_SystemWayland.cc +++ b/intern/ghost/intern/GHOST_SystemWayland.cc @@ -4706,8 +4706,7 @@ static void touch_seat_handle_frame(void *data, wl_touch * /*touch*/) seat->touch.wl.surface_window = nullptr; } - GHOST_ASSERT(touch_events_num <= sizeof(touch_events) / sizeof(touch_events[0]), - "Buffer overflow"); + GHOST_ASSERT(touch_events_num <= ARRAY_SIZE(touch_events), "Buffer overflow"); /* Ensure events are ordered in time. */ if (UNLIKELY(touch_events_num > 1)) { diff --git a/intern/guardedalloc/intern/mallocn_lockfree_impl.cc b/intern/guardedalloc/intern/mallocn_lockfree_impl.cc index a1528481a58..4e1746e746f 100644 --- a/intern/guardedalloc/intern/mallocn_lockfree_impl.cc +++ b/intern/guardedalloc/intern/mallocn_lockfree_impl.cc @@ -587,5 +587,5 @@ const char *MEM_lockfree_name_ptr(void *vmemh) return "MEM_lockfree_name_ptr(nullptr)"; } -void MEM_lockfree_name_ptr_set(void *UNUSED(vmemh), const char *UNUSED(str)) {} +void MEM_lockfree_name_ptr_set(void * /*vmemh*/, const char * /*str*/) {} #endif /* !NDEBUG */ diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 7cf9fd17734..4aae6f53806 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -516,7 +516,7 @@ static void node_foreach_working_space_color(ID *id, const IDTypeForeachColorFun NodeInputColor *input_color_storage = static_cast(node->storage); fn.single(input_color_storage->color); } - else if (node->type_legacy == TEX_NODE_VALTORGB || node->type_legacy == SH_NODE_VALTORGB) { + else if (ELEM(node->type_legacy, TEX_NODE_VALTORGB, SH_NODE_VALTORGB)) { ColorBand *coba = static_cast(node->storage); BKE_colorband_foreach_working_space_color(coba, fn); } diff --git a/source/blender/blenloader/intern/versioning_500.cc b/source/blender/blenloader/intern/versioning_500.cc index 4f7f66c59af..cb7f3fd4c30 100644 --- a/source/blender/blenloader/intern/versioning_500.cc +++ b/source/blender/blenloader/intern/versioning_500.cc @@ -1534,7 +1534,7 @@ static void do_version_file_output_node(bNode &node) char directory[FILE_MAX] = ""; char file_name[FILE_MAX] = ""; BLI_path_split_dir_file(data->directory, directory, FILE_MAX, file_name, FILE_MAX); - BLI_strncpy(data->directory, directory, FILE_MAX); + STRNCPY(data->directory, directory); data->file_name = BLI_strdup_null(file_name); data->items_count = BLI_listbase_count(&node.inputs); diff --git a/source/blender/bmesh/tools/bmesh_bevel.cc b/source/blender/bmesh/tools/bmesh_bevel.cc index 3255759f8a7..e1feb22e845 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.cc +++ b/source/blender/bmesh/tools/bmesh_bevel.cc @@ -823,7 +823,7 @@ static void bevel_merge_uvs(BevelParams *bp, BMesh *bm) float *luv = BM_ELEM_CD_GET_FLOAT_P(l, uv_data_offset); add_v2_v2(uv, luv); } - mul_v2_fl(uv, 1.0f / (float)num_uv_verts); + mul_v2_fl(uv, 1.0f / float(num_uv_verts)); for (BMLoop *l : uv_vert_bucket) { float *luv = BM_ELEM_CD_GET_FLOAT_P(l, uv_data_offset); copy_v2_v2(luv, uv); @@ -2536,7 +2536,7 @@ static void check_edge_data_seam_sharp_edges(BevVert *bv, int flag) static void bevel_extend_edge_data_ex(BevVert *bv, int flag) { - BLI_assert(flag == BM_ELEM_SEAM || flag == BM_ELEM_SMOOTH); + BLI_assert(ELEM(flag, BM_ELEM_SEAM, BM_ELEM_SMOOTH)); VMesh *vm = bv->vmesh; BoundVert *bcur = bv->vmesh->boundstart, *start = bcur; diff --git a/source/blender/editors/mesh/editmesh_select.cc b/source/blender/editors/mesh/editmesh_select.cc index 96f22bbadd4..3689fc8cf8a 100644 --- a/source/blender/editors/mesh/editmesh_select.cc +++ b/source/blender/editors/mesh/editmesh_select.cc @@ -4633,7 +4633,7 @@ static void walker_deselect_nth_vertex_chain(BMEditMesh *em, /* Find next vertex in the loop. */ BMVert *v_next = bm_step_to_next_selected_vert_in_chain(v_curr, v_prev); - if (v_next == nullptr || v_next == v_start) { + if (ELEM(v_next, nullptr, v_start)) { break; } @@ -4666,7 +4666,7 @@ static void walker_deselect_nth_edge_chain(BMEditMesh *em, /* Find next edge in the loop. */ BMEdge *e_next = bm_step_over_vert_to_next_selected_edge_in_chain(e_curr, v_through); - if (e_next == nullptr || e_next == e_start) { + if (ELEM(e_next, nullptr, e_start)) { break; } @@ -4698,7 +4698,7 @@ static void walker_deselect_nth_face_chain(BMEditMesh *em, BM_elem_select_set(bm, (BMElem *)f_curr, false); } - if (f_next == nullptr || f_next == f_start) { + if (ELEM(f_next, nullptr, f_start)) { break; } diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 253295b91e3..5ebf3f35983 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -512,9 +512,7 @@ static void openexr_header_metadata(Header *header, ImBuf *ibuf) LISTBASE_FOREACH (IDProperty *, prop, &ibuf->metadata->data.group) { /* Do not blindly pass along compression or colorInteropID, as they might have * changed and will already be written when appropriate. */ - if (prop->type == IDP_STRING && - !(STREQ(prop->name, "compression") || STREQ(prop->name, "colorInteropID"))) - { + if ((prop->type == IDP_STRING) && !STR_ELEM(prop->name, "compression", "colorInteropID")) { header->insert(prop->name, StringAttribute(IDP_string_get(prop))); } } diff --git a/source/blender/imbuf/movie/intern/movie_write.cc b/source/blender/imbuf/movie/intern/movie_write.cc index e17f8e4c455..36232cebf97 100644 --- a/source/blender/imbuf/movie/intern/movie_write.cc +++ b/source/blender/imbuf/movie/intern/movie_write.cc @@ -837,7 +837,7 @@ static void set_colorspace_options(AVCodecContext *c, blender::StringRefNull int c->color_trc = AVCOL_TRC_BT709; c->colorspace = AVCOL_SPC_BT709; } - else if (interop_id == "srgb_p3d65_display" || interop_id == "srgbx_p3d65_display") { + else if (ELEM(interop_id, "srgb_p3d65_display", "srgbx_p3d65_display")) { c->color_primaries = AVCOL_PRI_SMPTE432; /* This should be AVCOL_TRC_IEC61966_2_1, but Quicktime refuses to open the file. * And we're currently also writing srgb_rec709_display the same way. */ diff --git a/source/blender/imbuf/opencolorio/intern/libocio/libocio_colorspace.cc b/source/blender/imbuf/opencolorio/intern/libocio/libocio_colorspace.cc index e5eae8d6aa2..1a6045c4b84 100644 --- a/source/blender/imbuf/opencolorio/intern/libocio/libocio_colorspace.cc +++ b/source/blender/imbuf/opencolorio/intern/libocio/libocio_colorspace.cc @@ -164,13 +164,13 @@ LibOCIOColorSpace::LibOCIOColorSpace(const int index, else if (alias == "st2084_p3d65_display") { interop_id_ = "pq_p3d65_display"; } - else if (alias == "lin_rec709_srgb" || alias == "lin_rec709") { + else if (ELEM(alias, "lin_rec709_srgb", "lin_rec709")) { interop_id_ = "lin_rec709_scene"; } else if (alias == "lin_rec2020") { interop_id_ = "lin_rec2020_scene"; } - else if (alias == "lin_p3d65" || alias == "lin_displayp3") { + else if (ELEM(alias, "lin_p3d65", "lin_displayp3")) { interop_id_ = "lin_p3d65_scene"; } else if ((alias.startswith("lin_") || alias.startswith("srgb_") || alias.startswith("g18_") || diff --git a/source/blender/nodes/composite/nodes/node_composite_file_output.cc b/source/blender/nodes/composite/nodes/node_composite_file_output.cc index 7b66251a4ca..efef8268e87 100644 --- a/source/blender/nodes/composite/nodes/node_composite_file_output.cc +++ b/source/blender/nodes/composite/nodes/node_composite_file_output.cc @@ -120,7 +120,7 @@ static void node_init(const bContext *C, PointerRNA *node_pointer) Scene *scene = CTX_data_scene(C); if (scene) { const RenderData *render_data = &scene->r; - BLI_strncpy(data->directory, render_data->pic, FILE_MAX); + STRNCPY(data->directory, render_data->pic); } } @@ -173,7 +173,7 @@ static Vector compute_image_path(const StringRefNull dire char *r_image_path) { char base_path[FILE_MAX] = ""; - BLI_strncpy(base_path, directory.c_str(), FILE_MAX); + STRNCPY(base_path, directory.c_str()); const std::string full_file_name = file_name + file_name_suffix; BLI_path_append(base_path, FILE_MAX, full_file_name.c_str()); @@ -853,7 +853,7 @@ void FileOutputItemsAccessor::blend_read_data_item(BlendDataReader *reader, Item std::string FileOutputItemsAccessor::validate_name(const StringRef name) { char file_name[FILE_MAX] = ""; - BLI_strncpy(file_name, name.data(), FILE_MAX); + STRNCPY(file_name, name.data()); BLI_path_make_safe_filename(file_name); return file_name; } diff --git a/source/blender/nodes/function/nodes/node_fn_string_to_value.cc b/source/blender/nodes/function/nodes/node_fn_string_to_value.cc index 14c8c8e18d6..489e971551e 100644 --- a/source/blender/nodes/function/nodes/node_fn_string_to_value.cc +++ b/source/blender/nodes/function/nodes/node_fn_string_to_value.cc @@ -79,7 +79,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams ¶ms) } } else if (params.in_out() == SOCK_OUT) { - if (socket_type == SOCK_INT || socket_type == SOCK_BOOLEAN) { + if (ELEM(socket_type, SOCK_INT, SOCK_BOOLEAN)) { params.add_item(IFACE_("Value"), [](LinkSearchOpParams ¶ms) { bNode &node = params.add_node("FunctionNodeStringToValue"); node.custom1 = SOCK_INT; diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 5e19deacb23..97c885d9fad 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -746,7 +746,7 @@ void wm_event_do_notifiers(bContext *C) /* Pass. */ } else if (note->category == NC_SCENE && note->reference && - (note->reference != scene && note->reference != workspace->sequencer_scene)) + (!ELEM(note->reference, scene, workspace->sequencer_scene))) { /* Pass. */ } diff --git a/source/blender/windowmanager/intern/wm_window.cc b/source/blender/windowmanager/intern/wm_window.cc index e1f469938cb..75c8ce90425 100644 --- a/source/blender/windowmanager/intern/wm_window.cc +++ b/source/blender/windowmanager/intern/wm_window.cc @@ -1324,10 +1324,10 @@ wmWindow *WM_window_open_temp(bContext *C, const char *title, int space_type, bo const bool mm_placement = WM_capabilities_flag() & WM_CAPABILITY_MULTIMONITOR_PLACEMENT; if (bounds_valid && mm_placement) { - rect.xmin = (int)(stored_bounds->xmin * UI_SCALE_FAC); - rect.ymin = (int)(stored_bounds->ymin * UI_SCALE_FAC); - rect.xmax = (int)(stored_bounds->xmax * UI_SCALE_FAC); - rect.ymax = (int)(stored_bounds->ymax * UI_SCALE_FAC); + rect.xmin = int(stored_bounds->xmin * UI_SCALE_FAC); + rect.ymin = int(stored_bounds->ymin * UI_SCALE_FAC); + rect.xmax = int(stored_bounds->xmax * UI_SCALE_FAC); + rect.ymax = int(stored_bounds->ymax * UI_SCALE_FAC); align = WIN_ALIGN_ABSOLUTE; } else {