diff --git a/source/blender/animrig/intern/bone_collections.cc b/source/blender/animrig/intern/bone_collections.cc index 5aac2707eb1..825be048b4c 100644 --- a/source/blender/animrig/intern/bone_collections.cc +++ b/source/blender/animrig/intern/bone_collections.cc @@ -436,7 +436,7 @@ void ANIM_armature_bonecoll_active_name_set(bArmature *armature, const char *nam ANIM_armature_bonecoll_active_set(armature, bcoll); } -void ANIM_armature_bonecoll_active_runtime_refresh(struct bArmature *armature) +void ANIM_armature_bonecoll_active_runtime_refresh(bArmature *armature) { const std::string_view active_name = armature->active_collection_name; if (active_name.empty()) { @@ -1058,8 +1058,8 @@ static bool bcoll_list_contains(const ListBase /*BoneCollectionRef*/ *collection return false; } -bool ANIM_armature_bonecoll_contains_active_bone(const struct bArmature *armature, - const struct BoneCollection *bcoll) +bool ANIM_armature_bonecoll_contains_active_bone(const bArmature *armature, + const BoneCollection *bcoll) { if (armature->edbo) { if (!armature->act_edbone) { diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index 84578f7b8c8..516d12adaa6 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -4170,7 +4170,7 @@ static void node_replace_undefined_types(bNode *node) /* This type name is arbitrary, it just has to be unique enough to not match a future node * idname. Includes the old type identifier for debugging purposes. */ const std::string old_idname = node->idname; - BLI_snprintf(node->idname, sizeof(node->idname), "Undefined[%s]", old_idname.c_str()); + SNPRINTF(node->idname, "Undefined[%s]", old_idname.c_str()); node->typeinfo = &NodeTypeUndefined; } } diff --git a/source/blender/blenlib/intern/BLI_ghash_utils.cc b/source/blender/blenlib/intern/BLI_ghash_utils.cc index 5bebf71e41f..9376dae39a3 100644 --- a/source/blender/blenlib/intern/BLI_ghash_utils.cc +++ b/source/blender/blenlib/intern/BLI_ghash_utils.cc @@ -9,7 +9,7 @@ * (not its implementation). */ -#include +#include #include "MEM_guardedalloc.h" @@ -34,13 +34,13 @@ uint BLI_ghashutil_ptrhash(const void *key) { /* Based Python3.7's pointer hashing function. */ - size_t y = (size_t)key; + size_t y = size_t(key); /* bottom 3 or 4 bits are likely to be 0; rotate y by 4 to avoid * excessive hash collisions for dictionaries and sets */ /* NOTE: Unlike Python `sizeof(uint)` is used instead of `sizeof(void *)`, * Otherwise casting to 'uint' ignores the upper bits on 64bit platforms. */ - return (uint)(y >> 4) | ((uint)y << (sizeof(uint[8]) - 4)); + return uint(y >> 4) | (uint(y) << (sizeof(uint[8]) - 4)); } #endif bool BLI_ghashutil_ptrcmp(const void *a, const void *b) @@ -85,7 +85,7 @@ uint BLI_ghashutil_uinthash(uint key) uint BLI_ghashutil_inthash_p(const void *ptr) { - uintptr_t key = (uintptr_t)ptr; + uintptr_t key = uintptr_t(ptr); key += ~(key << 16); key ^= (key >> 5); @@ -94,12 +94,12 @@ uint BLI_ghashutil_inthash_p(const void *ptr) key += ~(key << 9); key ^= (key >> 17); - return (uint)(key & 0xffffffff); + return uint(key & 0xffffffff); } uint BLI_ghashutil_inthash_p_murmur(const void *ptr) { - uintptr_t key = (uintptr_t)ptr; + uintptr_t key = uintptr_t(ptr); return BLI_hash_mm2((const uchar *)&key, sizeof(key), 0); } @@ -125,7 +125,7 @@ uint BLI_ghashutil_strhash_n(const char *key, size_t n) uint h = 5381; for (p = (const signed char *)key; n-- && *p != '\0'; p++) { - h = (uint)((h << 5) + h) + (uint)*p; + h = uint((h << 5) + h) + uint(*p); } return h; @@ -136,7 +136,7 @@ uint BLI_ghashutil_strhash_p(const void *ptr) uint h = 5381; for (p = static_cast(ptr); *p != '\0'; p++) { - h = (uint)((h << 5) + h) + (uint)*p; + h = uint((h << 5) + h) + uint(*p); } return h; diff --git a/source/blender/blenlib/intern/convexhull_2d.cc b/source/blender/blenlib/intern/convexhull_2d.cc index e7c90eab60e..fe187f109f4 100644 --- a/source/blender/blenlib/intern/convexhull_2d.cc +++ b/source/blender/blenlib/intern/convexhull_2d.cc @@ -8,8 +8,8 @@ */ #include -#include -#include +#include +#include #include "MEM_guardedalloc.h" diff --git a/source/blender/blenlib/intern/hash_md5.cc b/source/blender/blenlib/intern/hash_md5.cc index 0388cfdd6a9..ed1e105420e 100644 --- a/source/blender/blenlib/intern/hash_md5.cc +++ b/source/blender/blenlib/intern/hash_md5.cc @@ -10,9 +10,9 @@ * according to the definition of MD5 in RFC 1321 from April 1992. */ -#include -#include -#include +#include +#include +#include #include #include "BLI_hash_md5.hh" /* own include */ @@ -78,7 +78,7 @@ struct md5_ctx { /* This array contains the bytes used to pad the buffer to the next 64-byte boundary. * (RFC 1321, 3.1: Step 1) */ -static const unsigned char fillbuf[64] = {0x80, 0 /* , 0, 0, ... */}; +static const uchar fillbuf[64] = {0x80, 0 /* , 0, 0, ... */}; /** * Initialize structure containing state of computation. @@ -383,12 +383,12 @@ void *BLI_hash_md5_buffer(const char *buffer, size_t len, void *resblock) char *BLI_hash_md5_to_hexdigest(const void *resblock, char r_hex_digest[33]) { static const char hex_map[17] = "0123456789abcdef"; - const unsigned char *p; + const uchar *p; char *q; short len; - for (q = r_hex_digest, p = (const unsigned char *)resblock, len = 0; len < 16; p++, len++) { - const unsigned char c = *p; + for (q = r_hex_digest, p = (const uchar *)resblock, len = 0; len < 16; p++, len++) { + const uchar c = *p; *q++ = hex_map[c >> 4]; *q++ = hex_map[c & 15]; } diff --git a/source/blender/blenlib/intern/hash_mm2a.cc b/source/blender/blenlib/intern/hash_mm2a.cc index 9af4b60c690..f8a26aad932 100644 --- a/source/blender/blenlib/intern/hash_mm2a.cc +++ b/source/blender/blenlib/intern/hash_mm2a.cc @@ -45,7 +45,7 @@ static void mm2a_mix_tail(BLI_HashMurmur2A *mm2, const uchar **data, size_t *len) { while (*len && ((*len < 4) || mm2->count)) { - mm2->tail |= (uint32_t)(**data) << (mm2->count * 8); + mm2->tail |= uint32_t(**data) << (mm2->count * 8); mm2->count++; (*len)--; @@ -69,7 +69,7 @@ void BLI_hash_mm2a_init(BLI_HashMurmur2A *mm2, uint32_t seed) void BLI_hash_mm2a_add(BLI_HashMurmur2A *mm2, const uchar *data, size_t len) { - mm2->size += (uint32_t)len; + mm2->size += uint32_t(len); mm2a_mix_tail(mm2, &data, &len); diff --git a/source/blender/blenlib/intern/math_rotation.c b/source/blender/blenlib/intern/math_rotation.c index 04fc61f2dd6..d3d47dd847a 100644 --- a/source/blender/blenlib/intern/math_rotation.c +++ b/source/blender/blenlib/intern/math_rotation.c @@ -1034,7 +1034,7 @@ void sin_cos_from_fraction(int numerator, int denominator, float *r_sin, float * BLI_assert(-denominator / 4 <= numerator); /* Numerator may be negative. */ BLI_assert(numerator <= denominator / 4); - BLI_assert(cos_sign == -1.0f || cos_sign == 1.0f); + BLI_assert(ELEM(cos_sign, -1.0f, 1.0f)); const float angle = (float)(2.0 * M_PI) * ((float)numerator / (float)denominator); *r_sin = sinf(angle); diff --git a/source/blender/blenlib/tests/BLI_math_interp_test.cc b/source/blender/blenlib/tests/BLI_math_interp_test.cc index 0ce66170467..fa09dcdc884 100644 --- a/source/blender/blenlib/tests/BLI_math_interp_test.cc +++ b/source/blender/blenlib/tests/BLI_math_interp_test.cc @@ -13,7 +13,7 @@ using namespace blender::math; static constexpr float float_tolerance = 0.00005f; static constexpr int image_width = 3; static constexpr int image_height = 3; -static constexpr unsigned char image_char[image_height][image_width][4] = { +static constexpr uchar image_char[image_height][image_width][4] = { {{255, 254, 217, 216}, {230, 230, 230, 230}, {240, 160, 90, 20}}, {{0, 1, 2, 3}, {62, 72, 82, 92}, {126, 127, 128, 129}}, {{1, 2, 3, 4}, {73, 108, 153, 251}, {128, 129, 130, 131}}, diff --git a/source/blender/blenloader/intern/versioning_400.cc b/source/blender/blenloader/intern/versioning_400.cc index 0a05db636a4..f25fb33a087 100644 --- a/source/blender/blenloader/intern/versioning_400.cc +++ b/source/blender/blenloader/intern/versioning_400.cc @@ -2882,7 +2882,7 @@ void blo_do_versions_400(FileData *fd, Library * /*lib*/, Main *bmain) /* Keep point/spot light soft falloff for files created before 4.0. */ if (!MAIN_VERSION_FILE_ATLEAST(bmain, 400, 0)) { LISTBASE_FOREACH (Light *, light, &bmain->lights) { - if (light->type == LA_LOCAL || light->type == LA_SPOT) { + if (ELEM(light->type, LA_LOCAL, LA_SPOT)) { light->mode |= LA_USE_SOFT_FALLOFF; } } diff --git a/source/blender/bmesh/intern/bmesh_mesh_debug.cc b/source/blender/bmesh/intern/bmesh_mesh_debug.cc index b3671991886..de4a81e52ce 100644 --- a/source/blender/bmesh/intern/bmesh_mesh_debug.cc +++ b/source/blender/bmesh/intern/bmesh_mesh_debug.cc @@ -13,7 +13,7 @@ #ifndef NDEBUG -# include +# include # include "MEM_guardedalloc.h" diff --git a/source/blender/bmesh/intern/bmesh_polygon_edgenet.cc b/source/blender/bmesh/intern/bmesh_polygon_edgenet.cc index 0351f136050..5e5aa0fbfd7 100644 --- a/source/blender/bmesh/intern/bmesh_polygon_edgenet.cc +++ b/source/blender/bmesh/intern/bmesh_polygon_edgenet.cc @@ -1642,7 +1642,7 @@ finally: /* Sanity check: ensure we don't have connecting edges before splicing begins. */ # ifndef NDEBUG { - struct TempVertPair *tvp = temp_vert_pairs.list; + TempVertPair *tvp = temp_vert_pairs.list; do { /* We must _never_ create connections here * (in case the islands can't have a connection at all). */ diff --git a/source/blender/depsgraph/intern/depsgraph_tag.cc b/source/blender/depsgraph/intern/depsgraph_tag.cc index f5a02a2ef50..aec567019e7 100644 --- a/source/blender/depsgraph/intern/depsgraph_tag.cc +++ b/source/blender/depsgraph/intern/depsgraph_tag.cc @@ -840,7 +840,7 @@ void DEG_id_tag_update_ex(Main *bmain, ID *id, uint flags) deg::id_tag_update(bmain, id, flags, deg::DEG_UPDATE_SOURCE_USER_EDIT); } -void DEG_id_tag_update_for_side_effect_request(Depsgraph *depsgraph, ID *id, unsigned int flags) +void DEG_id_tag_update_for_side_effect_request(Depsgraph *depsgraph, ID *id, uint flags) { BLI_assert(depsgraph != nullptr); BLI_assert(id != nullptr); diff --git a/source/blender/draw/engines/eevee/eevee_shadows_cube.cc b/source/blender/draw/engines/eevee/eevee_shadows_cube.cc index 846d33c5f6a..091ee9b527f 100644 --- a/source/blender/draw/engines/eevee/eevee_shadows_cube.cc +++ b/source/blender/draw/engines/eevee/eevee_shadows_cube.cc @@ -189,13 +189,13 @@ void EEVEE_shadows_draw_cubemap(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, for (int j = 0; j < 6; j++) { /* Optimization: Only render the needed faces. */ /* Skip all but -Z face. */ - if ((evli->light_type == LA_SPOT || evli->light_type == LAMPTYPE_SPOT_DISK) && j != 5 && + if ((ELEM(evli->light_type, LA_SPOT, LAMPTYPE_SPOT_DISK)) && j != 5 && spot_angle_fit_single_face(evli)) { continue; } /* Skip +Z face. */ - if (!(evli->light_type == LA_LOCAL || evli->light_type == LAMPTYPE_OMNI_DISK) && j == 4) { + if (!(ELEM(evli->light_type, LA_LOCAL, LAMPTYPE_OMNI_DISK)) && j == 4) { continue; } /* TODO(fclem): some cube sides can be invisible in the main views. Cull them. */ diff --git a/source/blender/editors/space_sequencer/sequencer_preview_draw.cc b/source/blender/editors/space_sequencer/sequencer_preview_draw.cc index db46c2dc18e..95291a366dc 100644 --- a/source/blender/editors/space_sequencer/sequencer_preview_draw.cc +++ b/source/blender/editors/space_sequencer/sequencer_preview_draw.cc @@ -556,7 +556,7 @@ static void draw_histogram(ARegion *region, /* Label. */ char buf[10]; - BLI_snprintf(buf, sizeof(buf), "%.2f", val); + SNPRINTF(buf, "%.2f", val); size_t buf_len = strlen(buf); float text_width, text_height; diff --git a/source/blender/io/usd/intern/usd_skel_convert.cc b/source/blender/io/usd/intern/usd_skel_convert.cc index eec6e62fa88..4496d145565 100644 --- a/source/blender/io/usd/intern/usd_skel_convert.cc +++ b/source/blender/io/usd/intern/usd_skel_convert.cc @@ -1311,7 +1311,7 @@ void export_deform_verts(const Mesh *mesh, continue; } - int def_nr = static_cast(vert.dw[j].def_nr); + int def_nr = int(vert.dw[j].def_nr); if (def_nr >= joint_index.size()) { BLI_assert_unreachable();