Cleanup: various non functional changes for C++

This commit is contained in:
Campbell Barton
2025-09-20 16:26:42 +10:00
parent 198eb638b2
commit 4a6268e092
13 changed files with 22 additions and 25 deletions

View File

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

View File

@@ -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 */

View File

@@ -516,7 +516,7 @@ static void node_foreach_working_space_color(ID *id, const IDTypeForeachColorFun
NodeInputColor *input_color_storage = static_cast<NodeInputColor *>(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<ColorBand *>(node->storage);
BKE_colorband_foreach_working_space_color(coba, fn);
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -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. */

View File

@@ -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_") ||

View File

@@ -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<path_templates::Error> 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;
}

View File

@@ -79,7 +79,7 @@ static void node_gather_link_searches(GatherLinkSearchOpParams &params)
}
}
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 &params) {
bNode &node = params.add_node("FunctionNodeStringToValue");
node.custom1 = SOCK_INT;

View File

@@ -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. */
}

View File

@@ -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 {