diff --git a/intern/cycles/integrator/pass_accessor_gpu.cpp b/intern/cycles/integrator/pass_accessor_gpu.cpp index 9d109235717..2353d65c34c 100644 --- a/intern/cycles/integrator/pass_accessor_gpu.cpp +++ b/intern/cycles/integrator/pass_accessor_gpu.cpp @@ -14,7 +14,6 @@ PassAccessorGPU::PassAccessorGPU(DeviceQueue *queue, float exposure, int num_samples) : PassAccessor(pass_access_info, exposure, num_samples), queue_(queue) - { } diff --git a/source/blender/asset_system/tests/asset_library_service_test.cc b/source/blender/asset_system/tests/asset_library_service_test.cc index 56955c5fb95..dbe765a0b75 100644 --- a/source/blender/asset_system/tests/asset_library_service_test.cc +++ b/source/blender/asset_system/tests/asset_library_service_test.cc @@ -123,7 +123,7 @@ TEST_F(AssetLibraryServiceTest, library_from_reference) Main dummy_main{}; std::string dummy_filepath = asset_library_root_ + SEP + "dummy.blend"; - BLI_strncpy(dummy_main.filepath, dummy_filepath.c_str(), sizeof(dummy_main.filepath)); + STRNCPY(dummy_main.filepath, dummy_filepath.c_str()); EXPECT_EQ(lib, service->get_asset_library(&dummy_main, ref)) << "Getting the local (current file) reference with a main saved on disk should return " "the an asset library for this directory"; diff --git a/source/blender/blenkernel/BKE_idprop.h b/source/blender/blenkernel/BKE_idprop.h index 2441234d806..e8fd3580631 100644 --- a/source/blender/blenkernel/BKE_idprop.h +++ b/source/blender/blenkernel/BKE_idprop.h @@ -252,25 +252,15 @@ void IDP_Reset(struct IDProperty *prop, const struct IDProperty *reference); /* C11 const correctness for casts */ #if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) # define IDP_Float(prop) \ - _Generic((prop), \ - struct IDProperty *: (*(float *)&(prop)->data.val), \ - const struct IDProperty *: (*(const float *)&(prop)->data.val)) + _Generic((prop), struct IDProperty * : (*(float *)&(prop)->data.val), const struct IDProperty * : (*(const float *)&(prop)->data.val)) # define IDP_Double(prop) \ - _Generic((prop), \ - struct IDProperty *: (*(double *)&(prop)->data.val), \ - const struct IDProperty *: (*(const double *)&(prop)->data.val)) + _Generic((prop), struct IDProperty * : (*(double *)&(prop)->data.val), const struct IDProperty * : (*(const double *)&(prop)->data.val)) # define IDP_String(prop) \ - _Generic((prop), \ - struct IDProperty *: ((char *) (prop)->data.pointer), \ - const struct IDProperty *: ((const char *) (prop)->data.pointer)) + _Generic((prop), struct IDProperty * : ((char *)(prop)->data.pointer), const struct IDProperty * : ((const char *)(prop)->data.pointer)) # define IDP_IDPArray(prop) \ - _Generic((prop), \ - struct IDProperty *: ((struct IDProperty *) (prop)->data.pointer), \ - const struct IDProperty *: ((const struct IDProperty *) (prop)->data.pointer)) + _Generic((prop), struct IDProperty * : ((struct IDProperty *)(prop)->data.pointer), const struct IDProperty * : ((const struct IDProperty *)(prop)->data.pointer)) # define IDP_Id(prop) \ - _Generic((prop), \ - struct IDProperty *: ((ID *) (prop)->data.pointer), \ - const struct IDProperty *: ((const ID *) (prop)->data.pointer)) + _Generic((prop), struct IDProperty * : ((ID *)(prop)->data.pointer), const struct IDProperty * : ((const ID *)(prop)->data.pointer)) #else # define IDP_Float(prop) (*(float *)&(prop)->data.val) # define IDP_Double(prop) (*(double *)&(prop)->data.val) diff --git a/source/blender/blenkernel/intern/DerivedMesh.cc b/source/blender/blenkernel/intern/DerivedMesh.cc index 13f43b43a74..83874191f84 100644 --- a/source/blender/blenkernel/intern/DerivedMesh.cc +++ b/source/blender/blenkernel/intern/DerivedMesh.cc @@ -500,7 +500,7 @@ static void mesh_calc_finalize(const Mesh *mesh_input, Mesh *mesh_eval) { /* Make sure the name is the same. This is because mesh allocation from template does not * take care of naming. */ - BLI_strncpy(mesh_eval->id.name, mesh_input->id.name, sizeof(mesh_eval->id.name)); + STRNCPY(mesh_eval->id.name, mesh_input->id.name); /* Make evaluated mesh to share same edit mesh pointer as original and copied meshes. */ mesh_eval->edit_mesh = mesh_input->edit_mesh; } diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c index 7c6c97db73b..8f4f54a1b6c 100644 --- a/source/blender/blenkernel/intern/action.c +++ b/source/blender/blenkernel/intern/action.c @@ -422,7 +422,7 @@ bActionGroup *action_groups_add_new(bAction *act, const char name[]) /* make it selected, with default name */ agrp->flag = AGRP_SELECTED; - BLI_strncpy(agrp->name, name[0] ? name : DATA_("Group"), sizeof(agrp->name)); + STRNCPY(agrp->name, name[0] ? name : DATA_("Group")); /* add to action, and validate */ BLI_addtail(&act->groups, agrp); @@ -645,7 +645,7 @@ bPoseChannel *BKE_pose_channel_ensure(bPose *pose, const char *name) BKE_pose_channel_session_uuid_generate(chan); - BLI_strncpy(chan->name, name, sizeof(chan->name)); + STRNCPY(chan->name, name); copy_v3_fl(chan->custom_scale_xyz, 1.0f); zero_v3(chan->custom_translation); @@ -1273,7 +1273,7 @@ bActionGroup *BKE_pose_add_group(bPose *pose, const char *name) } grp = MEM_callocN(sizeof(bActionGroup), "PoseGroup"); - BLI_strncpy(grp->name, name, sizeof(grp->name)); + STRNCPY(grp->name, name); BLI_addtail(&pose->agroups, grp); BLI_uniquename(&pose->agroups, grp, name, '.', offsetof(bActionGroup, name), sizeof(grp->name)); @@ -1772,10 +1772,10 @@ void what_does_obaction(Object *ob, } } - BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); + STRNCPY(workob->parsubstr, ob->parsubstr); /* we don't use real object name, otherwise RNA screws with the real thing */ - BLI_strncpy(workob->id.name, "OB", sizeof(workob->id.name)); + STRNCPY(workob->id.name, "OB"); /* If we're given a group to use, it's likely to be more efficient * (though a bit more dangerous). */ diff --git a/source/blender/blenkernel/intern/addon.c b/source/blender/blenkernel/intern/addon.c index 65a958a1c51..3d2dce0e004 100644 --- a/source/blender/blenkernel/intern/addon.c +++ b/source/blender/blenkernel/intern/addon.c @@ -46,7 +46,7 @@ bAddon *BKE_addon_ensure(ListBase *addon_list, const char *module) bAddon *addon = BKE_addon_find(addon_list, module); if (addon == NULL) { addon = BKE_addon_new(); - BLI_strncpy(addon->module, module, sizeof(addon->module)); + STRNCPY(addon->module, module); BLI_addtail(addon_list, addon); } return addon; diff --git a/source/blender/blenkernel/intern/anim_data.c b/source/blender/blenkernel/intern/anim_data.c index a0643061a6d..012c9d71c23 100644 --- a/source/blender/blenkernel/intern/anim_data.c +++ b/source/blender/blenkernel/intern/anim_data.c @@ -767,7 +767,7 @@ static bool fcurves_path_rename_fix(ID *owner_id, bActionGroup *agrp = fcu->grp; is_changed = true; if (oldName != NULL && (agrp != NULL) && STREQ(oldName, agrp->name)) { - BLI_strncpy(agrp->name, newName, sizeof(agrp->name)); + STRNCPY(agrp->name, newName); } } } @@ -819,7 +819,7 @@ static bool drivers_path_rename_fix(ID *owner_id, (dtar->pchan_name[0]) && STREQ(oldName, dtar->pchan_name)) { is_changed = true; - BLI_strncpy(dtar->pchan_name, newName, sizeof(dtar->pchan_name)); + STRNCPY(dtar->pchan_name, newName); } } } diff --git a/source/blender/blenkernel/intern/anim_sys.c b/source/blender/blenkernel/intern/anim_sys.c index 4154c7b84db..f47c5199794 100644 --- a/source/blender/blenkernel/intern/anim_sys.c +++ b/source/blender/blenkernel/intern/anim_sys.c @@ -131,12 +131,8 @@ KeyingSet *BKE_keyingset_add( /* allocate new KeyingSet */ ks = MEM_callocN(sizeof(KeyingSet), "KeyingSet"); - BLI_strncpy(ks->idname, - (idname) ? idname : - (name) ? name : - DATA_("KeyingSet"), - sizeof(ks->idname)); - BLI_strncpy(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set"), sizeof(ks->name)); + STRNCPY(ks->idname, (idname) ? idname : (name) ? name : DATA_("KeyingSet")); + STRNCPY(ks->name, (name) ? name : (idname) ? idname : DATA_("Keying Set")); ks->flag = flag; ks->keyingflag = keyingflag; @@ -193,7 +189,7 @@ KS_Path *BKE_keyingset_add_path(KeyingSet *ks, /* just store absolute info */ ksp->id = id; if (group_name) { - BLI_strncpy(ksp->group, group_name, sizeof(ksp->group)); + STRNCPY(ksp->group, group_name); } else { ksp->group[0] = '\0'; diff --git a/source/blender/blenkernel/intern/appdir.c b/source/blender/blenkernel/intern/appdir.c index cbe00b12e21..b78c9bf5d04 100644 --- a/source/blender/blenkernel/intern/appdir.c +++ b/source/blender/blenkernel/intern/appdir.c @@ -115,7 +115,7 @@ static char *blender_version_decimal(const int version) { static char version_str[5]; BLI_assert(version < 1000); - BLI_snprintf(version_str, sizeof(version_str), "%d.%d", version / 100, version % 100); + SNPRINTF(version_str, "%d.%d", version / 100, version % 100); return version_str; } @@ -480,7 +480,7 @@ static bool get_path_user_ex(char *targetpath, const char *user_base_path = GHOST_getUserDir(version, blender_version_decimal(version)); if (user_base_path) { - BLI_strncpy(user_path, user_base_path, FILE_MAX); + STRNCPY(user_path, user_base_path); } } @@ -546,7 +546,7 @@ static bool get_path_system_ex(char *targetpath, system_path[0] = '\0'; const char *system_base_path = GHOST_getSystemDir(version, blender_version_decimal(version)); if (system_base_path) { - BLI_strncpy(system_path, system_base_path, FILE_MAX); + STRNCPY(system_path, system_base_path); } } diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c index 1a3699bb7af..e4be2984b05 100644 --- a/source/blender/blenkernel/intern/armature.c +++ b/source/blender/blenkernel/intern/armature.c @@ -708,7 +708,7 @@ bool bone_autoside_name( if (len == 0) { return false; } - BLI_strncpy(basename, name, sizeof(basename)); + STRNCPY(basename, name); /* Figure out extension to append: * - The extension to append is based upon the axis that we are working on. diff --git a/source/blender/blenkernel/intern/asset.cc b/source/blender/blenkernel/intern/asset.cc index 051bb3d3584..4f564bb40ae 100644 --- a/source/blender/blenkernel/intern/asset.cc +++ b/source/blender/blenkernel/intern/asset.cc @@ -52,7 +52,7 @@ AssetMetaData::~AssetMetaData() static AssetTag *asset_metadata_tag_add(AssetMetaData *asset_data, const char *const name) { AssetTag *tag = (AssetTag *)MEM_callocN(sizeof(*tag), __func__); - BLI_strncpy(tag->name, name, sizeof(tag->name)); + STRNCPY(tag->name, name); BLI_addtail(&asset_data->tags, tag); asset_data->tot_tags++; diff --git a/source/blender/blenkernel/intern/attribute.cc b/source/blender/blenkernel/intern/attribute.cc index 97fcff343da..e448119b9ad 100644 --- a/source/blender/blenkernel/intern/attribute.cc +++ b/source/blender/blenkernel/intern/attribute.cc @@ -217,7 +217,7 @@ bool BKE_id_attribute_rename(ID *id, BKE_id_attributes_default_color_set(id, result_name); } - BLI_strncpy_utf8(layer->name, result_name, sizeof(layer->name)); + STRNCPY_UTF8(layer->name, result_name); return true; } diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c index 8d294d859d8..d1b5bf980ad 100644 --- a/source/blender/blenkernel/intern/blender.c +++ b/source/blender/blenkernel/intern/blender.c @@ -111,13 +111,12 @@ static void blender_version_init(void) BLI_assert_msg(0, "Invalid Blender version cycle"); } - BLI_snprintf(blender_version_string, - ARRAY_SIZE(blender_version_string), - "%d.%01d.%d%s", - BLENDER_VERSION / 100, - BLENDER_VERSION % 100, - BLENDER_VERSION_PATCH, - version_cycle); + SNPRINTF(blender_version_string, + "%d.%01d.%d%s", + BLENDER_VERSION / 100, + BLENDER_VERSION % 100, + BLENDER_VERSION_PATCH, + version_cycle); } const char *BKE_blender_version_string(void) diff --git a/source/blender/blenkernel/intern/blender_undo.cc b/source/blender/blenkernel/intern/blender_undo.cc index 9f548c539c7..8581f1a41a1 100644 --- a/source/blender/blenkernel/intern/blender_undo.cc +++ b/source/blender/blenkernel/intern/blender_undo.cc @@ -57,7 +57,7 @@ bool BKE_memfile_undo_decode(MemFileUndoData *mfu, char mainstr[sizeof(bmain->filepath)]; int success = 0, fileflags; - BLI_strncpy(mainstr, BKE_main_blendfile_path(bmain), sizeof(mainstr)); /* temporal store */ + STRNCPY(mainstr, BKE_main_blendfile_path(bmain)); /* temporal store */ fileflags = G.fileflags; G.fileflags |= G_FILE_NO_UI; @@ -116,14 +116,14 @@ MemFileUndoData *BKE_memfile_undo_encode(Main *bmain, MemFileUndoData *mfu_prev) counter++; counter = counter % U.undosteps; - BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter); + SNPRINTF(numstr, "%d.blend", counter); BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_session(), numstr); const BlendFileWriteParams blend_file_write_params{}; /* success = */ /* UNUSED */ BLO_write_file( bmain, filepath, fileflags, &blend_file_write_params, nullptr); - BLI_strncpy(mfu->filepath, filepath, sizeof(mfu->filepath)); + STRNCPY(mfu->filepath, filepath); } else { MemFile *prevfile = (mfu_prev) ? &(mfu_prev->memfile) : nullptr; diff --git a/source/blender/blenkernel/intern/blendfile_link_append.c b/source/blender/blenkernel/intern/blendfile_link_append.c index 2631ea8e226..affa20ba466 100644 --- a/source/blender/blenkernel/intern/blendfile_link_append.c +++ b/source/blender/blenkernel/intern/blendfile_link_append.c @@ -1116,9 +1116,9 @@ void BKE_blendfile_append(BlendfileLinkAppendContext *lapp_context, ReportList * ID *local_appended_new_id = NULL; char lib_filepath[FILE_MAX]; - BLI_strncpy(lib_filepath, id->lib->filepath, sizeof(lib_filepath)); + STRNCPY(lib_filepath, id->lib->filepath); char lib_id_name[MAX_ID_NAME]; - BLI_strncpy(lib_id_name, id->name, sizeof(lib_id_name)); + STRNCPY(lib_id_name, id->name); switch (item->action) { case LINK_APPEND_ACT_COPY_LOCAL: diff --git a/source/blender/blenkernel/intern/boids.c b/source/blender/blenkernel/intern/boids.c index f09eef2ed84..a8724c7b110 100644 --- a/source/blender/blenkernel/intern/boids.c +++ b/source/blender/blenkernel/intern/boids.c @@ -1617,7 +1617,7 @@ BoidRule *boid_new_rule(int type) rule->type = type; rule->flag |= BOIDRULE_IN_AIR | BOIDRULE_ON_LAND; - BLI_strncpy(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name), sizeof(rule->name)); + STRNCPY(rule->name, DATA_(rna_enum_boidrule_type_items[type - 1].name)); return rule; } @@ -1653,7 +1653,7 @@ BoidState *boid_new_state(BoidSettings *boids) state->id = boids->last_state_id++; if (state->id) { - BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id); + SNPRINTF(state->name, "State %i", state->id); } else { strcpy(state->name, "State"); diff --git a/source/blender/blenkernel/intern/bpath.c b/source/blender/blenkernel/intern/bpath.c index 0add85aec06..400e9174764 100644 --- a/source/blender/blenkernel/intern/bpath.c +++ b/source/blender/blenkernel/intern/bpath.c @@ -135,7 +135,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char char path_dst[FILE_MAX]; if (absolute_base_path) { - BLI_strncpy(path_src_buf, path, sizeof(path_src_buf)); + STRNCPY(path_src_buf, path); BLI_path_abs(path_src_buf, absolute_base_path); path_src = path_src_buf; } @@ -144,7 +144,7 @@ bool BKE_bpath_foreach_path_fixed_process(BPathForeachPathData *bpath_data, char } /* so functions can check old value */ - BLI_strncpy(path_dst, path, FILE_MAX); + STRNCPY(path_dst, path); if (bpath_data->callback_function(bpath_data, path_dst, path_src)) { BLI_strncpy(path, path_dst, FILE_MAX); @@ -167,7 +167,7 @@ bool BKE_bpath_foreach_path_dirfile_fixed_process(BPathForeachPathData *bpath_da BLI_path_join(path_src, sizeof(path_src), path_dir, path_file); /* So that functions can access the old value. */ - BLI_strncpy(path_dst, path_src, FILE_MAX); + STRNCPY(path_dst, path_src); if (absolute_base_path) { BLI_path_abs(path_src, absolute_base_path); @@ -191,7 +191,7 @@ bool BKE_bpath_foreach_path_allocated_process(BPathForeachPathData *bpath_data, char path_dst[FILE_MAX]; if (absolute_base_path) { - BLI_strncpy(path_src_buf, *path, sizeof(path_src_buf)); + STRNCPY(path_src_buf, *path); BLI_path_abs(path_src_buf, absolute_base_path); path_src = path_src_buf; } diff --git a/source/blender/blenkernel/intern/bpath_test.cc b/source/blender/blenkernel/intern/bpath_test.cc index a614f9b3954..cd2d0448f54 100644 --- a/source/blender/blenkernel/intern/bpath_test.cc +++ b/source/blender/blenkernel/intern/bpath_test.cc @@ -82,7 +82,7 @@ TEST_F(BPathTest, rebase_on_relative) text->filepath = BLI_strdup(TEXT_PATH_RELATIVE); MovieClip *movie_clip = reinterpret_cast(bmain->movieclips.first); - BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath)); + STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE); BKE_bpath_relative_rebase(bmain, BASE_DIR, REBASE_DIR, nullptr); @@ -97,7 +97,7 @@ TEST_F(BPathTest, rebase_on_absolute) text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE); MovieClip *movie_clip = reinterpret_cast(bmain->movieclips.first); - BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath)); + STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE); BKE_bpath_relative_rebase(bmain, BASE_DIR, REBASE_DIR, nullptr); @@ -111,7 +111,7 @@ TEST_F(BPathTest, convert_to_relative) text->filepath = BLI_strdup(TEXT_PATH_RELATIVE); MovieClip *movie_clip = reinterpret_cast(bmain->movieclips.first); - BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath)); + STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE); BKE_bpath_relative_convert(bmain, BASE_DIR, nullptr); @@ -127,7 +127,7 @@ TEST_F(BPathTest, convert_to_absolute) text->filepath = BLI_strdup(TEXT_PATH_RELATIVE); MovieClip *movie_clip = reinterpret_cast(bmain->movieclips.first); - BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath)); + STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE); BKE_bpath_absolute_convert(bmain, BASE_DIR, nullptr); @@ -143,7 +143,7 @@ TEST_F(BPathTest, list_backup_restore) text->filepath = BLI_strdup(TEXT_PATH_RELATIVE); MovieClip *movie_clip = reinterpret_cast(bmain->movieclips.first); - BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE, sizeof(movie_clip->filepath)); + STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_ABSOLUTE); void *path_list_handle = BKE_bpath_list_backup(bmain, static_cast(0)); @@ -152,7 +152,7 @@ TEST_F(BPathTest, list_backup_restore) MEM_freeN(text->filepath); text->filepath = BLI_strdup(TEXT_PATH_ABSOLUTE); - BLI_strncpy(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE, sizeof(movie_clip->filepath)); + STRNCPY(movie_clip->filepath, MOVIECLIP_PATH_RELATIVE); BKE_bpath_list_restore(bmain, static_cast(0), path_list_handle); diff --git a/source/blender/blenkernel/intern/cachefile.c b/source/blender/blenkernel/intern/cachefile.c index 9b2cccb7690..3050945075e 100644 --- a/source/blender/blenkernel/intern/cachefile.c +++ b/source/blender/blenkernel/intern/cachefile.c @@ -58,7 +58,7 @@ static void cache_file_init_data(ID *id) cache_file->scale = 1.0f; cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND; - BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name)); + STRNCPY(cache_file->velocity_name, ".velocities"); } static void cache_file_copy_data(Main *UNUSED(bmain), @@ -362,7 +362,7 @@ void BKE_cachefile_eval(Main *bmain, Depsgraph *depsgraph, CacheFile *cache_file cache_file->type = CACHEFILE_TYPE_ALEMBIC; cache_file->handle = ABC_create_handle( bmain, filepath, cache_file->layers.first, &cache_file->object_paths); - BLI_strncpy(cache_file->handle_filepath, filepath, FILE_MAX); + STRNCPY(cache_file->handle_filepath, filepath); } #endif #ifdef WITH_USD @@ -441,7 +441,7 @@ CacheFileLayer *BKE_cachefile_add_layer(CacheFile *cache_file, const char filepa const int num_layers = BLI_listbase_count(&cache_file->layers); CacheFileLayer *layer = MEM_callocN(sizeof(CacheFileLayer), "CacheFileLayer"); - BLI_strncpy(layer->filepath, filepath, sizeof(layer->filepath)); + STRNCPY(layer->filepath, filepath); BLI_addtail(&cache_file->layers, layer); diff --git a/source/blender/blenkernel/intern/camera.c b/source/blender/blenkernel/intern/camera.c index 297344f4627..33220a24b18 100644 --- a/source/blender/blenkernel/intern/camera.c +++ b/source/blender/blenkernel/intern/camera.c @@ -1034,7 +1034,7 @@ static Object *camera_multiview_advanced(const Scene *scene, Object *camera, con } if (STREQ(camera_name + (len_name - len_suffix), srv->suffix)) { - BLI_snprintf(name, sizeof(name), "%.*s%s", (len_name - len_suffix), camera_name, suffix); + SNPRINTF(name, "%.*s%s", (len_name - len_suffix), camera_name, suffix); len_suffix_max = len_suffix; } } diff --git a/source/blender/blenkernel/intern/colortools.c b/source/blender/blenkernel/intern/colortools.c index cefc1295130..c644a663e41 100644 --- a/source/blender/blenkernel/intern/colortools.c +++ b/source/blender/blenkernel/intern/colortools.c @@ -1790,15 +1790,13 @@ void BKE_color_managed_display_settings_init(ColorManagedDisplaySettings *settin { const char *display_name = IMB_colormanagement_display_get_default_name(); - BLI_strncpy(settings->display_device, display_name, sizeof(settings->display_device)); + STRNCPY(settings->display_device, display_name); } void BKE_color_managed_display_settings_copy(ColorManagedDisplaySettings *new_settings, const ColorManagedDisplaySettings *settings) { - BLI_strncpy(new_settings->display_device, - settings->display_device, - sizeof(new_settings->display_device)); + STRNCPY(new_settings->display_device, settings->display_device); } void BKE_color_managed_view_settings_init_render( @@ -1836,10 +1834,8 @@ void BKE_color_managed_view_settings_init_default( void BKE_color_managed_view_settings_copy(ColorManagedViewSettings *new_settings, const ColorManagedViewSettings *settings) { - BLI_strncpy(new_settings->look, settings->look, sizeof(new_settings->look)); - BLI_strncpy(new_settings->view_transform, - settings->view_transform, - sizeof(new_settings->view_transform)); + STRNCPY(new_settings->look, settings->look); + STRNCPY(new_settings->view_transform, settings->view_transform); new_settings->flag = settings->flag; new_settings->exposure = settings->exposure; @@ -1882,14 +1878,14 @@ void BKE_color_managed_view_settings_blend_read_data(BlendDataReader *reader, void BKE_color_managed_colorspace_settings_init( ColorManagedColorspaceSettings *colorspace_settings) { - BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name)); + STRNCPY(colorspace_settings->name, ""); } void BKE_color_managed_colorspace_settings_copy( ColorManagedColorspaceSettings *colorspace_settings, const ColorManagedColorspaceSettings *settings) { - BLI_strncpy(colorspace_settings->name, settings->name, sizeof(colorspace_settings->name)); + STRNCPY(colorspace_settings->name, settings->name); } bool BKE_color_managed_colorspace_settings_equals(const ColorManagedColorspaceSettings *settings1, diff --git a/source/blender/blenkernel/intern/constraint.c b/source/blender/blenkernel/intern/constraint.c index 75af451d7b6..8382fc5244d 100644 --- a/source/blender/blenkernel/intern/constraint.c +++ b/source/blender/blenkernel/intern/constraint.c @@ -859,7 +859,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph), ct = MEM_callocN(sizeof(bConstraintTarget), "tempConstraintTarget"); \ \ ct->tar = datatar; \ - BLI_strncpy(ct->subtarget, datasubtarget, sizeof(ct->subtarget)); \ + STRNCPY(ct->subtarget, datasubtarget); \ ct->space = con->tarspace; \ ct->flag = CONSTRAINT_TAR_TEMP; \ \ @@ -916,7 +916,7 @@ static void default_get_tarmat_full_bbone(struct Depsgraph *UNUSED(depsgraph), bConstraintTarget *ctn = ct->next; \ if (no_copy == 0) { \ datatar = ct->tar; \ - BLI_strncpy(datasubtarget, ct->subtarget, sizeof(datasubtarget)); \ + STRNCPY(datasubtarget, ct->subtarget); \ con->tarspace = (char)ct->space; \ } \ \ @@ -5403,7 +5403,7 @@ static void transformcache_copy(bConstraint *con, bConstraint *srccon) bTransformCacheConstraint *src = srccon->data; bTransformCacheConstraint *dst = con->data; - BLI_strncpy(dst->object_path, src->object_path, sizeof(dst->object_path)); + STRNCPY(dst->object_path, src->object_path); dst->cache_file = src->cache_file; dst->reader = NULL; dst->reader_object_path[0] = '\0'; @@ -5779,7 +5779,7 @@ static bConstraint *add_new_constraint_internal(const char *name, short type) } /* copy the name */ - BLI_strncpy(con->name, newName, sizeof(con->name)); + STRNCPY(con->name, newName); /* return the new constraint */ return con; @@ -6201,7 +6201,7 @@ void BKE_constraint_targets_flush(struct bConstraint *con, struct ListBase *targ if (!no_copy) { con->space_object = ct->tar; - BLI_strncpy(con->space_subtarget, ct->subtarget, sizeof(con->space_subtarget)); + STRNCPY(con->space_subtarget, ct->subtarget); } BLI_freelinkN(targets, ct); diff --git a/source/blender/blenkernel/intern/cryptomatte_test.cc b/source/blender/blenkernel/intern/cryptomatte_test.cc index 8d360677599..e3ffefaea98 100644 --- a/source/blender/blenkernel/intern/cryptomatte_test.cc +++ b/source/blender/blenkernel/intern/cryptomatte_test.cc @@ -146,7 +146,7 @@ TEST(cryptomatte, session_from_stamp_data) /* Create StampData from CryptomatteSession. */ ViewLayer view_layer; - BLI_strncpy(view_layer.name, "viewlayername", sizeof(view_layer.name)); + STRNCPY(view_layer.name, "viewlayername"); RenderResult *render_result2 = static_cast( MEM_callocN(sizeof(RenderResult), __func__)); BKE_cryptomatte_store_metadata(session.get(), render_result2, &view_layer); diff --git a/source/blender/blenkernel/intern/customdata.cc b/source/blender/blenkernel/intern/customdata.cc index 3d1919c57db..cacfe1a97eb 100644 --- a/source/blender/blenkernel/intern/customdata.cc +++ b/source/blender/blenkernel/intern/customdata.cc @@ -2955,7 +2955,7 @@ static CustomDataLayer *customData_add_layer__internal( } if (name) { - BLI_strncpy(new_layer.name, name, sizeof(new_layer.name)); + STRNCPY(new_layer.name, name); CustomData_set_layer_unique_name(data, index); } else { @@ -3669,7 +3669,7 @@ bool CustomData_set_layer_name(CustomData *data, return false; } - BLI_strncpy(data->layers[layer_index].name, name, sizeof(data->layers[layer_index].name)); + STRNCPY(data->layers[layer_index].name, name); return true; } @@ -4781,7 +4781,7 @@ void CustomData_external_add(CustomData *data, external = MEM_cnew(__func__); data->external = external; } - BLI_strncpy(external->filepath, filepath, sizeof(external->filepath)); + STRNCPY(external->filepath, filepath); layer->flag |= CD_FLAG_EXTERNAL | CD_FLAG_IN_MEMORY; } diff --git a/source/blender/blenkernel/intern/customdata_file.c b/source/blender/blenkernel/intern/customdata_file.c index c17313c9c0a..68fe274d5da 100644 --- a/source/blender/blenkernel/intern/customdata_file.c +++ b/source/blender/blenkernel/intern/customdata_file.c @@ -444,7 +444,7 @@ CDataFileLayer *cdf_layer_add(CDataFile *cdf, int type, const char *name, size_t layer->datatype = CDF_DATA_FLOAT; layer->datasize = datasize; layer->type = type; - BLI_strncpy(layer->name, name, CDF_LAYER_NAME_MAX); + STRNCPY(layer->name, name); return layer; } diff --git a/source/blender/blenkernel/intern/deform.cc b/source/blender/blenkernel/intern/deform.cc index b191866a4a5..86d7085775e 100644 --- a/source/blender/blenkernel/intern/deform.cc +++ b/source/blender/blenkernel/intern/deform.cc @@ -48,7 +48,7 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const char *name) defgroup = MEM_cnew(__func__); - BLI_strncpy(defgroup->name, name, sizeof(defgroup->name)); + STRNCPY(defgroup->name, name); ListBase *defbase = BKE_object_defgroup_list_mutable(ob); diff --git a/source/blender/blenkernel/intern/displist.cc b/source/blender/blenkernel/intern/displist.cc index 3e6cd9e86b0..8f6f6652d36 100644 --- a/source/blender/blenkernel/intern/displist.cc +++ b/source/blender/blenkernel/intern/displist.cc @@ -761,7 +761,7 @@ static GeometrySet curve_calc_modifiers_post(Depsgraph *depsgraph, BKE_mesh_ensure_normals_for_display(final_mesh); - BLI_strncpy(final_mesh->id.name, cu->id.name, sizeof(final_mesh->id.name)); + STRNCPY(final_mesh->id.name, cu->id.name); *((short *)final_mesh->id.name) = ID_ME; } diff --git a/source/blender/blenkernel/intern/dynamicpaint.cc b/source/blender/blenkernel/intern/dynamicpaint.cc index 0700955c9dc..44f139494af 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.cc +++ b/source/blender/blenkernel/intern/dynamicpaint.cc @@ -295,7 +295,7 @@ static Mesh *dynamicPaint_brush_mesh_get(DynamicPaintBrushSettings *brush) static bool setError(DynamicPaintCanvasSettings *canvas, const char *string) { /* Add error to canvas ui info label */ - BLI_strncpy(canvas->error, string, sizeof(canvas->error)); + STRNCPY(canvas->error, string); CLOG_STR_ERROR(&LOG, string); return false; } @@ -369,7 +369,7 @@ static bool surface_duplicateOutputExists(void *arg, const char *name) static void surface_setUniqueOutputName(DynamicPaintSurface *surface, char *basename, int output) { char name[64]; - BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */ + STRNCPY(name, basename); /* in case basename is surface->name use a copy */ if (output == 0) { BLI_uniquename_cb(surface_duplicateOutputExists, surface, @@ -405,7 +405,7 @@ static bool surface_duplicateNameExists(void *arg, const char *name) void dynamicPaintSurface_setUniqueName(DynamicPaintSurface *surface, const char *basename) { char name[64]; - BLI_strncpy(name, basename, sizeof(name)); /* in case basename is surface->name use a copy */ + STRNCPY(name, basename); /* in case basename is surface->name use a copy */ BLI_uniquename_cb( surface_duplicateNameExists, surface, name, '.', surface->name, sizeof(surface->name)); } @@ -420,7 +420,7 @@ void dynamicPaintSurface_updateType(DynamicPaintSurface *surface) } else { strcpy(surface->output_name, "dp_"); - BLI_strncpy(surface->output_name2, surface->output_name, sizeof(surface->output_name2)); + STRNCPY(surface->output_name2, surface->output_name); surface->flags &= ~MOD_DPAINT_ANTIALIAS; surface->depth_clamp = 0.0f; } @@ -1233,7 +1233,7 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd, t_surface->effector_weights = static_cast( MEM_dupallocN(surface->effector_weights)); - BLI_strncpy(t_surface->name, surface->name, sizeof(t_surface->name)); + STRNCPY(t_surface->name, surface->name); t_surface->format = surface->format; t_surface->type = surface->type; t_surface->disp_type = surface->disp_type; @@ -1250,8 +1250,7 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd, copy_v4_v4(t_surface->init_color, surface->init_color); t_surface->init_texture = surface->init_texture; - BLI_strncpy( - t_surface->init_layername, surface->init_layername, sizeof(t_surface->init_layername)); + STRNCPY(t_surface->init_layername, surface->init_layername); t_surface->dry_speed = surface->dry_speed; t_surface->diss_speed = surface->diss_speed; @@ -1274,12 +1273,10 @@ void dynamicPaint_Modifier_copy(const DynamicPaintModifierData *pmd, t_surface->wave_spring = surface->wave_spring; t_surface->wave_smoothness = surface->wave_smoothness; - BLI_strncpy(t_surface->uvlayer_name, surface->uvlayer_name, sizeof(t_surface->uvlayer_name)); - BLI_strncpy(t_surface->image_output_path, - surface->image_output_path, - sizeof(t_surface->image_output_path)); - BLI_strncpy(t_surface->output_name, surface->output_name, sizeof(t_surface->output_name)); - BLI_strncpy(t_surface->output_name2, surface->output_name2, sizeof(t_surface->output_name2)); + STRNCPY(t_surface->uvlayer_name, surface->uvlayer_name); + STRNCPY(t_surface->image_output_path, surface->image_output_path); + STRNCPY(t_surface->output_name, surface->output_name); + STRNCPY(t_surface->output_name2, surface->output_name2); } } if (tpmd->brush) { @@ -3314,7 +3311,7 @@ void dynamicPaint_outputSurfaceImage(DynamicPaintSurface *surface, format = R_IMF_IMTYPE_PNG; } #endif - BLI_strncpy(output_file, filepath, sizeof(output_file)); + STRNCPY(output_file, filepath); BKE_image_path_ext_from_imtype_ensure(output_file, sizeof(output_file), format); /* Validate output file path */ diff --git a/source/blender/blenkernel/intern/effect.c b/source/blender/blenkernel/intern/effect.c index 0db431764ba..d23b2aa2db6 100644 --- a/source/blender/blenkernel/intern/effect.c +++ b/source/blender/blenkernel/intern/effect.c @@ -1351,7 +1351,7 @@ void BKE_sim_debug_data_add_element(int type, zero_v3(elem->v2); } if (str) { - BLI_strncpy(elem->str, str, sizeof(elem->str)); + STRNCPY(elem->str, str); } else { elem->str[0] = '\0'; diff --git a/source/blender/blenkernel/intern/fcurve.c b/source/blender/blenkernel/intern/fcurve.c index 7e1b95ac6b1..3471cb87014 100644 --- a/source/blender/blenkernel/intern/fcurve.c +++ b/source/blender/blenkernel/intern/fcurve.c @@ -161,7 +161,7 @@ void BKE_fcurves_copy(ListBase *dst, ListBase *src) void BKE_fmodifier_name_set(FModifier *fcm, const char *name) { /* Copy new Modifier name. */ - BLI_strncpy(fcm->name, name, sizeof(fcm->name)); + STRNCPY(fcm->name, name); /* Set default modifier name when name parameter is an empty string. * Ensure the name is unique. */ diff --git a/source/blender/blenkernel/intern/fluid.cc b/source/blender/blenkernel/intern/fluid.cc index e8f9680afc5..7a6887f0f4b 100644 --- a/source/blender/blenkernel/intern/fluid.cc +++ b/source/blender/blenkernel/intern/fluid.cc @@ -4455,12 +4455,12 @@ void BKE_fluid_particle_system_create(Main *bmain, part->phystype = PART_PHYS_NO; /* No physics needed, part system only used to display data. */ psys->part = part; psys->pointcache = BKE_ptcache_add(&psys->ptcaches); - BLI_strncpy(psys->name, parts_name, sizeof(psys->name)); + STRNCPY(psys->name, parts_name); BLI_addtail(&ob->particlesystem, psys); /* add modifier */ pfmd = (ParticleSystemModifierData *)BKE_modifier_new(eModifierType_ParticleSystem); - BLI_strncpy(pfmd->modifier.name, psys_name, sizeof(pfmd->modifier.name)); + STRNCPY(pfmd->modifier.name, psys_name); pfmd->psys = psys; BLI_addtail(&ob->modifiers, pfmd); BKE_modifier_unique_name(&ob->modifiers, (ModifierData *)pfmd); @@ -4968,7 +4968,7 @@ void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tf tfds->cache_data_format = fds->cache_data_format; tfds->cache_particle_format = fds->cache_particle_format; tfds->cache_noise_format = fds->cache_noise_format; - BLI_strncpy(tfds->cache_directory, fds->cache_directory, sizeof(tfds->cache_directory)); + STRNCPY(tfds->cache_directory, fds->cache_directory); /* time options */ tfds->time_scale = fds->time_scale; @@ -5056,7 +5056,7 @@ void BKE_fluid_modifier_copy(const FluidModifierData *fmd, FluidModifierData *tf /* texture control */ tffs->texture_size = ffs->texture_size; tffs->texture_offset = ffs->texture_offset; - BLI_strncpy(tffs->uvlayer_name, ffs->uvlayer_name, sizeof(tffs->uvlayer_name)); + STRNCPY(tffs->uvlayer_name, ffs->uvlayer_name); tffs->vgroup_density = ffs->vgroup_density; tffs->type = ffs->type; diff --git a/source/blender/blenkernel/intern/freestyle.c b/source/blender/blenkernel/intern/freestyle.c index afb32c4b50c..ad4cf4fb958 100644 --- a/source/blender/blenkernel/intern/freestyle.c +++ b/source/blender/blenkernel/intern/freestyle.c @@ -180,10 +180,10 @@ FreestyleLineSet *BKE_freestyle_lineset_add(struct Main *bmain, lineset->exclude_edge_types = 0; lineset->group = NULL; if (name) { - BLI_strncpy(lineset->name, name, sizeof(lineset->name)); + STRNCPY(lineset->name, name); } else if (lineset_index > 0) { - BLI_snprintf(lineset->name, sizeof(lineset->name), "LineSet %i", lineset_index + 1); + SNPRINTF(lineset->name, "LineSet %i", lineset_index + 1); } else { strcpy(lineset->name, "LineSet"); diff --git a/source/blender/blenkernel/intern/gpencil_legacy.c b/source/blender/blenkernel/intern/gpencil_legacy.c index 6a889cc20f3..4ccd572a18f 100644 --- a/source/blender/blenkernel/intern/gpencil_legacy.c +++ b/source/blender/blenkernel/intern/gpencil_legacy.c @@ -675,7 +675,7 @@ bGPDlayer *BKE_gpencil_layer_addnew(bGPdata *gpd, } /* auto-name */ - BLI_strncpy(gpl->info, DATA_(name), sizeof(gpl->info)); + STRNCPY(gpl->info, DATA_(name)); BLI_uniquename(&gpd->layers, gpl, (gpd->flag & GP_DATA_ANNOTATIONS) ? DATA_("Note") : DATA_("GP_Layer"), @@ -1018,9 +1018,9 @@ void BKE_gpencil_layer_copy_settings(const bGPDlayer *gpl_src, bGPDlayer *gpl_ds gpl_dst->pass_index = gpl_src->pass_index; gpl_dst->parent = gpl_src->parent; copy_m4_m4(gpl_dst->inverse, gpl_src->inverse); - BLI_strncpy(gpl_dst->parsubstr, gpl_src->parsubstr, 64); + STRNCPY(gpl_dst->parsubstr, gpl_src->parsubstr); gpl_dst->partype = gpl_src->partype; - BLI_strncpy(gpl_dst->viewlayername, gpl_src->viewlayername, 64); + STRNCPY(gpl_dst->viewlayername, gpl_src->viewlayername); copy_v3_v3(gpl_dst->location, gpl_src->location); copy_v3_v3(gpl_dst->rotation, gpl_src->rotation); copy_v3_v3(gpl_dst->scale, gpl_src->scale); @@ -1436,7 +1436,7 @@ bGPDlayer_Mask *BKE_gpencil_layer_mask_add(bGPDlayer *gpl, const char *name) bGPDlayer_Mask *mask = MEM_callocN(sizeof(bGPDlayer_Mask), "bGPDlayer_Mask"); BLI_addtail(&gpl->mask_layers, mask); - BLI_strncpy(mask->name, name, sizeof(mask->name)); + STRNCPY(mask->name, name); gpl->act_mask++; return mask; diff --git a/source/blender/blenkernel/intern/gpencil_modifier_legacy.c b/source/blender/blenkernel/intern/gpencil_modifier_legacy.c index af6954d4cd1..8c791eb4cc4 100644 --- a/source/blender/blenkernel/intern/gpencil_modifier_legacy.c +++ b/source/blender/blenkernel/intern/gpencil_modifier_legacy.c @@ -356,7 +356,7 @@ GpencilModifierData *BKE_gpencil_modifier_new(int type) GpencilModifierData *md = MEM_callocN(mti->struct_size, mti->struct_name); /* NOTE: this name must be made unique later. */ - BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name)); + STRNCPY(md->name, DATA_(mti->name)); md->type = type; md->mode = eGpencilModifierMode_Realtime | eGpencilModifierMode_Render; diff --git a/source/blender/blenkernel/intern/idprop.c b/source/blender/blenkernel/intern/idprop.c index d60d7adbcb7..ca65c0c128f 100644 --- a/source/blender/blenkernel/intern/idprop.c +++ b/source/blender/blenkernel/intern/idprop.c @@ -65,7 +65,7 @@ IDProperty *IDP_NewIDPArray(const char *name) IDProperty *prop = MEM_callocN(sizeof(IDProperty), "IDProperty prop array"); prop->type = IDP_IDPARRAY; prop->len = 0; - BLI_strncpy(prop->name, name, MAX_IDPROP_NAME); + STRNCPY(prop->name, name); return prop; } @@ -300,7 +300,7 @@ static IDProperty *idp_generic_copy(const IDProperty *prop, const int UNUSED(fla { IDProperty *newp = MEM_callocN(sizeof(IDProperty), __func__); - BLI_strncpy(newp->name, prop->name, MAX_IDPROP_NAME); + STRNCPY(newp->name, prop->name); newp->type = prop->type; newp->flag = prop->flag; newp->data.val = prop->data.val; @@ -369,7 +369,7 @@ IDProperty *IDP_NewStringMaxSize(const char *st, const char *name, int maxncpy) } prop->type = IDP_STRING; - BLI_strncpy(prop->name, name, MAX_IDPROP_NAME); + STRNCPY(prop->name, name); return prop; } @@ -1005,7 +1005,7 @@ IDProperty *IDP_New(const char type, const IDPropertyTemplate *val, const char * } prop->type = type; - BLI_strncpy(prop->name, name, MAX_IDPROP_NAME); + STRNCPY(prop->name, name); return prop; } diff --git a/source/blender/blenkernel/intern/idprop_utils.c b/source/blender/blenkernel/intern/idprop_utils.c index 0ade0aa654e..812d064d6ac 100644 --- a/source/blender/blenkernel/intern/idprop_utils.c +++ b/source/blender/blenkernel/intern/idprop_utils.c @@ -67,7 +67,7 @@ static void idp_str_append_escape(struct ReprState *state, state->str_append_fn(state->user_data, str + i_prev, i - i_prev); } char buf[5]; - uint len = (uint)BLI_snprintf_rlen(buf, sizeof(buf), "\\x%02x", c); + uint len = (uint)SNPRINTF_RLEN(buf, "\\x%02x", c); BLI_assert(len == 4); state->str_append_fn(state->user_data, buf, len); i_prev = i + 1; @@ -90,9 +90,7 @@ static void idp_repr_fn_recursive(struct ReprState *state, const IDProperty *pro #define STR_APPEND_FMT(format, ...) \ state->str_append_fn( \ - state->user_data, \ - state->buf, \ - (uint)BLI_snprintf_rlen(state->buf, sizeof(state->buf), format, __VA_ARGS__)) + state->user_data, state->buf, (uint)SNPRINTF_RLEN(state->buf, format, __VA_ARGS__)) switch (prop->type) { case IDP_STRING: { diff --git a/source/blender/blenkernel/intern/image.cc b/source/blender/blenkernel/intern/image.cc index dd0ca70148e..6947527cf8d 100644 --- a/source/blender/blenkernel/intern/image.cc +++ b/source/blender/blenkernel/intern/image.cc @@ -290,7 +290,7 @@ static void image_foreach_path(ID *id, BPathForeachPathData *bpath_data) bool result = false; if (ima->source == IMA_SRC_TILED && (flag & BKE_BPATH_FOREACH_PATH_RESOLVE_TOKEN) != 0) { char temp_path[FILE_MAX], orig_file[FILE_MAXFILE]; - BLI_strncpy(temp_path, ima->filepath, sizeof(temp_path)); + STRNCPY(temp_path, ima->filepath); BLI_path_split_file_part(temp_path, orig_file, sizeof(orig_file)); eUDIM_TILE_FORMAT tile_format; @@ -3195,7 +3195,7 @@ void BKE_image_signal(Main *bmain, Image *ima, ImageUser *iuser, int signal) int new_start, new_range; char filepath[FILE_MAX]; - BLI_strncpy(filepath, ima->filepath, sizeof(filepath)); + STRNCPY(filepath, ima->filepath); BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&ima->id)); bool result = BKE_image_get_tile_info(filepath, &new_tiles, &new_start, &new_range); if (result) { @@ -3407,7 +3407,7 @@ ImageTile *BKE_image_add_tile(struct Image *ima, int tile_number, const char *la } if (label) { - BLI_strncpy(tile->label, label, sizeof(tile->label)); + STRNCPY(tile->label, label); } for (int eye = 0; eye < 2; eye++) { @@ -5561,11 +5561,11 @@ RenderSlot *BKE_image_add_renderslot(Image *ima, const char *name) { RenderSlot *slot = MEM_cnew("Image new Render Slot"); if (name && name[0]) { - BLI_strncpy(slot->name, name, sizeof(slot->name)); + STRNCPY(slot->name, name); } else { int n = BLI_listbase_count(&ima->renderslots) + 1; - BLI_snprintf(slot->name, sizeof(slot->name), DATA_("Slot %d"), n); + SNPRINTF(slot->name, DATA_("Slot %d"), n); } BLI_addtail(&ima->renderslots, slot); return slot; diff --git a/source/blender/blenkernel/intern/image_save.cc b/source/blender/blenkernel/intern/image_save.cc index 67f8700725b..9f669d17395 100644 --- a/source/blender/blenkernel/intern/image_save.cc +++ b/source/blender/blenkernel/intern/image_save.cc @@ -167,7 +167,7 @@ bool BKE_image_save_options_init(ImageSaveOptions *opts, const bool is_prev_save = !STREQ(G.ima, "//"); if (opts->save_as_render) { if (is_prev_save) { - BLI_strncpy(opts->filepath, G.ima, sizeof(opts->filepath)); + STRNCPY(opts->filepath, G.ima); } else { BLI_path_join(opts->filepath, sizeof(opts->filepath), "//", DATA_("untitled")); @@ -252,7 +252,7 @@ static void image_save_update_filepath(Image *ima, const ImageSaveOptions *opts) { if (opts->do_newpath) { - BLI_strncpy(ima->filepath, filepath, sizeof(ima->filepath)); + STRNCPY(ima->filepath, filepath); /* only image path, never ibuf */ if (opts->relative) { @@ -281,7 +281,7 @@ static void image_save_post(ReportList *reports, } if (opts->do_newpath) { - BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); + STRNCPY(ibuf->filepath, filepath); } /* The tiled image code-path must call this on its own. */ @@ -776,7 +776,7 @@ bool BKE_image_render_write_exr(ReportList *reports, if (multi_layer) { RE_render_result_full_channel_name(passname, nullptr, "Combined", nullptr, chan_id, a); - BLI_strncpy(layname, "Composite", sizeof(layname)); + STRNCPY(layname, "Composite"); } else { passname[0] = chan_id[a]; @@ -842,7 +842,7 @@ bool BKE_image_render_write_exr(ReportList *reports, if (multi_layer) { RE_render_result_full_channel_name(passname, nullptr, rp->name, nullptr, rp->chan_id, a); - BLI_strncpy(layname, rl->name, sizeof(layname)); + STRNCPY(layname, rl->name); } else { passname[0] = rp->chan_id[a]; diff --git a/source/blender/blenkernel/intern/image_test.cc b/source/blender/blenkernel/intern/image_test.cc index 5219552cc9b..ee7f5bf6daa 100644 --- a/source/blender/blenkernel/intern/image_test.cc +++ b/source/blender/blenkernel/intern/image_test.cc @@ -17,7 +17,7 @@ TEST(udim, image_ensure_tile_token) auto verify = [](const char *original, const char *expected) { char result[FILE_MAX]; - BLI_strncpy(result, original, sizeof(result)); + STRNCPY(result, original); BKE_image_ensure_tile_token_filename_only(result, sizeof(result)); EXPECT_STREQ(result, expected); }; @@ -172,7 +172,7 @@ TEST(udim, image_set_filepath_from_tile_number) char filepath[FILE_MAX]; /* Parameter validation. */ - BLI_strncpy(filepath, "xxxx", FILE_MAX); + STRNCPY(filepath, "xxxx"); BKE_image_set_filepath_from_tile_number(nullptr, udim_pattern, tile_format, 1028); BKE_image_set_filepath_from_tile_number(filepath, nullptr, tile_format, 1028); diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c index 30cbf3caff8..8e2f6688654 100644 --- a/source/blender/blenkernel/intern/ipo.c +++ b/source/blender/blenkernel/intern/ipo.c @@ -445,7 +445,7 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_i /* block will be attached to ID_KE block... */ if (adrcode == 0) { /* adrcode=0 was the misnamed "speed" curve (now "evaluation time") */ - BLI_strncpy(buf, "eval_time", sizeof(buf)); + STRNCPY(buf, "eval_time"); } else { /* Find the name of the ShapeKey (i.e. KeyBlock) to look for */ @@ -457,11 +457,11 @@ static char *shapekey_adrcodes_to_paths(ID *id, int adrcode, int *UNUSED(array_i /* Use the keyblock name, escaped, so that path lookups for this will work */ char kb_name_esc[sizeof(kb->name) * 2]; BLI_str_escape(kb_name_esc, kb->name, sizeof(kb_name_esc)); - BLI_snprintf(buf, sizeof(buf), "key_blocks[\"%s\"].value", kb_name_esc); + SNPRINTF(buf, "key_blocks[\"%s\"].value", kb_name_esc); } else { /* Fallback - Use the adrcode as index directly, so that this can be manually fixed */ - BLI_snprintf(buf, sizeof(buf), "key_blocks[%d].value", adrcode); + SNPRINTF(buf, "key_blocks[%d].value", adrcode); } } return buf; @@ -580,7 +580,7 @@ static const char *mtex_adrcodes_to_paths(int adrcode, int *UNUSED(array_index)) /* only build and return path if there's a property */ if (prop) { - BLI_snprintf(buf, 128, "%s.%s", base, prop); + SNPRINTF(buf, "%s.%s", base, prop); return buf; } @@ -1154,8 +1154,7 @@ static char *get_rna_access(ID *id, char constname_esc[sizeof(((bConstraint *)NULL)->name) * 2]; BLI_str_escape(actname_esc, actname, sizeof(actname_esc)); BLI_str_escape(constname_esc, constname, sizeof(constname_esc)); - BLI_snprintf( - buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc); + SNPRINTF(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname_esc, constname_esc); } else if (actname && actname[0]) { if ((blocktype == ID_OB) && STREQ(actname, "Object")) { @@ -1171,20 +1170,20 @@ static char *get_rna_access(ID *id, /* Pose-Channel */ char actname_esc[sizeof(((bActionChannel *)NULL)->name) * 2]; BLI_str_escape(actname_esc, actname, sizeof(actname_esc)); - BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"]", actname_esc); + SNPRINTF(buf, "pose.bones[\"%s\"]", actname_esc); } } else if (constname && constname[0]) { /* Constraint in Object */ char constname_esc[sizeof(((bConstraint *)NULL)->name) * 2]; BLI_str_escape(constname_esc, constname, sizeof(constname_esc)); - BLI_snprintf(buf, sizeof(buf), "constraints[\"%s\"]", constname_esc); + SNPRINTF(buf, "constraints[\"%s\"]", constname_esc); } else if (seq) { /* Sequence names in Scene */ char seq_name_esc[(sizeof(seq->name) - 2) * 2]; BLI_str_escape(seq_name_esc, seq->name + 2, sizeof(seq_name_esc)); - BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq_name_esc); + SNPRINTF(buf, "sequence_editor.sequences_all[\"%s\"]", seq_name_esc); } else { buf[0] = '\0'; /* empty string */ @@ -1202,7 +1201,7 @@ static char *get_rna_access(ID *id, /* if there was no array index pointer provided, add it to the path */ if (array_index == NULL) { - BLI_snprintf(buf, sizeof(buf), "[\"%d\"]", dummy_index); + SNPRINTF(buf, "[\"%d\"]", dummy_index); BLI_dynstr_append(path, buf); } @@ -1261,7 +1260,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver) /* FIXME: expression will be useless due to API changes, but at least not totally lost */ cdriver->type = DRIVER_TYPE_PYTHON; if (idriver->name[0]) { - BLI_strncpy(cdriver->expression, idriver->name, sizeof(cdriver->expression)); + STRNCPY(cdriver->expression, idriver->name); } } else { @@ -1283,7 +1282,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver) dtar->id = (ID *)idriver->ob; dtar->idtype = ID_OB; if (idriver->name[0]) { - BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); + STRNCPY(dtar->pchan_name, idriver->name); } /* second bone target (name was stored in same var as the first one) */ @@ -1291,8 +1290,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver) dtar->id = (ID *)idriver->ob; dtar->idtype = ID_OB; if (idriver->name[0]) { /* XXX: for safety. */ - BLI_strncpy( - dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS, sizeof(dtar->pchan_name)); + STRNCPY(dtar->pchan_name, idriver->name + DRIVER_NAME_OFFS); } } else { @@ -1305,7 +1303,7 @@ static ChannelDriver *idriver_to_cdriver(IpoDriver *idriver) dtar->id = (ID *)idriver->ob; dtar->idtype = ID_OB; if (idriver->name[0]) { - BLI_strncpy(dtar->pchan_name, idriver->name, sizeof(dtar->pchan_name)); + STRNCPY(dtar->pchan_name, idriver->name); } dtar->transChan = adrcode_to_dtar_transchan(idriver->adrcode); dtar->flag |= DTAR_FLAG_LOCALSPACE; /* old drivers took local space */ @@ -1362,7 +1360,7 @@ static void fcurve_add_to_list( agrp->flag |= AGRP_MUTED; } - BLI_strncpy(agrp->name, grpname, sizeof(agrp->name)); + STRNCPY(agrp->name, grpname); BLI_addtail(&tmp_act.groups, agrp); BLI_uniquename(&tmp_act.groups, @@ -1876,7 +1874,7 @@ static void ipo_to_animdata( if (adt->action == NULL) { char nameBuf[MAX_ID_NAME]; - BLI_snprintf(nameBuf, sizeof(nameBuf), "CDA:%s", ipo->id.name + 2); + SNPRINTF(nameBuf, "CDA:%s", ipo->id.name + 2); adt->action = BKE_action_add(bmain, nameBuf); if (G.debug & G_DEBUG) { diff --git a/source/blender/blenkernel/intern/key.cc b/source/blender/blenkernel/intern/key.cc index 3dcddffc166..167f44f4d18 100644 --- a/source/blender/blenkernel/intern/key.cc +++ b/source/blender/blenkernel/intern/key.cc @@ -1841,14 +1841,14 @@ KeyBlock *BKE_keyblock_add(Key *key, const char *name) tot = BLI_listbase_count(&key->block); if (name) { - BLI_strncpy(kb->name, name, sizeof(kb->name)); + STRNCPY(kb->name, name); } else { if (tot == 1) { - BLI_strncpy(kb->name, DATA_("Basis"), sizeof(kb->name)); + STRNCPY(kb->name, DATA_("Basis")); } else { - BLI_snprintf(kb->name, sizeof(kb->name), DATA_("Key %d"), tot - 1); + SNPRINTF(kb->name, DATA_("Key %d"), tot - 1); } } @@ -1961,7 +1961,7 @@ void BKE_keyblock_copy_settings(KeyBlock *kb_dst, const KeyBlock *kb_src) kb_dst->curval = kb_src->curval; kb_dst->type = kb_src->type; kb_dst->relative = kb_src->relative; - BLI_strncpy(kb_dst->vgroup, kb_src->vgroup, sizeof(kb_dst->vgroup)); + STRNCPY(kb_dst->vgroup, kb_src->vgroup); kb_dst->slidermin = kb_src->slidermin; kb_dst->slidermax = kb_src->slidermax; } diff --git a/source/blender/blenkernel/intern/layer.cc b/source/blender/blenkernel/intern/layer.cc index e031ba01d94..cdd260ca5cc 100644 --- a/source/blender/blenkernel/intern/layer.cc +++ b/source/blender/blenkernel/intern/layer.cc @@ -161,7 +161,7 @@ static ViewLayer *view_layer_add(const char *name) ViewLayer *view_layer = MEM_cnew("View Layer"); view_layer->flag = VIEW_LAYER_RENDER | VIEW_LAYER_FREESTYLE; - BLI_strncpy_utf8(view_layer->name, name, sizeof(view_layer->name)); + STRNCPY_UTF8(view_layer->name, name); /* Pure rendering pipeline settings. */ view_layer->layflag = SCE_LAY_FLAG_DEFAULT; @@ -210,7 +210,7 @@ ViewLayer *BKE_view_layer_add(Scene *scene, BKE_view_layer_copy_data(scene, scene, view_layer_new, view_layer_source, 0); BLI_addtail(&scene->view_layers, view_layer_new); - BLI_strncpy_utf8(view_layer_new->name, name, sizeof(view_layer_new->name)); + STRNCPY_UTF8(view_layer_new->name, name); break; } case VIEWLAYER_ADD_EMPTY: { @@ -553,9 +553,9 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con { char oldname[sizeof(view_layer->name)]; - BLI_strncpy(oldname, view_layer->name, sizeof(view_layer->name)); + STRNCPY(oldname, view_layer->name); - BLI_strncpy_utf8(view_layer->name, newname, sizeof(view_layer->name)); + STRNCPY_UTF8(view_layer->name, newname); BLI_uniquename(&scene->view_layers, view_layer, DATA_("ViewLayer"), @@ -570,7 +570,7 @@ void BKE_view_layer_rename(Main *bmain, Scene *scene, ViewLayer *view_layer, con for (node = static_cast(scene->nodetree->nodes.first); node; node = node->next) { if (node->type == CMP_NODE_R_LAYERS && node->id == nullptr) { if (node->custom1 == index) { - BLI_strncpy(node->name, view_layer->name, NODE_MAXSTR); + STRNCPY(node->name, view_layer->name); } } } @@ -2522,7 +2522,7 @@ ViewLayerAOV *BKE_view_layer_add_aov(ViewLayer *view_layer) ViewLayerAOV *aov; aov = MEM_cnew(__func__); aov->type = AOV_TYPE_COLOR; - BLI_strncpy(aov->name, DATA_("AOV"), sizeof(aov->name)); + STRNCPY(aov->name, DATA_("AOV")); BLI_addtail(&view_layer->aovs, aov); viewlayer_aov_active_set(view_layer, aov); viewlayer_aov_make_name_unique(view_layer); @@ -2643,10 +2643,10 @@ ViewLayerLightgroup *BKE_view_layer_add_lightgroup(ViewLayer *view_layer, const ViewLayerLightgroup *lightgroup; lightgroup = MEM_cnew(__func__); if (name && name[0]) { - BLI_strncpy(lightgroup->name, name, sizeof(lightgroup->name)); + STRNCPY(lightgroup->name, name); } else { - BLI_strncpy(lightgroup->name, DATA_("Lightgroup"), sizeof(lightgroup->name)); + STRNCPY(lightgroup->name, DATA_("Lightgroup")); } BLI_addtail(&view_layer->lightgroups, lightgroup); viewlayer_lightgroup_active_set(view_layer, lightgroup); @@ -2690,8 +2690,8 @@ void BKE_view_layer_rename_lightgroup(Scene *scene, const char *name) { char old_name[64]; - BLI_strncpy_utf8(old_name, lightgroup->name, sizeof(old_name)); - BLI_strncpy_utf8(lightgroup->name, name, sizeof(lightgroup->name)); + STRNCPY_UTF8(old_name, lightgroup->name); + STRNCPY_UTF8(lightgroup->name, name); viewlayer_lightgroup_make_name_unique(view_layer, lightgroup); if (scene != nullptr) { @@ -2700,7 +2700,7 @@ void BKE_view_layer_rename_lightgroup(Scene *scene, if (!ID_IS_LINKED(ob) && ob->lightgroup != nullptr) { LightgroupMembership *lgm = ob->lightgroup; if (STREQ(lgm->name, old_name)) { - BLI_strncpy_utf8(lgm->name, lightgroup->name, sizeof(lgm->name)); + STRNCPY_UTF8(lgm->name, lightgroup->name); } } } @@ -2711,7 +2711,7 @@ void BKE_view_layer_rename_lightgroup(Scene *scene, scene->world->lightgroup != nullptr) { LightgroupMembership *lgm = scene->world->lightgroup; if (STREQ(lgm->name, old_name)) { - BLI_strncpy_utf8(lgm->name, lightgroup->name, sizeof(lgm->name)); + STRNCPY_UTF8(lgm->name, lightgroup->name); } } } diff --git a/source/blender/blenkernel/intern/layer_test.cc b/source/blender/blenkernel/intern/layer_test.cc index 9dccef76649..8cbf429a919 100644 --- a/source/blender/blenkernel/intern/layer_test.cc +++ b/source/blender/blenkernel/intern/layer_test.cc @@ -60,7 +60,7 @@ TEST(view_layer, aov_unique_names) EXPECT_TRUE(STREQ(aov2->name, "AOV_001")); /* Revert previous resolution */ - BLI_strncpy(aov2->name, "AOV", MAX_NAME); + STRNCPY(aov2->name, "AOV"); BKE_view_layer_verify_aov(engine, &scene, view_layer); EXPECT_TRUE(BKE_view_layer_has_valid_aov(view_layer)); EXPECT_FALSE((aov1->flag & AOV_CONFLICT) != 0); @@ -97,7 +97,7 @@ static void test_render_pass_conflict(Scene *scene, RNA_boolean_set(&ptr, rna_prop_name, false); /* Rename to Conflicting name */ - BLI_strncpy(aov->name, render_pass_name, MAX_NAME); + STRNCPY(aov->name, render_pass_name); BKE_view_layer_verify_aov(engine, scene, view_layer); EXPECT_TRUE(BKE_view_layer_has_valid_aov(view_layer)); EXPECT_FALSE((aov->flag & AOV_CONFLICT) != 0); diff --git a/source/blender/blenkernel/intern/lib_id.c b/source/blender/blenkernel/intern/lib_id.c index 036a1bb07f7..5fbea894c5d 100644 --- a/source/blender/blenkernel/intern/lib_id.c +++ b/source/blender/blenkernel/intern/lib_id.c @@ -1361,7 +1361,7 @@ void BKE_libblock_copy_ex(Main *bmain, const ID *id, ID **r_newid, const int ori if ((flag & LIB_ID_CREATE_NO_ALLOCATE) != 0) { /* r_newid already contains pointer to allocated memory. */ /* TODO: do we want to memset(0) whole mem before filling it? */ - BLI_strncpy(new_id->name, id->name, sizeof(new_id->name)); + STRNCPY(new_id->name, id->name); new_id->us = 0; new_id->tag |= LIB_TAG_NOT_ALLOCATED | LIB_TAG_NO_MAIN | LIB_TAG_NO_USER_REFCOUNT; /* TODO: Do we want/need to copy more from ID struct itself? */ @@ -1597,11 +1597,11 @@ bool BKE_id_new_name_validate( tname = id->name + 2; } /* Make a copy of given name (tname args can be const). */ - BLI_strncpy(name, tname, sizeof(name)); + STRNCPY(name, tname); if (name[0] == '\0') { /* Disallow empty names. */ - BLI_strncpy(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name))), sizeof(name)); + STRNCPY(name, DATA_(BKE_idtype_idcode_to_name(GS(id->name)))); } else { /* disallow non utf8 chars, diff --git a/source/blender/blenkernel/intern/lib_id_remapper_test.cc b/source/blender/blenkernel/intern/lib_id_remapper_test.cc index 03f456d2d1e..3ee80198112 100644 --- a/source/blender/blenkernel/intern/lib_id_remapper_test.cc +++ b/source/blender/blenkernel/intern/lib_id_remapper_test.cc @@ -39,8 +39,8 @@ TEST(lib_id_remapper, mapped) ID id1; ID id2; ID *idp = &id1; - BLI_strncpy(id1.name, "OB1", sizeof(id1.name)); - BLI_strncpy(id2.name, "OB2", sizeof(id2.name)); + STRNCPY(id1.name, "OB1"); + STRNCPY(id2.name, "OB2"); IDRemapper *remapper = BKE_id_remapper_create(); BKE_id_remapper_add(remapper, &id1, &id2); @@ -55,7 +55,7 @@ TEST(lib_id_remapper, unassigned) { ID id1; ID *idp = &id1; - BLI_strncpy(id1.name, "OB2", sizeof(id1.name)); + STRNCPY(id1.name, "OB2"); IDRemapper *remapper = BKE_id_remapper_create(); BKE_id_remapper_add(remapper, &id1, nullptr); @@ -73,9 +73,9 @@ TEST(lib_id_remapper, unassign_when_mapped_to_self) ID id2; ID *idp; - BLI_strncpy(id_self.name, "OBSelf", sizeof(id1.name)); - BLI_strncpy(id1.name, "OB1", sizeof(id1.name)); - BLI_strncpy(id2.name, "OB2", sizeof(id2.name)); + STRNCPY(id_self.name, "OBSelf"); + STRNCPY(id1.name, "OB1"); + STRNCPY(id2.name, "OB2"); /* Default mapping behavior. Should just remap to id2. */ idp = &id1; diff --git a/source/blender/blenkernel/intern/lib_override.cc b/source/blender/blenkernel/intern/lib_override.cc index 528bce8ef3c..fd3446b68bb 100644 --- a/source/blender/blenkernel/intern/lib_override.cc +++ b/source/blender/blenkernel/intern/lib_override.cc @@ -4323,7 +4323,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local) * different from reference linked ID. But local ID names need to be unique in a given type * list of Main, so we cannot always keep it identical, which is why we need this special * manual handling here. */ - BLI_strncpy(tmp_id->name, local->name, sizeof(tmp_id->name)); + STRNCPY(tmp_id->name, local->name); /* Those ugly loop-back pointers again. Luckily we only need to deal with the shape keys here, * collections' parents are fully runtime and reconstructed later. */ @@ -4333,7 +4333,7 @@ void BKE_lib_override_library_update(Main *bmain, ID *local) tmp_key->id.flag |= (local_key->id.flag & LIB_EMBEDDED_DATA_LIB_OVERRIDE); BKE_main_namemap_remove_name(bmain, &tmp_key->id, tmp_key->id.name + 2); tmp_key->id.lib = local_key->id.lib; - BLI_strncpy(tmp_key->id.name, local_key->id.name, sizeof(tmp_key->id.name)); + STRNCPY(tmp_key->id.name, local_key->id.name); } PointerRNA rnaptr_src, rnaptr_dst, rnaptr_storage_stack, *rnaptr_storage = nullptr; diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c index c883f8747e1..cbbaa868fc1 100644 --- a/source/blender/blenkernel/intern/library.c +++ b/source/blender/blenkernel/intern/library.c @@ -113,10 +113,10 @@ void BKE_library_filepath_set(Main *bmain, Library *lib, const char *filepath) /* in some cases this is used to update the absolute path from the * relative */ if (lib->filepath != filepath) { - BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath)); + STRNCPY(lib->filepath, filepath); } - BLI_strncpy(lib->filepath_abs, filepath, sizeof(lib->filepath_abs)); + STRNCPY(lib->filepath_abs, filepath); /* Not essential but set `filepath_abs` is an absolute copy of value which * is more useful if its kept in sync. */ diff --git a/source/blender/blenkernel/intern/linestyle.cc b/source/blender/blenkernel/intern/linestyle.cc index 2b29d44e3c4..e1840a9af63 100644 --- a/source/blender/blenkernel/intern/linestyle.cc +++ b/source/blender/blenkernel/intern/linestyle.cc @@ -815,7 +815,7 @@ static LineStyleModifier *new_modifier(const char *name, int type, size_t size) } m = (LineStyleModifier *)MEM_callocN(size, "line style modifier"); m->type = type; - BLI_strncpy(m->name, name, sizeof(m->name)); + STRNCPY(m->name, name); m->influence = 1.0f; m->flags = LS_MODIFIER_ENABLED | LS_MODIFIER_EXPANDED; diff --git a/source/blender/blenkernel/intern/main.c b/source/blender/blenkernel/intern/main.c index 474f173778d..f4dc89d91c7 100644 --- a/source/blender/blenkernel/intern/main.c +++ b/source/blender/blenkernel/intern/main.c @@ -377,8 +377,8 @@ static LibWeakRefKey *lib_weak_key_create(LibWeakRefKey *key, if (key == NULL) { key = MEM_mallocN(sizeof(*key), __func__); } - BLI_strncpy(key->filepath, lib_path, sizeof(key->filepath)); - BLI_strncpy(key->id_name, id_name, sizeof(key->id_name)); + STRNCPY(key->filepath, lib_path); + STRNCPY(key->id_name, id_name); return key; } @@ -463,12 +463,8 @@ void BKE_main_library_weak_reference_add_item(GHash *library_weak_reference_mapp BLI_assert(!already_exist_in_mapping); UNUSED_VARS_NDEBUG(already_exist_in_mapping); - BLI_strncpy(new_id->library_weak_reference->library_filepath, - library_filepath, - sizeof(new_id->library_weak_reference->library_filepath)); - BLI_strncpy(new_id->library_weak_reference->library_id_name, - library_id_name, - sizeof(new_id->library_weak_reference->library_id_name)); + STRNCPY(new_id->library_weak_reference->library_filepath, library_filepath); + STRNCPY(new_id->library_weak_reference->library_id_name, library_id_name); *id_p = new_id; } diff --git a/source/blender/blenkernel/intern/main_namemap.cc b/source/blender/blenkernel/intern/main_namemap.cc index b37eaac057e..3aa0e522dfa 100644 --- a/source/blender/blenkernel/intern/main_namemap.cc +++ b/source/blender/blenkernel/intern/main_namemap.cc @@ -47,7 +47,7 @@ using namespace blender; static bool id_name_final_build(char *name, char *base_name, size_t base_name_len, int number) { char number_str[11]; /* Dot + nine digits + NULL terminator. */ - size_t number_str_len = BLI_snprintf_rlen(number_str, ARRAY_SIZE(number_str), ".%.3d", number); + size_t number_str_len = SNPRINTF_RLEN(number_str, ".%.3d", number); /* If the number would lead to an overflow of the maximum ID name length, we need to truncate * the base name part and do all the number checks again. */ @@ -229,7 +229,7 @@ static void main_namemap_populate(UniqueName_Map *name_map, struct Main *bmain, /* Insert the full name into the set. */ UniqueName_Key key; - BLI_strncpy(key.name, id->name + 2, MAX_NAME); + STRNCPY(key.name, id->name + 2); type_map->full_names.add(key); /* Get the name and number parts ("name.number"). */ @@ -279,7 +279,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name) UniqueName_Key key; while (true) { /* Check if the full original name has a duplicate. */ - BLI_strncpy(key.name, name, MAX_NAME); + STRNCPY(key.name, name); const bool has_dup = type_map->full_names.contains(key); /* Get the name and number parts ("name.number"). */ @@ -299,7 +299,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name) val.mark_used(number); if (!has_dup) { - BLI_strncpy(key.name, name, MAX_NAME); + STRNCPY(key.name, name); type_map->full_names.add(key); } return is_name_changed; @@ -334,7 +334,7 @@ bool BKE_main_namemap_get_name(struct Main *bmain, struct ID *id, char *name) BLI_assert(number_to_use >= MIN_NUMBER); if (id_name_final_build(name, key.name, base_name_len, number_to_use)) { /* All good, add final name to the set. */ - BLI_strncpy(key.name, name, MAX_NAME); + STRNCPY(key.name, name); type_map->full_names.add(key); break; } @@ -369,7 +369,7 @@ void BKE_main_namemap_remove_name(struct Main *bmain, struct ID *id, const char UniqueName_Key key; /* Remove full name from the set. */ - BLI_strncpy(key.name, name, MAX_NAME); + STRNCPY(key.name, name); type_map->full_names.remove(key); int number = MIN_NUMBER; @@ -408,7 +408,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix) FOREACH_MAIN_LISTBASE_BEGIN (bmain, lb_iter) { LISTBASE_FOREACH_MUTABLE (ID *, id_iter, lb_iter) { Uniqueness_Key key; - BLI_strncpy(key.name, id_iter->name, MAX_ID_NAME); + STRNCPY(key.name, id_iter->name); key.lib = id_iter->lib; if (!id_names_libs.add(key)) { is_valid = false; @@ -421,7 +421,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix) * not really an issue. */ BKE_id_new_name_validate( bmain, which_libbase(bmain, GS(id_iter->name)), id_iter, nullptr, true); - BLI_strncpy(key.name, id_iter->name, MAX_ID_NAME); + STRNCPY(key.name, id_iter->name); if (!id_names_libs.add(key)) { CLOG_ERROR(&LOG, "\tID has been renamed to '%s', but it still seems to be already in use", @@ -442,7 +442,7 @@ static bool main_namemap_validate_and_fix(Main *bmain, const bool do_fix) UniqueName_Key key_namemap; /* Remove full name from the set. */ - BLI_strncpy(key_namemap.name, id_iter->name + 2, MAX_NAME); + STRNCPY(key_namemap.name, id_iter->name + 2); if (!type_map->full_names.contains(key_namemap)) { is_valid = false; CLOG_ERROR(&LOG, diff --git a/source/blender/blenkernel/intern/mask.cc b/source/blender/blenkernel/intern/mask.cc index 24f70c9c374..140a86557da 100644 --- a/source/blender/blenkernel/intern/mask.cc +++ b/source/blender/blenkernel/intern/mask.cc @@ -336,7 +336,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name) MaskLayer *masklay = MEM_cnew(__func__); if (name && name[0]) { - BLI_strncpy(masklay->name, name, sizeof(masklay->name)); + STRNCPY(masklay->name, name); } else { strcpy(masklay->name, DATA_("MaskLayer")); @@ -389,7 +389,7 @@ void BKE_mask_layer_unique_name(Mask *mask, MaskLayer *masklay) void BKE_mask_layer_rename(Mask *mask, MaskLayer *masklay, char *oldname, char *newname) { - BLI_strncpy(masklay->name, newname, sizeof(masklay->name)); + STRNCPY(masklay->name, newname); BKE_mask_layer_unique_name(mask, masklay); @@ -401,7 +401,7 @@ MaskLayer *BKE_mask_layer_copy(const MaskLayer *masklay) { MaskLayer *masklay_new = MEM_cnew("new mask layer"); - BLI_strncpy(masklay_new->name, masklay->name, sizeof(masklay_new->name)); + STRNCPY(masklay_new->name, masklay->name); masklay_new->alpha = masklay->alpha; masklay_new->blend = masklay->blend; @@ -1011,7 +1011,7 @@ Mask *BKE_mask_new(Main *bmain, const char *name) char mask_name[MAX_ID_NAME - 2]; if (name && name[0]) { - BLI_strncpy(mask_name, name, sizeof(mask_name)); + STRNCPY(mask_name, name); } else { strcpy(mask_name, "Mask"); diff --git a/source/blender/blenkernel/intern/mesh_convert.cc b/source/blender/blenkernel/intern/mesh_convert.cc index 40dbc03586f..fc06793bb44 100644 --- a/source/blender/blenkernel/intern/mesh_convert.cc +++ b/source/blender/blenkernel/intern/mesh_convert.cc @@ -770,7 +770,7 @@ static Mesh *mesh_new_from_mesh(Object *object, Mesh *mesh) nullptr, &mesh->id, nullptr, LIB_ID_CREATE_NO_MAIN | LIB_ID_CREATE_NO_USER_REFCOUNT); /* NOTE: Materials should already be copied. */ /* Copy original mesh name. This is because edit meshes might not have one properly set name. */ - BLI_strncpy(mesh_result->id.name, ((ID *)object->data)->name, sizeof(mesh_result->id.name)); + STRNCPY(mesh_result->id.name, ((ID *)object->data)->name); return mesh_result; } diff --git a/source/blender/blenkernel/intern/modifier.cc b/source/blender/blenkernel/intern/modifier.cc index 15baafbc166..3b277f869f0 100644 --- a/source/blender/blenkernel/intern/modifier.cc +++ b/source/blender/blenkernel/intern/modifier.cc @@ -137,7 +137,7 @@ static ModifierData *modifier_allocate_and_init(ModifierType type) ModifierData *md = static_cast(MEM_callocN(mti->structSize, mti->structName)); /* NOTE: this name must be made unique later. */ - BLI_strncpy(md->name, DATA_(mti->name), sizeof(md->name)); + STRNCPY(md->name, DATA_(mti->name)); md->type = type; md->mode = eModifierMode_Realtime | eModifierMode_Render; @@ -329,7 +329,7 @@ ModifierData *BKE_modifier_copy_ex(const ModifierData *md, int flag) { ModifierData *md_dst = modifier_allocate_and_init(ModifierType(md->type)); - BLI_strncpy(md_dst->name, md->name, sizeof(md_dst->name)); + STRNCPY(md_dst->name, md->name); BKE_modifier_copydata_ex(md, md_dst, flag); return md_dst; diff --git a/source/blender/blenkernel/intern/movieclip.c b/source/blender/blenkernel/intern/movieclip.c index 81e7d398e56..34baffa78ae 100644 --- a/source/blender/blenkernel/intern/movieclip.c +++ b/source/blender/blenkernel/intern/movieclip.c @@ -518,10 +518,10 @@ static void get_proxy_filepath(const MovieClip *clip, BLI_path_split_dir_file(clip->filepath, clipdir, FILE_MAX, clipfile, FILE_MAX); if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) { - BLI_strncpy(dir, clip->proxy.dir, sizeof(dir)); + STRNCPY(dir, clip->proxy.dir); } else { - BLI_snprintf(dir, sizeof(dir), "%s" SEP_STR "BL_proxy", clipdir); + SNPRINTF(dir, "%s" SEP_STR "BL_proxy", clipdir); } if (undistorted) { @@ -671,7 +671,7 @@ static void movieclip_open_anim_file(MovieClip *clip) char str[FILE_MAX]; if (!clip->anim) { - BLI_strncpy(str, clip->filepath, FILE_MAX); + STRNCPY(str, clip->filepath); BLI_path_abs(str, ID_BLEND_PATH_FROM_GLOBAL(&clip->id)); /* FIXME: make several stream accessible in image editor, too */ @@ -680,7 +680,7 @@ static void movieclip_open_anim_file(MovieClip *clip) if (clip->anim) { if (clip->flag & MCLIP_USE_PROXY_CUSTOM_DIR) { char dir[FILE_MAX]; - BLI_strncpy(dir, clip->proxy.dir, sizeof(dir)); + STRNCPY(dir, clip->proxy.dir); BLI_path_abs(dir, BKE_main_blendfile_path_from_global()); IMB_anim_set_index_dir(clip->anim, dir); } @@ -935,7 +935,7 @@ static bool put_imbuf_cache( struct MovieCache *moviecache; // char cache_name[64]; - // BLI_snprintf(cache_name, sizeof(cache_name), "movie %s", clip->id.name); + // SNPRINTF(cache_name, "movie %s", clip->id.name); clip->cache = MEM_callocN(sizeof(MovieClipCache), "movieClipCache"); @@ -1018,7 +1018,7 @@ static void detect_clip_source(Main *bmain, MovieClip *clip) ImBuf *ibuf; char filepath[FILE_MAX]; - BLI_strncpy(filepath, clip->filepath, sizeof(filepath)); + STRNCPY(filepath, clip->filepath); BLI_path_abs(filepath, BKE_main_blendfile_path(bmain)); ibuf = IMB_testiffname(filepath, IB_rect | IB_multilayer); @@ -1037,7 +1037,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath) int file; char str[FILE_MAX]; - BLI_strncpy(str, filepath, sizeof(str)); + STRNCPY(str, filepath); BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* exists? */ @@ -1051,7 +1051,7 @@ MovieClip *BKE_movieclip_file_add(Main *bmain, const char *filepath) /* create a short library name */ clip = movieclip_alloc(bmain, BLI_path_basename(filepath)); - BLI_strncpy(clip->filepath, filepath, sizeof(clip->filepath)); + STRNCPY(clip->filepath, filepath); detect_clip_source(bmain, clip); @@ -1072,12 +1072,12 @@ MovieClip *BKE_movieclip_file_add_exists_ex(Main *bmain, const char *filepath, b MovieClip *clip; char str[FILE_MAX], strtest[FILE_MAX]; - BLI_strncpy(str, filepath, sizeof(str)); + STRNCPY(str, filepath); BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (clip = bmain->movieclips.first; clip; clip = clip->id.next) { - BLI_strncpy(strtest, clip->filepath, sizeof(clip->filepath)); + STRNCPY(strtest, clip->filepath); BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &clip->id)); if (BLI_path_cmp(strtest, str) == 0) { diff --git a/source/blender/blenkernel/intern/nla.c b/source/blender/blenkernel/intern/nla.c index 0a4d5e43d18..70823538cd3 100644 --- a/source/blender/blenkernel/intern/nla.c +++ b/source/blender/blenkernel/intern/nla.c @@ -517,7 +517,7 @@ NlaStrip *BKE_nlastack_add_strip(AnimData *adt, bAction *act, const bool is_libo nlt = BKE_nlatrack_new_tail(&adt->nla_tracks, is_liboverride); BKE_nlatrack_set_active(&adt->nla_tracks, nlt); BKE_nlatrack_add_strip(nlt, strip, is_liboverride); - BLI_strncpy(nlt->name, act->id.name + 2, sizeof(nlt->name)); + STRNCPY(nlt->name, act->id.name + 2); } /* automatically name it too */ @@ -1798,18 +1798,16 @@ void BKE_nlastrip_validate_name(AnimData *adt, NlaStrip *strip) if (strip->name[0] == 0) { switch (strip->type) { case NLASTRIP_TYPE_CLIP: /* act-clip */ - BLI_strncpy(strip->name, - (strip->act) ? (strip->act->id.name + 2) : (""), - sizeof(strip->name)); + STRNCPY(strip->name, (strip->act) ? (strip->act->id.name + 2) : ("")); break; case NLASTRIP_TYPE_TRANSITION: /* transition */ - BLI_strncpy(strip->name, "Transition", sizeof(strip->name)); + STRNCPY(strip->name, "Transition"); break; case NLASTRIP_TYPE_META: /* meta */ - BLI_strncpy(strip->name, "Meta", sizeof(strip->name)); + STRNCPY(strip->name, "Meta"); break; default: - BLI_strncpy(strip->name, "NLA Strip", sizeof(strip->name)); + STRNCPY(strip->name, "NLA Strip"); break; } } @@ -2066,7 +2064,7 @@ bool BKE_nla_action_stash(AnimData *adt, const bool is_liboverride) BLI_addhead(&adt->nla_tracks, nlt); } - BLI_strncpy(nlt->name, STASH_TRACK_NAME, sizeof(nlt->name)); + STRNCPY(nlt->name, STASH_TRACK_NAME); BLI_uniquename( &adt->nla_tracks, nlt, STASH_TRACK_NAME, '.', offsetof(NlaTrack, name), sizeof(nlt->name)); diff --git a/source/blender/blenkernel/intern/node.cc b/source/blender/blenkernel/intern/node.cc index abee776bceb..44af925ec60 100644 --- a/source/blender/blenkernel/intern/node.cc +++ b/source/blender/blenkernel/intern/node.cc @@ -1159,7 +1159,7 @@ static void node_init(const bContext *C, bNodeTree *ntree, bNode *node) * Data have their own translation option! * This solution may be a bit rougher than nodeLabel()'s returned string, but it's simpler * than adding "do_translate" flags to this func (and labelfunc() as well). */ - BLI_strncpy(node->name, DATA_(ntype->ui_name), NODE_MAXSTR); + STRNCPY(node->name, DATA_(ntype->ui_name)); nodeUniqueName(ntree, node); /* Generally sockets should be added after the initialization, because the set of sockets might @@ -1596,11 +1596,11 @@ static bNodeSocket *make_socket(bNodeTree *ntree, if (identifier && identifier[0] != '\0') { /* use explicit identifier */ - BLI_strncpy(auto_identifier, identifier, sizeof(auto_identifier)); + STRNCPY(auto_identifier, identifier); } else { /* if no explicit identifier is given, assign a unique identifier based on the name */ - BLI_strncpy(auto_identifier, name, sizeof(auto_identifier)); + STRNCPY(auto_identifier, name); } /* Make the identifier unique. */ BLI_uniquename_cb( @@ -1610,15 +1610,15 @@ static bNodeSocket *make_socket(bNodeTree *ntree, sock->runtime = MEM_new(__func__); sock->in_out = in_out; - BLI_strncpy(sock->identifier, auto_identifier, NODE_MAXSTR); + STRNCPY(sock->identifier, auto_identifier); sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF); - BLI_strncpy(sock->name, name, NODE_MAXSTR); + STRNCPY(sock->name, name); sock->storage = nullptr; sock->flag |= SOCK_COLLAPSED; sock->type = SOCK_CUSTOM; /* int type undefined by default */ - BLI_strncpy(sock->idname, idname, sizeof(sock->idname)); + STRNCPY(sock->idname, idname); node_socket_set_typeinfo(ntree, sock, nodeSocketTypeFind(idname)); return sock; @@ -1772,7 +1772,7 @@ void nodeModifySocketType(bNodeTree *ntree, } } - BLI_strncpy(sock->idname, idname, sizeof(sock->idname)); + STRNCPY(sock->idname, idname); node_socket_set_typeinfo(ntree, sock, socktype); } @@ -2327,7 +2327,7 @@ bNode *nodeAddNode(const bContext *C, bNodeTree *ntree, const char *idname) BLI_addtail(&ntree->nodes, node); nodeUniqueID(ntree, node); - BLI_strncpy(node->idname, idname, sizeof(node->idname)); + STRNCPY(node->idname, idname); node_set_typeinfo(C, ntree, node, nodeTypeFind(idname)); BKE_ntree_update_tag_node_new(ntree, node); @@ -2898,7 +2898,7 @@ static bNodeTree *ntreeAddTree_do( BLI_assert(owner_id == nullptr); } - BLI_strncpy(ntree->idname, idname, sizeof(ntree->idname)); + STRNCPY(ntree->idname, idname); ntree_set_typeinfo(ntree, ntreeTypeFind(idname)); return ntree; @@ -3283,7 +3283,7 @@ void nodeRemoveNode(Main *bmain, bNodeTree *ntree, bNode *node, const bool do_id char prefix[MAX_IDPROP_NAME * 2]; BLI_str_escape(propname_esc, node->name, sizeof(propname_esc)); - BLI_snprintf(prefix, sizeof(prefix), "nodes[\"%s\"]", propname_esc); + SNPRINTF(prefix, "nodes[\"%s\"]", propname_esc); if (BKE_animdata_fix_paths_remove(&ntree->id, prefix)) { if (bmain != nullptr) { @@ -3538,7 +3538,7 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree, bNodeSocket *sock = MEM_cnew("socket template"); sock->runtime = MEM_new(__func__); - BLI_strncpy(sock->idname, stype->idname, sizeof(sock->idname)); + STRNCPY(sock->idname, stype->idname); sock->in_out = int(in_out); sock->type = int(SOCK_CUSTOM); /* int type undefined by default */ node_socket_set_typeinfo(ntree, sock, stype); @@ -3547,15 +3547,15 @@ static bNodeSocket *make_socket_interface(bNodeTree *ntree, const int own_index = ntree->cur_index++; /* use the own_index as socket identifier */ if (in_out == SOCK_IN) { - BLI_snprintf(sock->identifier, MAX_NAME, "Input_%d", own_index); + SNPRINTF(sock->identifier, "Input_%d", own_index); } else { - BLI_snprintf(sock->identifier, MAX_NAME, "Output_%d", own_index); + SNPRINTF(sock->identifier, "Output_%d", own_index); } sock->limit = (in_out == SOCK_IN ? 1 : 0xFFF); - BLI_strncpy(sock->name, name, NODE_MAXSTR); + STRNCPY(sock->name, name); sock->storage = nullptr; sock->flag |= SOCK_COLLAPSED; @@ -4158,7 +4158,7 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh */ #define DefNode(Category, ID, DefFunc, EnumName, StructName, UIName, UIDesc) \ case ID: \ - BLI_strncpy(ntype->idname, #Category #StructName, sizeof(ntype->idname)); \ + STRNCPY(ntype->idname, #Category #StructName); \ ntype->rna_ext.srna = RNA_struct_find(#Category #StructName); \ BLI_assert(ntype->rna_ext.srna != nullptr); \ RNA_struct_blender_type_set(ntype->rna_ext.srna, ntype); \ @@ -4172,7 +4172,7 @@ void node_type_base(bNodeType *ntype, const int type, const char *name, const sh BLI_assert(ntype->idname[0] != '\0'); ntype->type = type; - BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name)); + STRNCPY(ntype->ui_name, name); ntype->nclass = nclass; node_type_base_defaults(ntype); @@ -4186,9 +4186,9 @@ void node_type_base_custom(bNodeType *ntype, const char *name, const short nclass) { - BLI_strncpy(ntype->idname, idname, sizeof(ntype->idname)); + STRNCPY(ntype->idname, idname); ntype->type = NODE_CUSTOM; - BLI_strncpy(ntype->ui_name, name, sizeof(ntype->ui_name)); + STRNCPY(ntype->ui_name, name); ntype->nclass = nclass; node_type_base_defaults(ntype); @@ -4247,7 +4247,7 @@ void node_type_socket_templates(bNodeType *ntype, } for (bNodeSocketTemplate *ntemp = inputs; ntemp->type >= 0; ntemp++) { - BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier)); + STRNCPY(ntemp->identifier, ntemp->name); unique_socket_template_identifier(inputs, ntemp, ntemp->identifier, '_'); } } @@ -4258,7 +4258,7 @@ void node_type_socket_templates(bNodeType *ntype, } for (bNodeSocketTemplate *ntemp = outputs; ntemp->type >= 0; ntemp++) { - BLI_strncpy(ntemp->identifier, ntemp->name, sizeof(ntemp->identifier)); + STRNCPY(ntemp->identifier, ntemp->name); unique_socket_template_identifier(outputs, ntemp, ntemp->identifier, '_'); } } @@ -4302,7 +4302,7 @@ void node_type_storage(bNodeType *ntype, const bNode *src_node)) { if (storagename) { - BLI_strncpy(ntype->storagename, storagename, sizeof(ntype->storagename)); + STRNCPY(ntype->storagename, storagename); } else { ntype->storagename[0] = '\0'; diff --git a/source/blender/blenkernel/intern/object.cc b/source/blender/blenkernel/intern/object.cc index d4bb1112971..acca27b63f2 100644 --- a/source/blender/blenkernel/intern/object.cc +++ b/source/blender/blenkernel/intern/object.cc @@ -216,7 +216,7 @@ static void object_copy_data(Main *bmain, ID *id_dst, const ID *id_src, const in BLI_listbase_clear(&ob_dst->shader_fx); LISTBASE_FOREACH (ShaderFxData *, fx, &ob_src->shader_fx) { ShaderFxData *nfx = BKE_shaderfx_new(fx->type); - BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name)); + STRNCPY(nfx->name, fx->name); BKE_shaderfx_copydata_ex(fx, nfx, flag_subdata); BLI_addtail(&ob_dst->shader_fx, nfx); } @@ -1574,7 +1574,7 @@ bool BKE_object_copy_modifier( else { md_dst = BKE_modifier_new(md_src->type); - BLI_strncpy(md_dst->name, md_src->name, sizeof(md_dst->name)); + STRNCPY(md_dst->name, md_src->name); if (md_src->type == eModifierType_Multires) { /* Has to be done after mod creation, but *before* we actually copy its settings! */ @@ -1618,7 +1618,7 @@ bool BKE_object_copy_gpencil_modifier(struct Object *ob_dst, GpencilModifierData BLI_assert(ob_dst->type == OB_GPENCIL_LEGACY); GpencilModifierData *gmd_dst = BKE_gpencil_modifier_new(gmd_src->type); - BLI_strncpy(gmd_dst->name, gmd_src->name, sizeof(gmd_dst->name)); + STRNCPY(gmd_dst->name, gmd_src->name); const GpencilModifierTypeInfo *mti = BKE_gpencil_modifier_get_info( (GpencilModifierType)gmd_src->type); @@ -1663,7 +1663,7 @@ bool BKE_object_modifier_stack_copy(Object *ob_dst, LISTBASE_FOREACH (GpencilModifierData *, gmd_src, &ob_src->greasepencil_modifiers) { GpencilModifierData *gmd_dst = BKE_gpencil_modifier_new(gmd_src->type); - BLI_strncpy(gmd_dst->name, gmd_src->name, sizeof(gmd_dst->name)); + STRNCPY(gmd_dst->name, gmd_src->name); BKE_gpencil_modifier_copydata_ex(gmd_src, gmd_dst, flag_subdata); BLI_addtail(&ob_dst->greasepencil_modifiers, gmd_dst); } @@ -3595,7 +3595,7 @@ void BKE_object_workob_calc_parent(Depsgraph *depsgraph, Scene *scene, Object *o * object's local loc/rot/scale instead of after. For example, a "Copy Rotation" constraint would * rotate the object's local translation as well. See #82156. */ - BLI_strncpy(workob->parsubstr, ob->parsubstr, sizeof(workob->parsubstr)); + STRNCPY(workob->parsubstr, ob->parsubstr); BKE_object_where_is_calc(depsgraph, scene, workob); } diff --git a/source/blender/blenkernel/intern/object_facemap.c b/source/blender/blenkernel/intern/object_facemap.c index 31404afe07c..c10da333915 100644 --- a/source/blender/blenkernel/intern/object_facemap.c +++ b/source/blender/blenkernel/intern/object_facemap.c @@ -100,7 +100,7 @@ bFaceMap *BKE_object_facemap_add_name(Object *ob, const char *name) fmap = MEM_callocN(sizeof(bFaceMap), __func__); - BLI_strncpy(fmap->name, name, sizeof(fmap->name)); + STRNCPY(fmap->name, name); BLI_addtail(&ob->fmaps, fmap); diff --git a/source/blender/blenkernel/intern/packedFile.c b/source/blender/blenkernel/intern/packedFile.c index 3ce473c7fa4..2a78f4e5a54 100644 --- a/source/blender/blenkernel/intern/packedFile.c +++ b/source/blender/blenkernel/intern/packedFile.c @@ -191,7 +191,7 @@ PackedFile *BKE_packedfile_new(ReportList *reports, const char *filepath_rel, co /* convert relative filenames to absolute filenames */ - BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + STRNCPY(filepath, filepath_rel); BLI_path_abs(filepath, basepath); /* open the file @@ -299,12 +299,12 @@ int BKE_packedfile_write_to_file(ReportList *reports, if (guimode) { } // XXX waitcursor(1); - BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + STRNCPY(filepath, filepath_rel); BLI_path_abs(filepath, ref_file_name); if (BLI_exists(filepath)) { for (number = 1; number <= 999; number++) { - BLI_snprintf(filepath_temp, sizeof(filepath_temp), "%s.%03d_", filepath, number); + SNPRINTF(filepath_temp, "%s.%03d_", filepath, number); if (!BLI_exists(filepath_temp)) { if (BLI_copy(filepath, filepath_temp) == RET_OK) { remove_tmp = true; @@ -365,7 +365,7 @@ enum ePF_FileCompare BKE_packedfile_compare_to_file(const char *ref_file_name, char buf[4096]; char filepath[FILE_MAX]; - BLI_strncpy(filepath, filepath_rel, sizeof(filepath)); + STRNCPY(filepath, filepath_rel); BLI_path_abs(filepath, ref_file_name); if (BLI_stat(filepath, &st) == -1) { @@ -429,7 +429,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports, case PF_USE_LOCAL: { char temp_abs[FILE_MAX]; - BLI_strncpy(temp_abs, local_name, sizeof(temp_abs)); + STRNCPY(temp_abs, local_name); BLI_path_abs(temp_abs, ref_file_name); /* if file exists use it */ @@ -448,7 +448,7 @@ char *BKE_packedfile_unpack_to_file(ReportList *reports, case PF_USE_ORIGINAL: { char temp_abs[FILE_MAX]; - BLI_strncpy(temp_abs, abs_name, sizeof(temp_abs)); + STRNCPY(temp_abs, abs_name); BLI_path_abs(temp_abs, ref_file_name); /* if file exists use it */ @@ -494,7 +494,7 @@ static void unpack_generate_paths(const char *filepath, if (temp_filename[0] == '\0') { /* NOTE: we generally do not have any real way to re-create extension out of data. */ - const size_t len = BLI_strncpy_rlen(temp_filename, id->name + 2, sizeof(temp_filename)); + const size_t len = STRNCPY_RLEN(temp_filename, id->name + 2); printf("%s\n", temp_filename); /* For images ensure that the temporary filename contains tile number information as well as @@ -507,7 +507,7 @@ static void unpack_generate_paths(const char *filepath, enum eImbFileType ftype = IMB_ispic_type_from_memory((const uchar *)pf->data, pf->size); if (ima->source == IMA_SRC_TILED) { char tile_number[6]; - BLI_snprintf(tile_number, sizeof(tile_number), ".%d", imapf->tile_number); + SNPRINTF(tile_number, ".%d", imapf->tile_number); BLI_strncpy(temp_filename + len, tile_number, sizeof(temp_filename) - len); } if (ftype != IMB_FTYPE_NONE) { @@ -523,7 +523,7 @@ static void unpack_generate_paths(const char *filepath, if (temp_dirname[0] == '\0') { /* Fallback to relative dir. */ - BLI_strncpy(temp_dirname, "//", sizeof(temp_dirname)); + STRNCPY(temp_dirname, "//"); } { @@ -589,7 +589,7 @@ int BKE_packedfile_unpack_vfont(Main *bmain, ret_value = RET_OK; BKE_packedfile_free(vfont->packedfile); vfont->packedfile = NULL; - BLI_strncpy(vfont->filepath, new_file_path, sizeof(vfont->filepath)); + STRNCPY(vfont->filepath, new_file_path); MEM_freeN(new_file_path); } } @@ -608,7 +608,7 @@ int BKE_packedfile_unpack_sound(Main *bmain, char *new_file_path = BKE_packedfile_unpack( bmain, reports, (ID *)sound, sound->filepath, sound->packedfile, how); if (new_file_path != NULL) { - BLI_strncpy(sound->filepath, new_file_path, sizeof(sound->filepath)); + STRNCPY(sound->filepath, new_file_path); MEM_freeN(new_file_path); BKE_packedfile_free(sound->packedfile); @@ -646,12 +646,12 @@ int BKE_packedfile_unpack_image(Main *bmain, /* update the new corresponding view filepath */ iv = BLI_findstring(&ima->views, imapf->filepath, offsetof(ImageView, filepath)); if (iv) { - BLI_strncpy(iv->filepath, new_file_path, sizeof(imapf->filepath)); + STRNCPY(iv->filepath, new_file_path); } /* keep the new name in the image for non-pack specific reasons */ if (how != PF_REMOVE) { - BLI_strncpy(ima->filepath, new_file_path, sizeof(imapf->filepath)); + STRNCPY(ima->filepath, new_file_path); if (ima->source == IMA_SRC_TILED) { /* Ensure that the Image filepath is kept in a tokenized format. */ BKE_image_ensure_tile_token(ima->filepath, sizeof(ima->filepath)); @@ -686,7 +686,7 @@ int BKE_packedfile_unpack_volume(Main *bmain, char *new_file_path = BKE_packedfile_unpack( bmain, reports, (ID *)volume, volume->filepath, volume->packedfile, how); if (new_file_path != NULL) { - BLI_strncpy(volume->filepath, new_file_path, sizeof(volume->filepath)); + STRNCPY(volume->filepath, new_file_path); MEM_freeN(new_file_path); BKE_packedfile_free(volume->packedfile); diff --git a/source/blender/blenkernel/intern/paint.cc b/source/blender/blenkernel/intern/paint.cc index 3c03d679771..9ce1cb867a1 100644 --- a/source/blender/blenkernel/intern/paint.cc +++ b/source/blender/blenkernel/intern/paint.cc @@ -2428,7 +2428,7 @@ static bool sculpt_attribute_create(SculptSession *ss, out->params = *params; out->proptype = proptype; out->domain = domain; - BLI_strncpy_utf8(out->name, name, sizeof(out->name)); + STRNCPY_UTF8(out->name, name); /* Force non-CustomData simple_array mode if not PBVH_FACES. */ if (pbvhtype == PBVH_GRIDS || (pbvhtype == PBVH_BMESH && flat_array_for_bmesh)) { @@ -2696,7 +2696,7 @@ SculptAttribute *BKE_sculpt_attribute_get(struct Object *ob, attr->layer = cdata->layers + index; attr->elem_size = CustomData_get_elem_size(attr->layer); - BLI_strncpy_utf8(attr->name, name, sizeof(attr->name)); + STRNCPY_UTF8(attr->name, name); return attr; } } diff --git a/source/blender/blenkernel/intern/particle.cc b/source/blender/blenkernel/intern/particle.cc index 0320f98e349..891a8ea8d7c 100644 --- a/source/blender/blenkernel/intern/particle.cc +++ b/source/blender/blenkernel/intern/particle.cc @@ -4020,7 +4020,7 @@ static ModifierData *object_add_or_copy_particle_system( psys->part = BKE_particlesettings_add(bmain, DATA_("ParticleSettings")); } md = BKE_modifier_new(eModifierType_ParticleSystem); - BLI_strncpy(md->name, psys->name, sizeof(md->name)); + STRNCPY(md->name, psys->name); BKE_modifier_unique_name(&ob->modifiers, md); psmd = (ParticleSystemModifierData *)md; diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 8bad91e54ee..eb8f6d717c3 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1288,7 +1288,7 @@ static int ptcache_frame_from_filename(const char *filename, const char *ext) if (len > ext_len) { /* using frame_len here gives compile error (vla) */ char num[/* frame_len */ 6 + 1]; - BLI_strncpy(num, filename + len - ext_len, sizeof(num)); + STRNCPY(num, filename + len - ext_len); return atoi(num); } @@ -3503,24 +3503,24 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c } /* save old name */ - BLI_strncpy(old_name, pid->cache->name, sizeof(old_name)); + STRNCPY(old_name, pid->cache->name); /* get "from" filename */ - BLI_strncpy(pid->cache->name, name_src, sizeof(pid->cache->name)); + STRNCPY(pid->cache->name, name_src); len = ptcache_filepath(pid, old_filepath, 0, false, false); /* no path */ ptcache_path(pid, path); dir = opendir(path); if (dir == NULL) { - BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name)); + STRNCPY(pid->cache->name, old_name); return; } ptcache_filepath_ext_append(pid, ext, 0, false, 0); /* put new name into cache */ - BLI_strncpy(pid->cache->name, name_dst, sizeof(pid->cache->name)); + STRNCPY(pid->cache->name, name_dst); while ((de = readdir(dir)) != NULL) { if (strstr(de->d_name, ext)) { /* Do we have the right extension? */ @@ -3538,7 +3538,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c } closedir(dir); - BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name)); + STRNCPY(pid->cache->name, old_name); } void BKE_ptcache_load_external(PTCacheID *pid) @@ -3573,10 +3573,10 @@ void BKE_ptcache_load_external(PTCacheID *pid) const char *fext = ptcache_file_extension(pid); if (cache->index >= 0) { - BLI_snprintf(ext, sizeof(ext), "_%02d%s", cache->index, fext); + SNPRINTF(ext, "_%02d%s", cache->index, fext); } else { - BLI_strncpy(ext, fext, sizeof(ext)); + STRNCPY(ext, fext); } while ((de = readdir(dir)) != NULL) { @@ -3674,13 +3674,13 @@ void BKE_ptcache_update_info(PTCacheID *pid) /* smoke doesn't use frame 0 as info frame so can't check based on totpoint */ if (pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes) { - BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%i frames found!"), totframes); + SNPRINTF(cache->info, TIP_("%i frames found!"), totframes); } else if (totframes && cache->totpoint) { - BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%i points found!"), cache->totpoint); + SNPRINTF(cache->info, TIP_("%i points found!"), cache->totpoint); } else { - BLI_strncpy(cache->info, TIP_("No valid data to read!"), sizeof(cache->info)); + STRNCPY(cache->info, TIP_("No valid data to read!")); } return; } @@ -3690,11 +3690,10 @@ void BKE_ptcache_update_info(PTCacheID *pid) int totpoint = pid->totpoint(pid->calldata, 0); if (cache->totpoint > totpoint) { - BLI_snprintf( - mem_info, sizeof(mem_info), TIP_("%i cells + High Resolution cached"), totpoint); + SNPRINTF(mem_info, TIP_("%i cells + High Resolution cached"), totpoint); } else { - BLI_snprintf(mem_info, sizeof(mem_info), TIP_("%i cells cached"), totpoint); + SNPRINTF(mem_info, TIP_("%i cells cached"), totpoint); } } else { @@ -3706,7 +3705,7 @@ void BKE_ptcache_update_info(PTCacheID *pid) } } - BLI_snprintf(mem_info, sizeof(mem_info), TIP_("%i frames on disk"), totframes); + SNPRINTF(mem_info, TIP_("%i frames on disk"), totframes); } } else { @@ -3734,25 +3733,17 @@ void BKE_ptcache_update_info(PTCacheID *pid) BLI_str_format_int_grouped(formatted_tot, totframes); BLI_str_format_byte_unit(formatted_mem, bytes, false); - BLI_snprintf(mem_info, - sizeof(mem_info), - TIP_("%s frames in memory (%s)"), - formatted_tot, - formatted_mem); + SNPRINTF(mem_info, TIP_("%s frames in memory (%s)"), formatted_tot, formatted_mem); } if (cache->flag & PTCACHE_OUTDATED) { - BLI_snprintf(cache->info, sizeof(cache->info), TIP_("%s, cache is outdated!"), mem_info); + SNPRINTF(cache->info, TIP_("%s, cache is outdated!"), mem_info); } else if (cache->flag & PTCACHE_FRAMES_SKIPPED) { - BLI_snprintf(cache->info, - sizeof(cache->info), - TIP_("%s, not exact since frame %i"), - mem_info, - cache->last_exact); + SNPRINTF(cache->info, TIP_("%s, not exact since frame %i"), mem_info, cache->last_exact); } else { - BLI_snprintf(cache->info, sizeof(cache->info), "%s.", mem_info); + SNPRINTF(cache->info, "%s.", mem_info); } } diff --git a/source/blender/blenkernel/intern/preferences.c b/source/blender/blenkernel/intern/preferences.c index 814390be8f9..90eb6d86e2e 100644 --- a/source/blender/blenkernel/intern/preferences.c +++ b/source/blender/blenkernel/intern/preferences.c @@ -46,7 +46,7 @@ bUserAssetLibrary *BKE_preferences_asset_library_add(UserDef *userdef, BKE_preferences_asset_library_name_set(userdef, library, name); } if (path) { - BLI_strncpy(library->path, path, sizeof(library->path)); + STRNCPY(library->path, path); } return library; @@ -61,7 +61,7 @@ void BKE_preferences_asset_library_name_set(UserDef *userdef, bUserAssetLibrary *library, const char *name) { - BLI_strncpy_utf8(library->name, name, sizeof(library->name)); + STRNCPY_UTF8(library->name, name); BLI_uniquename(&userdef->asset_libraries, library, name, @@ -72,7 +72,7 @@ void BKE_preferences_asset_library_name_set(UserDef *userdef, void BKE_preferences_asset_library_path_set(bUserAssetLibrary *library, const char *path) { - BLI_strncpy(library->path, path, sizeof(library->path)); + STRNCPY(library->path, path); if (BLI_is_file(library->path)) { BLI_path_parent_dir(library->path); } diff --git a/source/blender/blenkernel/intern/scene.cc b/source/blender/blenkernel/intern/scene.cc index 225136ebcbe..0433d086d02 100644 --- a/source/blender/blenkernel/intern/scene.cc +++ b/source/blender/blenkernel/intern/scene.cc @@ -154,7 +154,7 @@ static void scene_init_data(ID *id) MEMCPY_STRUCT_AFTER(scene, DNA_struct_default_get(Scene), id); - BLI_strncpy(scene->r.bake.filepath, U.renderdir, sizeof(scene->r.bake.filepath)); + STRNCPY(scene->r.bake.filepath, U.renderdir); mblur_shutter_curve = &scene->r.mblur_shutter_curve; BKE_curvemapping_set_defaults(mblur_shutter_curve, 1, 0.0f, 0.0f, 1.0f, 1.0f); @@ -203,9 +203,9 @@ static void scene_init_data(ID *id) pset->brush[PE_BRUSH_CUT].strength = 1.0f; } - BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine)); + STRNCPY(scene->r.engine, RE_engine_id_BLENDER_EEVEE); - BLI_strncpy(scene->r.pic, U.renderdir, sizeof(scene->r.pic)); + STRNCPY(scene->r.pic, U.renderdir); /* NOTE: in header_info.c the scene copy happens..., * if you add more to renderdata it has to be checked there. */ @@ -213,11 +213,11 @@ static void scene_init_data(ID *id) /* multiview - stereo */ BKE_scene_add_render_view(scene, STEREO_LEFT_NAME); srv = static_cast(scene->r.views.first); - BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix)); + STRNCPY(srv->suffix, STEREO_LEFT_SUFFIX); BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME); srv = static_cast(scene->r.views.last); - BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix)); + STRNCPY(srv->suffix, STEREO_RIGHT_SUFFIX); BKE_sound_reset_scene_runtime(scene); @@ -227,9 +227,7 @@ static void scene_init_data(ID *id) BKE_color_managed_display_settings_init(&scene->display_settings); BKE_color_managed_view_settings_init_render( &scene->view_settings, &scene->display_settings, "Filmic"); - BLI_strncpy(scene->sequencer_colorspace_settings.name, - colorspace_name, - sizeof(scene->sequencer_colorspace_settings.name)); + STRNCPY(scene->sequencer_colorspace_settings.name, colorspace_name); BKE_image_format_init(&scene->r.im_format, true); BKE_image_format_init(&scene->r.bake.im_format, true); @@ -2853,7 +2851,7 @@ SceneRenderView *BKE_scene_add_render_view(Scene *sce, const char *name) } SceneRenderView *srv = MEM_cnew(__func__); - BLI_strncpy(srv->name, name, sizeof(srv->name)); + STRNCPY(srv->name, name); BLI_uniquename(&sce->r.views, srv, DATA_("RenderView"), @@ -3018,14 +3016,12 @@ void BKE_scene_disable_color_management(Scene *scene) none_display_name = IMB_colormanagement_display_get_none_name(); - BLI_strncpy(display_settings->display_device, - none_display_name, - sizeof(display_settings->display_device)); + STRNCPY(display_settings->display_device, none_display_name); view = IMB_colormanagement_view_get_default_name(display_settings->display_device); if (view) { - BLI_strncpy(view_settings->view_transform, view, sizeof(view_settings->view_transform)); + STRNCPY(view_settings->view_transform, view); } } @@ -3303,10 +3299,10 @@ void BKE_scene_multiview_view_filepath_get(const RenderData *rd, srv = static_cast( BLI_findstring(&rd->views, viewname, offsetof(SceneRenderView, name))); if (srv) { - BLI_strncpy(suffix, srv->suffix, sizeof(suffix)); + STRNCPY(suffix, srv->suffix); } else { - BLI_strncpy(suffix, viewname, sizeof(suffix)); + STRNCPY(suffix, viewname); } BLI_strncpy(r_filepath, filepath, FILE_MAX); @@ -3543,7 +3539,7 @@ static Depsgraph **scene_ensure_depsgraph_p(Main *bmain, Scene *scene, ViewLayer * we will ever enable debug messages for this depsgraph. */ char name[1024]; - BLI_snprintf(name, sizeof(name), "%s :: %s", scene->id.name, view_layer->name); + SNPRINTF(name, "%s :: %s", scene->id.name, view_layer->name); DEG_debug_name_set(*depsgraph_ptr, name); /* These viewport depsgraphs communicate changes to the editors. */ diff --git a/source/blender/blenkernel/intern/shader_fx.c b/source/blender/blenkernel/intern/shader_fx.c index 7b3377e3c6e..26cc5f86194 100644 --- a/source/blender/blenkernel/intern/shader_fx.c +++ b/source/blender/blenkernel/intern/shader_fx.c @@ -65,7 +65,7 @@ ShaderFxData *BKE_shaderfx_new(int type) ShaderFxData *fx = MEM_callocN(fxi->struct_size, fxi->struct_name); /* NOTE: this name must be made unique later. */ - BLI_strncpy(fx->name, DATA_(fxi->name), sizeof(fx->name)); + STRNCPY(fx->name, DATA_(fxi->name)); fx->type = type; fx->mode = eShaderFxMode_Realtime | eShaderFxMode_Render; diff --git a/source/blender/blenkernel/intern/simulation_state.cc b/source/blender/blenkernel/intern/simulation_state.cc index 9480972ea1f..fdd92a72d49 100644 --- a/source/blender/blenkernel/intern/simulation_state.cc +++ b/source/blender/blenkernel/intern/simulation_state.cc @@ -69,7 +69,7 @@ void ModifierSimulationCache::try_discover_bake(const StringRefNull meta_dir, continue; } char modified_file_name[FILENAME_MAX]; - BLI_strncpy(modified_file_name, dir_entry.relname, sizeof(modified_file_name)); + STRNCPY(modified_file_name, dir_entry.relname); BLI_str_replace_char(modified_file_name, '_', '.'); const SubFrame frame = std::stof(modified_file_name); diff --git a/source/blender/blenkernel/intern/sound.c b/source/blender/blenkernel/intern/sound.c index af957824bce..319ee05bad3 100644 --- a/source/blender/blenkernel/intern/sound.c +++ b/source/blender/blenkernel/intern/sound.c @@ -258,11 +258,11 @@ bSound *BKE_sound_new_file(Main *bmain, const char *filepath) const char *blendfile_path = BKE_main_blendfile_path(bmain); char str[FILE_MAX]; - BLI_strncpy(str, filepath, sizeof(str)); + STRNCPY(str, filepath); BLI_path_abs(str, blendfile_path); sound = BKE_libblock_alloc(bmain, ID_SO, BLI_path_basename(filepath), 0); - BLI_strncpy(sound->filepath, filepath, FILE_MAX); + STRNCPY(sound->filepath, filepath); /* sound->type = SOUND_TYPE_FILE; */ /* XXX unused currently */ /* Extract sound specs for bSound */ @@ -286,12 +286,12 @@ bSound *BKE_sound_new_file_exists_ex(Main *bmain, const char *filepath, bool *r_ bSound *sound; char str[FILE_MAX], strtest[FILE_MAX]; - BLI_strncpy(str, filepath, sizeof(str)); + STRNCPY(str, filepath); BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (sound = bmain->sounds.first; sound; sound = sound->id.next) { - BLI_strncpy(strtest, sound->filepath, sizeof(sound->filepath)); + STRNCPY(strtest, sound->filepath); BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &sound->id)); if (BLI_path_cmp(strtest, str) == 0) { @@ -551,7 +551,7 @@ static void sound_load_audio(Main *bmain, bSound *sound, bool free_waveform) PackedFile *pf = sound->packedfile; /* don't modify soundact->sound->filepath, only change a copy */ - BLI_strncpy(fullpath, sound->filepath, sizeof(fullpath)); + STRNCPY(fullpath, sound->filepath); BLI_path_abs(fullpath, ID_BLEND_PATH(bmain, &sound->id)); /* but we need a packed file then */ @@ -1258,7 +1258,7 @@ bool BKE_sound_stream_info_get(struct Main *main, AUD_StreamInfo *stream_infos; int stream_count; - BLI_strncpy(str, filepath, sizeof(str)); + STRNCPY(str, filepath); BLI_path_abs(str, blendfile_path); sound = AUD_Sound_file(str); diff --git a/source/blender/blenkernel/intern/studiolight.c b/source/blender/blenkernel/intern/studiolight.c index f19944b9b43..f31e33d0768 100644 --- a/source/blender/blenkernel/intern/studiolight.c +++ b/source/blender/blenkernel/intern/studiolight.c @@ -1407,7 +1407,7 @@ void BKE_studiolight_init(void) StudioLight *sl = studiolight_create( STUDIOLIGHT_INTERNAL | STUDIOLIGHT_SPHERICAL_HARMONICS_COEFFICIENTS_CALCULATED | STUDIOLIGHT_TYPE_STUDIO | STUDIOLIGHT_SPECULAR_HIGHLIGHT_PASS); - BLI_strncpy(sl->name, "Default", FILE_MAXFILE); + STRNCPY(sl->name, "Default"); BLI_addtail(&studiolights, sl); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index 5dc7f0e8a97..1c1450da9de 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -428,7 +428,7 @@ bool BKE_text_reload(Text *text) return false; } - BLI_strncpy(filepath_abs, text->filepath, FILE_MAX); + STRNCPY(filepath_abs, text->filepath); BLI_path_abs(filepath_abs, ID_BLEND_PATH_FROM_GLOBAL(&text->id)); buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len); @@ -465,7 +465,7 @@ Text *BKE_text_load_ex(Main *bmain, char filepath_abs[FILE_MAX]; BLI_stat_t st; - BLI_strncpy(filepath_abs, filepath, FILE_MAX); + STRNCPY(filepath_abs, filepath); BLI_path_abs(filepath_abs, relbase); buffer = BLI_file_read_text_as_mem(filepath_abs, 0, &buffer_len); @@ -537,7 +537,7 @@ int BKE_text_file_modified_check(Text *text) return 0; } - BLI_strncpy(filepath, text->filepath, FILE_MAX); + STRNCPY(filepath, text->filepath); BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&text->id)); if (!BLI_exists(filepath)) { @@ -571,7 +571,7 @@ void BKE_text_file_modified_ignore(Text *text) return; } - BLI_strncpy(filepath, text->filepath, FILE_MAX); + STRNCPY(filepath, text->filepath); BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&text->id)); if (!BLI_exists(filepath)) { diff --git a/source/blender/blenkernel/intern/tracking.cc b/source/blender/blenkernel/intern/tracking.cc index a0ac5779d16..7502212a9a4 100644 --- a/source/blender/blenkernel/intern/tracking.cc +++ b/source/blender/blenkernel/intern/tracking.cc @@ -1902,12 +1902,12 @@ MovieTrackingObject *BKE_tracking_object_add(MovieTracking *tracking, const char if (tracking->tot_object == 0) { /* first object is always camera */ - BLI_strncpy(tracking_object->name, "Camera", sizeof(tracking_object->name)); + STRNCPY(tracking_object->name, "Camera"); tracking_object->flag |= TRACKING_OBJECT_CAMERA; } else { - BLI_strncpy(tracking_object->name, name, sizeof(tracking_object->name)); + STRNCPY(tracking_object->name, name); } BLI_addtail(&tracking->objects, tracking_object); @@ -3194,10 +3194,10 @@ static void tracking_dopesheet_channels_calc(MovieTracking *tracking) channel->track = track; if (reconstruction->flag & TRACKING_RECONSTRUCTED) { - BLI_snprintf(channel->name, sizeof(channel->name), "%s (%.4f)", track->name, track->error); + SNPRINTF(channel->name, "%s (%.4f)", track->name, track->error); } else { - BLI_strncpy(channel->name, track->name, sizeof(channel->name)); + STRNCPY(channel->name, track->name); } tracking_dopesheet_channels_segments_calc(channel); diff --git a/source/blender/blenkernel/intern/tracking_solver.cc b/source/blender/blenkernel/intern/tracking_solver.cc index 68ca69232d3..d47bd90964e 100644 --- a/source/blender/blenkernel/intern/tracking_solver.cc +++ b/source/blender/blenkernel/intern/tracking_solver.cc @@ -334,7 +334,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new( const int num_tracks = BLI_listbase_count(&tracking_object->tracks); int sfra = INT_MAX, efra = INT_MIN; - BLI_strncpy(context->object_name, tracking_object->name, sizeof(context->object_name)); + STRNCPY(context->object_name, tracking_object->name); context->motion_flag = tracking->settings.motion_flag; context->select_keyframes = (tracking->settings.reconstruction_flag & @@ -393,7 +393,7 @@ void BKE_tracking_reconstruction_report_error_message(MovieReconstructContext *c /* Only keep initial error message, the rest are inducted ones. */ return; } - BLI_strncpy(context->error_message, error_message, sizeof(context->error_message)); + STRNCPY(context->error_message, error_message); } const char *BKE_tracking_reconstruction_error_message_get(const MovieReconstructContext *context) diff --git a/source/blender/blenkernel/intern/tracking_util.cc b/source/blender/blenkernel/intern/tracking_util.cc index 7b2da85afac..8228f12750a 100644 --- a/source/blender/blenkernel/intern/tracking_util.cc +++ b/source/blender/blenkernel/intern/tracking_util.cc @@ -52,7 +52,7 @@ TracksMap *tracks_map_new(const char *object_name, int num_tracks) { TracksMap *map = MEM_cnew("TrackingsMap"); - BLI_strncpy(map->object_name, object_name, sizeof(map->object_name)); + STRNCPY(map->object_name, object_name); map->num_tracks = num_tracks; diff --git a/source/blender/blenkernel/intern/undo_system.cc b/source/blender/blenkernel/intern/undo_system.cc index 76d3f26b59b..1fce7d6500c 100644 --- a/source/blender/blenkernel/intern/undo_system.cc +++ b/source/blender/blenkernel/intern/undo_system.cc @@ -119,7 +119,7 @@ static void undosys_id_ref_store(void * /*user_data*/, UndoRefID *id_ref) { BLI_assert(id_ref->name[0] == '\0'); if (id_ref->ptr) { - BLI_strncpy(id_ref->name, id_ref->ptr->name, sizeof(id_ref->name)); + STRNCPY(id_ref->name, id_ref->ptr->name); /* Not needed, just prevents stale data access. */ id_ref->ptr = nullptr; } @@ -456,7 +456,7 @@ UndoStep *BKE_undosys_step_push_init_with_type(UndoStack *ustack, UndoStep *us = static_cast(MEM_callocN(ut->step_size, __func__)); if (name != nullptr) { - BLI_strncpy(us->name, name, sizeof(us->name)); + STRNCPY(us->name, name); } us->type = ut; ustack->step_init = us; @@ -541,7 +541,7 @@ eUndoPushReturn BKE_undosys_step_push_with_type(UndoStack *ustack, static_cast(MEM_callocN(ut->step_size, __func__)); ustack->step_init = nullptr; if (us->name[0] == '\0') { - BLI_strncpy(us->name, name, sizeof(us->name)); + STRNCPY(us->name, name); } us->type = ut; /* True by default, code needs to explicitly set it to false if necessary. */ diff --git a/source/blender/blenkernel/intern/unit.c b/source/blender/blenkernel/intern/unit.c index fbdb7d171cb..47ab904198f 100644 --- a/source/blender/blenkernel/intern/unit.c +++ b/source/blender/blenkernel/intern/unit.c @@ -1112,9 +1112,7 @@ bool BKE_unit_replace_string( /* Apply the default unit on the whole expression, this allows to handle nasty cases like * '2+2in'. */ - if (BLI_snprintf(str_tmp, sizeof(str_tmp), "(%s)*%.9g", str, default_unit->scalar) < - sizeof(str_tmp)) - { + if (SNPRINTF(str_tmp, "(%s)*%.9g", str, default_unit->scalar) < sizeof(str_tmp)) { strncpy(str, str_tmp, str_maxncpy); } else { diff --git a/source/blender/blenkernel/intern/vfont.c b/source/blender/blenkernel/intern/vfont.c index ef6ecfbf63d..92c63e5d041 100644 --- a/source/blender/blenkernel/intern/vfont.c +++ b/source/blender/blenkernel/intern/vfont.c @@ -66,7 +66,7 @@ static void vfont_init_data(ID *id) if (vfd) { vfont->data = vfd; - BLI_strncpy(vfont->filepath, FO_BUILTIN_NAME, sizeof(vfont->filepath)); + STRNCPY(vfont->filepath, FO_BUILTIN_NAME); } /* Free the packed file */ @@ -321,7 +321,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath) bool is_builtin; if (STREQ(filepath, FO_BUILTIN_NAME)) { - BLI_strncpy(filename, filepath, sizeof(filename)); + STRNCPY(filename, filepath); pf = get_builtin_packedfile(); is_builtin = true; @@ -341,7 +341,7 @@ VFont *BKE_vfont_load(Main *bmain, const char *filepath) /* If there's a font name, use it for the ID name. */ vfont = BKE_libblock_alloc(bmain, ID_VF, vfd->name[0] ? vfd->name : filename, 0); vfont->data = vfd; - BLI_strncpy(vfont->filepath, filepath, sizeof(vfont->filepath)); + STRNCPY(vfont->filepath, filepath); /* if auto-pack is on store the packed-file in de font structure */ if (!is_builtin && (G.fileflags & G_FILE_AUTOPACK)) { @@ -368,12 +368,12 @@ VFont *BKE_vfont_load_exists_ex(struct Main *bmain, const char *filepath, bool * VFont *vfont; char str[FILE_MAX], strtest[FILE_MAX]; - BLI_strncpy(str, filepath, sizeof(str)); + STRNCPY(str, filepath); BLI_path_abs(str, BKE_main_blendfile_path(bmain)); /* first search an identical filepath */ for (vfont = bmain->fonts.first; vfont; vfont = vfont->id.next) { - BLI_strncpy(strtest, vfont->filepath, sizeof(vfont->filepath)); + STRNCPY(strtest, vfont->filepath); BLI_path_abs(strtest, ID_BLEND_PATH(bmain, &vfont->id)); if (BLI_path_cmp(strtest, str) == 0) { diff --git a/source/blender/blenkernel/intern/vfontdata_freetype.c b/source/blender/blenkernel/intern/vfontdata_freetype.c index ee3515d2a1f..8212e6f6011 100644 --- a/source/blender/blenkernel/intern/vfontdata_freetype.c +++ b/source/blender/blenkernel/intern/vfontdata_freetype.c @@ -321,7 +321,7 @@ VFontData *BKE_vfontdata_from_freetypefont(PackedFile *pf) /* Get the name. */ if (face->family_name) { - BLI_snprintf(vfd->name, sizeof(vfd->name), "%s %s", face->family_name, face->style_name); + SNPRINTF(vfd->name, "%s %s", face->family_name, face->style_name); BLI_str_utf8_invalid_strip(vfd->name, strlen(vfd->name)); } diff --git a/source/blender/blenkernel/intern/volume.cc b/source/blender/blenkernel/intern/volume.cc index 6a48d0d0292..5a09f6402cd 100644 --- a/source/blender/blenkernel/intern/volume.cc +++ b/source/blender/blenkernel/intern/volume.cc @@ -515,7 +515,7 @@ static void volume_init_data(ID *id) BKE_volume_init_grids(volume); - BLI_strncpy(volume->velocity_grid, "velocity", sizeof(volume->velocity_grid)); + STRNCPY(volume->velocity_grid, "velocity"); } static void volume_copy_data(Main * /*bmain*/, ID *id_dst, const ID *id_src, const int /*flag*/) @@ -793,7 +793,7 @@ bool BKE_volume_set_velocity_grid_by_name(Volume *volume, const char *base_name) const StringRefNull ref_base_name = base_name; if (BKE_volume_grid_find_for_read(volume, base_name)) { - BLI_strncpy(volume->velocity_grid, base_name, sizeof(volume->velocity_grid)); + STRNCPY(volume->velocity_grid, base_name); volume->runtime.velocity_x_grid[0] = '\0'; volume->runtime.velocity_y_grid[0] = '\0'; volume->runtime.velocity_z_grid[0] = '\0'; @@ -818,16 +818,10 @@ bool BKE_volume_set_velocity_grid_by_name(Volume *volume, const char *base_name) } /* Save the base name as well. */ - BLI_strncpy(volume->velocity_grid, base_name, sizeof(volume->velocity_grid)); - BLI_strncpy(volume->runtime.velocity_x_grid, - (ref_base_name + postfix[0]).c_str(), - sizeof(volume->runtime.velocity_x_grid)); - BLI_strncpy(volume->runtime.velocity_y_grid, - (ref_base_name + postfix[1]).c_str(), - sizeof(volume->runtime.velocity_y_grid)); - BLI_strncpy(volume->runtime.velocity_z_grid, - (ref_base_name + postfix[2]).c_str(), - sizeof(volume->runtime.velocity_z_grid)); + STRNCPY(volume->velocity_grid, base_name); + STRNCPY(volume->runtime.velocity_x_grid, (ref_base_name + postfix[0]).c_str()); + STRNCPY(volume->runtime.velocity_y_grid, (ref_base_name + postfix[1]).c_str()); + STRNCPY(volume->runtime.velocity_z_grid, (ref_base_name + postfix[2]).c_str()); return true; } diff --git a/source/blender/blenkernel/intern/workspace.cc b/source/blender/blenkernel/intern/workspace.cc index b0524f9b5d4..b3422eff8c5 100644 --- a/source/blender/blenkernel/intern/workspace.cc +++ b/source/blender/blenkernel/intern/workspace.cc @@ -224,7 +224,7 @@ static void workspace_layout_name_set(WorkSpace *workspace, WorkSpaceLayout *layout, const char *new_name) { - BLI_strncpy(layout->name, new_name, sizeof(layout->name)); + STRNCPY(layout->name, new_name); BLI_uniquename(&workspace->layouts, layout, "Layout", diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index 6beda0593df..a9b4a768030 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -535,7 +535,7 @@ static const AVCodec *get_av1_encoder( } /* Set gop_size as rav1e's "--keyint". */ char buffer[64]; - BLI_snprintf(buffer, sizeof(buffer), "keyint=%d", context->ffmpeg_gop_size); + SNPRINTF(buffer, "keyint=%d", context->ffmpeg_gop_size); av_dict_set(opts, "rav1e-params", buffer, 0); } else if (STREQ(codec->name, "libsvtav1")) { @@ -1073,7 +1073,7 @@ static void ffmpeg_dict_set_int(AVDictionary **dict, const char *key, int value) { char buffer[32]; - BLI_snprintf(buffer, sizeof(buffer), "%d", value); + SNPRINTF(buffer, "%d", value); av_dict_set(dict, key, buffer, 0); } @@ -1391,7 +1391,7 @@ static void ffmpeg_filepath_get(FFMpegContext *context, if ((rd->ffcodecdata.flags & FFMPEG_AUTOSPLIT_OUTPUT) != 0) { if (context) { - BLI_snprintf(autosplit, sizeof(autosplit), "_%03d", context->ffmpeg_autosplit_count); + SNPRINTF(autosplit, "_%03d", context->ffmpeg_autosplit_count); } } diff --git a/source/blender/blenlib/intern/BLI_filelist.c b/source/blender/blenlib/intern/BLI_filelist.c index 4d489c0ae9f..3a6f4635933 100644 --- a/source/blender/blenlib/intern/BLI_filelist.c +++ b/source/blender/blenlib/intern/BLI_filelist.c @@ -151,7 +151,7 @@ static void bli_builddir(struct BuildDirCtx *dir_ctx, const char *dirname) if (!has_parent) { char pardir[FILE_MAXDIR]; - BLI_strncpy(pardir, dirname, sizeof(pardir)); + STRNCPY(pardir, dirname); if (BLI_path_parent_dir(pardir) && (BLI_access(pardir, R_OK) == 0)) { struct dirlink *const dlink = (struct dirlink *)malloc(sizeof(struct dirlink)); if (dlink != NULL) { diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c index 350d18c5264..7f2f1c9dbc1 100644 --- a/source/blender/blenlib/intern/path_util.c +++ b/source/blender/blenlib/intern/path_util.c @@ -645,7 +645,7 @@ void BLI_path_rel(char *path, const char *basename) } } #else - BLI_strncpy(temp, basename, FILE_MAX); + STRNCPY(temp, basename); #endif BLI_str_replace_char(temp + BLI_path_unc_prefix_len(temp), '\\', '/'); @@ -887,8 +887,7 @@ bool BLI_path_frame(char *path, size_t path_maxncpy, int frame, int digits) if (stringframe_chars(path, &ch_sta, &ch_end)) { /* Warning: `ch_end` is the last # +1. */ char tmp[FILE_MAX]; - BLI_snprintf( - tmp, sizeof(tmp), "%.*s%.*d%s", ch_sta, path, ch_end - ch_sta, frame, path + ch_end); + SNPRINTF(tmp, "%.*s%.*d%s", ch_sta, path, ch_end - ch_sta, frame, path + ch_end); BLI_strncpy(path, tmp, path_maxncpy); return true; } @@ -907,16 +906,15 @@ bool BLI_path_frame_range(char *path, int sta, int end, int digits) if (stringframe_chars(path, &ch_sta, &ch_end)) { /* Warning: `ch_end` is the last # +1. */ char tmp[FILE_MAX]; - BLI_snprintf(tmp, - sizeof(tmp), - "%.*s%.*d-%.*d%s", - ch_sta, - path, - ch_end - ch_sta, - sta, - ch_end - ch_sta, - end, - path + ch_end); + SNPRINTF(tmp, + "%.*s%.*d-%.*d%s", + ch_sta, + path, + ch_end - ch_sta, + sta, + ch_end - ch_sta, + end, + path + ch_end); BLI_strncpy(path, tmp, FILE_MAX); return true; } @@ -1054,7 +1052,7 @@ bool BLI_path_abs(char *path, const char *basepath) BLI_strncpy(tmp, path, FILE_MAX); } #else - BLI_strncpy(tmp, path, sizeof(tmp)); + STRNCPY(tmp, path); /* Check for loading a MS-Windows path on a POSIX system * in this case, there is no use in trying `C:/` since it @@ -1086,7 +1084,7 @@ bool BLI_path_abs(char *path, const char *basepath) * this isn't standard in any OS but is used in blender all over the place. */ if (wasrelative) { const char *lslash; - BLI_strncpy(base, basepath, sizeof(base)); + STRNCPY(base, basepath); /* File component is ignored, so don't bother with the trailing slash. */ BLI_path_normalize(base); @@ -1152,7 +1150,7 @@ bool BLI_path_abs_from_cwd(char *path, const size_t path_maxncpy) /* In case the full path to the blend isn't used. */ if (BLI_current_working_dir(cwd, sizeof(cwd))) { char origpath[FILE_MAX]; - BLI_strncpy(origpath, path, FILE_MAX); + STRNCPY(origpath, path); BLI_path_join(path, path_maxncpy, cwd, origpath); } else { @@ -1245,7 +1243,7 @@ bool BLI_path_program_search(char *program_filepath, path = temp + 1; } else { - BLI_strncpy(filepath_test, path, sizeof(filepath_test)); + STRNCPY(filepath_test, path); } BLI_path_append(filepath_test, program_filepath_maxncpy, program_name); @@ -1391,7 +1389,7 @@ bool BLI_path_extension_check_glob(const char *path, const char *ext_fnmatch) BLI_strncpy(pattern, ext_step, (len_ext > sizeof(pattern)) ? sizeof(pattern) : len_ext); } else { - len_ext = BLI_strncpy_rlen(pattern, ext_step, sizeof(pattern)); + len_ext = STRNCPY_RLEN(pattern, ext_step); } if (fnmatch(pattern, path, FNM_CASEFOLD) == 0) { @@ -1811,7 +1809,7 @@ bool BLI_path_contains(const char *container_path, const char *containee_path) /* Keep space for a trailing slash. If the path is truncated by this, the containee path is * longer than #PATH_MAX and the result is ill-defined. */ BLI_strncpy(container_native, container_path, PATH_MAX - 1); - BLI_strncpy(containee_native, containee_path, PATH_MAX); + STRNCPY(containee_native, containee_path); BLI_path_slash_native(container_native); BLI_path_slash_native(containee_native); @@ -1916,8 +1914,8 @@ int BLI_path_cmp_normalized(const char *p1, const char *p2) char norm_p1[FILE_MAX]; char norm_p2[FILE_MAX]; - BLI_strncpy(norm_p1, p1, sizeof(norm_p1)); - BLI_strncpy(norm_p2, p2, sizeof(norm_p2)); + STRNCPY(norm_p1, p1); + STRNCPY(norm_p2, p2); BLI_path_slash_native(norm_p1); BLI_path_slash_native(norm_p2); diff --git a/source/blender/blenlib/intern/string.c b/source/blender/blenlib/intern/string.c index 04ba5f5a0df..420abdcb41c 100644 --- a/source/blender/blenlib/intern/string.c +++ b/source/blender/blenlib/intern/string.c @@ -1141,7 +1141,7 @@ size_t BLI_str_format_int_grouped(char dst[BLI_STR_FORMAT_INT32_GROUPED_SIZE], i BLI_string_debug_size(dst, BLI_STR_FORMAT_INT32_GROUPED_SIZE); char src[BLI_STR_FORMAT_INT32_GROUPED_SIZE]; - const int num_len = BLI_snprintf(src, sizeof(src), "%d", num); + const int num_len = SNPRINTF(src, "%d", num); return BLI_str_format_int_grouped_ex(src, dst, num_len); } @@ -1151,7 +1151,7 @@ size_t BLI_str_format_uint64_grouped(char dst[BLI_STR_FORMAT_UINT64_GROUPED_SIZE BLI_string_debug_size(dst, BLI_STR_FORMAT_UINT64_GROUPED_SIZE); char src[BLI_STR_FORMAT_UINT64_GROUPED_SIZE]; - const int num_len = BLI_snprintf(src, sizeof(src), "%" PRIu64 "", num); + const int num_len = SNPRINTF(src, "%" PRIu64 "", num); return BLI_str_format_int_grouped_ex(src, dst, num_len); } diff --git a/source/blender/blenlib/intern/string_utils.c b/source/blender/blenlib/intern/string_utils.c index 65cb2566e3b..9864d01820c 100644 --- a/source/blender/blenlib/intern/string_utils.c +++ b/source/blender/blenlib/intern/string_utils.c @@ -269,7 +269,7 @@ bool BLI_uniquename_cb(UniquenameCheckCallback unique_check, size_t len = BLI_string_split_name_number(name, delim, left, &number); do { /* add 1 to account for \0 */ - const size_t numlen = BLI_snprintf(numstr, sizeof(numstr), "%c%03d", delim, ++number) + 1; + const size_t numlen = SNPRINTF(numstr, "%c%03d", delim, ++number) + 1; /* highly unlikely the string only has enough room for the number * but support anyway */ diff --git a/source/blender/blenlib/tests/BLI_listbase_test.cc b/source/blender/blenlib/tests/BLI_listbase_test.cc index 74d69373c7b..d6a28ff974d 100644 --- a/source/blender/blenlib/tests/BLI_listbase_test.cc +++ b/source/blender/blenlib/tests/BLI_listbase_test.cc @@ -122,10 +122,10 @@ TEST(listbase, FindLinkFromStringOrPointer) ListBase lb; struct TestLink *link1 = (struct TestLink *)MEM_callocN(sizeof(TestLink), "link1"); - BLI_strncpy(link1->name, link1_name, sizeof(link1->name)); + STRNCPY(link1->name, link1_name); link1->ptr = link1_ptr; struct TestLink *link2 = (struct TestLink *)MEM_callocN(sizeof(TestLink), "link2"); - BLI_strncpy(link2->name, link2_name, sizeof(link2->name)); + STRNCPY(link2->name, link2_name); link2->ptr = link2_ptr; /* Empty list */ diff --git a/source/blender/blenlib/tests/BLI_path_util_test.cc b/source/blender/blenlib/tests/BLI_path_util_test.cc index 81b9628d592..24e88af43a1 100644 --- a/source/blender/blenlib/tests/BLI_path_util_test.cc +++ b/source/blender/blenlib/tests/BLI_path_util_test.cc @@ -711,7 +711,7 @@ TEST(path_util, SplitDirfile) { \ char path[FILE_MAX]; \ char ext[FILE_MAX]; \ - BLI_strncpy(path, (input_path), FILE_MAX); \ + STRNCPY(path, (input_path)); \ BLI_path_frame_strip(path, ext, sizeof(ext)); \ EXPECT_STREQ(path, expect_path); \ EXPECT_STREQ(ext, expect_ext); \ @@ -814,7 +814,7 @@ TEST(path_util, ExtensionCheck) { \ BLI_assert(maxlen <= FILE_MAX); \ char path[FILE_MAX]; \ - BLI_strncpy(path, input_path, sizeof(path)); \ + STRNCPY(path, input_path); \ const bool ret = BLI_path_extension_replace(path, maxlen, input_ext); \ if (expect_result) { \ EXPECT_TRUE(ret); \ @@ -885,7 +885,7 @@ TEST(path_util, ExtensionReplace_Overflow) { \ BLI_assert(maxlen <= FILE_MAX); \ char path[FILE_MAX]; \ - BLI_strncpy(path, input_path, sizeof(path)); \ + STRNCPY(path, input_path); \ const bool ret = BLI_path_extension_ensure(path, maxlen, input_ext); \ if (expect_result) { \ EXPECT_TRUE(ret); \ @@ -986,7 +986,7 @@ TEST(path_util, FrameCheckChars) { \ char path[FILE_MAX]; \ bool ret; \ - BLI_strncpy(path, input_path, FILE_MAX); \ + STRNCPY(path, input_path); \ ret = BLI_path_frame_range(path, sta, end, digits); \ if (expect_outpath == nullptr) { \ EXPECT_FALSE(ret); \ @@ -1023,7 +1023,7 @@ TEST(path_util, FrameRange) { \ char path[FILE_MAX]; \ int out_frame = -1, out_numdigits = -1; \ - BLI_strncpy(path, input_path, FILE_MAX); \ + STRNCPY(path, input_path); \ const bool ret = BLI_path_frame_get(path, &out_frame, &out_numdigits); \ if (expect_pathisvalid) { \ EXPECT_TRUE(ret); \ @@ -1136,7 +1136,7 @@ TEST(path_util, Suffix) { \ char path[FILE_MAX]; \ const char *ref_path_test = ref_path; \ - BLI_strncpy(path, abs_path, sizeof(path)); \ + STRNCPY(path, abs_path); \ if (SEP == '\\') { \ BLI_str_replace_char(path, '/', '\\'); \ ref_path_test = str_replace_char_strdup(ref_path_test, '/', '\\'); \ diff --git a/source/blender/blenloader/intern/readblenentry.cc b/source/blender/blenloader/intern/readblenentry.cc index 4de3874b3e9..0ea7131b397 100644 --- a/source/blender/blenloader/intern/readblenentry.cc +++ b/source/blender/blenloader/intern/readblenentry.cc @@ -448,7 +448,7 @@ BlendFileData *BLO_read_from_memfile(Main *oldmain, fd = blo_filedata_from_memfile(memfile, params, &bf_reports); if (fd) { fd->skip_flags = eBLOReadSkip(params->skip_flags); - BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase)); + STRNCPY(fd->relabase, filepath); /* separate libraries from old main */ blo_split_main(&old_mainlist, oldmain); diff --git a/source/blender/blenloader/intern/readfile.cc b/source/blender/blenloader/intern/readfile.cc index 229b1960fe3..7eee5348dd6 100644 --- a/source/blender/blenloader/intern/readfile.cc +++ b/source/blender/blenloader/intern/readfile.cc @@ -517,7 +517,7 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab Library *lib; char filepath_abs[FILE_MAX]; - BLI_strncpy(filepath_abs, filepath, sizeof(filepath_abs)); + STRNCPY(filepath_abs, filepath); BLI_path_abs(filepath_abs, relabase); BLI_path_normalize(filepath_abs); @@ -550,8 +550,8 @@ static Main *blo_find_main(FileData *fd, const char *filepath, const char *relab /* Matches direct_link_library(). */ id_us_ensure_real(&lib->id); - BLI_strncpy(lib->filepath, filepath, sizeof(lib->filepath)); - BLI_strncpy(lib->filepath_abs, filepath_abs, sizeof(lib->filepath_abs)); + STRNCPY(lib->filepath, filepath); + STRNCPY(lib->filepath_abs, filepath_abs); m->curlib = lib; @@ -1185,7 +1185,7 @@ FileData *blo_filedata_from_file(const char *filepath, BlendFileReadReport *repo FileData *fd = blo_filedata_from_file_open(filepath, reports); if (fd != nullptr) { /* needed for library_append and read_libraries */ - BLI_strncpy(fd->relabase, filepath, sizeof(fd->relabase)); + STRNCPY(fd->relabase, filepath); return blo_decode_and_check(fd, reports->reports); } @@ -2698,7 +2698,7 @@ static void direct_link_library(FileData *fd, Library *lib, Main *main) } /* Make sure we have full path in lib->filepath_abs */ - BLI_strncpy(lib->filepath_abs, lib->filepath, sizeof(lib->filepath)); + STRNCPY(lib->filepath_abs, lib->filepath); BLI_path_abs(lib->filepath_abs, fd->relabase); BLI_path_normalize(lib->filepath_abs); @@ -2733,7 +2733,7 @@ static void fix_relpaths_library(const char *basepath, Main *main) * link into an unsaved blend file. See #27405. * The remap relative option will make it relative again on save - campbell */ if (BLI_path_is_rel(lib->filepath)) { - BLI_strncpy(lib->filepath, lib->filepath_abs, sizeof(lib->filepath)); + STRNCPY(lib->filepath, lib->filepath_abs); } } } @@ -2743,7 +2743,7 @@ static void fix_relpaths_library(const char *basepath, Main *main) * relative to the blend file since indirectly linked libraries will be * relative to their direct linked library. */ if (BLI_path_is_rel(lib->filepath)) { /* if this is relative to begin with? */ - BLI_strncpy(lib->filepath, lib->filepath_abs, sizeof(lib->filepath)); + STRNCPY(lib->filepath, lib->filepath_abs); BLI_path_rel(lib->filepath, basepath); } } @@ -3401,7 +3401,7 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) bfd->main->minversionfile = fg->minversion; bfd->main->minsubversionfile = fg->minsubversion; bfd->main->build_commit_timestamp = fg->build_commit_timestamp; - BLI_strncpy(bfd->main->build_hash, fg->build_hash, sizeof(bfd->main->build_hash)); + STRNCPY(bfd->main->build_hash, fg->build_hash); bfd->fileflags = fg->fileflags; bfd->globalf = fg->globalf; @@ -3423,7 +3423,7 @@ static BHead *read_global(BlendFileData *bfd, FileData *fd, BHead *bhead) } if (G.fileflags & G_FILE_RECOVER_READ) { - BLI_strncpy(fd->relabase, fg->filepath, sizeof(fd->relabase)); + STRNCPY(fd->relabase, fg->filepath); } bfd->curscreen = fg->curscreen; @@ -3485,7 +3485,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main) strftime(build_commit_datetime, sizeof(build_commit_datetime), "%Y-%m-%d %H:%M", tm); } else { - BLI_strncpy(build_commit_datetime, "unknown", sizeof(build_commit_datetime)); + STRNCPY(build_commit_datetime, "unknown"); } CLOG_INFO(&LOG, 0, "Read file %s", fd->relabase); @@ -4548,7 +4548,7 @@ static void library_link_end(Main *mainl, FileData **fd, const int flag) /* make the lib path relative if required */ if (flag & FILE_RELPATH) { /* use the full path, this could have been read by other library even */ - BLI_strncpy(curlib->filepath, curlib->filepath_abs, sizeof(curlib->filepath)); + STRNCPY(curlib->filepath, curlib->filepath_abs); /* uses current .blend file as reference */ BLI_path_rel(curlib->filepath, BKE_main_blendfile_path_from_global()); @@ -4828,7 +4828,7 @@ static FileData *read_library_file_data(FileData *basefd, fd = blo_filedata_from_memory(pf->data, pf->size, basefd->reports); /* Needed for library_append and read_libraries. */ - BLI_strncpy(fd->relabase, mainptr->curlib->filepath_abs, sizeof(fd->relabase)); + STRNCPY(fd->relabase, mainptr->curlib->filepath_abs); } else { /* Read file on disk. */ diff --git a/source/blender/blenloader/intern/versioning_250.c b/source/blender/blenloader/intern/versioning_250.c index c94022153a7..e85478e0e15 100644 --- a/source/blender/blenloader/intern/versioning_250.c +++ b/source/blender/blenloader/intern/versioning_250.c @@ -565,7 +565,7 @@ static bNodeSocket *do_versions_node_group_add_socket_2_56_2(bNodeTree *ngroup, // bNodeSocketType *stype = ntreeGetSocketType(type); bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket"); - BLI_strncpy(gsock->name, name, sizeof(gsock->name)); + STRNCPY(gsock->name, name); gsock->type = type; gsock->next = gsock->prev = NULL; @@ -640,7 +640,7 @@ static bool seq_sound_proxy_update_cb(Sequence *seq, void *user_data) #define SEQ_USE_PROXY_CUSTOM_FILE (1 << 21) /* don't know, if anybody used that this way, but just in case, upgrade to new way... */ if ((seq->flag & SEQ_USE_PROXY_CUSTOM_FILE) && !(seq->flag & SEQ_USE_PROXY_CUSTOM_DIR)) { - BLI_snprintf(seq->strip->proxy->dir, FILE_MAXDIR, "%s" SEP_STR "BL_proxy", seq->strip->dir); + SNPRINTF(seq->strip->proxy->dir, "%s" SEP_STR "BL_proxy", seq->strip->dir); } #undef SEQ_USE_PROXY_CUSTOM_DIR #undef SEQ_USE_PROXY_CUSTOM_FILE diff --git a/source/blender/blenloader/intern/versioning_260.c b/source/blender/blenloader/intern/versioning_260.c index 1a3cc7570f3..90b2c54ecf8 100644 --- a/source/blender/blenloader/intern/versioning_260.c +++ b/source/blender/blenloader/intern/versioning_260.c @@ -274,11 +274,11 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo BLI_path_split_dir_file( old_data->name, basepath, sizeof(basepath), filename, sizeof(filename)); - BLI_strncpy(nimf->base_path, basepath, sizeof(nimf->base_path)); + STRNCPY(nimf->base_path, basepath); nimf->format = old_data->im_format; } else { - BLI_strncpy(filename, old_image->name, sizeof(filename)); + STRNCPY(filename, old_image->name); } /* If Z buffer is saved, change the image type to multi-layer EXR. @@ -289,19 +289,19 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo nimf->format.imtype = R_IMF_IMTYPE_MULTILAYER; - BLI_snprintf(sockpath, sizeof(sockpath), "%s_Image", filename); + SNPRINTF(sockpath, "%s_Image", filename); sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format); /* XXX later do_versions copies path from socket name, need to set this explicitly */ - BLI_strncpy(sock->name, sockpath, sizeof(sock->name)); + STRNCPY(sock->name, sockpath); if (old_image->link) { old_image->link->tosock = sock; sock->link = old_image->link; } - BLI_snprintf(sockpath, sizeof(sockpath), "%s_Z", filename); + SNPRINTF(sockpath, "%s_Z", filename); sock = ntreeCompositOutputFileAddSocket(ntree, node, sockpath, &nimf->format); /* XXX later do_versions copies path from socket name, need to set this explicitly */ - BLI_strncpy(sock->name, sockpath, sizeof(sock->name)); + STRNCPY(sock->name, sockpath); if (old_z->link) { old_z->link->tosock = sock; sock->link = old_z->link; @@ -310,7 +310,7 @@ static void do_versions_nodetree_multi_file_output_format_2_62_1(Scene *sce, bNo else { sock = ntreeCompositOutputFileAddSocket(ntree, node, filename, &nimf->format); /* XXX later do_versions copies path from socket name, need to set this explicitly */ - BLI_strncpy(sock->name, filename, sizeof(sock->name)); + STRNCPY(sock->name, filename); if (old_image->link) { old_image->link->tosock = sock; sock->link = old_image->link; @@ -377,7 +377,7 @@ static void do_versions_nodetree_multi_file_output_path_2_63_1(bNodeTree *ntree) for (sock = node->inputs.first; sock; sock = sock->next) { NodeImageMultiFileSocket *input = sock->storage; /* input file path is stored in dedicated struct now instead socket name */ - BLI_strncpy(input->path, sock->name, sizeof(input->path)); + STRNCPY(input->path, sock->name); } } } @@ -395,7 +395,7 @@ static void do_versions_nodetree_file_output_layers_2_64_5(bNodeTree *ntree) /* Multi-layer names are stored as separate strings now, * used the path string before, so copy it over. */ - BLI_strncpy(input->layer, input->path, sizeof(input->layer)); + STRNCPY(input->layer, input->path); /* paths/layer names also have to be unique now, initial check */ ntreeCompositOutputFileUniquePath(&node->inputs, sock, input->path, '_'); @@ -569,18 +569,18 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro /* sockets idname */ for (sock = node->inputs.first; sock; sock = sock->next) { - BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname)); + STRNCPY(sock->idname, node_socket_get_static_idname(sock)); } for (sock = node->outputs.first; sock; sock = sock->next) { - BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname)); + STRNCPY(sock->idname, node_socket_get_static_idname(sock)); } } /* tree sockets idname */ for (sock = ntree->inputs.first; sock; sock = sock->next) { - BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname)); + STRNCPY(sock->idname, node_socket_get_static_idname(sock)); } for (sock = ntree->outputs.first; sock; sock = sock->next) { - BLI_strncpy(sock->idname, node_socket_get_static_idname(sock), sizeof(sock->idname)); + STRNCPY(sock->idname, node_socket_get_static_idname(sock)); } } @@ -612,7 +612,7 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro for (node = ntree->nodes.first; node; node = node->next) { for (sock = node->inputs.first; sock; sock = sock->next) { - BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier)); + STRNCPY(sock->identifier, sock->name); BLI_uniquename(&node->inputs, sock, "socket", @@ -621,7 +621,7 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro sizeof(sock->identifier)); } for (sock = node->outputs.first; sock; sock = sock->next) { - BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier)); + STRNCPY(sock->identifier, sock->name); BLI_uniquename(&node->outputs, sock, "socket", @@ -631,7 +631,7 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro } } for (sock = ntree->inputs.first; sock; sock = sock->next) { - BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier)); + STRNCPY(sock->identifier, sock->name); BLI_uniquename(&ntree->inputs, sock, "socket", @@ -640,7 +640,7 @@ static void do_versions_nodetree_customnodes(bNodeTree *ntree, int UNUSED(is_gro sizeof(sock->identifier)); } for (sock = ntree->outputs.first; sock; sock = sock->next) { - BLI_strncpy(sock->identifier, sock->name, sizeof(sock->identifier)); + STRNCPY(sock->identifier, sock->name); BLI_uniquename(&ntree->outputs, sock, "socket", @@ -1142,7 +1142,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) KeyingSet *ks; for (ks = scene->keyingsets.first; ks; ks = ks->next) { if (!ks->idname[0]) { - BLI_strncpy(ks->idname, ks->name, sizeof(ks->idname)); + STRNCPY(ks->idname, ks->name); } } } @@ -1565,7 +1565,7 @@ void blo_do_versions_260(FileData *fd, Library *UNUSED(lib), Main *bmain) * crazy anyway and think it's fair enough to break compatibility in that cases. */ - BLI_strncpy(ima->colorspace_settings.name, "Raw", sizeof(ima->colorspace_settings.name)); + STRNCPY(ima->colorspace_settings.name, "Raw"); } } } diff --git a/source/blender/blenloader/intern/versioning_270.c b/source/blender/blenloader/intern/versioning_270.c index c915c36ed40..6f9dfc3bc0a 100644 --- a/source/blender/blenloader/intern/versioning_270.c +++ b/source/blender/blenloader/intern/versioning_270.c @@ -96,7 +96,7 @@ static bGPDpalette *BKE_gpencil_palette_addnew(bGPdata *gpd, const char *name) /* set basic settings */ /* auto-name */ - BLI_strncpy(palette->info, name, sizeof(palette->info)); + STRNCPY(palette->info, name); BLI_uniquename(&gpd->palettes, palette, DATA_("GP_Palette"), @@ -129,7 +129,7 @@ static bGPDpalettecolor *BKE_gpencil_palettecolor_addnew(bGPDpalette *palette, c ARRAY_SET_ITEMS(palcolor->fill, 1.0f, 1.0f, 1.0f); /* auto-name */ - BLI_strncpy(palcolor->info, name, sizeof(palcolor->info)); + STRNCPY(palcolor->info, name); BLI_uniquename(&palette->colors, palcolor, DATA_("Color"), @@ -325,9 +325,7 @@ static void do_versions_compositor_render_passes_storage(bNode *node) if (sock->storage == NULL) { NodeImageLayer *sockdata = MEM_callocN(sizeof(NodeImageLayer), "node image layer"); sock->storage = sockdata; - BLI_strncpy(sockdata->pass_name, - node_cmp_rlayers_sock_to_pass(pass_index), - sizeof(sockdata->pass_name)); + STRNCPY(sockdata->pass_name, node_cmp_rlayers_sock_to_pass(pass_index)); if (pass_index == 0) { sockname = "Image"; @@ -338,7 +336,7 @@ static void do_versions_compositor_render_passes_storage(bNode *node) else { sockname = node_cmp_rlayers_sock_to_pass(pass_index); } - BLI_strncpy(sock->name, sockname, sizeof(sock->name)); + STRNCPY(sock->name, sockname); } } } @@ -610,7 +608,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) sce->r.bake.normal_swizzle[0] = R_BAKE_POSX; sce->r.bake.normal_swizzle[1] = R_BAKE_POSY; sce->r.bake.normal_swizzle[2] = R_BAKE_POSZ; - BLI_strncpy(sce->r.bake.filepath, U.renderdir, sizeof(sce->r.bake.filepath)); + STRNCPY(sce->r.bake.filepath, U.renderdir); sce->r.bake.im_format.planes = R_IMF_PLANES_RGBA; sce->r.bake.im_format.imtype = R_IMF_IMTYPE_PNG; @@ -930,11 +928,11 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) for (scene = bmain->scenes.first; scene; scene = scene->id.next) { BKE_scene_add_render_view(scene, STEREO_LEFT_NAME); srv = scene->r.views.first; - BLI_strncpy(srv->suffix, STEREO_LEFT_SUFFIX, sizeof(srv->suffix)); + STRNCPY(srv->suffix, STEREO_LEFT_SUFFIX); BKE_scene_add_render_view(scene, STEREO_RIGHT_NAME); srv = scene->r.views.last; - BLI_strncpy(srv->suffix, STEREO_RIGHT_SUFFIX, sizeof(srv->suffix)); + STRNCPY(srv->suffix, STEREO_RIGHT_SUFFIX); if (scene->ed) { SEQ_for_each_callback(&scene->ed->seqbase, seq_update_proxy_cb, NULL); @@ -979,7 +977,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) BLI_addtail(&ima->packedfiles, imapf); imapf->packedfile = ima->packedfile; - BLI_strncpy(imapf->filepath, ima->filepath, FILE_MAX); + STRNCPY(imapf->filepath, ima->filepath); ima->packedfile = NULL; } } @@ -1372,7 +1370,7 @@ void blo_do_versions_270(FileData *fd, Library *UNUSED(lib), Main *bmain) LISTBASE_FOREACH (bGPDframe *, gpf, &gpl->frames) { LISTBASE_FOREACH (bGPDstroke *, gps, &gpf->strokes) { /* set stroke to palette and force recalculation */ - BLI_strncpy(gps->colorname, gpl->info, sizeof(gps->colorname)); + STRNCPY(gps->colorname, gpl->info); gps->thickness = gpl->thickness; /* set alpha strength to 1 */ diff --git a/source/blender/blenloader/intern/versioning_280.c b/source/blender/blenloader/intern/versioning_280.c index 335cf087517..fc38ee8ee90 100644 --- a/source/blender/blenloader/intern/versioning_280.c +++ b/source/blender/blenloader/intern/versioning_280.c @@ -430,7 +430,7 @@ static void do_version_layers_to_collections(Main *bmain, Scene *scene) if (collections[layer] == NULL) { char name[MAX_ID_NAME - 2]; - BLI_snprintf(name, sizeof(name), DATA_("Collection %d"), layer + 1); + SNPRINTF(name, DATA_("Collection %d"), layer + 1); Collection *collection = BKE_collection_add(bmain, collection_master, name); collection->id.lib = scene->id.lib; @@ -1215,7 +1215,7 @@ void do_versions_after_linking_280(FileData *fd, Main *bmain) if (*collection_hidden == NULL) { char name[MAX_ID_NAME]; - BLI_snprintf(name, sizeof(name), DATA_("Hidden %d"), coll_idx + 1); + SNPRINTF(name, DATA_("Hidden %d"), coll_idx + 1); *collection_hidden = BKE_collection_add(bmain, collection, name); (*collection_hidden)->flag |= COLLECTION_HIDE_VIEWPORT | COLLECTION_HIDE_RENDER; } @@ -1856,13 +1856,13 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && STREQ(node->idname, "ShaderNodeOutputMetallic")) { - BLI_strncpy(node->idname, "ShaderNodeEeveeMetallic", sizeof(node->idname)); + STRNCPY(node->idname, "ShaderNodeEeveeMetallic"); error |= NTREE_DOVERSION_NEED_OUTPUT; } else if (node->type == SH_NODE_EEVEE_SPECULAR && STREQ(node->idname, "ShaderNodeOutputSpecular")) { - BLI_strncpy(node->idname, "ShaderNodeEeveeSpecular", sizeof(node->idname)); + STRNCPY(node->idname, "ShaderNodeEeveeSpecular"); error |= NTREE_DOVERSION_NEED_OUTPUT; } @@ -1870,14 +1870,14 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) STREQ(node->idname, "ShaderNodeOutputEeveeMaterial")) { node->type = SH_NODE_OUTPUT_MATERIAL; - BLI_strncpy(node->idname, "ShaderNodeOutputMaterial", sizeof(node->idname)); + STRNCPY(node->idname, "ShaderNodeOutputMaterial"); } else if (node->type == 194 /* SH_NODE_EEVEE_METALLIC */ && STREQ(node->idname, "ShaderNodeEeveeMetallic")) { node->type = SH_NODE_BSDF_PRINCIPLED; - BLI_strncpy(node->idname, "ShaderNodeBsdfPrincipled", sizeof(node->idname)); + STRNCPY(node->idname, "ShaderNodeBsdfPrincipled"); node->custom1 = SHD_GLOSSY_MULTI_GGX; error |= NTREE_DOVERSION_TRANSPARENCY_EMISSION; } @@ -2085,7 +2085,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) * as scene render engine. */ if (MAIN_VERSION_ATLEAST(bmain, 280, 0)) { for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { - BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine)); + STRNCPY(scene->r.engine, RE_engine_id_BLENDER_EEVEE); } } } @@ -2094,7 +2094,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) /* Blender Internal removal */ for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) { if (STR_ELEM(scene->r.engine, "BLENDER_RENDER", "BLENDER_GAME")) { - BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine)); + STRNCPY(scene->r.engine, RE_engine_id_BLENDER_EEVEE); } scene->r.bake_mode = 0; @@ -2524,7 +2524,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) LISTBASE_FOREACH (SpaceLink *, sl, &area->spacedata) { if (sl->spacetype == SPACE_VIEW3D) { View3D *v3d = (View3D *)sl; - BLI_strncpy(v3d->shading.matcap, default_matcap->name, FILE_MAXFILE); + STRNCPY(v3d->shading.matcap, default_matcap->name); } } } @@ -2576,7 +2576,7 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain) if (ima->type == IMA_TYPE_R_RESULT) { for (int i = 0; i < 8; i++) { RenderSlot *slot = MEM_callocN(sizeof(RenderSlot), "Image Render Slot Init"); - BLI_snprintf(slot->name, sizeof(slot->name), "Slot %d", i + 1); + SNPRINTF(slot->name, "Slot %d", i + 1); BLI_addtail(&ima->renderslots, slot); } } diff --git a/source/blender/blenloader/intern/versioning_290.cc b/source/blender/blenloader/intern/versioning_290.cc index 4b620d97851..a8e9e6bfb6d 100644 --- a/source/blender/blenloader/intern/versioning_290.cc +++ b/source/blender/blenloader/intern/versioning_290.cc @@ -1068,7 +1068,7 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain) if (!DNA_struct_elem_find(fd->filesdna, "CacheFile", "char", "velocity_unit")) { LISTBASE_FOREACH (CacheFile *, cache_file, &bmain->cachefiles) { - BLI_strncpy(cache_file->velocity_name, ".velocities", sizeof(cache_file->velocity_name)); + STRNCPY(cache_file->velocity_name, ".velocities"); cache_file->velocity_unit = CACHEFILE_VELOCITY_UNIT_SECOND; } } @@ -1457,7 +1457,7 @@ void blo_do_versions_290(FileData *fd, Library * /*lib*/, Main *bmain) LISTBASE_FOREACH (bNodeSocket *, output_socket, &node->outputs) { const char *volume_scatter = "VolumeScatterCol"; if (STREQLEN(output_socket->name, volume_scatter, MAX_NAME)) { - BLI_strncpy(output_socket->name, RE_PASSNAME_VOLUME_LIGHT, MAX_NAME); + STRNCPY(output_socket->name, RE_PASSNAME_VOLUME_LIGHT); } } } diff --git a/source/blender/blenloader/intern/versioning_300.cc b/source/blender/blenloader/intern/versioning_300.cc index f5533edf72f..8f4fcb4cb35 100644 --- a/source/blender/blenloader/intern/versioning_300.cc +++ b/source/blender/blenloader/intern/versioning_300.cc @@ -923,7 +923,7 @@ static void version_geometry_nodes_primitive_uv_maps(bNodeTree &ntree) store_attribute_name_input->default_value); const char *uv_map_name = node->type == GEO_NODE_MESH_PRIMITIVE_ICO_SPHERE ? "UVMap" : "uv_map"; - BLI_strncpy(name_value->value, uv_map_name, sizeof(name_value->value)); + STRNCPY(name_value->value, uv_map_name); nodeAddLink(&ntree, node, @@ -1397,7 +1397,7 @@ static void version_switch_node_input_prefix(Main *bmain) /* Replace "A" and "B", but keep the unique number suffix at the end. */ char number_suffix[8]; - BLI_strncpy(number_suffix, socket->identifier + 1, sizeof(number_suffix)); + STRNCPY(number_suffix, socket->identifier + 1); BLI_string_join( socket->identifier, sizeof(socket->identifier), socket->name, number_suffix); } @@ -1576,22 +1576,14 @@ static void version_geometry_nodes_add_attribute_input_settings(NodesModifierDat } char use_attribute_prop_name[MAX_IDPROP_NAME]; - BLI_snprintf(use_attribute_prop_name, - sizeof(use_attribute_prop_name), - "%s%s", - property->name, - "_use_attribute"); + SNPRINTF(use_attribute_prop_name, "%s%s", property->name, "_use_attribute"); IDPropertyTemplate idprop = {0}; IDProperty *use_attribute_prop = IDP_New(IDP_INT, &idprop, use_attribute_prop_name); IDP_AddToGroup(nmd->settings.properties, use_attribute_prop); char attribute_name_prop_name[MAX_IDPROP_NAME]; - BLI_snprintf(attribute_name_prop_name, - sizeof(attribute_name_prop_name), - "%s%s", - property->name, - "_attribute_name"); + SNPRINTF(attribute_name_prop_name, "%s%s", property->name, "_attribute_name"); IDProperty *attribute_prop = IDP_New(IDP_STRING, &idprop, attribute_name_prop_name); IDP_AddToGroup(nmd->settings.properties, attribute_prop); @@ -4335,43 +4327,38 @@ void blo_do_versions_300(FileData *fd, Library * /*lib*/, Main *bmain) * This only affects files that have been created using simulation nodes before they were first * officially released. */ if (!DNA_struct_elem_find(fd->filesdna, "NodeSimulationItem", "int", "identifier")) { - static auto set_socket_identifiers = - [](bNode *node, const bNode *output_node, int extra_outputs) { - const NodeGeometrySimulationOutput *output_data = - static_cast(output_node->storage); - /* Includes extension socket. */ - BLI_assert(BLI_listbase_count(&node->inputs) == output_data->items_num + 1); - /* Includes extension socket. */ - BLI_assert(BLI_listbase_count(&node->outputs) == - output_data->items_num + 1 + extra_outputs); + static auto set_socket_identifiers = [](bNode *node, + const bNode *output_node, + int extra_outputs) { + const NodeGeometrySimulationOutput *output_data = + static_cast(output_node->storage); + /* Includes extension socket. */ + BLI_assert(BLI_listbase_count(&node->inputs) == output_data->items_num + 1); + /* Includes extension socket. */ + BLI_assert(BLI_listbase_count(&node->outputs) == + output_data->items_num + 1 + extra_outputs); - int i; - LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->inputs, i) { - /* Skip extension socket. */ - if (i >= output_data->items_num) { - break; - } - BLI_snprintf(sock->identifier, - sizeof(sock->identifier), - "Item_%d", - output_data->items[i].identifier); - } - LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->outputs, i) { - const int item_i = i - extra_outputs; - /* Skip extra outputs. */ - if (i < extra_outputs) { - continue; - } - /* Skip extension socket. */ - if (item_i >= output_data->items_num) { - break; - } - BLI_snprintf(sock->identifier, - sizeof(sock->identifier), - "Item_%d", - output_data->items[i - extra_outputs].identifier); - } - }; + int i; + LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->inputs, i) { + /* Skip extension socket. */ + if (i >= output_data->items_num) { + break; + } + SNPRINTF(sock->identifier, "Item_%d", output_data->items[i].identifier); + } + LISTBASE_FOREACH_INDEX (bNodeSocket *, sock, &node->outputs, i) { + const int item_i = i - extra_outputs; + /* Skip extra outputs. */ + if (i < extra_outputs) { + continue; + } + /* Skip extension socket. */ + if (item_i >= output_data->items_num) { + break; + } + SNPRINTF(sock->identifier, "Item_%d", output_data->items[i - extra_outputs].identifier); + } + }; LISTBASE_FOREACH (bNodeTree *, ntree, &bmain->nodetrees) { if (ntree->type == NTREE_GEOMETRY) { diff --git a/source/blender/blenloader/intern/versioning_common.cc b/source/blender/blenloader/intern/versioning_common.cc index 9468b978716..8bbc4166229 100644 --- a/source/blender/blenloader/intern/versioning_common.cc +++ b/source/blender/blenloader/intern/versioning_common.cc @@ -103,10 +103,10 @@ static void change_node_socket_name(ListBase *sockets, const char *old_name, con { LISTBASE_FOREACH (bNodeSocket *, socket, sockets) { if (STREQ(socket->name, old_name)) { - BLI_strncpy(socket->name, new_name, sizeof(socket->name)); + STRNCPY(socket->name, new_name); } if (STREQ(socket->identifier, old_name)) { - BLI_strncpy(socket->identifier, new_name, sizeof(socket->name)); + STRNCPY(socket->identifier, new_name); } } } diff --git a/source/blender/blenloader/intern/versioning_defaults.cc b/source/blender/blenloader/intern/versioning_defaults.cc index abdda14bb72..1f2990118a3 100644 --- a/source/blender/blenloader/intern/versioning_defaults.cc +++ b/source/blender/blenloader/intern/versioning_defaults.cc @@ -288,7 +288,7 @@ void BLO_update_defaults_workspace(WorkSpace *workspace, const char *app_templat static void blo_update_defaults_scene(Main *bmain, Scene *scene) { - BLI_strncpy(scene->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(scene->r.engine)); + STRNCPY(scene->r.engine, RE_engine_id_BLENDER_EEVEE); scene->r.cfra = 1.0f; diff --git a/source/blender/blenloader/intern/versioning_legacy.c b/source/blender/blenloader/intern/versioning_legacy.c index 153a49f167a..0547c116cea 100644 --- a/source/blender/blenloader/intern/versioning_legacy.c +++ b/source/blender/blenloader/intern/versioning_legacy.c @@ -326,7 +326,7 @@ static void customdata_version_242(Mesh *me) strcpy(layer->name, "UVMap"); } else { - BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen); + SNPRINTF(layer->name, "UVMap.%.3d", mtfacen); } } mtfacen++; @@ -337,7 +337,7 @@ static void customdata_version_242(Mesh *me) strcpy(layer->name, "Col"); } else { - BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln); + SNPRINTF(layer->name, "Col.%.3d", mcoln); } } mcoln++; @@ -422,7 +422,7 @@ static void do_version_constraints_245(ListBase *lb) ct = MEM_callocN(sizeof(bConstraintTarget), "PyConTarget"); ct->tar = data->tar; - BLI_strncpy(ct->subtarget, data->subtarget, sizeof(ct->subtarget)); + STRNCPY(ct->subtarget, data->subtarget); ct->space = con->tarspace; BLI_addtail(&data->targets, ct); @@ -1480,7 +1480,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) } else { if (kb->name[0] == 0) { - BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index); + SNPRINTF(kb->name, "Key %d", index); } index++; } @@ -2223,10 +2223,7 @@ void blo_do_versions_pre250(FileData *fd, Library *lib, Main *bmain) BLI_addtail(&ob->particlesystem, psys); md = BKE_modifier_new(eModifierType_ParticleSystem); - BLI_snprintf(md->name, - sizeof(md->name), - "ParticleSystem %i", - BLI_listbase_count(&ob->particlesystem)); + SNPRINTF(md->name, "ParticleSystem %i", BLI_listbase_count(&ob->particlesystem)); psmd = (ParticleSystemModifierData *)md; psmd->psys = psys; BLI_addtail(&ob->modifiers, md); diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index 3c74f5faec7..d985622395f 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -840,7 +840,7 @@ static void write_renderinfo(WriteData *wd, Main *mainvar) data.efra = sce->r.efra; memset(data.scene_name, 0, sizeof(data.scene_name)); - BLI_strncpy(data.scene_name, sce->id.name + 2, sizeof(data.scene_name)); + STRNCPY(data.scene_name, sce->id.name + 2); writedata(wd, BLO_CODE_REND, sizeof(data), &data); } @@ -1054,7 +1054,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) if (fileflags & G_FILE_RECOVER_WRITE) { STRNCPY(fg.filepath, mainvar->filepath); } - BLI_snprintf(subvstr, sizeof(subvstr), "%4d", BLENDER_FILE_SUBVERSION); + SNPRINTF(subvstr, "%4d", BLENDER_FILE_SUBVERSION); memcpy(fg.subvstr, subvstr, 4); fg.subversion = BLENDER_FILE_SUBVERSION; @@ -1066,7 +1066,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash)); #else fg.build_commit_timestamp = 0; - BLI_strncpy(fg.build_hash, "unknown", sizeof(fg.build_hash)); + STRNCPY(fg.build_hash, "unknown"); #endif writestruct(wd, BLO_CODE_GLOB, FileGlobal, 1, &fg); } @@ -1239,12 +1239,11 @@ static bool write_file_handle(Main *mainvar, blo_split_main(&mainlist, mainvar); - BLI_snprintf(buf, - sizeof(buf), - "BLENDER%c%c%.3d", - (sizeof(void *) == 8) ? '-' : '_', - (ENDIAN_ORDER == B_ENDIAN) ? 'V' : 'v', - BLENDER_FILE_VERSION); + SNPRINTF(buf, + "BLENDER%c%c%.3d", + (sizeof(void *) == 8) ? '-' : '_', + (ENDIAN_ORDER == B_ENDIAN) ? 'V' : 'v', + BLENDER_FILE_VERSION); mywrite(wd, buf, 12); @@ -1380,9 +1379,9 @@ static bool do_history(const char *name, ReportList *reports) } while (hisnr > 1) { - BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr - 1); + SNPRINTF(tempname1, "%s%d", name, hisnr - 1); if (BLI_exists(tempname1)) { - BLI_snprintf(tempname2, sizeof(tempname2), "%s%d", name, hisnr); + SNPRINTF(tempname2, "%s%d", name, hisnr); if (BLI_rename(tempname1, tempname2)) { BKE_report(reports, RPT_ERROR, "Unable to make version backup"); @@ -1394,7 +1393,7 @@ static bool do_history(const char *name, ReportList *reports) /* is needed when hisnr==1 */ if (BLI_exists(name)) { - BLI_snprintf(tempname1, sizeof(tempname1), "%s%d", name, hisnr); + SNPRINTF(tempname1, "%s%d", name, hisnr); if (BLI_rename(name, tempname1)) { BKE_report(reports, RPT_ERROR, "Unable to make version backup"); @@ -1442,7 +1441,7 @@ bool BLO_write_file(Main *mainvar, } /* open temporary file, so we preserve the original in case we crash */ - BLI_snprintf(tempname, sizeof(tempname), "%s@", filepath); + SNPRINTF(tempname, "%s@", filepath); ww_handle_init((write_flags & G_FILE_COMPRESS) ? WW_WRAP_ZSTD : WW_WRAP_NONE, &ww); diff --git a/source/blender/bmesh/intern/bmesh_operators.c b/source/blender/bmesh/intern/bmesh_operators.c index 2a704f9b1c9..3f5dde9a155 100644 --- a/source/blender/bmesh/intern/bmesh_operators.c +++ b/source/blender/bmesh/intern/bmesh_operators.c @@ -1659,7 +1659,7 @@ bool BMO_op_vinitf(BMesh *bm, BMOperator *op, const int flag, const char *_fmt, GOTO_ERROR("name to slot code check failed"); } - BLI_strncpy(slot_name, fmt, sizeof(slot_name)); + STRNCPY(slot_name, fmt); state = false; fmt += i; diff --git a/source/blender/compositor/intern/COM_Debug.cc b/source/blender/compositor/intern/COM_Debug.cc index ebe9b7fe2ea..83ab3adfc26 100644 --- a/source/blender/compositor/intern/COM_Debug.cc +++ b/source/blender/compositor/intern/COM_Debug.cc @@ -305,7 +305,7 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma for (NodeOperation *operation : group->operations_) { - BLI_snprintf(strbuf, sizeof(strbuf), "_%p", group); + SNPRINTF(strbuf, "_%p", group); op_groups[operation].push_back(std::string(strbuf)); len += graphviz_operation( @@ -423,10 +423,10 @@ void DebugInfo::graphviz(const ExecutionSystem *system, StringRefNull name) char filepath[FILE_MAX]; if (name.is_empty()) { - BLI_snprintf(basename, sizeof(basename), "compositor_%d.dot", file_index_); + SNPRINTF(basename, "compositor_%d.dot", file_index_); } else { - BLI_strncpy(basename, (name + ".dot").c_str(), sizeof(basename)); + STRNCPY(basename, (name + ".dot").c_str()); } BLI_path_join(filepath, sizeof(filepath), BKE_tempdir_session(), basename); file_index_++; diff --git a/source/blender/compositor/intern/COM_ExecutionGroup.cc b/source/blender/compositor/intern/COM_ExecutionGroup.cc index ae24770a317..6a3923a62cb 100644 --- a/source/blender/compositor/intern/COM_ExecutionGroup.cc +++ b/source/blender/compositor/intern/COM_ExecutionGroup.cc @@ -419,8 +419,7 @@ void ExecutionGroup::finalize_chunk_execution(int chunk_number, MemoryBuffer **m bTree_->runtime->progress(bTree_->runtime->prh, progress); char buf[128]; - BLI_snprintf( - buf, sizeof(buf), TIP_("Compositing | Tile %u-%u"), chunks_finished_, chunks_len_); + SNPRINTF(buf, TIP_("Compositing | Tile %u-%u"), chunks_finished_, chunks_len_); bTree_->runtime->stats_draw(bTree_->runtime->sdh, buf); } } diff --git a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc index fd6890a60c1..947fe256b3b 100644 --- a/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc +++ b/source/blender/compositor/intern/COM_FullFrameExecutionModel.cc @@ -276,11 +276,10 @@ void FullFrameExecutionModel::update_progress_bar() tree->runtime->progress(tree->runtime->prh, progress); char buf[128]; - BLI_snprintf(buf, - sizeof(buf), - TIP_("Compositing | Operation %i-%li"), - num_operations_finished_ + 1, - operations_.size()); + SNPRINTF(buf, + TIP_("Compositing | Operation %i-%li"), + num_operations_finished_ + 1, + operations_.size()); tree->runtime->stats_draw(tree->runtime->sdh, buf); } } diff --git a/source/blender/compositor/nodes/COM_OutputFileNode.cc b/source/blender/compositor/nodes/COM_OutputFileNode.cc index e591b4aed9e..9f44f7a9cbd 100644 --- a/source/blender/compositor/nodes/COM_OutputFileNode.cc +++ b/source/blender/compositor/nodes/COM_OutputFileNode.cc @@ -108,7 +108,7 @@ void OutputFileNode::convert_to_operations(NodeConverter &converter, BLI_path_join(path, FILE_MAX, storage->base_path, sockdata->path); } else { - BLI_strncpy(path, storage->base_path, FILE_MAX); + STRNCPY(path, storage->base_path); BLI_path_slash_ensure(path, FILE_MAX); } diff --git a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc index f427b194f08..4b9bd9d7d3a 100644 --- a/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc +++ b/source/blender/compositor/operations/COM_OutputFileMultiViewOperation.cc @@ -253,7 +253,7 @@ OutputStereoOperation::OutputStereoOperation(const Scene *scene, : OutputSingleLayerOperation( scene, rd, tree, datatype, format, path, view_name, save_as_render) { - BLI_strncpy(pass_name_, pass_name, sizeof(pass_name_)); + STRNCPY(pass_name_, pass_name); channels_ = get_datatype_size(datatype); } diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cc b/source/blender/compositor/operations/COM_OutputFileOperation.cc index 22a8ef7381b..53ad32bb26f 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cc +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cc @@ -225,7 +225,7 @@ OutputSingleLayerOperation::OutputSingleLayerOperation(const Scene *scene, format_.linear_colorspace_settings.name[0] = '\0'; } - BLI_strncpy(path_, path, sizeof(path_)); + STRNCPY(path_, path); view_name_ = view_name; save_as_render_ = save_as_render; @@ -307,7 +307,7 @@ void OutputSingleLayerOperation::update_memory_buffer_partial(MemoryBuffer * /*o OutputOpenExrLayer::OutputOpenExrLayer(const char *name_, DataType datatype_, bool use_layer_) { - BLI_strncpy(this->name, name_, sizeof(this->name)); + STRNCPY(this->name, name_); this->datatype = datatype_; this->use_layer = use_layer_; @@ -328,7 +328,7 @@ OutputOpenExrMultiLayerOperation::OutputOpenExrMultiLayerOperation(const Scene * rd_ = rd; tree_ = tree; - BLI_strncpy(path_, path, sizeof(path_)); + STRNCPY(path_, path); exr_codec_ = exr_codec; exr_half_float_ = exr_half_float; view_name_ = view_name; diff --git a/source/blender/depsgraph/intern/debug/deg_debug.cc b/source/blender/depsgraph/intern/debug/deg_debug.cc index aff4c6a99eb..665afde8460 100644 --- a/source/blender/depsgraph/intern/debug/deg_debug.cc +++ b/source/blender/depsgraph/intern/debug/deg_debug.cc @@ -69,7 +69,7 @@ string color_for_pointer(const void *pointer) int r, g, b; BLI_hash_pointer_to_color(pointer, &r, &g, &b); char buffer[64]; - BLI_snprintf(buffer, sizeof(buffer), TRUECOLOR_ANSI_COLOR_FORMAT, r, g, b); + SNPRINTF(buffer, TRUECOLOR_ANSI_COLOR_FORMAT, r, g, b); return string(buffer); } diff --git a/source/blender/depsgraph/intern/node/deg_node_id.cc b/source/blender/depsgraph/intern/node/deg_node_id.cc index 60a8891f930..55e549ffb91 100644 --- a/source/blender/depsgraph/intern/node/deg_node_id.cc +++ b/source/blender/depsgraph/intern/node/deg_node_id.cc @@ -134,8 +134,8 @@ void IDNode::destroy() string IDNode::identifier() const { char orig_ptr[24], cow_ptr[24]; - BLI_snprintf(orig_ptr, sizeof(orig_ptr), "%p", id_orig); - BLI_snprintf(cow_ptr, sizeof(cow_ptr), "%p", id_cow); + SNPRINTF(orig_ptr, "%p", id_orig); + SNPRINTF(cow_ptr, "%p", id_cow); return string(nodeTypeAsString(type)) + " : " + name + " (orig: " + orig_ptr + ", eval: " + cow_ptr + ", is_visible_on_build " + (is_visible_on_build ? "true" : "false") + ")"; diff --git a/source/blender/draw/engines/eevee/eevee_cryptomatte.c b/source/blender/draw/engines/eevee/eevee_cryptomatte.c index df5c761a73e..003f36d18f5 100644 --- a/source/blender/draw/engines/eevee/eevee_cryptomatte.c +++ b/source/blender/draw/engines/eevee/eevee_cryptomatte.c @@ -429,21 +429,21 @@ void EEVEE_cryptomatte_update_passes(RenderEngine *engine, Scene *scene, ViewLay const short num_passes = eevee_cryptomatte_passes_per_layer(view_layer); if ((view_layer->cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_OBJECT) != 0) { for (short pass = 0; pass < num_passes; pass++) { - BLI_snprintf_rlen(cryptomatte_pass_name, MAX_NAME, "CryptoObject%02d", pass); + SNPRINTF_RLEN(cryptomatte_pass_name, "CryptoObject%02d", pass); RE_engine_register_pass( engine, scene, view_layer, cryptomatte_pass_name, 4, "rgba", SOCK_RGBA); } } if ((view_layer->cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_MATERIAL) != 0) { for (short pass = 0; pass < num_passes; pass++) { - BLI_snprintf_rlen(cryptomatte_pass_name, MAX_NAME, "CryptoMaterial%02d", pass); + SNPRINTF_RLEN(cryptomatte_pass_name, "CryptoMaterial%02d", pass); RE_engine_register_pass( engine, scene, view_layer, cryptomatte_pass_name, 4, "rgba", SOCK_RGBA); } } if ((view_layer->cryptomatte_flag & VIEW_LAYER_CRYPTOMATTE_ASSET) != 0) { for (short pass = 0; pass < num_passes; pass++) { - BLI_snprintf_rlen(cryptomatte_pass_name, MAX_NAME, "CryptoAsset%02d", pass); + SNPRINTF_RLEN(cryptomatte_pass_name, "CryptoAsset%02d", pass); RE_engine_register_pass( engine, scene, view_layer, cryptomatte_pass_name, 4, "rgba", SOCK_RGBA); } @@ -580,7 +580,7 @@ static void eevee_cryptomatte_extract_render_passes( for (int pass = 0; pass < num_cryptomatte_passes; pass++) { /* Each pass holds 2 cryptomatte samples. */ const int pass_offset = pass * 2; - BLI_snprintf_rlen(cryptomatte_pass_name, MAX_NAME, render_pass_name_format, pass); + SNPRINTF_RLEN(cryptomatte_pass_name, render_pass_name_format, pass); RenderPass *rp_object = RE_pass_find_by_name(rl, cryptomatte_pass_name, viewname); for (int y = 0; y < rect_height; y++) { for (int x = 0; x < rect_width; x++) { diff --git a/source/blender/draw/engines/eevee/eevee_lightcache.c b/source/blender/draw/engines/eevee/eevee_lightcache.c index 03597f1bb0d..9bc4c5e1bfb 100644 --- a/source/blender/draw/engines/eevee/eevee_lightcache.c +++ b/source/blender/draw/engines/eevee/eevee_lightcache.c @@ -230,29 +230,25 @@ void EEVEE_lightcache_info_update(SceneEEVEE *eevee) } if (lcache->cube_tx.tex_size[2] > GPU_max_texture_layers()) { - BLI_strncpy(eevee->light_cache_info, - TIP_("Error: Light cache is too big for the GPU to be loaded"), - sizeof(eevee->light_cache_info)); + STRNCPY(eevee->light_cache_info, + TIP_("Error: Light cache is too big for the GPU to be loaded")); return; } if (lcache->flag & LIGHTCACHE_INVALID) { - BLI_strncpy(eevee->light_cache_info, - TIP_("Error: Light cache dimensions not supported by the GPU"), - sizeof(eevee->light_cache_info)); + STRNCPY(eevee->light_cache_info, + TIP_("Error: Light cache dimensions not supported by the GPU")); return; } if (lcache->flag & LIGHTCACHE_BAKING) { - BLI_strncpy( - eevee->light_cache_info, TIP_("Baking light cache"), sizeof(eevee->light_cache_info)); + STRNCPY(eevee->light_cache_info, TIP_("Baking light cache")); return; } if (!eevee_lightcache_can_be_saved(lcache)) { - BLI_strncpy(eevee->light_cache_info, - TIP_("Error: LightCache is too large and will not be saved to disk"), - sizeof(eevee->light_cache_info)); + STRNCPY(eevee->light_cache_info, + TIP_("Error: LightCache is too large and will not be saved to disk")); return; } @@ -261,17 +257,14 @@ void EEVEE_lightcache_info_update(SceneEEVEE *eevee) int irr_samples = eevee_lightcache_irradiance_sample_count(lcache); - BLI_snprintf(eevee->light_cache_info, - sizeof(eevee->light_cache_info), - TIP_("%d Ref. Cubemaps, %d Irr. Samples (%s in memory)"), - lcache->cube_len - 1, - irr_samples, - formatted_mem); + SNPRINTF(eevee->light_cache_info, + TIP_("%d Ref. Cubemaps, %d Irr. Samples (%s in memory)"), + lcache->cube_len - 1, + irr_samples, + formatted_mem); } else { - BLI_strncpy(eevee->light_cache_info, - TIP_("No light cache in this scene"), - sizeof(eevee->light_cache_info)); + STRNCPY(eevee->light_cache_info, TIP_("No light cache in this scene")); } } diff --git a/source/blender/draw/engines/eevee/eevee_render.c b/source/blender/draw/engines/eevee/eevee_render.c index 4e34b5a5efe..8e892a3e9ae 100644 --- a/source/blender/draw/engines/eevee/eevee_render.c +++ b/source/blender/draw/engines/eevee/eevee_render.c @@ -86,11 +86,10 @@ bool EEVEE_render_init(EEVEE_Data *ved, RenderEngine *engine, struct Depsgraph * int max_dim = max_ii(final_res[0], final_res[1]); if (max_dim > GPU_max_texture_size()) { char error_msg[128]; - BLI_snprintf(error_msg, - sizeof(error_msg), - "Error: Reported texture size limit (%dpx) is lower than output size (%dpx).", - GPU_max_texture_size(), - max_dim); + SNPRINTF(error_msg, + "Error: Reported texture size limit (%dpx) is lower than output size (%dpx).", + GPU_max_texture_size(), + max_dim); RE_engine_set_error_message(engine, error_msg); G.is_break = true; return false; @@ -209,7 +208,7 @@ void EEVEE_render_cache(void *vedata, * (see #59649) */ if (engine && (ob->base_flag & BASE_FROM_DUPLI) == 0) { char info[42]; - BLI_snprintf(info, sizeof(info), "Syncing %s", ob->id.name + 2); + SNPRINTF(info, "Syncing %s", ob->id.name + 2); RE_engine_update_stats(engine, NULL, info); } @@ -575,8 +574,7 @@ void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl /* Don't print every samples as it can lead to bad performance. (see #59649) */ else if ((render_samples % 25) == 0 || (render_samples + 1) == tot_sample) { char info[42]; - BLI_snprintf( - info, sizeof(info), "Rendering %u / %u samples", render_samples + 1, tot_sample); + SNPRINTF(info, "Rendering %u / %u samples", render_samples + 1, tot_sample); RE_engine_update_stats(engine, NULL, info); } diff --git a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl index 6bd9d222420..1eb8e40e5ae 100644 --- a/source/blender/draw/engines/eevee/shaders/surface_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/surface_lib.glsl @@ -79,13 +79,13 @@ IN_OUT ShaderPointCloudInterface /** Checks to ensure create-info is setup correctly. **/ # ifdef HAIR_SHADER # ifndef USE_SURFACE_LIB_HAIR -#error Ensure CreateInfo eevee_legacy_surface_lib_hair is included if using surface library with a hair shader. +# error Ensure CreateInfo eevee_legacy_surface_lib_hair is included if using surface library with a hair shader. # endif # endif # ifdef POINTCLOUD_SHADER # ifndef USE_SURFACE_LIB_POINTCLOUD -#error Ensure CreateInfo eevee_legacy_surface_lib_pointcloud is included if using surface library with a hair shader. +# error Ensure CreateInfo eevee_legacy_surface_lib_pointcloud is included if using surface library with a hair shader. # endif # endif diff --git a/source/blender/draw/engines/external/external_engine.c b/source/blender/draw/engines/external/external_engine.c index 2f540df235b..316dbd1c5fb 100644 --- a/source/blender/draw/engines/external/external_engine.c +++ b/source/blender/draw/engines/external/external_engine.c @@ -271,7 +271,7 @@ static void external_draw_scene_do_v3d(void *vedata) /* Set render info. */ EXTERNAL_Data *data = vedata; if (rv3d->render_engine->text[0] != '\0') { - BLI_strncpy(data->info, rv3d->render_engine->text, sizeof(data->info)); + STRNCPY(data->info, rv3d->render_engine->text); } else { data->info[0] = '\0'; diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.cc b/source/blender/draw/engines/overlay/overlay_motion_path.cc index 17b14363a50..82882568ae5 100644 --- a/source/blender/draw/engines/overlay/overlay_motion_path.cc +++ b/source/blender/draw/engines/overlay/overlay_motion_path.cc @@ -175,7 +175,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, bool is_keyframe = (mpv->flag & MOTIONPATH_VERT_KEY) != 0; if ((show_keyframes && show_keyframes_no && is_keyframe) || (show_frame_no && (i == 0))) { - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), " %d", frame); + numstr_len = SNPRINTF_RLEN(numstr, " %d", frame); DRW_text_cache_add( dt, mpv->co, numstr, numstr_len, 0, 0, txt_flag, (is_keyframe) ? col_kf : col); } @@ -185,7 +185,7 @@ static void motion_path_cache(OVERLAY_Data *vedata, /* Only draw frame number if several consecutive highlighted points * don't occur on same point. */ if ((equals_v3v3(mpv->co, mpvP->co) == 0) || (equals_v3v3(mpv->co, mpvN->co) == 0)) { - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), " %d", frame); + numstr_len = SNPRINTF_RLEN(numstr, " %d", frame); DRW_text_cache_add(dt, mpv->co, numstr, numstr_len, 0, 0, txt_flag, col); } } diff --git a/source/blender/draw/intern/draw_attributes.cc b/source/blender/draw/intern/draw_attributes.cc index 73e7dabd117..5bfab0fad69 100644 --- a/source/blender/draw/intern/draw_attributes.cc +++ b/source/blender/draw/intern/draw_attributes.cc @@ -71,7 +71,7 @@ void drw_attributes_add_request(DRW_Attributes *attrs, DRW_AttributeRequest *req = &attrs->requests[attrs->num_requests]; req->cd_type = type; - BLI_strncpy(req->attribute_name, name, sizeof(req->attribute_name)); + STRNCPY(req->attribute_name, name); req->layer_index = layer_index; req->domain = domain; attrs->num_requests += 1; diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index df6d4f59933..4240126e35f 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -3406,11 +3406,11 @@ void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format, GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); /* Attribute layer name. */ - BLI_snprintf(attr_name, sizeof(attr_name), "%s%s", base_name, attr_safe_name); + SNPRINTF(attr_name, "%s%s", base_name, attr_safe_name); GPU_vertformat_alias_add(format, attr_name); /* Auto layer name. */ - BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); + SNPRINTF(attr_name, "a%s", attr_safe_name); GPU_vertformat_alias_add(format, attr_name); /* Active render layer name. */ @@ -3420,7 +3420,7 @@ void DRW_cdlayer_attr_aliases_add(GPUVertFormat *format, /* Active display layer name. */ if (is_active_layer) { - BLI_snprintf(attr_name, sizeof(attr_name), "a%s", base_name); + SNPRINTF(attr_name, "a%s", base_name); GPU_vertformat_alias_add(format, attr_name); } } diff --git a/source/blender/draw/intern/draw_cache_impl_particles.c b/source/blender/draw/intern/draw_cache_impl_particles.c index e1c15dcaa78..9e360a56874 100644 --- a/source/blender/draw/intern/draw_cache_impl_particles.c +++ b/source/blender/draw/intern/draw_cache_impl_particles.c @@ -903,13 +903,16 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); int n = 0; - BLI_snprintf(cache->uv_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); + SNPRINTF(cache->uv_layer_names[i][n], "a%s", attr_safe_name); + n++; if (i == active_uv) { - BLI_strncpy(cache->uv_layer_names[i][n++], "au", MAX_LAYER_NAME_LEN); + STRNCPY(cache->uv_layer_names[i][n], "au"); + n++; } if (i == render_uv) { - BLI_strncpy(cache->uv_layer_names[i][n++], "a", MAX_LAYER_NAME_LEN); + STRNCPY(cache->uv_layer_names[i][n], "a"); + n++; } } @@ -934,13 +937,16 @@ static void particle_batch_cache_ensure_procedural_strand_data(PTCacheEdit *edit GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); int n = 0; - BLI_snprintf(cache->col_layer_names[i][n++], MAX_LAYER_NAME_LEN, "a%s", attr_safe_name); + SNPRINTF(cache->col_layer_names[i][n], "a%s", attr_safe_name); + n++; if (i == active_col) { - BLI_strncpy(cache->col_layer_names[i][n++], "ac", MAX_LAYER_NAME_LEN); + STRNCPY(cache->col_layer_names[i][n], "ac"); + n++; } if (i == render_col) { - BLI_strncpy(cache->col_layer_names[i][n++], "c", MAX_LAYER_NAME_LEN); + STRNCPY(cache->col_layer_names[i][n], "c"); + n++; } } @@ -1203,7 +1209,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, const char *name = CustomData_get_layer_name(&psmd->mesh_final->ldata, CD_PROP_FLOAT2, i); GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); - BLI_snprintf(uuid, sizeof(uuid), "a%s", attr_safe_name); + SNPRINTF(uuid, "a%s", attr_safe_name); uv_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (i == active_uv) { @@ -1217,7 +1223,7 @@ static void particle_batch_cache_ensure_pos_and_seg(PTCacheEdit *edit, &psmd->mesh_final->ldata, CD_PROP_BYTE_COLOR, i); GPU_vertformat_safe_attr_name(name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); - BLI_snprintf(uuid, sizeof(uuid), "a%s", attr_safe_name); + SNPRINTF(uuid, "a%s", attr_safe_name); col_id[i] = GPU_vertformat_attr_add(&format, uuid, GPU_COMP_U16, 4, GPU_FETCH_FLOAT); if (i == active_col) { diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 6f1a09bb078..2a4a4b5eb67 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -1425,7 +1425,7 @@ void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, attrs[attrs_num].type = eCustomDataType(layer->type); attrs[attrs_num].domain = domain; - BLI_strncpy(attrs[attrs_num].name, layer->name, sizeof(attrs[attrs_num].name)); + STRNCPY(attrs[attrs_num].name, layer->name); attrs_num++; } } @@ -1437,7 +1437,7 @@ void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, attrs[attrs_num].type = CD_PROP_FLOAT2; attrs[attrs_num].domain = ATTR_DOMAIN_CORNER; - BLI_strncpy(attrs[attrs_num].name, layer->name, sizeof(attrs[attrs_num].name)); + STRNCPY(attrs[attrs_num].name, layer->name); attrs_num++; } @@ -1483,7 +1483,7 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups, attrs[attrs_i].type = req->cd_type; attrs[attrs_i].domain = req->domain; - BLI_strncpy(attrs[attrs_i].name, req->attribute_name, sizeof(PBVHAttrReq::name)); + STRNCPY(attrs[attrs_i].name, req->attribute_name); attrs_i++; } @@ -1498,7 +1498,7 @@ void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups, if (layer) { attrs[attrs_i].type = CD_PROP_FLOAT2; attrs[attrs_i].domain = ATTR_DOMAIN_CORNER; - BLI_strncpy(attrs[attrs_i].name, layer->name, sizeof(PBVHAttrReq::name)); + STRNCPY(attrs[attrs_i].name, layer->name); attrs_i++; } } @@ -2414,7 +2414,7 @@ DRWPass *DRW_pass_create(const char *name, DRWState state) DRWPass *pass = static_cast(BLI_memblock_alloc(DST.vmempool->passes)); pass->state = state | DRW_STATE_PROGRAM_POINT_SIZE; if (G.debug & G_DEBUG_GPU) { - BLI_strncpy(pass->name, name, MAX_PASS_NAME); + STRNCPY(pass->name, name); } pass->shgroups.first = nullptr; diff --git a/source/blender/draw/intern/draw_manager_profiling.cc b/source/blender/draw/intern/draw_manager_profiling.cc index a8314ff0f2f..8c147e2409d 100644 --- a/source/blender/draw/intern/draw_manager_profiling.cc +++ b/source/blender/draw/intern/draw_manager_profiling.cc @@ -97,7 +97,7 @@ static void drw_stats_timer_start_ex(const char *name, const bool is_query) { if (DTP.is_recording) { DRWTimer *timer = drw_stats_timer_get(); - BLI_strncpy(timer->name, name, MAX_TIMER_NAME); + STRNCPY(timer->name, name); timer->lvl = DTP.timer_increment - DTP.end_increment - 1; timer->is_query = is_query; @@ -248,22 +248,19 @@ void DRW_stats_draw(const rcti *rect) draw_stat_5row(rect, u++, v, engine->idname, sizeof(engine->idname)); init_tot_time += data->init_time; - BLI_snprintf(time_to_txt, sizeof(time_to_txt), "%.2fms", data->init_time); + SNPRINTF(time_to_txt, "%.2fms", data->init_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); background_tot_time += data->background_time; - BLI_snprintf(time_to_txt, sizeof(time_to_txt), "%.2fms", data->background_time); + SNPRINTF(time_to_txt, "%.2fms", data->background_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); render_tot_time += data->render_time; - BLI_snprintf(time_to_txt, sizeof(time_to_txt), "%.2fms", data->render_time); + SNPRINTF(time_to_txt, "%.2fms", data->render_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); tot_time += data->init_time + data->background_time + data->render_time; - BLI_snprintf(time_to_txt, - sizeof(time_to_txt), - "%.2fms", - data->init_time + data->background_time + data->render_time); + SNPRINTF(time_to_txt, "%.2fms", data->init_time + data->background_time + data->render_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); v++; } @@ -272,13 +269,13 @@ void DRW_stats_draw(const rcti *rect) u = 0; BLI_snprintf(col_label, sizeof(col_label), "Sub Total"); draw_stat_5row(rect, u++, v, col_label, sizeof(col_label)); - BLI_snprintf(time_to_txt, sizeof(time_to_txt), "%.2fms", init_tot_time); + SNPRINTF(time_to_txt, "%.2fms", init_tot_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); - BLI_snprintf(time_to_txt, sizeof(time_to_txt), "%.2fms", background_tot_time); + SNPRINTF(time_to_txt, "%.2fms", background_tot_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); - BLI_snprintf(time_to_txt, sizeof(time_to_txt), "%.2fms", render_tot_time); + SNPRINTF(time_to_txt, "%.2fms", render_tot_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); - BLI_snprintf(time_to_txt, sizeof(time_to_txt), "%.2fms", tot_time); + SNPRINTF(time_to_txt, "%.2fms", tot_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); v += 2; @@ -286,7 +283,7 @@ void DRW_stats_draw(const rcti *rect) double *cache_time = DRW_view_data_cache_time_get(DST.view_data_active); BLI_snprintf(col_label, sizeof(col_label), "Cache Time"); draw_stat_5row(rect, u++, v, col_label, sizeof(col_label)); - BLI_snprintf(time_to_txt, sizeof(time_to_txt), "%.2fms", *cache_time); + SNPRINTF(time_to_txt, "%.2fms", *cache_time); draw_stat_5row(rect, u++, v, time_to_txt, sizeof(time_to_txt)); v += 2; @@ -300,20 +297,20 @@ void DRW_stats_draw(const rcti *rect) BLI_snprintf(stat_string, sizeof(stat_string), "GPU Memory"); draw_stat(rect, 0, v, stat_string, sizeof(stat_string)); - BLI_snprintf(stat_string, sizeof(stat_string), "%.2fMB", double(tex_mem + vbo_mem) / 1000000.0); + SNPRINTF(stat_string, "%.2fMB", double(tex_mem + vbo_mem) / 1000000.0); draw_stat_5row(rect, 1, v++, stat_string, sizeof(stat_string)); BLI_snprintf(stat_string, sizeof(stat_string), "Textures"); draw_stat(rect, 1, v, stat_string, sizeof(stat_string)); - BLI_snprintf(stat_string, sizeof(stat_string), "%.2fMB", double(tex_mem) / 1000000.0); + SNPRINTF(stat_string, "%.2fMB", double(tex_mem) / 1000000.0); draw_stat_5row(rect, 1, v++, stat_string, sizeof(stat_string)); BLI_snprintf(stat_string, sizeof(stat_string), "Meshes"); draw_stat(rect, 1, v, stat_string, sizeof(stat_string)); - BLI_snprintf(stat_string, sizeof(stat_string), "%.2fMB", double(vbo_mem) / 1000000.0); + SNPRINTF(stat_string, "%.2fMB", double(vbo_mem) / 1000000.0); draw_stat_5row(rect, 1, v++, stat_string, sizeof(stat_string)); v += 1; /* GPU Timings */ - BLI_strncpy(stat_string, "GPU Render Timings", sizeof(stat_string)); + STRNCPY(stat_string, "GPU Render Timings"); draw_stat(rect, 0, v++, stat_string, sizeof(stat_string)); for (int i = 0; i < DTP.timer_increment; i++) { @@ -342,11 +339,11 @@ void DRW_stats_draw(const rcti *rect) time_ms = MIN2(time_ms, 999.0); time_percent = MIN2(time_percent, 100.0); - BLI_snprintf(stat_string, sizeof(stat_string), "%s", timer->name); + SNPRINTF(stat_string, "%s", timer->name); draw_stat(rect, 0 + timer->lvl, v, stat_string, sizeof(stat_string)); - BLI_snprintf(stat_string, sizeof(stat_string), "%.2fms", time_ms); + SNPRINTF(stat_string, "%.2fms", time_ms); draw_stat(rect, 12 + timer->lvl, v, stat_string, sizeof(stat_string)); - BLI_snprintf(stat_string, sizeof(stat_string), "%.0f", time_percent); + SNPRINTF(stat_string, "%.0f", time_percent); draw_stat(rect, 16 + timer->lvl, v, stat_string, sizeof(stat_string)); v++; } diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index ad358f86f37..61f464a13c9 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -694,7 +694,7 @@ void DRW_shader_library_add_file(DRWShaderLibrary *lib, const char *lib_code, co if (index > -1) { lib->libs[index] = lib_code; - BLI_strncpy(lib->libs_name[index], lib_name, MAX_LIB_NAME); + STRNCPY(lib->libs_name[index], lib_name); lib->libs_deps[index] = drw_shader_dependencies_get( lib, "BLENDER_REQUIRE(", lib_code, lib_name); } diff --git a/source/blender/draw/intern/draw_manager_text.cc b/source/blender/draw/intern/draw_manager_text.cc index d1c1d9a2294..124356e54f2 100644 --- a/source/blender/draw/intern/draw_manager_text.cc +++ b/source/blender/draw/intern/draw_manager_text.cc @@ -325,7 +325,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, false); } else { - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, len_v3v3(v1, v2)); + numstr_len = SNPRINTF_RLEN(numstr, conv_float, len_v3v3(v1, v2)); } DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, edge_tex_sep, txt_flag, col); @@ -397,11 +397,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, angle = angle_normalized_v3v3(no_a, no_b); - numstr_len = BLI_snprintf_rlen(numstr, - sizeof(numstr), - "%.3f%s", - (is_rad) ? angle : RAD2DEGF(angle), - (is_rad) ? "r" : "°"); + numstr_len = SNPRINTF_RLEN( + numstr, "%.3f%s", (is_rad) ? angle : RAD2DEGF(angle), (is_rad) ? "r" : "°"); DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, -edge_tex_sep, txt_flag, col); } @@ -469,7 +466,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, false); } else { - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), conv_float, area); + numstr_len = SNPRINTF_RLEN(numstr, conv_float, area); } DRW_text_cache_add(dt, vmid, numstr, numstr_len, 0, 0, txt_flag, col); @@ -534,11 +531,8 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, float angle = angle_v3v3v3(v1, v2, v3); - numstr_len = BLI_snprintf_rlen(numstr, - sizeof(numstr), - "%.3f%s", - (is_rad) ? angle : RAD2DEGF(angle), - (is_rad) ? "r" : "°"); + numstr_len = SNPRINTF_RLEN( + numstr, "%.3f%s", (is_rad) ? angle : RAD2DEGF(angle), (is_rad) ? "r" : "°"); interp_v3_v3v3(fvec, vmid, v2_local, 0.8f); mul_m4_v3(ob->object_to_world, fvec); DRW_text_cache_add(dt, fvec, numstr, numstr_len, 0, 0, txt_flag, col); @@ -573,7 +567,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, mul_m4_v3(ob->object_to_world, v1); - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i); + numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, 0, txt_flag, col); } } @@ -602,7 +596,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, mid_v3_v3v3(vmid, v1_clip, v2_clip); mul_m4_v3(ob->object_to_world, vmid); - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i); + numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add( dt, vmid, @@ -636,7 +630,7 @@ void DRW_text_edit_mesh_measure_stats(ARegion *region, mul_m4_v3(ob->object_to_world, v1); - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", i); + numstr_len = SNPRINTF_RLEN(numstr, "%d", i); DRW_text_cache_add(dt, v1, numstr, numstr_len, 0, 0, txt_flag, col); } } diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index 4e420ef085a..2510412df0f 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -104,7 +104,7 @@ struct PBVHVbo { { char buf[512]; - BLI_snprintf(buf, sizeof(buf), "%d:%d:%s", int(type), int(domain), name.c_str()); + SNPRINTF(buf, "%d:%d:%s", int(type), int(domain), name.c_str()); key = string(buf); return key; diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc index a2ad86f7651..da023a5940b 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_attributes.cc @@ -157,7 +157,7 @@ static void init_vbo_for_attribute(const MeshRenderData &mr, char attr_name[32], attr_safe_name[GPU_MAX_SAFE_ATTR_NAME]; GPU_vertformat_safe_attr_name(request.attribute_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); /* Attributes use auto-name. */ - BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); + SNPRINTF(attr_name, "a%s", attr_safe_name); GPUVertFormat format = {0}; GPU_vertformat_deinterleave(&format); diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc index ecbb1efb2aa..91dfad3dfb6 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_tan.cc @@ -60,7 +60,7 @@ static void extract_tan_init_common(const MeshRenderData *mr, const char *layer_name = CustomData_get_layer_name(cd_ldata, CD_PROP_FLOAT2, i); GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); /* Tangent layer name. */ - BLI_snprintf(attr_name, sizeof(attr_name), "t%s", attr_safe_name); + SNPRINTF(attr_name, "t%s", attr_safe_name); GPU_vertformat_attr_add(format, attr_name, comp_type, 4, fetch_mode); /* Active render layer name. */ if (i == CustomData_get_render_layer(cd_ldata, CD_PROP_FLOAT2)) { @@ -71,7 +71,7 @@ static void extract_tan_init_common(const MeshRenderData *mr, GPU_vertformat_alias_add(format, "at"); } - BLI_strncpy(r_tangent_names[tan_len++], layer_name, MAX_CUSTOMDATA_LAYER_NAME); + STRNCPY(r_tangent_names[tan_len++], layer_name); } } if (use_orco_tan && orco == nullptr) { diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc index 988ce18f902..9358c0d1e25 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_vbo_uv.cc @@ -45,7 +45,7 @@ static bool mesh_extract_uv_format_init(GPUVertFormat *format, GPU_vertformat_safe_attr_name(layer_name, attr_safe_name, GPU_MAX_SAFE_ATTR_NAME); /* UV layer name. */ - BLI_snprintf(attr_name, sizeof(attr_name), "a%s", attr_safe_name); + SNPRINTF(attr_name, "a%s", attr_safe_name); GPU_vertformat_attr_add(format, attr_name, GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* Active render layer name. */ if (i == CustomData_get_render_layer(cd_ldata, CD_PROP_FLOAT2)) { diff --git a/source/blender/editors/animation/anim_channels_defines.c b/source/blender/editors/animation/anim_channels_defines.c index abcb3883f10..68e7abb048b 100644 --- a/source/blender/editors/animation/anim_channels_defines.c +++ b/source/blender/editors/animation/anim_channels_defines.c @@ -4185,7 +4185,7 @@ void ANIM_channel_debug_print_info(bAnimListElem *ale, short indent_level) acf->name(ale, name); } else { - BLI_strncpy(name, "", sizeof(name)); + STRNCPY(name, ""); } /* print type name + ui name */ diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index 38764873719..5ea2e4b049a 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -1487,7 +1487,7 @@ static void split_groups_action_temp(bAction *act, bActionGroup *tgrp) /* Initialize memory for temp-group */ memset(tgrp, 0, sizeof(bActionGroup)); tgrp->flag |= (AGRP_EXPANDED | AGRP_TEMP); - BLI_strncpy(tgrp->name, "#TempGroup", sizeof(tgrp->name)); + STRNCPY(tgrp->name, "#TempGroup"); /* Move any action-channels not already moved, to the temp group */ if (act->curves.first) { diff --git a/source/blender/editors/animation/anim_ipo_utils.c b/source/blender/editors/animation/anim_ipo_utils.c index 4b35fc4f1fa..0b9d680f237 100644 --- a/source/blender/editors/animation/anim_ipo_utils.c +++ b/source/blender/editors/animation/anim_ipo_utils.c @@ -153,10 +153,10 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu) /* we need to write the index to a temp buffer (in py syntax) */ if (c) { - BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c); + SNPRINTF(arrayindbuf, "%c ", c); } else { - BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index); + SNPRINTF(arrayindbuf, "[%d]", fcu->array_index); } arrayname = &arrayindbuf[0]; diff --git a/source/blender/editors/animation/anim_markers.c b/source/blender/editors/animation/anim_markers.c index 6a1717fe45e..2e4300e8a46 100644 --- a/source/blender/editors/animation/anim_markers.c +++ b/source/blender/editors/animation/anim_markers.c @@ -746,7 +746,7 @@ static int ed_marker_add_exec(bContext *C, wmOperator *UNUSED(op)) marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); marker->flag = SELECT; marker->frame = frame; - BLI_snprintf(marker->name, sizeof(marker->name), "F_%02d", frame); /* XXX: temp code only. */ + SNPRINTF(marker->name, "F_%02d", frame); /* XXX: temp code only. */ BLI_addtail(markers, marker); WM_event_add_notifier(C, NC_SCENE | ND_MARKERS, NULL); @@ -843,24 +843,23 @@ static void ed_marker_move_update_header(bContext *C, wmOperator *op) outputNumInput(&mm->num, str_ofs, &scene->unit); } else if (use_time) { - BLI_snprintf(str_ofs, sizeof(str_ofs), "%.2f", FRA2TIME(ofs)); + SNPRINTF(str_ofs, "%.2f", FRA2TIME(ofs)); } else { - BLI_snprintf(str_ofs, sizeof(str_ofs), "%d", ofs); + SNPRINTF(str_ofs, "%d", ofs); } if (totmark == 1 && selmarker) { /* we print current marker value */ if (use_time) { - BLI_snprintf( - str, sizeof(str), TIP_("Marker %.2f offset %s"), FRA2TIME(selmarker->frame), str_ofs); + SNPRINTF(str, TIP_("Marker %.2f offset %s"), FRA2TIME(selmarker->frame), str_ofs); } else { - BLI_snprintf(str, sizeof(str), TIP_("Marker %d offset %s"), selmarker->frame, str_ofs); + SNPRINTF(str, TIP_("Marker %d offset %s"), selmarker->frame, str_ofs); } } else { - BLI_snprintf(str, sizeof(str), TIP_("Marker offset %s"), str_ofs); + SNPRINTF(str, TIP_("Marker offset %s"), str_ofs); } ED_area_status_text(CTX_wm_area(C), str); @@ -1174,7 +1173,7 @@ static void ed_marker_duplicate_apply(bContext *C) newmarker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); newmarker->flag = SELECT; newmarker->frame = marker->frame; - BLI_strncpy(newmarker->name, marker->name, sizeof(marker->name)); + STRNCPY(newmarker->name, marker->name); #ifdef DURIAN_CAMERA_SWITCH newmarker->camera = marker->camera; diff --git a/source/blender/editors/animation/drivers.c b/source/blender/editors/animation/drivers.c index 006253bf049..fe0e90e90b8 100644 --- a/source/blender/editors/animation/drivers.c +++ b/source/blender/editors/animation/drivers.c @@ -178,7 +178,7 @@ static int add_driver_with_target(ReportList *UNUSED(reports), /* Rotation Destination: normal -> radians, so convert src to radians * (However, if both input and output is a rotation, don't apply such corrections) */ - BLI_strncpy(driver->expression, "radians(var)", sizeof(driver->expression)); + STRNCPY(driver->expression, "radians(var)"); } else if ((RNA_property_unit(src_prop) == PROP_UNIT_ROTATION) && (RNA_property_unit(dst_prop) != PROP_UNIT_ROTATION)) @@ -186,11 +186,11 @@ static int add_driver_with_target(ReportList *UNUSED(reports), /* Rotation Source: radians -> normal, so convert src to degrees * (However, if both input and output is a rotation, don't apply such corrections) */ - BLI_strncpy(driver->expression, "degrees(var)", sizeof(driver->expression)); + STRNCPY(driver->expression, "degrees(var)"); } else { /* Just a normal property without any unit problems */ - BLI_strncpy(driver->expression, "var", sizeof(driver->expression)); + STRNCPY(driver->expression, "var"); } /* Create a driver variable for the target @@ -815,7 +815,7 @@ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const ch /* Set the variable name. */ if (var_name) { - BLI_strncpy(var->name, var_name, sizeof(var->name)); + STRNCPY(var->name, var_name); /* Sanitize the name. */ for (int i = 0; var->name[i]; i++) { @@ -825,7 +825,7 @@ void ANIM_copy_as_driver(struct ID *target_id, const char *target_path, const ch } } - BLI_strncpy(driver->expression, var->name, sizeof(driver->expression)); + STRNCPY(driver->expression, var->name); /* Store the driver into the copy/paste buffers. */ channeldriver_copypaste_buf = fcu; diff --git a/source/blender/editors/animation/fmodifier_ui.c b/source/blender/editors/animation/fmodifier_ui.c index 175bce8266f..de09b1baa67 100644 --- a/source/blender/editors/animation/fmodifier_ui.c +++ b/source/blender/editors/animation/fmodifier_ui.c @@ -162,9 +162,9 @@ static PanelType *fmodifier_panel_register(ARegionType *region_type, /* Intentionally leave the label field blank. The header is filled with buttons. */ const FModifierTypeInfo *fmi = get_fmodifier_typeinfo(type); - BLI_snprintf(panel_type->idname, BKE_ST_MAXNAME, "%s_PT_%s", id_prefix, fmi->name); - BLI_strncpy(panel_type->category, "Modifiers", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); + SNPRINTF(panel_type->idname, "%s_PT_%s", id_prefix, fmi->name); + STRNCPY(panel_type->category, "Modifiers"); + STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); panel_type->draw_header = fmodifier_panel_header; panel_type->draw = draw; @@ -198,10 +198,10 @@ static PanelType *fmodifier_subpanel_register(ARegionType *region_type, { PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); - BLI_snprintf(panel_type->idname, BKE_ST_MAXNAME, "%s_%s", parent->idname, name); - BLI_strncpy(panel_type->label, label, BKE_ST_MAXNAME); - BLI_strncpy(panel_type->category, "Modifiers", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); + SNPRINTF(panel_type->idname, "%s_%s", parent->idname, name); + STRNCPY(panel_type->label, label); + STRNCPY(panel_type->category, "Modifiers"); + STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); panel_type->draw_header = draw_header; panel_type->draw = draw; @@ -209,7 +209,7 @@ static PanelType *fmodifier_subpanel_register(ARegionType *region_type, panel_type->flag = PANEL_TYPE_DEFAULT_CLOSED; BLI_assert(parent != NULL); - BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME); + STRNCPY(panel_type->parent_id, parent->idname); panel_type->parent = parent; BLI_addtail(&parent->children, BLI_genericNodeN(panel_type)); BLI_addtail(®ion_type->paneltypes, panel_type); @@ -380,11 +380,11 @@ static void generator_panel_draw(const bContext *C, Panel *panel) char xval[32]; /* The first value gets a "Coefficient" label. */ - BLI_strncpy(xval, N_("Coefficient"), sizeof(xval)); + STRNCPY(xval, N_("Coefficient")); for (int i = 0; i < data->arraysize; i++) { uiItemFullR(col, ptr, prop, i, 0, 0, IFACE_(xval), ICON_NONE); - BLI_snprintf(xval, sizeof(xval), "x^%d", i + 1); + SNPRINTF(xval, "x^%d", i + 1); } break; } diff --git a/source/blender/editors/animation/keyframing.c b/source/blender/editors/animation/keyframing.c index 9f2c11ff33d..8411d778a78 100644 --- a/source/blender/editors/animation/keyframing.c +++ b/source/blender/editors/animation/keyframing.c @@ -139,7 +139,7 @@ bAction *ED_id_action_ensure(Main *bmain, ID *id) if (adt->action == NULL) { /* init action name from name of ID block */ char actname[sizeof(id->name) - 2]; - BLI_snprintf(actname, sizeof(actname), "%sAction", id->name + 2); + SNPRINTF(actname, "%sAction", id->name + 2); /* create action */ adt->action = BKE_action_add(bmain, actname); diff --git a/source/blender/editors/animation/keyingsets.c b/source/blender/editors/animation/keyingsets.c index a106ecb84e9..e9829984fc3 100644 --- a/source/blender/editors/animation/keyingsets.c +++ b/source/blender/editors/animation/keyingsets.c @@ -577,7 +577,7 @@ void ANIM_keyingset_info_register(KeyingSetInfo *ksi) memcpy(&ks->typeinfo, ksi->idname, sizeof(ks->typeinfo)); /* Copy description... */ - BLI_strncpy(ks->description, ksi->description, sizeof(ks->description)); + STRNCPY(ks->description, ksi->description); /* add type-info to the list */ BLI_addtail(&keyingset_type_infos, ksi); diff --git a/source/blender/editors/armature/armature_add.c b/source/blender/editors/armature/armature_add.c index 812d6e6d3f2..0436ee7a442 100644 --- a/source/blender/editors/armature/armature_add.c +++ b/source/blender/editors/armature/armature_add.c @@ -52,7 +52,7 @@ EditBone *ED_armature_ebone_add(bArmature *arm, const char *name) { EditBone *bone = MEM_callocN(sizeof(EditBone), "eBone"); - BLI_strncpy(bone->name, name, sizeof(bone->name)); + STRNCPY(bone->name, name); ED_armature_ebone_unique_name(arm->edbo, bone->name, NULL); BLI_addtail(arm->edbo, bone); @@ -389,7 +389,7 @@ static void updateDuplicateSubtarget(EditBone *dup_bone, */ if (oldtarget->temp.ebone) { newtarget = oldtarget->temp.ebone; - BLI_strncpy(ct->subtarget, newtarget->name, sizeof(ct->subtarget)); + STRNCPY(ct->subtarget, newtarget->name); } else if (lookup_mirror_subtarget) { /* The subtarget was not selected for duplication, try to see if a mirror bone of @@ -399,7 +399,7 @@ static void updateDuplicateSubtarget(EditBone *dup_bone, BLI_string_flip_side_name(name_flip, oldtarget->name, false, sizeof(name_flip)); newtarget = get_named_editbone(editbones, name_flip); if (newtarget) { - BLI_strncpy(ct->subtarget, newtarget->name, sizeof(ct->subtarget)); + STRNCPY(ct->subtarget, newtarget->name); } } } @@ -910,7 +910,7 @@ EditBone *duplicateEditBoneObjects( e_bone->temp.ebone = cur_bone; if (name != NULL) { - BLI_strncpy(e_bone->name, name, sizeof(e_bone->name)); + STRNCPY(e_bone->name, name); } ED_armature_ebone_unique_name(editbones, e_bone->name, NULL); @@ -1487,7 +1487,7 @@ static int armature_extrude_exec(bContext *C, wmOperator *op) copy_v3_v3(newbone->scale_in, ebone->scale_in); copy_v3_v3(newbone->scale_out, ebone->scale_out); - BLI_strncpy(newbone->name, ebone->name, sizeof(newbone->name)); + STRNCPY(newbone->name, ebone->name); if (flipbone && forked_iter) { /* only set if mirror edit */ if (strlen(newbone->name) < (MAXBONENAME - 2)) { diff --git a/source/blender/editors/armature/armature_naming.c b/source/blender/editors/armature/armature_naming.c index 730ad990635..2a8fc752d60 100644 --- a/source/blender/editors/armature/armature_naming.c +++ b/source/blender/editors/armature/armature_naming.c @@ -117,7 +117,7 @@ static void constraint_bone_name_fix(Object *ob, for (ct = targets.first; ct; ct = ct->next) { if (ct->tar == ob) { if (STREQ(ct->subtarget, oldname)) { - BLI_strncpy(ct->subtarget, newname, MAXBONENAME); + STRNCPY(ct->subtarget, newname); } } } @@ -146,9 +146,9 @@ void ED_armature_bone_rename(Main *bmain, if (!STREQLEN(oldnamep, newnamep, MAXBONENAME)) { /* we alter newname string... so make copy */ - BLI_strncpy(newname, newnamep, MAXBONENAME); + STRNCPY(newname, newnamep); /* we use oldname for search... so make copy */ - BLI_strncpy(oldname, oldnamep, MAXBONENAME); + STRNCPY(oldname, oldnamep); /* now check if we're in editmode, we need to find the unique name */ if (arm->edbo) { @@ -156,7 +156,7 @@ void ED_armature_bone_rename(Main *bmain, if (eBone) { ED_armature_ebone_unique_name(arm->edbo, newname, NULL); - BLI_strncpy(eBone->name, newname, MAXBONENAME); + STRNCPY(eBone->name, newname); } else { return; @@ -173,7 +173,7 @@ void ED_armature_bone_rename(Main *bmain, BLI_ghash_remove(arm->bonehash, bone->name, NULL, NULL); } - BLI_strncpy(bone->name, newname, MAXBONENAME); + STRNCPY(bone->name, newname); if (arm->bonehash) { BLI_ghash_insert(arm->bonehash, bone->name, bone); @@ -207,7 +207,7 @@ void ED_armature_bone_rename(Main *bmain, BLI_ghash_remove(gh, pchan->name, NULL, NULL); } - BLI_strncpy(pchan->name, newname, MAXBONENAME); + STRNCPY(pchan->name, newname); if (gh) { BLI_ghash_insert(gh, pchan->name, pchan); @@ -236,7 +236,7 @@ void ED_armature_bone_rename(Main *bmain, if (ob->partype == PARBONE) { /* bone name in object */ if (STREQ(ob->parsubstr, oldname)) { - BLI_strncpy(ob->parsubstr, newname, MAXBONENAME); + STRNCPY(ob->parsubstr, newname); } } } @@ -244,7 +244,7 @@ void ED_armature_bone_rename(Main *bmain, if (BKE_modifiers_uses_armature(ob, arm) && BKE_object_supports_vertex_groups(ob)) { bDeformGroup *dg = BKE_object_defgroup_find_name(ob, oldname); if (dg) { - BLI_strncpy(dg->name, newname, MAXBONENAME); + STRNCPY(dg->name, newname); DEG_id_tag_update(ob->data, ID_RECALC_GEOMETRY); } } @@ -257,7 +257,7 @@ void ED_armature_bone_rename(Main *bmain, if (hmd->object && (hmd->object->data == arm)) { if (STREQ(hmd->subtarget, oldname)) { - BLI_strncpy(hmd->subtarget, newname, MAXBONENAME); + STRNCPY(hmd->subtarget, newname); } } break; @@ -267,12 +267,12 @@ void ED_armature_bone_rename(Main *bmain, if (umd->object_src && (umd->object_src->data == arm)) { if (STREQ(umd->bone_src, oldname)) { - BLI_strncpy(umd->bone_src, newname, MAXBONENAME); + STRNCPY(umd->bone_src, newname); } } if (umd->object_dst && (umd->object_dst->data == arm)) { if (STREQ(umd->bone_dst, oldname)) { - BLI_strncpy(umd->bone_dst, newname, MAXBONENAME); + STRNCPY(umd->bone_dst, newname); } } break; @@ -287,7 +287,7 @@ void ED_armature_bone_rename(Main *bmain, Camera *cam = (Camera *)ob->data; if ((cam->dof.focus_object != NULL) && (cam->dof.focus_object->data == arm)) { if (STREQ(cam->dof.focus_subtarget, oldname)) { - BLI_strncpy(cam->dof.focus_subtarget, newname, MAXBONENAME); + STRNCPY(cam->dof.focus_subtarget, newname); DEG_id_tag_update(&cam->id, ID_RECALC_COPY_ON_WRITE); } } @@ -300,7 +300,7 @@ void ED_armature_bone_rename(Main *bmain, LISTBASE_FOREACH (bGPDlayer *, gpl, &gpd->layers) { if ((gpl->parent != NULL) && (gpl->parent->data == arm)) { if (STREQ(gpl->parsubstr, oldname)) { - BLI_strncpy(gpl->parsubstr, newname, MAXBONENAME); + STRNCPY(gpl->parsubstr, newname); } } } @@ -312,7 +312,7 @@ void ED_armature_bone_rename(Main *bmain, if (mmd->object && mmd->object->data == arm) { bDeformGroup *dg = BKE_object_defgroup_find_name(ob, oldname); if (dg) { - BLI_strncpy(dg->name, newname, MAXBONENAME); + STRNCPY(dg->name, newname); DEG_id_tag_update(ob->data, ID_RECALC_GEOMETRY); } } @@ -322,7 +322,7 @@ void ED_armature_bone_rename(Main *bmain, HookGpencilModifierData *hgp_md = (HookGpencilModifierData *)gp_md; if (hgp_md->object && (hgp_md->object->data == arm)) { if (STREQ(hgp_md->subtarget, oldname)) { - BLI_strncpy(hgp_md->subtarget, newname, MAXBONENAME); + STRNCPY(hgp_md->subtarget, newname); } } break; @@ -359,7 +359,7 @@ void ED_armature_bone_rename(Main *bmain, View3D *v3d = (View3D *)sl; if (v3d->ob_center && v3d->ob_center->data == arm) { if (STREQ(v3d->ob_center_bone, oldname)) { - BLI_strncpy(v3d->ob_center_bone, newname, MAXBONENAME); + STRNCPY(v3d->ob_center_bone, newname); } } } @@ -406,7 +406,7 @@ void ED_armature_bones_flip_names(Main *bmain, if (!STREQ(name, name_flip)) { bfn = alloca(sizeof(BoneFlipNameData)); bfn->name = name; - BLI_strncpy(bfn->name_flip, name_flip, sizeof(bfn->name_flip)); + STRNCPY(bfn->name_flip, name_flip); BLI_addtail(&bones_names_conflicts, bfn); } } @@ -545,7 +545,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op) if (arm->flag & ARM_MIRROR_EDIT) { EditBone *flipbone = ED_armature_ebone_get_mirrored(arm->edbo, ebone); if ((flipbone) && !(flipbone->flag & BONE_SELECTED)) { - BLI_strncpy(newname, flipbone->name, sizeof(newname)); + STRNCPY(newname, flipbone->name); if (bone_autoside_name(newname, 1, axis, flipbone->head[axis], flipbone->tail[axis])) { ED_armature_bone_rename(bmain, arm, flipbone->name, newname); changed = true; @@ -553,7 +553,7 @@ static int armature_autoside_names_exec(bContext *C, wmOperator *op) } } - BLI_strncpy(newname, ebone->name, sizeof(newname)); + STRNCPY(newname, ebone->name); if (bone_autoside_name(newname, 1, axis, ebone->head[axis], ebone->tail[axis])) { ED_armature_bone_rename(bmain, arm, ebone->name, newname); changed = true; diff --git a/source/blender/editors/armature/armature_relations.c b/source/blender/editors/armature/armature_relations.c index fccf2964868..4b70398ed22 100644 --- a/source/blender/editors/armature/armature_relations.c +++ b/source/blender/editors/armature/armature_relations.c @@ -81,7 +81,7 @@ static void joined_armature_fix_links_constraints(Main *bmain, } else if (STREQ(ct->subtarget, pchan->name)) { ct->tar = tarArm; - BLI_strncpy(ct->subtarget, curbone->name, sizeof(ct->subtarget)); + STRNCPY(ct->subtarget, curbone->name); changed = true; } } @@ -193,7 +193,7 @@ static void joined_armature_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data } if (STREQ(dtar->pchan_name, old_name)) { /* Change target bone name */ - BLI_strncpy(dtar->pchan_name, new_name, sizeof(dtar->pchan_name)); + STRNCPY(dtar->pchan_name, new_name); break; /* no need to try any more names for bone subtarget */ } } @@ -241,7 +241,7 @@ static void joined_armature_fix_links( if (ob->partype == PARBONE) { /* bone name in object */ if (STREQ(ob->parsubstr, pchan->name)) { - BLI_strncpy(ob->parsubstr, curbone->name, sizeof(ob->parsubstr)); + STRNCPY(ob->parsubstr, curbone->name); } } @@ -364,7 +364,7 @@ int ED_armature_join_objects_exec(bContext *C, wmOperator *op) joined_armature_fix_links(bmain, ob_active, ob_iter, pchan, curbone); /* Rename pchan */ - BLI_strncpy(pchan->name, curbone->name, sizeof(pchan->name)); + STRNCPY(pchan->name, curbone->name); /* Jump Ship! */ BLI_remlink(curarm->edbo, curbone); diff --git a/source/blender/editors/armature/armature_utils.c b/source/blender/editors/armature/armature_utils.c index 26ac342b707..97a08f381e7 100644 --- a/source/blender/editors/armature/armature_utils.c +++ b/source/blender/editors/armature/armature_utils.c @@ -466,7 +466,7 @@ static EditBone *make_boneList_recursive(ListBase *edbo, * Keep selection logic in sync with ED_armature_edit_sync_selection. */ eBone->parent = parent; - BLI_strncpy(eBone->name, curBone->name, sizeof(eBone->name)); + STRNCPY(eBone->name, curBone->name); eBone->flag = curBone->flag; eBone->inherit_scale_mode = curBone->inherit_scale_mode; @@ -694,7 +694,7 @@ void ED_armature_from_edit(Main *bmain, bArmature *arm) newBone = MEM_callocN(sizeof(Bone), "bone"); eBone->temp.bone = newBone; /* Associate the real Bones with the EditBones */ - BLI_strncpy(newBone->name, eBone->name, sizeof(newBone->name)); + STRNCPY(newBone->name, eBone->name); copy_v3_v3(newBone->arm_head, eBone->head); copy_v3_v3(newBone->arm_tail, eBone->tail); newBone->arm_roll = eBone->roll; diff --git a/source/blender/editors/armature/meshlaplacian.cc b/source/blender/editors/armature/meshlaplacian.cc index b5d0dee887c..ac4fbbca662 100644 --- a/source/blender/editors/armature/meshlaplacian.cc +++ b/source/blender/editors/armature/meshlaplacian.cc @@ -1553,11 +1553,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind break; } - BLI_snprintf(message, - sizeof(message), - "Mesh deform solve %d / %d |||", - a + 1, - mdb->cage_verts_num); + SNPRINTF(message, "Mesh deform solve %d / %d |||", a + 1, mdb->cage_verts_num); progress_bar(float(a + 1) / float(mdb->cage_verts_num), message); } diff --git a/source/blender/editors/armature/pose_edit.c b/source/blender/editors/armature/pose_edit.c index 0dc6f3e609a..e3fe0416ca4 100644 --- a/source/blender/editors/armature/pose_edit.c +++ b/source/blender/editors/armature/pose_edit.c @@ -568,7 +568,7 @@ static int pose_autoside_names_exec(bContext *C, wmOperator *op) /* loop through selected bones, auto-naming them */ CTX_DATA_BEGIN_WITH_ID (C, bPoseChannel *, pchan, selected_pose_bones, Object *, ob) { bArmature *arm = ob->data; - BLI_strncpy(newname, pchan->name, sizeof(newname)); + STRNCPY(newname, pchan->name); if (bone_autoside_name(newname, 1, axis, pchan->bone->head[axis], pchan->bone->tail[axis])) { ED_armature_bone_rename(bmain, arm, pchan->name, newname); } diff --git a/source/blender/editors/armature/pose_lib_2.c b/source/blender/editors/armature/pose_lib_2.c index 6e9cc1a06ee..b309020e460 100644 --- a/source/blender/editors/armature/pose_lib_2.c +++ b/source/blender/editors/armature/pose_lib_2.c @@ -501,11 +501,7 @@ static int poselib_blend_modal(bContext *C, wmOperator *op, const wmEvent *event strcpy(tab_string, TIP_("[Tab] - Show blended pose")); } - BLI_snprintf(status_string, - sizeof(status_string), - "%s | %s | [Ctrl] - Flip Pose", - tab_string, - slider_string); + SNPRINTF(status_string, "%s | %s | [Ctrl] - Flip Pose", tab_string, slider_string); ED_workspace_status_text(C, status_string); poselib_blend_apply(C, op); diff --git a/source/blender/editors/armature/pose_slide.c b/source/blender/editors/armature/pose_slide.c index aa3fb9184c2..13b3c04b530 100644 --- a/source/blender/editors/armature/pose_slide.c +++ b/source/blender/editors/armature/pose_slide.c @@ -981,22 +981,13 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso) switch (pso->channels) { case PS_TFM_LOC: - BLI_snprintf(limits_str, - sizeof(limits_str), - TIP_("[G]/R/S/B/C - Location only (G to clear) | %s"), - axis_str); + SNPRINTF(limits_str, TIP_("[G]/R/S/B/C - Location only (G to clear) | %s"), axis_str); break; case PS_TFM_ROT: - BLI_snprintf(limits_str, - sizeof(limits_str), - TIP_("G/[R]/S/B/C - Rotation only (R to clear) | %s"), - axis_str); + SNPRINTF(limits_str, TIP_("G/[R]/S/B/C - Rotation only (R to clear) | %s"), axis_str); break; case PS_TFM_SIZE: - BLI_snprintf(limits_str, - sizeof(limits_str), - TIP_("G/R/[S]/B/C - Scale only (S to clear) | %s"), - axis_str); + SNPRINTF(limits_str, TIP_("G/R/[S]/B/C - Scale only (S to clear) | %s"), axis_str); break; case PS_TFM_BBONE_SHAPE: STRNCPY(limits_str, TIP_("G/R/S/[B]/C - Bendy Bone properties only (B to clear) | %s")); @@ -1019,16 +1010,10 @@ static void pose_slide_draw_status(bContext *C, tPoseSlideOp *pso) outputNumInput(&pso->num, str_offs, &scene->unit); - BLI_snprintf(status_str, sizeof(status_str), "%s: %s | %s", mode_str, str_offs, limits_str); + SNPRINTF(status_str, "%s: %s | %s", mode_str, str_offs, limits_str); } else { - BLI_snprintf(status_str, - sizeof(status_str), - "%s: %s | %s | %s", - mode_str, - limits_str, - slider_str, - bone_vis_str); + SNPRINTF(status_str, "%s: %s | %s | %s", mode_str, limits_str, slider_str, bone_vis_str); } ED_workspace_status_text(C, status_str); diff --git a/source/blender/editors/armature/pose_transform.c b/source/blender/editors/armature/pose_transform.c index 6466ecc6dac..ae6e31098d7 100644 --- a/source/blender/editors/armature/pose_transform.c +++ b/source/blender/editors/armature/pose_transform.c @@ -617,7 +617,7 @@ static bPoseChannel *pose_bone_do_paste(Object *ob, BLI_string_flip_side_name(name, chan->name, false, sizeof(name)); } else { - BLI_strncpy(name, chan->name, sizeof(name)); + STRNCPY(name, chan->name); } /* only copy when: @@ -1360,7 +1360,7 @@ static int pose_clear_user_transforms_exec(bContext *C, wmOperator *op) /* execute animation step for current frame using a dummy copy of the pose */ BKE_pose_copy_data(&dummyPose, ob->pose, 0); - BLI_strncpy(workob.id.name, "OB", sizeof(workob.id.name)); + STRNCPY(workob.id.name, "OB"); workob.type = OB_ARMATURE; workob.data = ob->data; workob.adt = ob->adt; diff --git a/source/blender/editors/asset/intern/asset_indexer.cc b/source/blender/editors/asset/intern/asset_indexer.cc index bc5799f8162..80d25285f8b 100644 --- a/source/blender/editors/asset/intern/asset_indexer.cc +++ b/source/blender/editors/asset/intern/asset_indexer.cc @@ -388,8 +388,7 @@ static void init_indexer_entry_from_value(FileIndexerEntry &indexer_entry, indexer_entry.idcode = entry.get_idcode(); const std::string name = entry.get_name(); - BLI_strncpy( - indexer_entry.datablock_info.name, name.c_str(), sizeof(indexer_entry.datablock_info.name)); + STRNCPY(indexer_entry.datablock_info.name, name.c_str()); AssetMetaData *asset_data = BKE_asset_metadata_create(); indexer_entry.datablock_info.asset_data = asset_data; @@ -421,9 +420,7 @@ static void init_indexer_entry_from_value(FileIndexerEntry &indexer_entry, } const StringRefNull catalog_name = entry.get_catalog_name(); - BLI_strncpy(asset_data->catalog_simple_name, - catalog_name.c_str(), - sizeof(asset_data->catalog_simple_name)); + STRNCPY(asset_data->catalog_simple_name, catalog_name.c_str()); asset_data->catalog_id = entry.get_catalog_id(); diff --git a/source/blender/editors/asset/intern/asset_list.cc b/source/blender/editors/asset/intern/asset_list.cc index f21dae321d6..401a0b5382f 100644 --- a/source/blender/editors/asset/intern/asset_list.cc +++ b/source/blender/editors/asset/intern/asset_list.cc @@ -155,7 +155,7 @@ void AssetList::setup() char path[FILE_MAXDIR] = ""; if (!asset_lib_path.empty()) { - BLI_strncpy(path, asset_lib_path.c_str(), sizeof(path)); + STRNCPY(path, asset_lib_path.c_str()); } filelist_setdir(files, path); } diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 6da8a8c4bf0..97c3a75ec74 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -953,23 +953,20 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) while (a--) { keyIndex = getCVKeyIndex(editnurb, bezt); if (keyIndex) { - BLI_snprintf( - rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index); - BLI_snprintf(orig_rna_path, - sizeof(orig_rna_path), - "splines[%d].bezier_points[%d]", - keyIndex->nu_index, - keyIndex->pt_index); + SNPRINTF(rna_path, "splines[%d].bezier_points[%d]", nu_index, pt_index); + SNPRINTF(orig_rna_path, + "splines[%d].bezier_points[%d]", + keyIndex->nu_index, + keyIndex->pt_index); if (keyIndex->switched) { char handle_path[64], orig_handle_path[64]; - BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_left", orig_rna_path); - BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_right", rna_path); + SNPRINTF(orig_handle_path, "%s.handle_left", orig_rna_path); + SNPRINTF(handle_path, "%s.handle_right", rna_path); fcurve_path_rename(adt, orig_handle_path, handle_path, orig_curves, &curves); - BLI_snprintf( - orig_handle_path, sizeof(orig_rna_path), "%s.handle_right", orig_rna_path); - BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_left", rna_path); + SNPRINTF(orig_handle_path, "%s.handle_right", orig_rna_path); + SNPRINTF(handle_path, "%s.handle_left", rna_path); fcurve_path_rename(adt, orig_handle_path, handle_path, orig_curves, &curves); } @@ -991,12 +988,9 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) while (a--) { keyIndex = getCVKeyIndex(editnurb, bp); if (keyIndex) { - BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index); - BLI_snprintf(orig_rna_path, - sizeof(orig_rna_path), - "splines[%d].points[%d]", - keyIndex->nu_index, - keyIndex->pt_index); + SNPRINTF(rna_path, "splines[%d].points[%d]", nu_index, pt_index); + SNPRINTF( + orig_rna_path, "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index); fcurve_path_rename(adt, orig_rna_path, rna_path, orig_curves, &curves); keyIndex->nu_index = nu_index; @@ -1035,8 +1029,8 @@ static void curve_rename_fcurves(Curve *cu, ListBase *orig_curves) } if (keyIndex) { - BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d]", nu_index); - BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index); + SNPRINTF(rna_path, "splines[%d]", nu_index); + SNPRINTF(orig_rna_path, "splines[%d]", keyIndex->nu_index); fcurve_path_rename(adt, orig_rna_path, rna_path, orig_curves, &curves); } } diff --git a/source/blender/editors/gpencil_legacy/editaction_gpencil.c b/source/blender/editors/gpencil_legacy/editaction_gpencil.c index 3795b439030..59ca280daf6 100644 --- a/source/blender/editors/gpencil_legacy/editaction_gpencil.c +++ b/source/blender/editors/gpencil_legacy/editaction_gpencil.c @@ -366,7 +366,7 @@ bool ED_gpencil_anim_copybuf_copy(bAnimContext *ac) BLI_assert(copied_frames.first == NULL); /* make a copy of the layer's name - for name-based matching later... */ - BLI_strncpy(new_layer->info, gpl->info, sizeof(new_layer->info)); + STRNCPY(new_layer->info, gpl->info); } } diff --git a/source/blender/editors/gpencil_legacy/gpencil_edit.c b/source/blender/editors/gpencil_legacy/gpencil_edit.c index 545c4973d86..302345e25ce 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_edit.c +++ b/source/blender/editors/gpencil_legacy/gpencil_edit.c @@ -873,7 +873,7 @@ static void gpencil_duplicate_points(bGPdata *gpd, gpsd = BKE_gpencil_stroke_duplicate((bGPDstroke *)gps, false, true); /* saves original layer name */ - BLI_strncpy(gpsd->runtime.tmp_layerinfo, layername, sizeof(gpsd->runtime.tmp_layerinfo)); + STRNCPY(gpsd->runtime.tmp_layerinfo, layername); /* now, make a new points array, and copy of the relevant parts */ gpsd->points = MEM_mallocN(sizeof(bGPDspoint) * len, "gps stroke points copy"); @@ -951,8 +951,7 @@ static int gpencil_duplicate_exec(bContext *C, wmOperator *op) /* make direct copies of the stroke and its points */ gpsd = BKE_gpencil_stroke_duplicate(gps, true, true); - BLI_strncpy( - gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo)); + STRNCPY(gpsd->runtime.tmp_layerinfo, gpl->info); /* Initialize triangle information. */ BKE_gpencil_stroke_geometry_update(gpd, gpsd); @@ -1522,8 +1521,7 @@ static int gpencil_strokes_copy_exec(bContext *C, wmOperator *op) gpsd = BKE_gpencil_stroke_duplicate(gps, false, true); /* saves original layer name */ - BLI_strncpy( - gpsd->runtime.tmp_layerinfo, gpl->info, sizeof(gpsd->runtime.tmp_layerinfo)); + STRNCPY(gpsd->runtime.tmp_layerinfo, gpl->info); gpsd->points = MEM_dupallocN(gps->points); if (gps->dvert != NULL) { gpsd->dvert = MEM_dupallocN(gps->dvert); diff --git a/source/blender/editors/gpencil_legacy/gpencil_fill.c b/source/blender/editors/gpencil_legacy/gpencil_fill.c index 1e072f9362a..3e73f0ebc36 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_fill.c +++ b/source/blender/editors/gpencil_legacy/gpencil_fill.c @@ -2291,14 +2291,13 @@ static void gpencil_fill_status_indicators(tGPDfill *tgpf) const bool use_stroke_collide = (tgpf->flag & GP_BRUSH_FILL_STROKE_COLLIDE) != 0; char status_str[UI_MAX_DRAW_STR]; - BLI_snprintf(status_str, - sizeof(status_str), - TIP_("Fill: ESC/RMB cancel, LMB Fill, Shift Draw on Back, MMB Adjust Extend, S: " - "Switch Mode, D: " - "Stroke Collision | %s %s (%.3f)"), - (is_extend) ? TIP_("Extend") : TIP_("Radius"), - (is_extend && use_stroke_collide) ? TIP_("Stroke: ON") : TIP_("Stroke: OFF"), - tgpf->fill_extend_fac); + SNPRINTF(status_str, + TIP_("Fill: ESC/RMB cancel, LMB Fill, Shift Draw on Back, MMB Adjust Extend, S: " + "Switch Mode, D: " + "Stroke Collision | %s %s (%.3f)"), + (is_extend) ? TIP_("Extend") : TIP_("Radius"), + (is_extend && use_stroke_collide) ? TIP_("Stroke: ON") : TIP_("Stroke: OFF"), + tgpf->fill_extend_fac); ED_workspace_status_text(tgpf->C, status_str); } diff --git a/source/blender/editors/gpencil_legacy/gpencil_interpolate.c b/source/blender/editors/gpencil_legacy/gpencil_interpolate.c index 5386bcb74ea..8145fd01088 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_interpolate.c +++ b/source/blender/editors/gpencil_legacy/gpencil_interpolate.c @@ -595,20 +595,16 @@ static void gpencil_interpolate_status_indicators(bContext *C, tGPDinterpolate * char status_str[UI_MAX_DRAW_STR]; char msg_str[UI_MAX_DRAW_STR]; - BLI_strncpy(msg_str, TIP_("GPencil Interpolation: "), UI_MAX_DRAW_STR); + STRNCPY(msg_str, TIP_("GPencil Interpolation: ")); if (hasNumInput(&p->num)) { char str_ofs[NUM_STR_REP_LEN]; outputNumInput(&p->num, str_ofs, &scene->unit); - BLI_snprintf(status_str, sizeof(status_str), "%s%s", msg_str, str_ofs); + SNPRINTF(status_str, "%s%s", msg_str, str_ofs); } else { - BLI_snprintf(status_str, - sizeof(status_str), - "%s%d %%", - msg_str, - (int)((p->init_factor + p->shift) * 100.0f)); + SNPRINTF(status_str, "%s%d %%", msg_str, (int)((p->init_factor + p->shift) * 100.0f)); } ED_area_status_text(p->area, status_str); diff --git a/source/blender/editors/gpencil_legacy/gpencil_primitive.c b/source/blender/editors/gpencil_legacy/gpencil_primitive.c index cce222cfad9..51f732b2711 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_primitive.c +++ b/source/blender/editors/gpencil_legacy/gpencil_primitive.c @@ -458,50 +458,42 @@ static void gpencil_primitive_status_indicators(bContext *C, tGPDprimitive *tgpi char str_ofs[NUM_STR_REP_LEN]; outputNumInput(&tgpi->num, str_ofs, &scene->unit); - BLI_snprintf(status_str, sizeof(status_str), "%s: %s", msg_str, str_ofs); + SNPRINTF(status_str, "%s: %s", msg_str, str_ofs); } else { if (tgpi->flag == IN_PROGRESS) { - BLI_snprintf(status_str, - sizeof(status_str), - "%s: %d (%d, %d) (%d, %d)", - msg_str, - cur_subdiv, - (int)tgpi->start[0], - (int)tgpi->start[1], - (int)tgpi->end[0], - (int)tgpi->end[1]); + SNPRINTF(status_str, + "%s: %d (%d, %d) (%d, %d)", + msg_str, + cur_subdiv, + (int)tgpi->start[0], + (int)tgpi->start[1], + (int)tgpi->end[0], + (int)tgpi->end[1]); } else { - BLI_snprintf(status_str, - sizeof(status_str), - "%s: %d (%d, %d)", - msg_str, - cur_subdiv, - (int)tgpi->end[0], - (int)tgpi->end[1]); + SNPRINTF(status_str, + "%s: %d (%d, %d)", + msg_str, + cur_subdiv, + (int)tgpi->end[0], + (int)tgpi->end[1]); } } } else { if (tgpi->flag == IN_PROGRESS) { - BLI_snprintf(status_str, - sizeof(status_str), - "%s: %d (%d, %d) (%d, %d)", - msg_str, - cur_subdiv, - (int)tgpi->start[0], - (int)tgpi->start[1], - (int)tgpi->end[0], - (int)tgpi->end[1]); + SNPRINTF(status_str, + "%s: %d (%d, %d) (%d, %d)", + msg_str, + cur_subdiv, + (int)tgpi->start[0], + (int)tgpi->start[1], + (int)tgpi->end[0], + (int)tgpi->end[1]); } else { - BLI_snprintf(status_str, - sizeof(status_str), - "%s: (%d, %d)", - msg_str, - (int)tgpi->end[0], - (int)tgpi->end[1]); + SNPRINTF(status_str, "%s: (%d, %d)", msg_str, (int)tgpi->end[0], (int)tgpi->end[1]); } } ED_workspace_status_text(C, status_str); diff --git a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c index fb17f5158e3..42d2229c93b 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c +++ b/source/blender/editors/gpencil_legacy/gpencil_sculpt_paint.c @@ -1127,12 +1127,11 @@ static void gpencil_sculpt_brush_header_set(bContext *C, tGP_BrushEditData *gso) Brush *brush = gso->brush; char str[UI_MAX_DRAW_STR] = ""; - BLI_snprintf(str, - sizeof(str), - TIP_("GPencil Sculpt: %s Stroke | LMB to paint | RMB/Escape to Exit" - " | Ctrl to Invert Action | Wheel Up/Down for Size " - " | Shift-Wheel Up/Down for Strength"), - brush->id.name + 2); + SNPRINTF(str, + TIP_("GPencil Sculpt: %s Stroke | LMB to paint | RMB/Escape to Exit" + " | Ctrl to Invert Action | Wheel Up/Down for Size " + " | Shift-Wheel Up/Down for Strength"), + brush->id.name + 2); ED_workspace_status_text(C, str); } diff --git a/source/blender/editors/gpencil_legacy/gpencil_uv.c b/source/blender/editors/gpencil_legacy/gpencil_uv.c index c1e4afa295a..c3a89160682 100644 --- a/source/blender/editors/gpencil_legacy/gpencil_uv.c +++ b/source/blender/editors/gpencil_legacy/gpencil_uv.c @@ -105,7 +105,7 @@ static void gpencil_uv_transform_update_header(wmOperator *op, bContext *C) default: break; } - BLI_snprintf(msg, sizeof(msg), str, flts_str, flts_str + NUM_STR_REP_LEN); + SNPRINTF(msg, str, flts_str, flts_str + NUM_STR_REP_LEN); ED_area_status_text(area, msg); } } diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc b/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc index 714538f912b..29f1e518bc6 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_datablock.cc @@ -176,8 +176,7 @@ static void datadropper_id_sample_pt( id = (ID *)ob->data; } else { - BLI_snprintf( - ddr->name, sizeof(ddr->name), "Incompatible, expected a %s", ddr->idcode_name); + SNPRINTF(ddr->name, "Incompatible, expected a %s", ddr->idcode_name); } } @@ -185,7 +184,7 @@ static void datadropper_id_sample_pt( RNA_id_pointer_create(id, &idptr); if (id && RNA_property_pointer_poll(&ddr->ptr, ddr->prop, &idptr)) { - BLI_snprintf(ddr->name, sizeof(ddr->name), "%s: %s", ddr->idcode_name, id->name + 2); + SNPRINTF(ddr->name, "%s: %s", ddr->idcode_name, id->name + 2); *r_id = id; } diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc index 8c52926b27b..e2f5ff5c8a6 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_depth.cc @@ -194,7 +194,7 @@ static void depthdropper_depth_sample_pt(bContext *C, false); } else { - BLI_strncpy(ddr->name, "Nothing under cursor", sizeof(ddr->name)); + STRNCPY(ddr->name, "Nothing under cursor"); } } } diff --git a/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc b/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc index 187902c46ff..b145d622735 100644 --- a/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc +++ b/source/blender/editors/interface/eyedroppers/eyedropper_gpencil_color.cc @@ -66,8 +66,7 @@ struct EyedropperGPencil { static void eyedropper_gpencil_status_indicators(bContext *C) { char msg_str[UI_MAX_DRAW_STR]; - BLI_strncpy( - msg_str, TIP_("LMB: Stroke - Shift: Fill - Shift+Ctrl: Stroke + Fill"), UI_MAX_DRAW_STR); + STRNCPY(msg_str, TIP_("LMB: Stroke - Shift: Fill - Shift+Ctrl: Stroke + Fill")); ED_workspace_status_text(C, msg_str); } diff --git a/source/blender/editors/interface/interface.cc b/source/blender/editors/interface/interface.cc index 54b5b048ecd..ed82b08a629 100644 --- a/source/blender/editors/interface/interface.cc +++ b/source/blender/editors/interface/interface.cc @@ -927,7 +927,7 @@ static void ui_but_update_old_active_from_new(uiBut *oldbut, uiBut *but) MEM_freeN(oldbut->str); oldbut->str = oldbut->strdata; } - BLI_strncpy(oldbut->strdata, but->strdata, sizeof(oldbut->strdata)); + STRNCPY(oldbut->strdata, but->strdata); } if (but->dragpoin) { @@ -1228,8 +1228,7 @@ void ui_but_add_shortcut(uiBut *but, const char *shortcut_str, const bool do_str else { butstr_orig = BLI_strdup(but->str); } - BLI_snprintf( - but->strdata, sizeof(but->strdata), "%s" UI_SEP_CHAR_S "%s", butstr_orig, shortcut_str); + SNPRINTF(but->strdata, "%s" UI_SEP_CHAR_S "%s", butstr_orig, shortcut_str); MEM_freeN(butstr_orig); but->str = but->strdata; but->flag |= UI_BUT_HAS_SEP_CHAR; @@ -3668,7 +3667,7 @@ uiBlock *UI_block_begin(const bContext *C, ARegion *region, const char *name, eU STRNCPY(block->display_device, IMB_colormanagement_display_get_default_name()); } - BLI_strncpy(block->name, name, sizeof(block->name)); + STRNCPY(block->name, name); if (region) { UI_block_region_set(block, region); @@ -3862,7 +3861,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate) } } } - BLI_strncpy(but->drawstr, but->str, sizeof(but->drawstr)); + STRNCPY(but->drawstr, but->str); } break; @@ -3884,10 +3883,10 @@ static void ui_but_update_ex(uiBut *but, const bool validate) if (ui_but_is_float(but)) { UI_GET_BUT_VALUE_INIT(but, value); const int prec = ui_but_calc_float_precision(but, value); - BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%.*f", but->str, prec, value); + SNPRINTF(but->drawstr, "%s%.*f", but->str, prec, value); } else { - BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); + STRNCPY(but->drawstr, but->str); } break; @@ -3898,7 +3897,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate) char str[UI_MAX_DRAW_STR]; ui_but_string_get(but, str, UI_MAX_DRAW_STR); - BLI_snprintf(but->drawstr, sizeof(but->drawstr), "%s%s", but->str, str); + SNPRINTF(but->drawstr, "%s%s", but->str, str); } break; @@ -3911,7 +3910,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate) UI_GET_BUT_VALUE_INIT(but, value); str = WM_key_event_string(short(value), false); } - BLI_snprintf(but->drawstr, UI_MAX_DRAW_STR, "%s%s", but->str, str); + SNPRINTF(but->drawstr, "%s%s", but->str, str); break; } case UI_BTYPE_HOTKEY_EVENT: @@ -3938,11 +3937,11 @@ static void ui_but_update_ex(uiBut *but, const bool validate) (void)str; /* UNUSED */ } else { - BLI_strncpy(but->drawstr, IFACE_("Press a key"), UI_MAX_DRAW_STR); + STRNCPY(but->drawstr, IFACE_("Press a key")); } } else { - BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); + STRNCPY(but->drawstr, but->str); } break; @@ -3951,7 +3950,7 @@ static void ui_but_update_ex(uiBut *but, const bool validate) case UI_BTYPE_HSVCIRCLE: break; default: - BLI_strncpy(but->drawstr, but->str, UI_MAX_DRAW_STR); + STRNCPY(but->drawstr, but->str); break; } diff --git a/source/blender/editors/interface/interface_anim.cc b/source/blender/editors/interface/interface_anim.cc index 4d5d59f3dd8..a406c2b8af0 100644 --- a/source/blender/editors/interface/interface_anim.cc +++ b/source/blender/editors/interface/interface_anim.cc @@ -207,7 +207,7 @@ bool ui_but_anim_expression_set(uiBut *but, const char *str) if (driver && (driver->type == DRIVER_TYPE_PYTHON)) { bContext *C = static_cast(but->block->evil_C); - BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression)); + STRNCPY_UTF8(driver->expression, str); /* tag driver as needing to be recompiled */ BKE_driver_invalidate_expression(driver, true, false); @@ -281,7 +281,7 @@ bool ui_but_anim_expression_create(uiBut *but, const char *str) /* set the expression */ /* TODO: need some way of identifying variables used */ - BLI_strncpy_utf8(driver->expression, str, sizeof(driver->expression)); + STRNCPY_UTF8(driver->expression, str); /* updates */ BKE_driver_invalidate_expression(driver, true, false); diff --git a/source/blender/editors/interface/interface_context_menu.cc b/source/blender/editors/interface/interface_context_menu.cc index c590d66c907..9aadcaf181f 100644 --- a/source/blender/editors/interface/interface_context_menu.cc +++ b/source/blender/editors/interface/interface_context_menu.cc @@ -1309,11 +1309,7 @@ void ui_popup_context_menu_for_panel(bContext *C, ARegion *region, Panel *panel) if (has_panel_category) { char tmpstr[80]; - BLI_snprintf(tmpstr, - sizeof(tmpstr), - "%s" UI_SEP_CHAR_S "%s", - IFACE_("Pin"), - IFACE_("Shift Left Mouse")); + SNPRINTF(tmpstr, "%s" UI_SEP_CHAR_S "%s", IFACE_("Pin"), IFACE_("Shift Left Mouse")); uiItemR(layout, &ptr, "use_pin", 0, tmpstr, ICON_NONE); /* evil, force shortcut flag */ diff --git a/source/blender/editors/interface/interface_draw.cc b/source/blender/editors/interface/interface_draw.cc index 2c74b32e626..11830412b70 100644 --- a/source/blender/editors/interface/interface_draw.cc +++ b/source/blender/editors/interface/interface_draw.cc @@ -610,7 +610,7 @@ void ui_draw_but_WAVEFORM(ARegion * /*region*/, /* draw scale numbers first before binding any shader */ for (int i = 0; i < 6; i++) { char str[4]; - BLI_snprintf(str, sizeof(str), "%-3d", i * 20); + SNPRINTF(str, "%-3d", i * 20); str[3] = '\0'; BLF_color4f(BLF_default(), 1.0f, 1.0f, 1.0f, 0.08f); BLF_draw_default(rect.xmin + 1, yofs - 5 + (i * 0.2f) * h, 0, str, sizeof(str) - 1); diff --git a/source/blender/editors/interface/interface_icons.cc b/source/blender/editors/interface/interface_icons.cc index 0cbf98d614f..f3af18b6bb6 100644 --- a/source/blender/editors/interface/interface_icons.cc +++ b/source/blender/editors/interface/interface_icons.cc @@ -1091,7 +1091,7 @@ static void init_iconfile_list(ListBase *list) /* found a potential icon file, so make an entry for it in the cache list */ IconFile *ifile = MEM_cnew(__func__); - BLI_strncpy(ifile->filename, filename, sizeof(ifile->filename)); + STRNCPY(ifile->filename, filename); ifile->index = index; BLI_addtail(list, ifile); diff --git a/source/blender/editors/interface/interface_layout.cc b/source/blender/editors/interface/interface_layout.cc index 6793af8f740..0fef04280b7 100644 --- a/source/blender/editors/interface/interface_layout.cc +++ b/source/blender/editors/interface/interface_layout.cc @@ -3569,8 +3569,8 @@ void uiItemMenuEnumFullO_ptr(uiLayout *layout, } MenuItemLevel *lvl = MEM_cnew("MenuItemLevel"); - BLI_strncpy(lvl->opname, ot->idname, sizeof(lvl->opname)); - BLI_strncpy(lvl->propname, propname, sizeof(lvl->propname)); + STRNCPY(lvl->opname, ot->idname); + STRNCPY(lvl->propname, propname); lvl->opcontext = layout->root->opcontext; uiBut *but = ui_item_menu( @@ -3648,7 +3648,7 @@ void uiItemMenuEnumR_prop( MenuItemLevel *lvl = MEM_cnew("MenuItemLevel"); lvl->rnapoin = *ptr; - BLI_strncpy(lvl->propname, RNA_property_identifier(prop), sizeof(lvl->propname)); + STRNCPY(lvl->propname, RNA_property_identifier(prop)); lvl->opcontext = layout->root->opcontext; ui_item_menu(layout, diff --git a/source/blender/editors/interface/interface_ops.cc b/source/blender/editors/interface/interface_ops.cc index 96f450b23a2..c364753f864 100644 --- a/source/blender/editors/interface/interface_ops.cc +++ b/source/blender/editors/interface/interface_ops.cc @@ -1722,7 +1722,7 @@ void UI_editsource_active_but_test(uiBut *but) PyC_FileAndNum_Safe(&fn, &line_number); if (line_number != -1) { - BLI_strncpy(but_store->py_dbg_fn, fn, sizeof(but_store->py_dbg_fn)); + STRNCPY(but_store->py_dbg_fn, fn); but_store->py_dbg_line_number = line_number; } else { @@ -1873,7 +1873,7 @@ static void edittranslation_find_po_file(const char *root, char tstr[32]; /* Should be more than enough! */ /* First, full lang code. */ - BLI_snprintf(tstr, sizeof(tstr), "%s.po", uilng); + SNPRINTF(tstr, "%s.po", uilng); BLI_path_join(path, path_maxncpy, root, uilng, tstr); if (BLI_is_file(path)) { return; diff --git a/source/blender/editors/interface/interface_panel.cc b/source/blender/editors/interface/interface_panel.cc index f5948afa4b0..764854da930 100644 --- a/source/blender/editors/interface/interface_panel.cc +++ b/source/blender/editors/interface/interface_panel.cc @@ -227,7 +227,7 @@ static Panel *panel_add_instanced(ARegion *region, { Panel *panel = MEM_cnew(__func__); panel->type = panel_type; - BLI_strncpy(panel->panelname, panel_type->idname, sizeof(panel->panelname)); + STRNCPY(panel->panelname, panel_type->idname); panel->runtime.custom_data_ptr = custom_data; panel->runtime_flag |= PANEL_NEW_ADDED; @@ -674,7 +674,7 @@ Panel *UI_panel_begin( if (newpanel) { panel = MEM_cnew(__func__); panel->type = pt; - BLI_strncpy(panel->panelname, idname, sizeof(panel->panelname)); + STRNCPY(panel->panelname, idname); if (pt->flag & PANEL_TYPE_DEFAULT_CLOSED) { panel->flag |= PNL_CLOSED; @@ -698,7 +698,7 @@ Panel *UI_panel_begin( panel->runtime.block = block; - BLI_strncpy(panel->drawname, drawname, sizeof(panel->drawname)); + STRNCPY(panel->drawname, drawname); /* If a new panel is added, we insert it right after the panel that was last added. * This way new panels are inserted in the right place between versions. */ @@ -2149,7 +2149,7 @@ static void ui_panel_category_active_set(ARegion *region, const char *idname, bo } else { pc_act = MEM_cnew(__func__); - BLI_strncpy(pc_act->idname, idname, sizeof(pc_act->idname)); + STRNCPY(pc_act->idname, idname); } if (fallback) { @@ -2225,7 +2225,7 @@ void UI_panel_category_add(ARegion *region, const char *name) PanelCategoryDyn *pc_dyn = MEM_cnew(__func__); BLI_addtail(®ion->panels_category, pc_dyn); - BLI_strncpy(pc_dyn->idname, name, sizeof(pc_dyn->idname)); + STRNCPY(pc_dyn->idname, name); /* 'pc_dyn->rect' must be set on draw. */ } diff --git a/source/blender/editors/interface/interface_region_color_picker.cc b/source/blender/editors/interface/interface_region_color_picker.cc index 0913a591c01..db757d410cd 100644 --- a/source/blender/editors/interface/interface_region_color_picker.cc +++ b/source/blender/editors/interface/interface_region_color_picker.cc @@ -213,7 +213,7 @@ static void ui_update_color_picker_buts_rgb(uiBut *from_but, } rgb_float_to_uchar(rgb_hex_uchar, rgb_hex); - BLI_snprintf(col, sizeof(col), "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, )); + SNPRINTF(col, "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, )); strcpy(bt->poin, col); } @@ -783,7 +783,7 @@ static void ui_block_colorpicker(uiBlock *block, } rgb_float_to_uchar(rgb_hex_uchar, rgb_hex); - BLI_snprintf(hexcol, sizeof(hexcol), "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, )); + SNPRINTF(hexcol, "%02X%02X%02X", UNPACK3_EX((uint), rgb_hex_uchar, )); yco = -3.0f * UI_UNIT_Y; bt = uiDefBut(block, diff --git a/source/blender/editors/interface/interface_region_hud.cc b/source/blender/editors/interface/interface_region_hud.cc index 85c96d52adb..59e6f0eee69 100644 --- a/source/blender/editors/interface/interface_region_hud.cc +++ b/source/blender/editors/interface/interface_region_hud.cc @@ -103,7 +103,7 @@ static bool hud_panel_operator_redo_poll(const bContext *C, PanelType * /*pt*/) static void hud_panel_operator_redo_draw_header(const bContext *C, Panel *panel) { wmOperator *op = WM_operator_last_redo(C); - BLI_strncpy(panel->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(panel->drawname)); + STRNCPY(panel->drawname, WM_operatortype_name(op->type, op->ptr)); } static void hud_panel_operator_redo_draw(const bContext *C, Panel *panel) diff --git a/source/blender/editors/interface/interface_region_menu_pie.cc b/source/blender/editors/interface/interface_region_menu_pie.cc index 23ebe322370..12fe1fe17f3 100644 --- a/source/blender/editors/interface/interface_region_menu_pie.cc +++ b/source/blender/editors/interface/interface_region_menu_pie.cc @@ -142,7 +142,7 @@ uiPieMenu *UI_pie_menu_begin(struct bContext *C, const char *title, int icon, co char titlestr[256]; int w; if (icon) { - BLI_snprintf(titlestr, sizeof(titlestr), " %s", title); + SNPRINTF(titlestr, " %s", title); w = ui_pie_menu_title_width(titlestr, icon); but = uiDefIconTextBut(pie->block_radial, UI_BTYPE_LABEL, @@ -377,7 +377,7 @@ void ui_pie_menu_level_create(uiBlock *block, /* yuk, static... issue is we can't reliably free this without doing dangerous changes */ static PieMenuLevelData lvl; - BLI_strncpy(lvl.title, block->pie_data.title, UI_MAX_NAME_STR); + STRNCPY(lvl.title, block->pie_data.title); lvl.totitem = totitem_remain; lvl.ot = ot; lvl.propname = propname; diff --git a/source/blender/editors/interface/interface_region_menu_popup.cc b/source/blender/editors/interface/interface_region_menu_popup.cc index 3a03b4c2753..ce891e385e2 100644 --- a/source/blender/editors/interface/interface_region_menu_popup.cc +++ b/source/blender/editors/interface/interface_region_menu_popup.cc @@ -449,7 +449,7 @@ static void create_title_button(uiLayout *layout, const char *title, int icon) char titlestr[256]; if (icon) { - BLI_snprintf(titlestr, sizeof(titlestr), " %s", title); + SNPRINTF(titlestr, " %s", title); uiDefIconTextBut(block, UI_BTYPE_LABEL, 0, @@ -577,7 +577,7 @@ void UI_popup_menu_reports(bContext *C, ReportList *reports) if (pup == nullptr) { char title[UI_MAX_DRAW_STR]; - BLI_snprintf(title, sizeof(title), "%s: %s", IFACE_("Report"), report->typestr); + SNPRINTF(title, "%s: %s", IFACE_("Report"), report->typestr); /* popup_menu stuff does just what we need (but pass meaningful block name) */ pup = UI_popup_menu_begin_ex(C, title, __func__, ICON_NONE); layout = UI_popup_menu_layout(pup); diff --git a/source/blender/editors/interface/interface_style.cc b/source/blender/editors/interface/interface_style.cc index c8a0ca22d5c..020d5dc3249 100644 --- a/source/blender/editors/interface/interface_style.cc +++ b/source/blender/editors/interface/interface_style.cc @@ -62,7 +62,7 @@ static uiStyle *ui_style_new(ListBase *styles, const char *name, short uifont_id uiStyle *style = MEM_cnew(__func__); BLI_addtail(styles, style); - BLI_strncpy(style->name, name, MAX_STYLE_NAME); + STRNCPY(style->name, name); style->panelzoom = 1.0; /* unused */ @@ -385,11 +385,11 @@ void uiStyleInit() } if (U.font_path_ui[0]) { - BLI_strncpy(font_first->filepath, U.font_path_ui, sizeof(font_first->filepath)); + STRNCPY(font_first->filepath, U.font_path_ui); font_first->uifont_id = UIFONT_CUSTOM1; } else { - BLI_strncpy(font_first->filepath, "default", sizeof(font_first->filepath)); + STRNCPY(font_first->filepath, "default"); font_first->uifont_id = UIFONT_DEFAULT; } diff --git a/source/blender/editors/interface/interface_template_asset_view.cc b/source/blender/editors/interface/interface_template_asset_view.cc index a21d5693a6a..c18ee3c37d8 100644 --- a/source/blender/editors/interface/interface_template_asset_view.cc +++ b/source/blender/editors/interface/interface_template_asset_view.cc @@ -167,7 +167,7 @@ uiListType *UI_UL_asset_view() { uiListType *list_type = (uiListType *)MEM_callocN(sizeof(*list_type), __func__); - BLI_strncpy(list_type->idname, "UI_UL_asset_view", sizeof(list_type->idname)); + STRNCPY(list_type->idname, "UI_UL_asset_view"); list_type->draw_item = asset_view_draw_item; list_type->filter_items = asset_view_filter_items; list_type->listener = asset_view_listener; diff --git a/source/blender/editors/interface/interface_template_list.cc b/source/blender/editors/interface/interface_template_list.cc index 01b573fee2a..30a59bb42c4 100644 --- a/source/blender/editors/interface/interface_template_list.cc +++ b/source/blender/editors/interface/interface_template_list.cc @@ -272,7 +272,7 @@ void UI_list_filter_and_sort_items(uiList *ui_list, if (do_order) { names[order_idx].org_idx = order_idx; - BLI_strncpy(names[order_idx++].name, name, MAX_IDPROP_NAME); + STRNCPY(names[order_idx++].name, name); } /* free name */ @@ -673,7 +673,7 @@ static uiList *ui_list_ensure(const bContext *C, if (!ui_list) { ui_list = static_cast(MEM_callocN(sizeof(uiList), "uiList")); - BLI_strncpy(ui_list->list_id, full_list_id, sizeof(ui_list->list_id)); + STRNCPY(ui_list->list_id, full_list_id); BLI_addtail(®ion->ui_lists, ui_list); ui_list->list_grip = -UI_LIST_AUTO_SIZE_THRESHOLD; /* Force auto size by default. */ if (sort_reverse) { @@ -865,7 +865,7 @@ static void ui_template_list_layout_draw(const bContext *C, } /* next/prev button */ - BLI_snprintf(numstr, sizeof(numstr), "%d :", dyn_data->items_shown); + SNPRINTF(numstr, "%d :", dyn_data->items_shown); but = uiDefIconTextButR_prop(block, UI_BTYPE_NUM, 0, diff --git a/source/blender/editors/interface/interface_template_search_operator.cc b/source/blender/editors/interface/interface_template_search_operator.cc index 6ceb419291d..ad20955a7fa 100644 --- a/source/blender/editors/interface/interface_template_search_operator.cc +++ b/source/blender/editors/interface/interface_template_search_operator.cc @@ -73,7 +73,7 @@ static void operator_search_update_fn(const bContext *C, const int len = strlen(ot_ui_name); /* display name for menu, can hold hotkey */ - BLI_strncpy(name, ot_ui_name, sizeof(name)); + STRNCPY(name, ot_ui_name); /* check for hotkey */ if (len < sizeof(name) - 6) { diff --git a/source/blender/editors/interface/interface_templates.cc b/source/blender/editors/interface/interface_templates.cc index df75a04446d..49b42bcf157 100644 --- a/source/blender/editors/interface/interface_templates.cc +++ b/source/blender/editors/interface/interface_templates.cc @@ -517,16 +517,14 @@ static ARegion *template_ID_search_menu_item_tooltip( uiSearchItemTooltipData tooltip_data = {{0}}; tooltip_data.name = active_id->name + 2; - BLI_snprintf(tooltip_data.description, - sizeof(tooltip_data.description), - TIP_("Choose %s data-block to be assigned to this user"), - RNA_struct_ui_name(type)); + SNPRINTF(tooltip_data.description, + TIP_("Choose %s data-block to be assigned to this user"), + RNA_struct_ui_name(type)); if (ID_IS_LINKED(active_id)) { - BLI_snprintf(tooltip_data.hint, - sizeof(tooltip_data.hint), - TIP_("Source library: %s\n%s"), - active_id->lib->id.name + 2, - active_id->lib->filepath); + SNPRINTF(tooltip_data.hint, + TIP_("Source library: %s\n%s"), + active_id->lib->id.name + 2, + active_id->lib->filepath); } return UI_tooltip_create_from_search_item_generic(C, region, item_rect, &tooltip_data); @@ -1434,7 +1432,7 @@ static void template_ID(const bContext *C, char numstr[32]; short numstr_len; - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%d", ID_REAL_USERS(id)); + numstr_len = SNPRINTF_RLEN(numstr, "%d", ID_REAL_USERS(id)); but = uiDefBut( block, @@ -3181,8 +3179,7 @@ void uiTemplatePreview(uiLayout *layout, if (!preview_id || (preview_id[0] == '\0')) { /* If no identifier given, generate one from ID type. */ - BLI_snprintf( - _preview_id, UI_MAX_NAME_STR, "uiPreview_%s", BKE_idtype_idcode_to_name(GS(id->name))); + SNPRINTF(_preview_id, "uiPreview_%s", BKE_idtype_idcode_to_name(GS(id->name))); preview_id = _preview_id; } @@ -3193,7 +3190,7 @@ void uiTemplatePreview(uiLayout *layout, if (!ui_preview) { ui_preview = MEM_cnew(__func__); - BLI_strncpy(ui_preview->preview_id, preview_id, sizeof(ui_preview->preview_id)); + STRNCPY(ui_preview->preview_id, preview_id); ui_preview->height = short(UI_UNIT_Y * 7.6f); BLI_addtail(®ion->ui_previews, ui_preview); } @@ -6255,7 +6252,7 @@ void uiTemplateRunningJobs(uiLayout *layout, bContext *C) /* get percentage done and set it as the UI text */ const float progress = WM_jobs_progress(wm, owner); char text[8]; - BLI_snprintf(text, 8, "%d%%", int(progress * 100)); + SNPRINTF(text, "%d%%", int(progress * 100)); const char *name = active ? WM_jobs_name(wm, owner) : "Canceling..."; @@ -6730,7 +6727,7 @@ void uiTemplateComponentMenu(uiLayout *layout, ComponentMenuArgs *args = MEM_cnew(__func__); args->ptr = *ptr; - BLI_strncpy(args->propname, propname, sizeof(args->propname)); + STRNCPY(args->propname, propname); uiBlock *block = uiLayoutGetBlock(layout); UI_block_align_begin(block); @@ -6884,7 +6881,7 @@ uiListType *UI_UL_cache_file_layers() { uiListType *list_type = (uiListType *)MEM_callocN(sizeof(*list_type), __func__); - BLI_strncpy(list_type->idname, "UI_UL_cache_file_layers", sizeof(list_type->idname)); + STRNCPY(list_type->idname, "UI_UL_cache_file_layers"); list_type->draw_item = cache_file_layer_item; return list_type; diff --git a/source/blender/editors/interface/interface_utils.cc b/source/blender/editors/interface/interface_utils.cc index 227f1642914..0bd8269d566 100644 --- a/source/blender/editors/interface/interface_utils.cc +++ b/source/blender/editors/interface/interface_utils.cc @@ -342,8 +342,7 @@ uiBut *uiDefAutoButR(uiBlock *block, } case PROP_COLLECTION: { char text[256]; - BLI_snprintf( - text, sizeof(text), IFACE_("%d items"), RNA_property_collection_length(ptr, prop)); + SNPRINTF(text, IFACE_("%d items"), RNA_property_collection_length(ptr, prop)); but = uiDefBut( block, UI_BTYPE_LABEL, 0, text, x, y, width, height, nullptr, 0, 0, 0, 0, nullptr); UI_but_flag_enable(but, UI_BUT_DISABLED); diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index 7bb662845aa..4bce1637405 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -5400,7 +5400,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, const size_t max_len = sizeof(drawstr); const float minwidth = float(UI_ICON_SIZE); - BLI_strncpy(drawstr, name, sizeof(drawstr)); + STRNCPY(drawstr, name); if (drawstr[0]) { UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0'); } @@ -5449,7 +5449,7 @@ void ui_draw_menu_item(const uiFontStyle *fstyle, const size_t max_len = sizeof(hint_drawstr); const float minwidth = float(UI_ICON_SIZE); - BLI_strncpy(hint_drawstr, cpoin + 1, sizeof(hint_drawstr)); + STRNCPY(hint_drawstr, cpoin + 1); if (hint_drawstr[0] && (max_hint_width < INT_MAX)) { UI_text_clip_middle_ex(fstyle, hint_drawstr, max_hint_width, minwidth, max_len, '\0'); } @@ -5504,7 +5504,7 @@ void ui_draw_preview_item_stateless(const uiFontStyle *fstyle, const size_t max_len = sizeof(drawstr); const float minwidth = float(UI_ICON_SIZE); - BLI_strncpy(drawstr, name, sizeof(drawstr)); + STRNCPY(drawstr, name); UI_text_clip_middle_ex(fstyle, drawstr, okwidth, minwidth, max_len, '\0'); uiFontStyleDraw_Params params{}; diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index 98286b0a3ba..09ce8fcb5a5 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -52,7 +52,7 @@ static int cachefile_open_invoke(bContext *C, wmOperator *op, const wmEvent *eve char filepath[FILE_MAX]; Main *bmain = CTX_data_main(C); - BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); + STRNCPY(filepath, BKE_main_blendfile_path(bmain)); BLI_path_extension_replace(filepath, sizeof(filepath), ".abc"); RNA_string_set(op->ptr, "filepath", filepath); } @@ -85,7 +85,7 @@ static int cachefile_open_exec(bContext *C, wmOperator *op) Main *bmain = CTX_data_main(C); CacheFile *cache_file = BKE_libblock_alloc(bmain, ID_CF, BLI_path_basename(filepath), 0); - BLI_strncpy(cache_file->filepath, filepath, FILE_MAX); + STRNCPY(cache_file->filepath, filepath); DEG_id_tag_update(&cache_file->id, ID_RECALC_COPY_ON_WRITE); /* Will be set when running invoke, not exec directly. */ @@ -164,7 +164,7 @@ static int cachefile_layer_open_invoke(bContext *C, wmOperator *op, const wmEven char filepath[FILE_MAX]; Main *bmain = CTX_data_main(C); - BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); + STRNCPY(filepath, BKE_main_blendfile_path(bmain)); BLI_path_extension_replace(filepath, sizeof(filepath), ".abc"); RNA_string_set(op->ptr, "filepath", filepath); } diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index e12bd6c52a3..80d1322a40d 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -218,7 +218,7 @@ static int wm_collada_export_exec(bContext *C, wmOperator *op) } char buff[100]; - BLI_snprintf(buff, sizeof(buff), "Exported %d Objects", export_count); + SNPRINTF(buff, "Exported %d Objects", export_count); BKE_report(op->reports, RPT_INFO, buff); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/mask/mask_relationships.cc b/source/blender/editors/mask/mask_relationships.cc index b52ac944e23..7053a790510 100644 --- a/source/blender/editors/mask/mask_relationships.cc +++ b/source/blender/editors/mask/mask_relationships.cc @@ -133,8 +133,8 @@ static int mask_parent_set_exec(bContext *C, wmOperator * /*op*/) point->parent.id_type = ID_MC; point->parent.id = &clip->id; point->parent.type = parent_type; - BLI_strncpy(point->parent.parent, tracking_object->name, sizeof(point->parent.parent)); - BLI_strncpy(point->parent.sub_parent, sub_parent_name, sizeof(point->parent.sub_parent)); + STRNCPY(point->parent.parent, tracking_object->name); + STRNCPY(point->parent.sub_parent, sub_parent_name); copy_v2_v2(point->parent.parent_orig, parmask_pos); memcpy(point->parent.parent_corners_orig, diff --git a/source/blender/editors/mesh/editmesh_bevel.c b/source/blender/editors/mesh/editmesh_bevel.c index 866c68bef53..054cc035925 100644 --- a/source/blender/editors/mesh/editmesh_bevel.c +++ b/source/blender/editors/mesh/editmesh_bevel.c @@ -132,7 +132,7 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) char offset_str[NUM_STR_REP_LEN]; if (RNA_enum_get(op->ptr, "offset_type") == BEVEL_AMT_PERCENT) { - BLI_snprintf(offset_str, NUM_STR_REP_LEN, "%.1f%%", RNA_float_get(op->ptr, "offset_pct")); + SNPRINTF(offset_str, "%.1f%%", RNA_float_get(op->ptr, "offset_pct")); } else { double offset_val = (double)RNA_float_get(op->ptr, "offset"); @@ -166,51 +166,50 @@ static void edbm_bevel_update_status_text(bContext *C, wmOperator *op) RNA_property_enum_name_gettexted( C, op->ptr, prop, RNA_property_enum_get(op->ptr, prop), &affect_str); - BLI_snprintf(status_text, - sizeof(status_text), - TIP_("%s: Confirm, " - "%s: Cancel, " - "%s: Width Type (%s), " - "%s: Width (%s), " - "%s: Segments (%d), " - "%s: Profile (%.3f), " - "%s: Clamp Overlap (%s), " - "%s: Affect (%s), " - "%s: Outer Miter (%s), " - "%s: Inner Miter (%s), " - "%s: Harden Normals (%s), " - "%s: Mark Seam (%s), " - "%s: Mark Sharp (%s), " - "%s: Profile Type (%s), " - "%s: Intersection (%s)"), - WM_MODALKEY(BEV_MODAL_CONFIRM), - WM_MODALKEY(BEV_MODAL_CANCEL), - WM_MODALKEY(BEV_MODAL_OFFSET_MODE_CHANGE), - mode_str, - WM_MODALKEY(BEV_MODAL_VALUE_OFFSET), - offset_str, - WM_MODALKEY(BEV_MODAL_VALUE_SEGMENTS), - RNA_int_get(op->ptr, "segments"), - WM_MODALKEY(BEV_MODAL_VALUE_PROFILE), - RNA_float_get(op->ptr, "profile"), - WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")), - WM_MODALKEY(BEV_MODAL_AFFECT_CHANGE), - affect_str, - WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE), - omiter_str, - WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE), - imiter_str, - WM_MODALKEY(BEV_MODAL_HARDEN_NORMALS_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")), - WM_MODALKEY(BEV_MODAL_MARK_SEAM_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")), - WM_MODALKEY(BEV_MODAL_MARK_SHARP_TOGGLE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp")), - WM_MODALKEY(BEV_MODAL_PROFILE_TYPE_CHANGE), - profile_type_str, - WM_MODALKEY(BEV_MODAL_VERTEX_MESH_CHANGE), - vmesh_str); + SNPRINTF(status_text, + TIP_("%s: Confirm, " + "%s: Cancel, " + "%s: Width Type (%s), " + "%s: Width (%s), " + "%s: Segments (%d), " + "%s: Profile (%.3f), " + "%s: Clamp Overlap (%s), " + "%s: Affect (%s), " + "%s: Outer Miter (%s), " + "%s: Inner Miter (%s), " + "%s: Harden Normals (%s), " + "%s: Mark Seam (%s), " + "%s: Mark Sharp (%s), " + "%s: Profile Type (%s), " + "%s: Intersection (%s)"), + WM_MODALKEY(BEV_MODAL_CONFIRM), + WM_MODALKEY(BEV_MODAL_CANCEL), + WM_MODALKEY(BEV_MODAL_OFFSET_MODE_CHANGE), + mode_str, + WM_MODALKEY(BEV_MODAL_VALUE_OFFSET), + offset_str, + WM_MODALKEY(BEV_MODAL_VALUE_SEGMENTS), + RNA_int_get(op->ptr, "segments"), + WM_MODALKEY(BEV_MODAL_VALUE_PROFILE), + RNA_float_get(op->ptr, "profile"), + WM_MODALKEY(BEV_MODAL_CLAMP_OVERLAP_TOGGLE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "clamp_overlap")), + WM_MODALKEY(BEV_MODAL_AFFECT_CHANGE), + affect_str, + WM_MODALKEY(BEV_MODAL_OUTER_MITER_CHANGE), + omiter_str, + WM_MODALKEY(BEV_MODAL_INNER_MITER_CHANGE), + imiter_str, + WM_MODALKEY(BEV_MODAL_HARDEN_NORMALS_TOGGLE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "harden_normals")), + WM_MODALKEY(BEV_MODAL_MARK_SEAM_TOGGLE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_seam")), + WM_MODALKEY(BEV_MODAL_MARK_SHARP_TOGGLE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "mark_sharp")), + WM_MODALKEY(BEV_MODAL_PROFILE_TYPE_CHANGE), + profile_type_str, + WM_MODALKEY(BEV_MODAL_VERTEX_MESH_CHANGE), + vmesh_str); #undef WM_MODALKEY diff --git a/source/blender/editors/mesh/editmesh_inset.c b/source/blender/editors/mesh/editmesh_inset.c index b3d48c8bfd5..50a3e3adcb7 100644 --- a/source/blender/editors/mesh/editmesh_inset.c +++ b/source/blender/editors/mesh/editmesh_inset.c @@ -98,15 +98,14 @@ static void edbm_inset_update_header(wmOperator *op, bContext *C) &sce->unit, true); } - BLI_snprintf(msg, - sizeof(msg), - str, - flts_str, - flts_str + NUM_STR_REP_LEN, - WM_bool_as_string(opdata->modify_depth), - WM_bool_as_string(RNA_boolean_get(op->ptr, "use_outset")), - WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")), - WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual"))); + SNPRINTF(msg, + str, + flts_str, + flts_str + NUM_STR_REP_LEN, + WM_bool_as_string(opdata->modify_depth), + WM_bool_as_string(RNA_boolean_get(op->ptr, "use_outset")), + WM_bool_as_string(RNA_boolean_get(op->ptr, "use_boundary")), + WM_bool_as_string(RNA_boolean_get(op->ptr, "use_individual"))); ED_area_status_text(area, msg); } diff --git a/source/blender/editors/mesh/editmesh_knife.c b/source/blender/editors/mesh/editmesh_knife.c index aa932d78040..1cd09a49b1e 100644 --- a/source/blender/editors/mesh/editmesh_knife.c +++ b/source/blender/editors/mesh/editmesh_knife.c @@ -504,7 +504,7 @@ static void knifetool_draw_visible_distances(const KnifeTool_OpData *kcd) UnitSettings *unit = &kcd->scene->unit; if (unit->system == USER_UNIT_NONE) { - BLI_snprintf(numstr, sizeof(numstr), "%.*f", distance_precision, cut_len); + SNPRINTF(numstr, "%.*f", distance_precision, cut_len); } else { BKE_unit_value_as_string(numstr, @@ -639,7 +639,7 @@ static void knifetool_draw_angle(const KnifeTool_OpData *kcd, UnitSettings *unit = &kcd->scene->unit; if (unit->system == USER_UNIT_NONE) { - BLI_snprintf(numstr, sizeof(numstr), "%.*f°", angle_precision, RAD2DEGF(angle)); + SNPRINTF(numstr, "%.*f°", angle_precision, RAD2DEGF(angle)); } else { BKE_unit_value_as_string( @@ -1100,9 +1100,8 @@ static void knife_update_header(bContext *C, wmOperator *op, KnifeTool_OpData *k WM_modalkeymap_operator_items_to_string_buf( \ op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) - BLI_snprintf( + SNPRINTF( header, - sizeof(header), TIP_("%s: confirm, %s: cancel, %s: undo, " "%s: start/define cut, %s: close cut, %s: new cut, " "%s: midpoint snap (%s), %s: ignore snap (%s), " diff --git a/source/blender/editors/mesh/editmesh_loopcut.c b/source/blender/editors/mesh/editmesh_loopcut.c index 061394d2fb7..54674bf58f6 100644 --- a/source/blender/editors/mesh/editmesh_loopcut.c +++ b/source/blender/editors/mesh/editmesh_loopcut.c @@ -683,11 +683,8 @@ static int loopcut_modal(bContext *C, wmOperator *op, const wmEvent *event) BLI_snprintf(str_rep, NUM_STR_REP_LEN, "%d", (int)lcd->cuts); BLI_snprintf(str_rep + NUM_STR_REP_LEN, NUM_STR_REP_LEN, "%.2f", smoothness); } - BLI_snprintf(buf, - sizeof(buf), - TIP_("Number of Cuts: %s, Smooth: %s (Alt)"), - str_rep, - str_rep + NUM_STR_REP_LEN); + SNPRINTF( + buf, TIP_("Number of Cuts: %s, Smooth: %s (Alt)"), str_rep, str_rep + NUM_STR_REP_LEN); ED_workspace_status_text(C, buf); } diff --git a/source/blender/editors/mesh/editmesh_tools.cc b/source/blender/editors/mesh/editmesh_tools.cc index 6c486cda58b..36d6249e857 100644 --- a/source/blender/editors/mesh/editmesh_tools.cc +++ b/source/blender/editors/mesh/editmesh_tools.cc @@ -8459,28 +8459,27 @@ static void point_normals_update_header(bContext *C, wmOperator *op) WM_modalkeymap_operator_items_to_string_buf( \ op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) - BLI_snprintf(header, - sizeof(header), - TIP_("%s: confirm, %s: cancel, " - "%s: point to mouse (%s), %s: point to Pivot, " - "%s: point to object origin, %s: reset normals, " - "%s: set & point to 3D cursor, %s: select & point to mesh item, " - "%s: invert normals (%s), %s: spherize (%s), %s: align (%s)"), - WM_MODALKEY(EDBM_CLNOR_MODAL_CONFIRM), - WM_MODALKEY(EDBM_CLNOR_MODAL_CANCEL), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_MOUSE), - WM_bool_as_string(RNA_enum_get(op->ptr, "mode") == EDBM_CLNOR_POINTTO_MODE_MOUSE), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_PIVOT), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_OBJECT), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_RESET), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SET_USE_3DCURSOR), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SET_USE_SELECTED), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_INVERT), - WM_bool_as_string(RNA_boolean_get(op->ptr, "invert")), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SPHERIZE), - WM_bool_as_string(RNA_boolean_get(op->ptr, "spherize")), - WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_ALIGN), - WM_bool_as_string(RNA_boolean_get(op->ptr, "align"))); + SNPRINTF(header, + TIP_("%s: confirm, %s: cancel, " + "%s: point to mouse (%s), %s: point to Pivot, " + "%s: point to object origin, %s: reset normals, " + "%s: set & point to 3D cursor, %s: select & point to mesh item, " + "%s: invert normals (%s), %s: spherize (%s), %s: align (%s)"), + WM_MODALKEY(EDBM_CLNOR_MODAL_CONFIRM), + WM_MODALKEY(EDBM_CLNOR_MODAL_CANCEL), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_MOUSE), + WM_bool_as_string(RNA_enum_get(op->ptr, "mode") == EDBM_CLNOR_POINTTO_MODE_MOUSE), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_PIVOT), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_USE_OBJECT), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_RESET), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SET_USE_3DCURSOR), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SET_USE_SELECTED), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_INVERT), + WM_bool_as_string(RNA_boolean_get(op->ptr, "invert")), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_SPHERIZE), + WM_bool_as_string(RNA_boolean_get(op->ptr, "spherize")), + WM_MODALKEY(EDBM_CLNOR_MODAL_POINTTO_ALIGN), + WM_bool_as_string(RNA_boolean_get(op->ptr, "align"))); #undef WM_MODALKEY diff --git a/source/blender/editors/object/object_add.cc b/source/blender/editors/object/object_add.cc index 108c74e11ae..7ccea4f1d24 100644 --- a/source/blender/editors/object/object_add.cc +++ b/source/blender/editors/object/object_add.cc @@ -2021,7 +2021,7 @@ static int object_speaker_add_exec(bContext *C, wmOperator *op) BKE_nlatrack_add_strip(nlt, strip, is_liboverride); /* Auto-name the strip, and give the track an interesting name. */ - BLI_strncpy(nlt->name, DATA_("SoundTrack"), sizeof(nlt->name)); + STRNCPY(nlt->name, DATA_("SoundTrack")); BKE_nlastrip_validate_name(adt, strip); WM_event_add_notifier(C, NC_ANIMATION | ND_NLA | NA_ADDED, nullptr); @@ -2643,7 +2643,7 @@ static void make_object_duplilist_real(bContext *C, if (ob_dst_par) { /* allow for all possible parent types */ ob_dst->partype = ob_src->partype; - BLI_strncpy(ob_dst->parsubstr, ob_src->parsubstr, sizeof(ob_dst->parsubstr)); + STRNCPY(ob_dst->parsubstr, ob_src->parsubstr); ob_dst->par1 = ob_src->par1; ob_dst->par2 = ob_src->par2; ob_dst->par3 = ob_src->par3; diff --git a/source/blender/editors/object/object_bake_api.cc b/source/blender/editors/object/object_bake_api.cc index b265f0301d9..78f7ef9a061 100644 --- a/source/blender/editors/object/object_bake_api.cc +++ b/source/blender/editors/object/object_bake_api.cc @@ -944,7 +944,7 @@ static bool bake_targets_output_external(const BakeAPIRender *bkr, else { /* if everything else fails, use the material index */ char tmp[5]; - BLI_snprintf(tmp, sizeof(tmp), "%d", i % 1000); + SNPRINTF(tmp, "%d", i % 1000); BLI_path_suffix(filepath, FILE_MAX, tmp, "_"); } } diff --git a/source/blender/editors/object/object_bake_simulation.cc b/source/blender/editors/object/object_bake_simulation.cc index ba6c78eb317..ef85a05370d 100644 --- a/source/blender/editors/object/object_bake_simulation.cc +++ b/source/blender/editors/object/object_bake_simulation.cc @@ -281,7 +281,7 @@ static void bake_simulation_job_startjob(void *customdata, job.scene->r.subframe = frame.subframe(); char frame_file_c_str[64]; - BLI_snprintf(frame_file_c_str, sizeof(frame_file_c_str), "%011.5f", double(frame)); + SNPRINTF(frame_file_c_str, "%011.5f", double(frame)); BLI_str_replace_char(frame_file_c_str, '.', '_'); const StringRefNull frame_file_str = frame_file_c_str; diff --git a/source/blender/editors/object/object_constraint.c b/source/blender/editors/object/object_constraint.c index 7202e954911..43ab79fa37d 100644 --- a/source/blender/editors/object/object_constraint.c +++ b/source/blender/editors/object/object_constraint.c @@ -201,7 +201,7 @@ static char *buildmenu_pyconstraints(Main *bmain, Text *con_text, int *pyconinde if (BPY_is_pyconstraint(text)) { BLI_dynstr_append(pupds, text->id.name + 2); - BLI_snprintf(buf, sizeof(buf), "%%x%d", i); + SNPRINTF(buf, "%%x%d", i); BLI_dynstr_append(pupds, buf); if (text->id.next) { @@ -269,7 +269,7 @@ static void set_constraint_nth_target(bConstraint *con, for (ct = targets.first, i = 0; ct; ct = ct->next, i++) { if (i == index) { ct->tar = target; - BLI_strncpy(ct->subtarget, subtarget, sizeof(ct->subtarget)); + STRNCPY(ct->subtarget, subtarget); break; } } diff --git a/source/blender/editors/object/object_gpencil_modifier.c b/source/blender/editors/object/object_gpencil_modifier.c index 7e8963e171d..4103e5feb14 100644 --- a/source/blender/editors/object/object_gpencil_modifier.c +++ b/source/blender/editors/object/object_gpencil_modifier.c @@ -78,7 +78,7 @@ GpencilModifierData *ED_object_gpencil_modifier_add( BLI_addtail(&ob->greasepencil_modifiers, new_md); if (name) { - BLI_strncpy_utf8(new_md->name, name, sizeof(new_md->name)); + STRNCPY_UTF8(new_md->name, name); } /* make sure modifier data has unique name */ diff --git a/source/blender/editors/object/object_hook.c b/source/blender/editors/object/object_hook.c index 868bc12fe46..bf3e144ba6b 100644 --- a/source/blender/editors/object/object_hook.c +++ b/source/blender/editors/object/object_hook.c @@ -545,14 +545,14 @@ static int add_hook_object(const bContext *C, hmd = (HookModifierData *)BKE_modifier_new(eModifierType_Hook); BLI_insertlinkbefore(&obedit->modifiers, md, hmd); - BLI_snprintf(hmd->modifier.name, sizeof(hmd->modifier.name), "Hook-%s", ob->id.name + 2); + SNPRINTF(hmd->modifier.name, "Hook-%s", ob->id.name + 2); BKE_modifier_unique_name(&obedit->modifiers, (ModifierData *)hmd); hmd->object = ob; hmd->indexar = indexar; copy_v3_v3(hmd->cent, cent); hmd->indexar_num = indexar_num; - BLI_strncpy(hmd->name, name, sizeof(hmd->name)); + STRNCPY(hmd->name, name); unit_m4(pose_mat); @@ -571,7 +571,7 @@ static int add_hook_object(const bContext *C, if (arm->act_bone) { bPoseChannel *pchan_act; - BLI_strncpy(hmd->subtarget, arm->act_bone->name, sizeof(hmd->subtarget)); + STRNCPY(hmd->subtarget, arm->act_bone->name); pchan_act = BKE_pose_channel_active_if_layer_visible(ob); if (LIKELY(pchan_act)) { diff --git a/source/blender/editors/object/object_modifier.cc b/source/blender/editors/object/object_modifier.cc index 4306722b071..e7032857e28 100644 --- a/source/blender/editors/object/object_modifier.cc +++ b/source/blender/editors/object/object_modifier.cc @@ -193,7 +193,7 @@ ModifierData *ED_object_modifier_add( } if (name) { - BLI_strncpy_utf8(new_md->name, name, sizeof(new_md->name)); + STRNCPY_UTF8(new_md->name, name); } /* make sure modifier data has unique name */ @@ -2469,7 +2469,7 @@ static int multires_external_save_invoke(bContext *C, wmOperator *op, const wmEv op->customdata = me; - BLI_snprintf(path, sizeof(path), "//%s.btx", me->id.name + 2); + SNPRINTF(path, "//%s.btx", me->id.name + 2); RNA_string_set(op->ptr, "filepath", path); WM_event_add_fileselect(C, op); @@ -2926,7 +2926,7 @@ static void skin_armature_bone_create(Object *skin_ob, copy_v3_v3(bone->head, positions[parent_v]); copy_v3_v3(bone->tail, positions[v]); bone->rad_head = bone->rad_tail = 0.25; - BLI_snprintf(bone->name, sizeof(bone->name), "Bone.%.2d", endx); + SNPRINTF(bone->name, "Bone.%.2d", endx); /* add bDeformGroup */ bDeformGroup *dg = BKE_object_defgroup_add_name(skin_ob, bone->name); diff --git a/source/blender/editors/object/object_relations.c b/source/blender/editors/object/object_relations.c index ace5c660bcf..84948139445 100644 --- a/source/blender/editors/object/object_relations.c +++ b/source/blender/editors/object/object_relations.c @@ -480,7 +480,7 @@ void ED_object_parent(Object *ob, Object *par, const int type, const char *subst ob->parent = par; ob->partype &= ~PARTYPE; ob->partype |= type; - BLI_strncpy(ob->parsubstr, substr, sizeof(ob->parsubstr)); + STRNCPY(ob->parsubstr, substr); } EnumPropertyItem prop_make_parent_types[] = { @@ -598,7 +598,7 @@ bool ED_object_parent_set(ReportList *reports, /* Handle types. */ if (pchan) { - BLI_strncpy(ob->parsubstr, pchan->name, sizeof(ob->parsubstr)); + STRNCPY(ob->parsubstr, pchan->name); } else { ob->parsubstr[0] = 0; diff --git a/source/blender/editors/object/object_shader_fx.c b/source/blender/editors/object/object_shader_fx.c index f76dbbeb4d4..fc7e3edcbd8 100644 --- a/source/blender/editors/object/object_shader_fx.c +++ b/source/blender/editors/object/object_shader_fx.c @@ -78,7 +78,7 @@ ShaderFxData *ED_object_shaderfx_add( BLI_addtail(&ob->shader_fx, new_fx); if (name) { - BLI_strncpy_utf8(new_fx->name, name, sizeof(new_fx->name)); + STRNCPY_UTF8(new_fx->name, name); } /* make sure effect data has unique name */ @@ -241,7 +241,7 @@ void ED_object_shaderfx_link(Object *dst, Object *src) void ED_object_shaderfx_copy(Object *dst, ShaderFxData *fx) { ShaderFxData *nfx = BKE_shaderfx_new(fx->type); - BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name)); + STRNCPY(nfx->name, fx->name); BKE_shaderfx_copydata(fx, nfx); BLI_addtail(&dst->shader_fx, nfx); @@ -682,7 +682,7 @@ static int shaderfx_copy_exec(bContext *C, wmOperator *op) return OPERATOR_CANCELLED; } - BLI_strncpy(nfx->name, fx->name, sizeof(nfx->name)); + STRNCPY(nfx->name, fx->name); /* Make sure effect data has unique name. */ BKE_shaderfx_unique_name(&ob->shader_fx, nfx); diff --git a/source/blender/editors/object/object_vgroup.cc b/source/blender/editors/object/object_vgroup.cc index 5c33228726d..576dd83cf61 100644 --- a/source/blender/editors/object/object_vgroup.cc +++ b/source/blender/editors/object/object_vgroup.cc @@ -1131,14 +1131,14 @@ static void vgroup_duplicate(Object *ob) } if (!strstr(dg->name, "_copy")) { - BLI_snprintf(name, sizeof(name), "%s_copy", dg->name); + SNPRINTF(name, "%s_copy", dg->name); } else { - BLI_strncpy(name, dg->name, sizeof(name)); + STRNCPY(name, dg->name); } cdg = BKE_defgroup_duplicate(dg); - BLI_strncpy(cdg->name, name, sizeof(cdg->name)); + STRNCPY(cdg->name, name); BKE_object_defgroup_unique_name(cdg, ob); BLI_addtail(defbase, cdg); diff --git a/source/blender/editors/physics/dynamicpaint_ops.c b/source/blender/editors/physics/dynamicpaint_ops.c index 6fffa3257ed..bf3694ee687 100644 --- a/source/blender/editors/physics/dynamicpaint_ops.c +++ b/source/blender/editors/physics/dynamicpaint_ops.c @@ -353,7 +353,7 @@ static void dynamicPaint_bakeImageSequence(DynamicPaintBakeJob *job) frames = surface->end_frame - surface->start_frame + 1; if (frames <= 0) { - BLI_strncpy(canvas->error, N_("No frames to bake"), sizeof(canvas->error)); + STRNCPY(canvas->error, N_("No frames to bake")); return; } diff --git a/source/blender/editors/physics/particle_object.c b/source/blender/editors/physics/particle_object.c index 54e2afc4711..5a27ba8e578 100644 --- a/source/blender/editors/physics/particle_object.c +++ b/source/blender/editors/physics/particle_object.c @@ -1146,7 +1146,7 @@ static bool copy_particle_systems_to_object(const bContext *C, /* push on top of the stack, no use trying to reproduce old stack order */ BLI_addtail(&ob_to->modifiers, md); - BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", i); + SNPRINTF(md->name, "ParticleSystem %i", i); BKE_modifier_unique_name(&ob_to->modifiers, (ModifierData *)psmd); psmd->psys = psys; diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c index 2c95f9e932b..096ed14ead2 100644 --- a/source/blender/editors/physics/physics_fluid.c +++ b/source/blender/editors/physics/physics_fluid.c @@ -239,7 +239,7 @@ static void fluid_bake_sequence(FluidJob *job) frames = fds->cache_frame_end - fds->cache_frame_start + 1; if (frames <= 0) { - BLI_strncpy(fds->error, N_("No frames to bake"), sizeof(fds->error)); + STRNCPY(fds->error, N_("No frames to bake")); return; } diff --git a/source/blender/editors/render/render_opengl.cc b/source/blender/editors/render/render_opengl.cc index 0daee0b2c90..3d6764dfe4b 100644 --- a/source/blender/editors/render/render_opengl.cc +++ b/source/blender/editors/render/render_opengl.cc @@ -254,7 +254,7 @@ static void screen_opengl_views_setup(OGLRender *oglrender) if (rv == nullptr) { rv = MEM_cnew("new opengl render view"); - BLI_strncpy(rv->name, srv->name, sizeof(rv->name)); + STRNCPY(rv->name, srv->name); BLI_addtail(&rr->views, rv); } } diff --git a/source/blender/editors/render/render_preview.cc b/source/blender/editors/render/render_preview.cc index 24b282ba320..2758c98fea8 100644 --- a/source/blender/editors/render/render_preview.cc +++ b/source/blender/editors/render/render_preview.cc @@ -475,7 +475,7 @@ static Scene *preview_prepare_scene( /* This flag tells render to not execute depsgraph or F-Curves etc. */ sce->r.scemode |= R_BUTS_PREVIEW; - BLI_strncpy(sce->r.engine, scene->r.engine, sizeof(sce->r.engine)); + STRNCPY(sce->r.engine, scene->r.engine); sce->r.color_mgt_flag = scene->r.color_mgt_flag; BKE_color_managed_display_settings_copy(&sce->display_settings, &scene->display_settings); @@ -498,7 +498,7 @@ static Scene *preview_prepare_scene( if (id_type == ID_TE) { /* Texture is not actually rendered with engine, just set dummy value. */ - BLI_strncpy(sce->r.engine, RE_engine_id_BLENDER_EEVEE, sizeof(sce->r.engine)); + STRNCPY(sce->r.engine, RE_engine_id_BLENDER_EEVEE); } if (id_type == ID_MA) { @@ -631,10 +631,10 @@ static bool ed_preview_draw_rect(ScrArea *area, int split, int first, rcti *rect bool ok = false; if (!split || first) { - BLI_snprintf(name, sizeof(name), "Preview %p", (void *)area); + SNPRINTF(name, "Preview %p", (void *)area); } else { - BLI_snprintf(name, sizeof(name), "SecondPreview %p", (void *)area); + SNPRINTF(name, "SecondPreview %p", (void *)area); } if (split) { @@ -1152,10 +1152,10 @@ static void shader_preview_render(ShaderPreview *sp, ID *id, int split, int firs } if (!split || first) { - BLI_snprintf(name, sizeof(name), "Preview %p", sp->owner); + SNPRINTF(name, "Preview %p", sp->owner); } else { - BLI_snprintf(name, sizeof(name), "SecondPreview %p", sp->owner); + SNPRINTF(name, "SecondPreview %p", sp->owner); } re = RE_GetRender(name); @@ -1314,7 +1314,7 @@ static ImBuf *icon_preview_imbuf_from_brush(Brush *brush) /* First use the path directly to try and load the file. */ char filepath[FILE_MAX]; - BLI_strncpy(filepath, brush->icon_filepath, sizeof(brush->icon_filepath)); + STRNCPY(filepath, brush->icon_filepath); BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL(&brush->id)); /* Use default color-spaces for brushes. */ diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index 57f2a4403ef..e8374c8c6df 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -3806,7 +3806,7 @@ void ED_region_cache_draw_curfra_label(const int framenr, const float x, const f /* frame number */ BLF_size(fontid, 11.0f * UI_SCALE_FAC); - BLI_snprintf(numstr, sizeof(numstr), "%d", framenr); + SNPRINTF(numstr, "%d", framenr); BLF_width_and_height(fontid, numstr, sizeof(numstr), &font_dims[0], &font_dims[1]); diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index da119cf30a8..189f764f727 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1445,7 +1445,7 @@ static bScreen *screen_state_to_nonnormal(bContext *C, bScreen *oldscreen = WM_window_get_active_screen(win); oldscreen->state = state; - BLI_snprintf(newname, sizeof(newname), "%s-%s", oldscreen->id.name + 2, "nonnormal"); + SNPRINTF(newname, "%s-%s", oldscreen->id.name + 2, "nonnormal"); layout_new = ED_workspace_layout_add(bmain, workspace, win, newname); diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index f8f252c935e..892959698c4 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -170,7 +170,7 @@ static int screenshot_invoke(bContext *C, wmOperator *op, const wmEvent *event) char filepath[FILE_MAX]; const char *blendfile_path = BKE_main_blendfile_path_from_global(); if (blendfile_path[0] != '\0') { - BLI_strncpy(filepath, blendfile_path, sizeof(filepath)); + STRNCPY(filepath, blendfile_path); BLI_path_extension_strip(filepath); /* Strip `.blend`. */ } else { diff --git a/source/blender/editors/sculpt_paint/paint_image.cc b/source/blender/editors/sculpt_paint/paint_image.cc index c21810224e1..72fb2e8274d 100644 --- a/source/blender/editors/sculpt_paint/paint_image.cc +++ b/source/blender/editors/sculpt_paint/paint_image.cc @@ -623,12 +623,10 @@ static void sample_color_update_header(SampleColorData *data, bContext *C) ScrArea *area = CTX_wm_area(C); if (area) { - BLI_snprintf(msg, - sizeof(msg), - TIP_("Sample color for %s"), - !data->sample_palette ? - TIP_("Brush. Use Left Click to sample for palette instead") : - TIP_("Palette. Use Left Click to sample more colors")); + SNPRINTF(msg, + TIP_("Sample color for %s"), + !data->sample_palette ? TIP_("Brush. Use Left Click to sample for palette instead") : + TIP_("Palette. Use Left Click to sample more colors")); ED_workspace_status_text(C, msg); } } diff --git a/source/blender/editors/sculpt_paint/paint_image_proj.cc b/source/blender/editors/sculpt_paint/paint_image_proj.cc index 2c7291a7f99..572a7c1e7e6 100644 --- a/source/blender/editors/sculpt_paint/paint_image_proj.cc +++ b/source/blender/editors/sculpt_paint/paint_image_proj.cc @@ -6729,7 +6729,7 @@ static bool proj_paint_add_slot(bContext *C, wmOperator *op) case PAINT_CANVAS_SOURCE_COLOR_ATTRIBUTE: { new_node = nodeAddStaticNode(C, ntree, SH_NODE_ATTRIBUTE); if (const char *name = proj_paint_color_attribute_create(op, ob)) { - BLI_strncpy_utf8(((NodeShaderAttribute *)new_node->storage)->name, name, MAX_NAME); + STRNCPY_UTF8(((NodeShaderAttribute *)new_node->storage)->name, name); } break; } diff --git a/source/blender/editors/sculpt_paint/paint_ops.cc b/source/blender/editors/sculpt_paint/paint_ops.cc index 14d6aa6acdf..ebabff27b47 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.cc +++ b/source/blender/editors/sculpt_paint/paint_ops.cc @@ -228,7 +228,7 @@ static int brush_add_gpencil_exec(bContext *C, wmOperator * /*op*/) /* Capitalize Brush name first letter using the tool name. */ char name[64]; - BLI_strncpy(name, tool->runtime->data_block, sizeof(name)); + STRNCPY(name, tool->runtime->data_block); BLI_str_tolower_ascii(name, sizeof(name)); name[0] = BLI_toupper_ascii(name[0]); diff --git a/source/blender/editors/sculpt_paint/paint_vertex.cc b/source/blender/editors/sculpt_paint/paint_vertex.cc index c6614d2da98..de01debacf9 100644 --- a/source/blender/editors/sculpt_paint/paint_vertex.cc +++ b/source/blender/editors/sculpt_paint/paint_vertex.cc @@ -1562,8 +1562,7 @@ static void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache Brush *brush = paint->brush; int cur_brush_size = BKE_brush_size_get(scene, brush); - BLI_strncpy( - cache->saved_active_brush_name, brush->id.name + 2, sizeof(cache->saved_active_brush_name)); + STRNCPY(cache->saved_active_brush_name, brush->id.name + 2); /* Switch to the blur (smooth) brush. */ brush = BKE_paint_toolslots_brush_get(paint, WPAINT_TOOL_BLUR); diff --git a/source/blender/editors/sculpt_paint/sculpt.cc b/source/blender/editors/sculpt_paint/sculpt.cc index 2960e788342..2ebe660c73f 100644 --- a/source/blender/editors/sculpt_paint/sculpt.cc +++ b/source/blender/editors/sculpt_paint/sculpt.cc @@ -4399,9 +4399,7 @@ static void smooth_brush_toggle_on(const bContext *C, Paint *paint, StrokeCache else { int cur_brush_size = BKE_brush_size_get(scene, brush); - BLI_strncpy(cache->saved_active_brush_name, - brush->id.name + 2, - sizeof(cache->saved_active_brush_name)); + STRNCPY(cache->saved_active_brush_name, brush->id.name + 2); /* Switch to the smooth brush. */ brush = BKE_paint_toolslots_brush_get(paint, SCULPT_TOOL_SMOOTH); diff --git a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc index 0935e3d3535..278757a0b68 100644 --- a/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc +++ b/source/blender/editors/sculpt_paint/sculpt_filter_mesh.cc @@ -745,11 +745,10 @@ static void sculpt_mesh_update_status_bar(bContext *C, wmOperator *op) WM_modalkeymap_operator_items_to_string_buf( \ op->type, (_id), true, UI_MAX_SHORTCUT_STR, &available_len, &p) - BLI_snprintf(header, - sizeof(header), - TIP_("%s: Confirm, %s: Cancel"), - WM_MODALKEY(FILTER_MESH_MODAL_CONFIRM), - WM_MODALKEY(FILTER_MESH_MODAL_CANCEL)); + SNPRINTF(header, + TIP_("%s: Confirm, %s: Cancel"), + WM_MODALKEY(FILTER_MESH_MODAL_CONFIRM), + WM_MODALKEY(FILTER_MESH_MODAL_CANCEL)); #undef WM_MODALKEY diff --git a/source/blender/editors/sculpt_paint/sculpt_undo.cc b/source/blender/editors/sculpt_paint/sculpt_undo.cc index b42d8a71c31..9be8af9f37a 100644 --- a/source/blender/editors/sculpt_paint/sculpt_undo.cc +++ b/source/blender/editors/sculpt_paint/sculpt_undo.cc @@ -1255,7 +1255,7 @@ static SculptUndoNode *sculpt_undo_alloc_node_type(Object *object, SculptUndoTyp { const size_t alloc_size = sizeof(SculptUndoNode); SculptUndoNode *unode = static_cast(MEM_callocN(alloc_size, "SculptUndoNode")); - BLI_strncpy(unode->idname, object->id.name, sizeof(unode->idname)); + STRNCPY(unode->idname, object->id.name); unode->type = type; UndoSculpt *usculpt = sculpt_undo_get_nodes(); @@ -1550,7 +1550,7 @@ static SculptUndoNode *sculpt_undo_bmesh_push(Object *ob, PBVHNode *node, Sculpt if (unode == nullptr) { unode = MEM_cnew(__func__); - BLI_strncpy(unode->idname, ob->id.name, sizeof(unode->idname)); + STRNCPY(unode->idname, ob->id.name); unode->type = type; unode->applied = true; @@ -1709,7 +1709,7 @@ SculptUndoNode *SCULPT_undo_push_node(Object *ob, PBVHNode *node, SculptUndoType /* Store active shape key. */ if (ss->shapekey_active) { - BLI_strncpy(unode->shapeName, ss->shapekey_active->name, sizeof(ss->shapekey_active->name)); + STRNCPY(unode->shapeName, ss->shapekey_active->name); } else { unode->shapeName[0] = '\0'; @@ -1747,7 +1747,7 @@ static void sculpt_save_active_attribute(Object *ob, SculptAttrRef *attr) return; } attr->domain = meta_data->domain; - BLI_strncpy(attr->name, name, sizeof(attr->name)); + STRNCPY(attr->name, name); attr->type = meta_data->data_type; } diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 77520898501..4e417138b52 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -355,7 +355,7 @@ static int sound_mixdown_exec(bContext *C, wmOperator *op) specs.channels = scene_eval->r.ffcodecdata.audio_channels; specs.rate = scene_eval->r.ffcodecdata.audio_mixrate; - BLI_strncpy(filename, path, sizeof(filename)); + STRNCPY(filename, path); BLI_path_abs(filename, BKE_main_blendfile_path(bmain)); const double fps = (((double)scene_eval->r.frs_sec) / (double)scene_eval->r.frs_sec_base); diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 3046357c27e..a7914731805 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -200,7 +200,7 @@ static int file_browse_exec(bContext *C, wmOperator *op) const bool is_relative = RNA_boolean_get(op->ptr, "relative_path"); id = fbo->ptr.owner_id; - BLI_strncpy(path, str, FILE_MAX); + STRNCPY(path, str); BLI_path_abs(path, id ? ID_BLEND_PATH(bmain, id) : BKE_main_blendfile_path(bmain)); if (BLI_is_dir(path)) { diff --git a/source/blender/editors/space_buttons/buttons_texture.cc b/source/blender/editors/space_buttons/buttons_texture.cc index 516607c901f..79ce0359beb 100644 --- a/source/blender/editors/space_buttons/buttons_texture.cc +++ b/source/blender/editors/space_buttons/buttons_texture.cc @@ -507,14 +507,14 @@ static void template_texture_user_menu(bContext *C, uiLayout *layout, void * /*a Tex *tex = static_cast(texptr.data); if (tex) { - BLI_snprintf(name, UI_MAX_NAME_STR, " %s - %s", user->name, tex->id.name + 2); + SNPRINTF(name, " %s - %s", user->name, tex->id.name + 2); } else { - BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); + SNPRINTF(name, " %s", user->name); } } else { - BLI_snprintf(name, UI_MAX_NAME_STR, " %s", user->name); + SNPRINTF(name, " %s", user->name); } but = uiDefIconTextBut(block, @@ -565,7 +565,7 @@ void uiTemplateTextureUser(uiLayout *layout, bContext *C) } /* create button */ - BLI_strncpy(name, user->name, UI_MAX_NAME_STR); + STRNCPY(name, user->name); if (user->icon) { but = uiDefIconTextMenuBut(block, diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c index 9c793253095..bb1a4f39ccf 100644 --- a/source/blender/editors/space_buttons/space_buttons.c +++ b/source/blender/editors/space_buttons/space_buttons.c @@ -323,7 +323,7 @@ int ED_buttons_search_string_length(struct SpaceProperties *sbuts) void ED_buttons_search_string_set(SpaceProperties *sbuts, const char *value) { - BLI_strncpy(sbuts->runtime->search_string, value, sizeof(sbuts->runtime->search_string)); + STRNCPY(sbuts->runtime->search_string, value); } bool ED_buttons_tab_has_search_result(SpaceProperties *sbuts, const int index) diff --git a/source/blender/editors/space_clip/clip_buttons.cc b/source/blender/editors/space_clip/clip_buttons.cc index 36e003fdcef..6e9d213a107 100644 --- a/source/blender/editors/space_clip/clip_buttons.cc +++ b/source/blender/editors/space_clip/clip_buttons.cc @@ -841,10 +841,10 @@ void uiTemplateMovieclipInformation(uiLayout *layout, /* Display current frame number. */ int framenr = BKE_movieclip_remap_scene_to_clip_frame(clip, user->framenr); if (framenr <= clip->len) { - BLI_snprintf(str, sizeof(str), TIP_("Frame: %d / %d"), framenr, clip->len); + SNPRINTF(str, TIP_("Frame: %d / %d"), framenr, clip->len); } else { - BLI_snprintf(str, sizeof(str), TIP_("Frame: - / %d"), clip->len); + SNPRINTF(str, TIP_("Frame: - / %d"), clip->len); } uiItemL(col, str, ICON_NONE); @@ -861,7 +861,7 @@ void uiTemplateMovieclipInformation(uiLayout *layout, file = "-"; } - BLI_snprintf(str, sizeof(str), TIP_("File: %s"), file); + SNPRINTF(str, TIP_("File: %s"), file); uiItemL(col, str, ICON_NONE); } diff --git a/source/blender/editors/space_clip/clip_draw.cc b/source/blender/editors/space_clip/clip_draw.cc index cb9a93b064b..2b93db09e59 100644 --- a/source/blender/editors/space_clip/clip_draw.cc +++ b/source/blender/editors/space_clip/clip_draw.cc @@ -267,7 +267,7 @@ static void draw_movieclip_notes(SpaceClip *sc, ARegion *region) bool full_redraw = false; if (tracking->stats) { - BLI_strncpy(str, tracking->stats->message, sizeof(str)); + STRNCPY(str, tracking->stats->message); full_redraw = true; } else { @@ -1094,10 +1094,10 @@ static void draw_marker_texts(SpaceClip *sc, } if (state[0]) { - BLI_snprintf(str, sizeof(str), "%s: %s", track->name, state); + SNPRINTF(str, "%s: %s", track->name, state); } else { - BLI_strncpy(str, track->name, sizeof(str)); + STRNCPY(str, track->name); } BLF_position(fontid, pos[0], pos[1], 0.0f); @@ -1105,7 +1105,7 @@ static void draw_marker_texts(SpaceClip *sc, pos[1] -= fontsize; if (track->flag & TRACK_HAS_BUNDLE) { - BLI_snprintf(str, sizeof(str), "Average error: %.2f px", track->error); + SNPRINTF(str, "Average error: %.2f px", track->error); BLF_position(fontid, pos[0], pos[1], 0.0f); BLF_draw(fontid, str, sizeof(str)); pos[1] -= fontsize; diff --git a/source/blender/editors/space_clip/clip_ops.cc b/source/blender/editors/space_clip/clip_ops.cc index fcc234259f2..245c565229b 100644 --- a/source/blender/editors/space_clip/clip_ops.cc +++ b/source/blender/editors/space_clip/clip_ops.cc @@ -268,13 +268,13 @@ static int open_invoke(bContext *C, wmOperator *op, const wmEvent * /*event*/) } if (clip) { - BLI_strncpy(path, clip->filepath, sizeof(path)); + STRNCPY(path, clip->filepath); BLI_path_abs(path, CTX_data_main(C)->filepath); BLI_path_parent_dir(path); } else { - BLI_strncpy(path, U.textudir, sizeof(path)); + STRNCPY(path, U.textudir); } if (RNA_struct_property_is_set(op->ptr, "files")) { diff --git a/source/blender/editors/space_clip/tracking_ops_solve.cc b/source/blender/editors/space_clip/tracking_ops_solve.cc index 64379b8cf7a..65871a853b8 100644 --- a/source/blender/editors/space_clip/tracking_ops_solve.cc +++ b/source/blender/editors/space_clip/tracking_ops_solve.cc @@ -88,7 +88,7 @@ static void solve_camera_updatejob(void *scv) SolveCameraJob *scj = (SolveCameraJob *)scv; MovieTracking *tracking = &scj->clip->tracking; - BLI_strncpy(tracking->stats->message, scj->stats_message, sizeof(tracking->stats->message)); + STRNCPY(tracking->stats->message, scj->stats_message); } static void solve_camera_startjob(void *scv, bool *stop, bool *do_update, float *progress) @@ -213,9 +213,7 @@ static int solve_camera_invoke(bContext *C, wmOperator *op, const wmEvent * /*ev return OPERATOR_CANCELLED; } - BLI_strncpy(tracking->stats->message, - "Solving camera | Preparing solve", - sizeof(tracking->stats->message)); + STRNCPY(tracking->stats->message, "Solving camera | Preparing solve"); /* Hide reconstruction statistics from previous solve. */ reconstruction->flag &= ~TRACKING_RECONSTRUCTED; diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c index 0291bebe862..0c3eb0a68db 100644 --- a/source/blender/editors/space_console/space_console.c +++ b/source/blender/editors/space_console/space_console.c @@ -172,7 +172,7 @@ static bool path_drop_poll(bContext *UNUSED(C), wmDrag *drag, const wmEvent *UNU static void path_drop_copy(bContext *UNUSED(C), wmDrag *drag, wmDropBox *drop) { char pathname[FILE_MAX + 2]; - BLI_snprintf(pathname, sizeof(pathname), "\"%s\"", WM_drag_get_path(drag)); + SNPRINTF(pathname, "\"%s\"", WM_drag_get_path(drag)); RNA_string_set(drop->ptr, "text", pathname); } diff --git a/source/blender/editors/space_file/file_draw.cc b/source/blender/editors/space_file/file_draw.cc index 1202959b125..54b32b9a4e7 100644 --- a/source/blender/editors/space_file/file_draw.cc +++ b/source/blender/editors/space_file/file_draw.cc @@ -226,7 +226,7 @@ static void file_draw_string(int sx, const uiStyle *style = UI_style_get(); fs = style->widget; - BLI_strncpy(filename, string, FILE_MAXFILE); + STRNCPY(filename, string); UI_text_clip_middle_ex(&fs, filename, width, UI_ICON_SIZE, sizeof(filename), '\0'); /* no text clipping needed, UI_fontstyle_draw does it but is a bit too strict @@ -599,7 +599,7 @@ static void renamebutton_cb(bContext *C, void * /*arg1*/, char *oldname) FileSelectParams *params = ED_fileselect_get_active_params(sfile); BLI_path_join(orgname, sizeof(orgname), params->dir, oldname); - BLI_strncpy(filename, params->renamefile, sizeof(filename)); + STRNCPY(filename, params->renamefile); BLI_path_make_safe_filename(filename); BLI_path_join(newname, sizeof(newname), params->dir, filename); @@ -612,7 +612,7 @@ static void renamebutton_cb(bContext *C, void * /*arg1*/, char *oldname) } else { /* If rename is successful, scroll to newly renamed entry. */ - BLI_strncpy(params->renamefile, filename, sizeof(params->renamefile)); + STRNCPY(params->renamefile, filename); file_params_invoke_rename_postscroll(wm, win, sfile); } @@ -621,7 +621,7 @@ static void renamebutton_cb(bContext *C, void * /*arg1*/, char *oldname) } else { /* Renaming failed, reset the name for further renaming handling. */ - BLI_strncpy(params->renamefile, oldname, sizeof(params->renamefile)); + STRNCPY(params->renamefile, oldname); } ED_region_tag_redraw(region); @@ -813,13 +813,9 @@ static const char *filelist_get_details_column_string( nullptr, file->time, small_size, time, date, &is_today, &is_yesterday); if (is_today || is_yesterday) { - BLI_strncpy(date, is_today ? N_("Today") : N_("Yesterday"), sizeof(date)); + STRNCPY(date, is_today ? N_("Today") : N_("Yesterday")); } - BLI_snprintf(file->draw_data.datetime_str, - sizeof(file->draw_data.datetime_str), - "%s %s", - date, - time); + SNPRINTF(file->draw_data.datetime_str, "%s %s", date, time); } return file->draw_data.datetime_str; diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index da66f37accc..a91ceaeb853 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -198,7 +198,7 @@ static FileSelect file_select_do(bContext *C, int selected_idx, bool do_diropen) } } else if (file->redirection_path) { - BLI_strncpy(params->dir, file->redirection_path, sizeof(params->dir)); + STRNCPY(params->dir, file->redirection_path); BLI_path_abs(params->dir, BKE_main_blendfile_path(bmain)); BLI_path_normalize_dir(params->dir, sizeof(params->dir)); } @@ -1103,7 +1103,7 @@ static int bookmark_select_exec(bContext *C, wmOperator *op) char entry[256]; RNA_property_string_get(op->ptr, prop, entry); - BLI_strncpy(params->dir, entry, sizeof(params->dir)); + STRNCPY(params->dir, entry); BLI_path_abs(params->dir, BKE_main_blendfile_path(bmain)); BLI_path_normalize_dir(params->dir, sizeof(params->dir)); ED_file_change_dir(C); @@ -1715,7 +1715,7 @@ void file_sfile_filepath_set(SpaceFile *sfile, const char *filepath) BLI_assert(BLI_exists(filepath)); if (BLI_is_dir(filepath)) { - BLI_strncpy(params->dir, filepath, sizeof(params->dir)); + STRNCPY(params->dir, filepath); } else { if ((params->flag & FILE_DIRSEL_ONLY) == 0) { @@ -2645,7 +2645,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op) else { /* We assume we are able to generate a valid name! */ char org_path[FILE_MAX]; - BLI_strncpy(org_path, path, sizeof(org_path)); + STRNCPY(org_path, path); if (BLI_path_make_safe(path)) { BKE_reportf(op->reports, RPT_WARNING, @@ -2676,7 +2676,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op) BLI_assert_msg(params->rename_id == NULL, "File rename handling should immediately clear rename_id when done, " "because otherwise it will keep taking precedence over renamefile."); - BLI_strncpy(params->renamefile, dirname, FILE_MAXFILE); + STRNCPY(params->renamefile, dirname); rename_flag = FILE_PARAMS_RENAME_PENDING; } @@ -2687,7 +2687,7 @@ static int file_directory_new_exec(bContext *C, wmOperator *op) ED_fileselect_clear(wm, sfile); if (do_diropen) { - BLI_strncpy(params->dir, path, sizeof(params->dir)); + STRNCPY(params->dir, path); ED_file_change_dir(C); } @@ -2742,7 +2742,7 @@ static void file_expand_directory(bContext *C) } else if (params->dir[0] == '~') { char tmpstr[sizeof(params->dir) - 1]; - BLI_strncpy(tmpstr, params->dir + 1, sizeof(tmpstr)); + STRNCPY(tmpstr, params->dir + 1); BLI_path_join(params->dir, sizeof(params->dir), BKE_appdir_folder_default_or_root(), tmpstr); } @@ -2795,7 +2795,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN if (params) { char old_dir[sizeof(params->dir)]; - BLI_strncpy(old_dir, params->dir, sizeof(old_dir)); + STRNCPY(old_dir, params->dir); file_expand_directory(C); @@ -2806,7 +2806,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN if (BLI_is_file(params->dir)) { char path[sizeof(params->dir)]; - BLI_strncpy(path, params->dir, sizeof(path)); + STRNCPY(path, params->dir); BLI_path_split_dir_file( path, params->dir, sizeof(params->dir), params->file, sizeof(params->file)); } @@ -2814,9 +2814,9 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN if (group) { BLI_path_append(tdir, sizeof(tdir), group); } - BLI_strncpy(params->dir, tdir, sizeof(params->dir)); + STRNCPY(params->dir, tdir); if (name) { - BLI_strncpy(params->file, name, sizeof(params->file)); + STRNCPY(params->file, name); } else { params->file[0] = '\0'; @@ -2851,7 +2851,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN /* If we are 'inside' a blend library, we cannot do anything... */ if (lastdir && BKE_blendfile_library_path_explode(lastdir, tdir, NULL, NULL)) { - BLI_strncpy(params->dir, lastdir, sizeof(params->dir)); + STRNCPY(params->dir, lastdir); } else { /* if not, ask to create it and enter if confirmed */ @@ -2865,7 +2865,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN RNA_boolean_set(&ptr, "confirm", true); if (lastdir) { - BLI_strncpy(params->dir, lastdir, sizeof(params->dir)); + STRNCPY(params->dir, lastdir); } WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &ptr, NULL); @@ -2902,7 +2902,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg if (matches) { /* replace the pattern (or filename that the user typed in, * with the first selected file of the match */ - BLI_strncpy(params->file, matched_file, sizeof(params->file)); + STRNCPY(params->file, matched_file); WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } @@ -2914,7 +2914,7 @@ void file_filename_enter_handle(bContext *C, void *UNUSED(arg_unused), void *arg if (filelist_is_dir(sfile->files, filepath)) { BLI_path_abs(filepath, BKE_main_blendfile_path(bmain)); BLI_path_normalize_dir(filepath, sizeof(filepath)); - BLI_strncpy(params->dir, filepath, sizeof(params->dir)); + STRNCPY(params->dir, filepath); params->file[0] = '\0'; ED_file_change_dir(C); UI_textbutton_activate_but(C, but); @@ -3063,7 +3063,7 @@ static void file_rename_state_activate(SpaceFile *sfile, int file_idx, bool requ filelist_entry_select_index_set( sfile->files, file_idx, FILE_SEL_ADD, FILE_SEL_EDITING, CHECK_ALL); - BLI_strncpy(params->renamefile, file->relpath, FILE_MAXFILE); + STRNCPY(params->renamefile, file->relpath); /* We can skip the pending state, * as we can directly set FILE_SEL_EDITING on the expected entry here. */ params->rename_flag = FILE_PARAMS_RENAME_ACTIVE; diff --git a/source/blender/editors/space_file/file_panels.c b/source/blender/editors/space_file/file_panels.c index c896271e11c..8e065b677e3 100644 --- a/source/blender/editors/space_file/file_panels.c +++ b/source/blender/editors/space_file/file_panels.c @@ -55,7 +55,7 @@ static void file_panel_operator_header(const bContext *C, Panel *panel) SpaceFile *sfile = CTX_wm_space_file(C); wmOperator *op = sfile->op; - BLI_strncpy(panel->drawname, WM_operatortype_name(op->type, op->ptr), sizeof(panel->drawname)); + STRNCPY(panel->drawname, WM_operatortype_name(op->type, op->ptr)); } static void file_panel_operator(const bContext *C, Panel *panel) diff --git a/source/blender/editors/space_file/file_utils.c b/source/blender/editors/space_file/file_utils.c index 97c228a7795..ef9f7730e1c 100644 --- a/source/blender/editors/space_file/file_utils.c +++ b/source/blender/editors/space_file/file_utils.c @@ -35,7 +35,7 @@ void file_tile_boundbox(const ARegion *region, FileLayout *layout, const int fil void file_path_to_ui_path(const char *path, char *r_path, int max_size) { char tmp_path[PATH_MAX]; - BLI_strncpy(tmp_path, path, sizeof(tmp_path)); + STRNCPY(tmp_path, path); BLI_path_slash_rstrip(tmp_path); BLI_strncpy(r_path, BKE_blendfile_extension_check(tmp_path) ? tmp_path : path, max_size); } diff --git a/source/blender/editors/space_file/filelist.cc b/source/blender/editors/space_file/filelist.cc index 7c1e2c32d79..1013af8ac29 100644 --- a/source/blender/editors/space_file/filelist.cc +++ b/source/blender/editors/space_file/filelist.cc @@ -633,7 +633,7 @@ static bool is_hidden_dot_filename(const char *filename, const FileListInternEnt if (!hidden && sep) { char tmp_filename[FILE_MAX_LIBEXTRA]; - BLI_strncpy(tmp_filename, filename, sizeof(tmp_filename)); + STRNCPY(tmp_filename, filename); sep = tmp_filename + (sep - filename); while (sep) { /* This happens when a path contains 'ALTSEP', '\' on Unix for e.g. @@ -1001,8 +1001,7 @@ void filelist_setfilter_options(FileList *filelist, update = true; } if (!STREQ(filelist->filter_data.filter_glob, filter_glob)) { - BLI_strncpy( - filelist->filter_data.filter_glob, filter_glob, sizeof(filelist->filter_data.filter_glob)); + STRNCPY(filelist->filter_data.filter_glob, filter_glob); update = true; } if (BLI_strcmp_ignore_pad(filelist->filter_data.filter_search, filter_search, '*') != 0) { @@ -2001,7 +2000,7 @@ void filelist_setdir(FileList *filelist, char *r_dir) UNUSED_VARS_NDEBUG(is_valid_path); if (!STREQ(filelist->filelist.root, r_dir)) { - BLI_strncpy(filelist->filelist.root, r_dir, sizeof(filelist->filelist.root)); + STRNCPY(filelist->filelist.root, r_dir); filelist->flags |= FL_FORCE_RESET; } } @@ -2933,7 +2932,7 @@ static int groupname_to_code(const char *group) BLI_assert(group); - BLI_strncpy(buf, group, sizeof(buf)); + STRNCPY(buf, group); lslash = (char *)BLI_path_slash_rfind(buf); if (lslash) { lslash[0] = '\0'; @@ -3486,7 +3485,7 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) } else { char relname[FILE_MAX + (MAX_ID_NAME - 2) + 3]; - BLI_snprintf(relname, sizeof(relname), "%s | %s", id->lib->filepath, id->name + 2); + SNPRINTF(relname, "%s | %s", id->lib->filepath, id->name + 2); files->entry->relpath = BLI_strdup(relname); } // files->type |= S_IFREG; @@ -3512,16 +3511,16 @@ static void filelist_readjob_main_recursive(Main *bmain, FileList *filelist) } # if 0 if (id->lib && fake) { - BLI_snprintf(files->extra, sizeof(files->entry->extra), "LF %d", id->us); + SNPRINTF(files->extra, "LF %d", id->us); } else if (id->lib) { - BLI_snprintf(files->extra, sizeof(files->entry->extra), "L %d", id->us); + SNPRINTF(files->extra, "L %d", id->us); } else if (fake) { - BLI_snprintf(files->extra, sizeof(files->entry->extra), "F %d", id->us); + SNPRINTF(files->extra, "F %d", id->us); } else { - BLI_snprintf(files->extra, sizeof(files->entry->extra), " %d", id->us); + SNPRINTF(files->extra, " %d", id->us); } # endif @@ -3624,8 +3623,8 @@ static void filelist_readjob_recursive_dir_add_items(const bool do_lib, td_dir = static_cast(BLI_stack_push_r(todo_dirs)); td_dir->level = 1; - BLI_strncpy(dir, filelist->filelist.root, sizeof(dir)); - BLI_strncpy(filter_glob, filelist->filter_data.filter_glob, sizeof(filter_glob)); + STRNCPY(dir, filelist->filelist.root); + STRNCPY(filter_glob, filelist->filter_data.filter_glob); BLI_path_abs(dir, job_params->main_filepath); BLI_path_normalize_dir(dir, sizeof(dir)); @@ -3658,13 +3657,13 @@ static void filelist_readjob_recursive_dir_add_items(const bool do_lib, * name inside .blend file, which can have slashes and backslashes! See #46827. * Note that in the end, this means we 'cache' valid relative subdir once here, * this is actually better. */ - BLI_strncpy(rel_subdir, subdir, sizeof(rel_subdir)); + STRNCPY(rel_subdir, subdir); BLI_path_abs(rel_subdir, root); BLI_path_normalize_dir(rel_subdir, sizeof(rel_subdir)); BLI_path_rel(rel_subdir, root); /* Update the current relative base path within the filelist root. */ - BLI_strncpy(job_params->cur_relbase, rel_subdir, sizeof(job_params->cur_relbase)); + STRNCPY(job_params->cur_relbase, rel_subdir); bool is_lib = false; if (do_lib) { @@ -3984,7 +3983,7 @@ static void filelist_readjob_all_asset_library(FileListReadJob *job_params, /* Override library info to read this library. */ job_params->load_asset_library = &nested_library; - BLI_strncpy(filelist->filelist.root, root_path.c_str(), sizeof(filelist->filelist.root)); + STRNCPY(filelist->filelist.root, root_path.c_str()); float progress_this = 0.0f; filelist_readjob_recursive_dir_add_items( @@ -4139,7 +4138,7 @@ void filelist_readjob_start(FileList *filelist, const int space_notifier, const flrj = MEM_cnew(__func__); flrj->filelist = filelist; flrj->current_main = bmain; - BLI_strncpy(flrj->main_filepath, BKE_main_blendfile_path(bmain), sizeof(flrj->main_filepath)); + STRNCPY(flrj->main_filepath, BKE_main_blendfile_path(bmain)); if ((filelist->flags & FL_FORCE_RESET_MAIN_FILES) && !(filelist->flags & FL_FORCE_RESET)) { flrj->only_main_data = true; } diff --git a/source/blender/editors/space_file/filesel.cc b/source/blender/editors/space_file/filesel.cc index 98e1b2160ec..8f5e481b330 100644 --- a/source/blender/editors/space_file/filesel.cc +++ b/source/blender/editors/space_file/filesel.cc @@ -82,7 +82,7 @@ static void fileselect_initialize_params_common(SpaceFile *sfile, FileSelectPara else { const char *doc_path = BKE_appdir_folder_default(); if (doc_path) { - BLI_strncpy(params->dir, doc_path, sizeof(params->dir)); + STRNCPY(params->dir, doc_path); } } } @@ -183,7 +183,7 @@ static FileSelectParams *fileselect_ensure_updated_file_params(SpaceFile *sfile) char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); if (params->type == FILE_LOADLIB) { - BLI_strncpy(params->dir, filepath, sizeof(params->dir)); + STRNCPY(params->dir, filepath); params->file[0] = '\0'; } else { @@ -277,7 +277,7 @@ static FileSelectParams *fileselect_ensure_updated_file_params(SpaceFile *sfile) char *tmp = RNA_property_string_get_alloc( op->ptr, prop, params->filter_glob, sizeof(params->filter_glob), nullptr); if (tmp != params->filter_glob) { - BLI_strncpy(params->filter_glob, tmp, sizeof(params->filter_glob)); + STRNCPY(params->filter_glob, tmp); MEM_freeN(tmp); /* Fix stupid things that truncating might have generated, @@ -431,9 +431,7 @@ static void fileselect_refresh_asset_params(FileAssetSelectParams *asset_params) switch (eAssetLibraryType(library->type)) { case ASSET_LIBRARY_ESSENTIALS: - BLI_strncpy(base_params->dir, - blender::asset_system::essentials_directory_path().c_str(), - sizeof(base_params->dir)); + STRNCPY(base_params->dir, blender::asset_system::essentials_directory_path().c_str()); base_params->type = FILE_ASSET_LIBRARY; break; case ASSET_LIBRARY_ALL: @@ -446,7 +444,7 @@ static void fileselect_refresh_asset_params(FileAssetSelectParams *asset_params) break; case ASSET_LIBRARY_CUSTOM: BLI_assert(user_library); - BLI_strncpy(base_params->dir, user_library->path, sizeof(base_params->dir)); + STRNCPY(base_params->dir, user_library->path); base_params->type = FILE_ASSET_LIBRARY; break; } @@ -724,7 +722,7 @@ void fileselect_file_set(struct bContext *C, SpaceFile *sfile, const int index) const struct FileDirEntry *file = filelist_file(sfile->files, index); if (file && file->relpath && file->relpath[0] && !(file->typeflag & FILE_TYPE_DIR)) { FileSelectParams *params = ED_fileselect_get_active_params(sfile); - BLI_strncpy(params->file, file->relpath, FILE_MAXFILE); + STRNCPY(params->file, file->relpath); if (sfile->op) { /* Update the filepath properties of the operator. */ Main *bmain = CTX_data_main(C); @@ -1154,7 +1152,7 @@ void ED_file_change_dir_ex(bContext *C, ScrArea *area) params->active_file = -1; if (!filelist_is_dir(sfile->files, params->dir)) { - BLI_strncpy(params->dir, filelist_dir(sfile->files), sizeof(params->dir)); + STRNCPY(params->dir, filelist_dir(sfile->files)); /* could return but just refresh the current dir */ } filelist_setdir(sfile->files, params->dir); @@ -1464,10 +1462,10 @@ void ED_fileselect_ensure_default_filepath(struct bContext *C, const char *blendfile_path = BKE_main_blendfile_path(bmain); if (blendfile_path[0] == '\0') { - BLI_strncpy(filepath, DATA_("untitled"), sizeof(filepath)); + STRNCPY(filepath, DATA_("untitled")); } else { - BLI_strncpy(filepath, blendfile_path, sizeof(filepath)); + STRNCPY(filepath, blendfile_path); } BLI_path_extension_replace(filepath, sizeof(filepath), extension); diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c index 823777b66ed..05e4ee2e3bf 100644 --- a/source/blender/editors/space_file/fsmenu.c +++ b/source/blender/editors/space_file/fsmenu.c @@ -316,7 +316,7 @@ void ED_fsmenu_entry_set_name(struct FSMenuEntry *fsentry, const char *name) fsentry->name[0] = '\0'; } else { - BLI_strncpy(fsentry->name, name, sizeof(fsentry->name)); + STRNCPY(fsentry->name, name); } BLI_path_join(tmp_name, @@ -457,7 +457,7 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu, } if (name && name[0]) { - BLI_strncpy(fsm_iter->name, name, sizeof(fsm_iter->name)); + STRNCPY(fsm_iter->name, name); } else { fsm_iter->name[0] = '\0'; @@ -590,7 +590,7 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filepath) if (line[len - 1] == '\n') { line[len - 1] = '\0'; } - BLI_strncpy(name, line + 1, sizeof(name)); + STRNCPY(name, line + 1); } } else { @@ -791,7 +791,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) const char *home = BLI_getenv("HOME"); if (home) { # define FS_MACOS_PATH(path, name, icon) \ - BLI_snprintf(line, sizeof(line), path, home); \ + SNPRINTF(line, path, home); \ fsmenu_insert_entry(fsmenu, FS_CATEGORY_OTHER, line, name, icon, FS_INSERT_LAST); FS_MACOS_PATH("%s/", NULL, ICON_HOME) @@ -1007,7 +1007,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks) const char *label_test = label + 6; label = *label_test ? label_test : dirname; } - BLI_snprintf(line, sizeof(line), "%s%s", filepath, dirname); + SNPRINTF(line, "%s%s", filepath, dirname); fsmenu_insert_entry( fsmenu, FS_CATEGORY_SYSTEM, line, label, ICON_NETWORK_DRIVE, FS_INSERT_SORTED); found = 1; diff --git a/source/blender/editors/space_graph/graph_buttons.c b/source/blender/editors/space_graph/graph_buttons.c index 5356a81d3e1..2d6faa0381c 100644 --- a/source/blender/editors/space_graph/graph_buttons.c +++ b/source/blender/editors/space_graph/graph_buttons.c @@ -1027,7 +1027,7 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, /* value of driver */ row = uiLayoutRow(col, true); uiItemL(row, IFACE_("Driver Value:"), ICON_NONE); - BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval); + SNPRINTF(valBuf, "%.3f", driver->curval); uiItemL(row, valBuf, ICON_NONE); } @@ -1259,11 +1259,10 @@ static void graph_draw_driver_settings_panel(uiLayout *layout, DTAR_TRANSCHAN_ROTW) && dvar->targets[0].rotation_mode != DTAR_ROTMODE_QUATERNION)) { - BLI_snprintf( - valBuf, sizeof(valBuf), "%.3f (%4.1f°)", dvar->curval, RAD2DEGF(dvar->curval)); + SNPRINTF(valBuf, "%.3f (%4.1f°)", dvar->curval, RAD2DEGF(dvar->curval)); } else { - BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval); + SNPRINTF(valBuf, "%.3f", dvar->curval); } uiItemL(row, valBuf, ICON_NONE); diff --git a/source/blender/editors/space_graph/graph_slider_ops.c b/source/blender/editors/space_graph/graph_slider_ops.c index 1b20ddf30f3..f984d3bbe98 100644 --- a/source/blender/editors/space_graph/graph_slider_ops.c +++ b/source/blender/editors/space_graph/graph_slider_ops.c @@ -131,10 +131,10 @@ static void common_draw_status_header(bContext *C, tGraphSliderOp *gso, const ch outputNumInput(&gso->num, str_ofs, &gso->scene->unit); - BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, str_ofs); + SNPRINTF(status_str, "%s: %s", mode_str, str_ofs); } else { - BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, slider_string); + SNPRINTF(status_str, "%s: %s", mode_str, slider_string); } ED_workspace_status_text(C, status_str); @@ -430,10 +430,10 @@ static void decimate_draw_status(bContext *C, tGraphSliderOp *gso) outputNumInput(&gso->num, str_ofs, &gso->scene->unit); - BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, str_ofs); + SNPRINTF(status_str, "%s: %s", mode_str, str_ofs); } else { - BLI_snprintf(status_str, sizeof(status_str), "%s: %s", mode_str, slider_string); + SNPRINTF(status_str, "%s: %s", mode_str, slider_string); } ED_workspace_status_text(C, status_str); diff --git a/source/blender/editors/space_image/image_buttons.c b/source/blender/editors/space_image/image_buttons.c index 0fe4b13ebef..4bddbf66f5e 100644 --- a/source/blender/editors/space_image/image_buttons.c +++ b/source/blender/editors/space_image/image_buttons.c @@ -75,10 +75,10 @@ static void ui_imageuser_slot_menu(bContext *UNUSED(C), uiLayout *layout, void * LISTBASE_FOREACH_INDEX (RenderSlot *, slot, &image->renderslots, slot_id) { char str[64]; if (slot->name[0] != '\0') { - BLI_strncpy(str, slot->name, sizeof(str)); + STRNCPY(str, slot->name); } else { - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), slot_id + 1); + SNPRINTF(str, IFACE_("Slot %d"), slot_id + 1); } uiDefButS(block, UI_BTYPE_BUT_MENU, @@ -587,10 +587,10 @@ static void uiblock_layer_pass_buttons(uiLayout *layout, char str[64]; RenderSlot *slot = BKE_image_get_renderslot(image, *render_slot); if (slot && slot->name[0] != '\0') { - BLI_strncpy(str, slot->name, sizeof(str)); + STRNCPY(str, slot->name); } else { - BLI_snprintf(str, sizeof(str), IFACE_("Slot %d"), *render_slot + 1); + SNPRINTF(str, IFACE_("Slot %d"), *render_slot + 1); } rnd_pt = ui_imageuser_data_copy(&rnd_pt_local); @@ -1249,17 +1249,17 @@ void uiTemplateImageInfo(uiLayout *layout, bContext *C, Image *ima, ImageUser *i if (duration > 0) { /* Movie duration */ - BLI_snprintf(str, MAX_IMAGE_INFO_LEN, TIP_("Frame %d / %d"), framenr, duration); + SNPRINTF(str, TIP_("Frame %d / %d"), framenr, duration); } else if (ima->source == IMA_SRC_SEQUENCE && ibuf) { /* Image sequence frame number + filename */ const char *filename = BLI_path_slash_rfind(ibuf->filepath); filename = (filename == NULL) ? ibuf->filepath : filename + 1; - BLI_snprintf(str, MAX_IMAGE_INFO_LEN, TIP_("Frame %d: %s"), framenr, filename); + SNPRINTF(str, TIP_("Frame %d: %s"), framenr, filename); } else { /* Frame number */ - BLI_snprintf(str, MAX_IMAGE_INFO_LEN, TIP_("Frame %d"), framenr); + SNPRINTF(str, TIP_("Frame %d"), framenr); } uiItemL(col, str, ICON_NONE); diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index df307c38028..3dd8959a14f 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1608,7 +1608,7 @@ static int image_file_browse_invoke(bContext *C, wmOperator *op, const wmEvent * } char filepath[FILE_MAX]; - BLI_strncpy(filepath, ima->filepath, sizeof(filepath)); + STRNCPY(filepath, ima->filepath); /* Shift+Click to open the file, Alt+Click to browse a folder in the OS's browser. */ if (event->modifier & (KM_SHIFT | KM_ALT)) { @@ -1745,7 +1745,7 @@ static int image_replace_exec(bContext *C, wmOperator *op) RNA_string_get(op->ptr, "filepath", str); /* we can't do much if the str is longer than FILE_MAX :/ */ - BLI_strncpy(sima->image->filepath, str, sizeof(sima->image->filepath)); + STRNCPY(sima->image->filepath, str); if (sima->image->source == IMA_SRC_GENERATED) { sima->image->source = IMA_SRC_FILE; @@ -1852,7 +1852,7 @@ static bool save_image_op( WM_cursor_wait(false); /* Remember file path for next save. */ - BLI_strncpy(G.ima, opts->filepath, sizeof(G.ima)); + STRNCPY(G.ima, opts->filepath); WM_main_add_notifier(NC_IMAGE | NA_EDITED, ima); diff --git a/source/blender/editors/space_image/image_sequence.c b/source/blender/editors/space_image/image_sequence.c index 5bf71c6a4cc..f6e2ea5e432 100644 --- a/source/blender/editors/space_image/image_sequence.c +++ b/source/blender/editors/space_image/image_sequence.c @@ -74,8 +74,8 @@ static void image_sequence_get_frame_ranges(wmOperator *op, ListBase *ranges) BLI_path_join(range->filepath, sizeof(range->filepath), dir, filename); BLI_addtail(ranges, range); - BLI_strncpy(base_head, head, sizeof(base_head)); - BLI_strncpy(base_tail, tail, sizeof(base_tail)); + STRNCPY(base_head, head); + STRNCPY(base_tail, tail); range_first_frame = frame->framenr; } @@ -169,7 +169,7 @@ ListBase ED_image_filesel_detect_sequences(Main *bmain, wmOperator *op, const bo ImageFrameRange *range = MEM_callocN(sizeof(*range), __func__); BLI_addtail(&ranges, range); - BLI_strncpy(range->filepath, filepath, FILE_MAX); + STRNCPY(range->filepath, filepath); image_detect_frame_range(range, detect_udim); } diff --git a/source/blender/editors/space_image/image_undo.cc b/source/blender/editors/space_image/image_undo.cc index 90cb5695602..13f13e4dcda 100644 --- a/source/blender/editors/space_image/image_undo.cc +++ b/source/blender/editors/space_image/image_undo.cc @@ -471,7 +471,7 @@ static UndoImageBuf *ubuf_from_image_no_tiles(Image *image, const ImBuf *ibuf) ubuf->tiles = static_cast( MEM_callocN(sizeof(*ubuf->tiles) * ubuf->tiles_len, __func__)); - BLI_strncpy(ubuf->ibuf_filepath, ibuf->filepath, sizeof(ubuf->ibuf_filepath)); + STRNCPY(ubuf->ibuf_filepath, ibuf->filepath); ubuf->image_state.source = image->source; ubuf->image_state.use_float = ibuf->rect_float != nullptr; diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index f62149523ad..d20975de302 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -249,10 +249,10 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( } if (count == 1) { - BLI_strncpy(title, IFACE_("Unpack 1 File"), sizeof(title)); + STRNCPY(title, IFACE_("Unpack 1 File")); } else { - BLI_snprintf(title, sizeof(title), IFACE_("Unpack %d Files"), count); + SNPRINTF(title, IFACE_("Unpack %d Files"), count); } pup = UI_popup_menu_begin(C, title, ICON_NONE); diff --git a/source/blender/editors/space_info/info_stats.cc b/source/blender/editors/space_info/info_stats.cc index f62af1191f3..b9510699c88 100644 --- a/source/blender/editors/space_info/info_stats.cc +++ b/source/blender/editors/space_info/info_stats.cc @@ -705,7 +705,7 @@ static void stats_row(int col1, *y -= height; BLF_draw_default(col1, *y, 0.0f, key, 128); char values[128]; - BLI_snprintf(values, sizeof(values), (value2) ? "%s / %s" : "%s", value1, value2); + SNPRINTF(values, (value2) ? "%s / %s" : "%s", value1, value2); BLF_draw_default(col2, *y, 0.0f, values, sizeof(values)); } diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c index 47b51657831..fd653a06c48 100644 --- a/source/blender/editors/space_nla/nla_draw.c +++ b/source/blender/editors/space_nla/nla_draw.c @@ -648,7 +648,7 @@ static void nla_draw_strip_text(AnimData *adt, str_len = BLI_snprintf_rlen(str, sizeof(str), "Temp-Meta"); } else { - str_len = BLI_strncpy_rlen(str, strip->name, sizeof(str)); + str_len = STRNCPY_RLEN(str, strip->name); } /* set text color - if colors (see above) are light, draw black text, otherwise draw white */ @@ -701,11 +701,11 @@ static void nla_draw_strip_frames_text( * while also preserving some accuracy, since we do use floats */ /* start frame */ - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.1f", strip->start); + numstr_len = SNPRINTF_RLEN(numstr, "%.1f", strip->start); UI_view2d_text_cache_add(v2d, strip->start - 1.0f, ymaxc + ytol, numstr, numstr_len, col); /* end frame */ - numstr_len = BLI_snprintf_rlen(numstr, sizeof(numstr), "%.1f", strip->end); + numstr_len = SNPRINTF_RLEN(numstr, "%.1f", strip->end); UI_view2d_text_cache_add(v2d, strip->end, ymaxc + ytol, numstr, numstr_len, col); } diff --git a/source/blender/editors/space_node/add_menu_assets.cc b/source/blender/editors/space_node/add_menu_assets.cc index a66d7df93fc..ba14abcdd92 100644 --- a/source/blender/editors/space_node/add_menu_assets.cc +++ b/source/blender/editors/space_node/add_menu_assets.cc @@ -306,7 +306,7 @@ static void add_root_catalogs_draw(const bContext *C, Menu *menu) MenuType add_catalog_assets_menu_type() { MenuType type{}; - BLI_strncpy(type.idname, "NODE_MT_node_add_catalog_assets", sizeof(type.idname)); + STRNCPY(type.idname, "NODE_MT_node_add_catalog_assets"); type.poll = node_add_menu_poll; type.draw = node_add_catalog_assets_draw; type.listener = node_add_menu_assets_listen_fn; @@ -316,7 +316,7 @@ MenuType add_catalog_assets_menu_type() MenuType add_root_catalogs_menu_type() { MenuType type{}; - BLI_strncpy(type.idname, "NODE_MT_node_add_root_catalogs", sizeof(type.idname)); + STRNCPY(type.idname, "NODE_MT_node_add_root_catalogs"); type.poll = node_add_menu_poll; type.draw = add_root_catalogs_draw; type.listener = node_add_menu_assets_listen_fn; diff --git a/source/blender/editors/space_node/add_node_search.cc b/source/blender/editors/space_node/add_node_search.cc index afacad6f247..8420fa45bcf 100644 --- a/source/blender/editors/space_node/add_node_search.cc +++ b/source/blender/editors/space_node/add_node_search.cc @@ -243,8 +243,7 @@ static ARegion *add_node_search_tooltip_fn( uiSearchItemTooltipData tooltip_data{}; - BLI_strncpy( - tooltip_data.description, TIP_(item->description.c_str()), sizeof(tooltip_data.description)); + STRNCPY(tooltip_data.description, TIP_(item->description.c_str())); return UI_tooltip_create_from_search_item_generic(C, region, item_rect, &tooltip_data); } diff --git a/source/blender/editors/space_node/drawnode.cc b/source/blender/editors/space_node/drawnode.cc index 18e7bf921f5..fbeb7dc0abc 100644 --- a/source/blender/editors/space_node/drawnode.cc +++ b/source/blender/editors/space_node/drawnode.cc @@ -331,7 +331,7 @@ static void node_buts_image_user(uiLayout *layout, char numstr[32]; const int framenr = BKE_image_user_frame_get(iuser, scene->r.cfra, nullptr); - BLI_snprintf(numstr, sizeof(numstr), IFACE_("Frame: %d"), framenr); + SNPRINTF(numstr, IFACE_("Frame: %d"), framenr); uiItemL(layout, numstr, ICON_NONE); } diff --git a/source/blender/editors/space_node/node_draw.cc b/source/blender/editors/space_node/node_draw.cc index 590fc592a30..f9dec9d2a80 100644 --- a/source/blender/editors/space_node/node_draw.cc +++ b/source/blender/editors/space_node/node_draw.cc @@ -956,12 +956,11 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn case GEO_COMPONENT_TYPE_MESH: { const geo_log::GeometryInfoLog::MeshInfo &mesh_info = *value_log.mesh_info; char line[256]; - BLI_snprintf(line, - sizeof(line), - TIP_("\u2022 Mesh: %s vertices, %s edges, %s faces"), - to_string(mesh_info.verts_num).c_str(), - to_string(mesh_info.edges_num).c_str(), - to_string(mesh_info.faces_num).c_str()); + SNPRINTF(line, + TIP_("\u2022 Mesh: %s vertices, %s edges, %s faces"), + to_string(mesh_info.verts_num).c_str(), + to_string(mesh_info.edges_num).c_str(), + to_string(mesh_info.faces_num).c_str()); ss << line; break; } @@ -969,31 +968,27 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn const geo_log::GeometryInfoLog::PointCloudInfo &pointcloud_info = *value_log.pointcloud_info; char line[256]; - BLI_snprintf(line, - sizeof(line), - TIP_("\u2022 Point Cloud: %s points"), - to_string(pointcloud_info.points_num).c_str()); + SNPRINTF(line, + TIP_("\u2022 Point Cloud: %s points"), + to_string(pointcloud_info.points_num).c_str()); ss << line; break; } case GEO_COMPONENT_TYPE_CURVE: { const geo_log::GeometryInfoLog::CurveInfo &curve_info = *value_log.curve_info; char line[256]; - BLI_snprintf(line, - sizeof(line), - TIP_("\u2022 Curve: %s points, %s splines"), - to_string(curve_info.points_num).c_str(), - to_string(curve_info.splines_num).c_str()); + SNPRINTF(line, + TIP_("\u2022 Curve: %s points, %s splines"), + to_string(curve_info.points_num).c_str(), + to_string(curve_info.splines_num).c_str()); ss << line; break; } case GEO_COMPONENT_TYPE_INSTANCES: { const geo_log::GeometryInfoLog::InstancesInfo &instances_info = *value_log.instances_info; char line[256]; - BLI_snprintf(line, - sizeof(line), - TIP_("\u2022 Instances: %s"), - to_string(instances_info.instances_num).c_str()); + SNPRINTF( + line, TIP_("\u2022 Instances: %s"), to_string(instances_info.instances_num).c_str()); ss << line; break; } @@ -1005,11 +1000,10 @@ static void create_inspection_string_for_geometry_info(const geo_log::GeometryIn if (value_log.edit_data_info.has_value()) { const geo_log::GeometryInfoLog::EditDataInfo &edit_info = *value_log.edit_data_info; char line[256]; - BLI_snprintf(line, - sizeof(line), - TIP_("\u2022 Edit Curves: %s, %s"), - edit_info.has_deformed_positions ? TIP_("positions") : TIP_("no positions"), - edit_info.has_deform_matrices ? TIP_("matrices") : TIP_("no matrices")); + SNPRINTF(line, + TIP_("\u2022 Edit Curves: %s, %s"), + edit_info.has_deformed_positions ? TIP_("positions") : TIP_("no positions"), + edit_info.has_deform_matrices ? TIP_("matrices") : TIP_("no matrices")); ss << line; } break; @@ -2993,7 +2987,7 @@ static void reroute_node_draw( if (node.label[0] != '\0') { /* Draw title (node label). */ char showname[128]; /* 128 used below */ - BLI_strncpy(showname, node.label, sizeof(showname)); + STRNCPY(showname, node.label); const short width = 512; const int x = BLI_rctf_cent_x(&node.runtime->totr) - (width / 2); const int y = node.runtime->totr.ymax; @@ -3459,7 +3453,7 @@ void node_draw_space(const bContext &C, ARegion ®ion) snode.id; if (name_id && UNLIKELY(!STREQ(path->display_name, name_id->name + 2))) { - BLI_strncpy(path->display_name, name_id->name + 2, sizeof(path->display_name)); + STRNCPY(path->display_name, name_id->name + 2); } /* Current View2D center, will be set temporarily for parent node trees. */ diff --git a/source/blender/editors/space_node/node_edit.cc b/source/blender/editors/space_node/node_edit.cc index 9d0decae542..9f83339b716 100644 --- a/source/blender/editors/space_node/node_edit.cc +++ b/source/blender/editors/space_node/node_edit.cc @@ -460,7 +460,7 @@ void ED_node_tree_propagate_change(const bContext *C, Main *bmain, bNodeTree *ro void ED_node_set_tree_type(SpaceNode *snode, bNodeTreeType *typeinfo) { if (typeinfo) { - BLI_strncpy(snode->tree_idname, typeinfo->idname, sizeof(snode->tree_idname)); + STRNCPY(snode->tree_idname, typeinfo->idname); } else { snode->tree_idname[0] = '\0'; @@ -507,7 +507,7 @@ void ED_node_shader_default(const bContext *C, ID *id) ma->nodetree = ntreeCopyTree(bmain, ma_default->nodetree); ma->nodetree->owner_id = &ma->id; for (bNode *node_iter : ma->nodetree->all_nodes()) { - BLI_strncpy(node_iter->name, DATA_(node_iter->name), NODE_MAXSTR); + STRNCPY(node_iter->name, DATA_(node_iter->name)); nodeUniqueName(ma->nodetree, node_iter); } diff --git a/source/blender/editors/space_node/node_geometry_attribute_search.cc b/source/blender/editors/space_node/node_geometry_attribute_search.cc index 01f08e1f969..84ce812bb14 100644 --- a/source/blender/editors/space_node/node_geometry_attribute_search.cc +++ b/source/blender/editors/space_node/node_geometry_attribute_search.cc @@ -245,7 +245,7 @@ void node_geometry_add_attribute_search_button(const bContext & /*C*/, const bNodeSocket &socket = *static_cast(socket_ptr.data); AttributeSearchData *data = MEM_new(__func__); data->node_id = node.identifier; - BLI_strncpy(data->socket_identifier, socket.identifier, sizeof(data->socket_identifier)); + STRNCPY(data->socket_identifier, socket.identifier); UI_but_func_search_set_results_are_suggestions(but, true); UI_but_func_search_set_sep_string(but, UI_MENU_ARROW_SEP); diff --git a/source/blender/editors/space_node/node_templates.cc b/source/blender/editors/space_node/node_templates.cc index a9dae4612f5..77dbd17d385 100644 --- a/source/blender/editors/space_node/node_templates.cc +++ b/source/blender/editors/space_node/node_templates.cc @@ -600,11 +600,11 @@ static void ui_node_menu_column(NodeLinkArg *arg, int nclass, const char *cname) ""); } - BLI_snprintf(name, UI_MAX_NAME_STR, "%s", IFACE_(item.socket_name)); + SNPRINTF(name, "%s", IFACE_(item.socket_name)); icon = ICON_BLANK1; } else { - BLI_strncpy(name, IFACE_(item.node_name), UI_MAX_NAME_STR); + STRNCPY(name, IFACE_(item.node_name)); icon = ICON_NONE; } diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc index 3185e723177..ace5c43a36e 100644 --- a/source/blender/editors/space_node/space_node.cc +++ b/source/blender/editors/space_node/space_node.cc @@ -64,7 +64,7 @@ void ED_node_tree_start(SpaceNode *snode, bNodeTree *ntree, ID *id, ID *from) copy_v2_v2(path->view_center, ntree->view_center); if (id) { - BLI_strncpy(path->display_name, id->name + 2, sizeof(path->display_name)); + STRNCPY(path->display_name, id->name + 2); } BLI_addtail(&snode->treepath, path); @@ -100,8 +100,8 @@ void ED_node_tree_push(SpaceNode *snode, bNodeTree *ntree, bNode *gnode) path->parent_key = NODE_INSTANCE_KEY_BASE; } - BLI_strncpy(path->node_name, gnode->name, sizeof(path->node_name)); - BLI_strncpy(path->display_name, gnode->name, sizeof(path->display_name)); + STRNCPY(path->node_name, gnode->name); + STRNCPY(path->display_name, gnode->name); } else { path->parent_key = NODE_INSTANCE_KEY_BASE; diff --git a/source/blender/editors/space_outliner/outliner_draw.cc b/source/blender/editors/space_outliner/outliner_draw.cc index 4ff90cf011f..83f2bc83098 100644 --- a/source/blender/editors/space_outliner/outliner_draw.cc +++ b/source/blender/editors/space_outliner/outliner_draw.cc @@ -719,7 +719,7 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) BKE_library_filepath_set(bmain, lib, lib->filepath); - BLI_strncpy(expanded, lib->filepath, sizeof(expanded)); + STRNCPY(expanded, lib->filepath); BLI_path_abs(expanded, BKE_main_blendfile_path(bmain)); if (!BLI_exists(expanded)) { BKE_reportf(CTX_wm_reports(C), @@ -763,8 +763,8 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) char newname[sizeof(ebone->name)]; /* restore bone name */ - BLI_strncpy(newname, ebone->name, sizeof(ebone->name)); - BLI_strncpy(ebone->name, oldname, sizeof(ebone->name)); + STRNCPY(newname, ebone->name); + STRNCPY(ebone->name, oldname); ED_armature_bone_rename(bmain, arm, oldname, newname); WM_msg_publish_rna_prop(mbus, &arm->id, ebone, EditBone, name); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, nullptr); @@ -785,8 +785,8 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) tree_element_activate(C, &tvc, te, OL_SETSEL_NORMAL, true); /* restore bone name */ - BLI_strncpy(newname, bone->name, sizeof(bone->name)); - BLI_strncpy(bone->name, oldname, sizeof(bone->name)); + STRNCPY(newname, bone->name); + STRNCPY(bone->name, oldname); ED_armature_bone_rename(bmain, arm, oldname, newname); WM_msg_publish_rna_prop(mbus, &arm->id, bone, Bone, name); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, nullptr); @@ -808,8 +808,8 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) BLI_assert(ob->type == OB_ARMATURE); /* restore bone name */ - BLI_strncpy(newname, pchan->name, sizeof(pchan->name)); - BLI_strncpy(pchan->name, oldname, sizeof(pchan->name)); + STRNCPY(newname, pchan->name); + STRNCPY(pchan->name, oldname); ED_armature_bone_rename(bmain, static_cast(ob->data), oldname, newname); WM_msg_publish_rna_prop(mbus, &arm->id, pchan->bone, Bone, name); WM_event_add_notifier(C, NC_OBJECT | ND_POSE, nullptr); @@ -855,8 +855,8 @@ static void namebutton_fn(bContext *C, void *tsep, char *oldname) /* Restore old name. */ char newname[sizeof(view_layer->name)]; - BLI_strncpy(newname, view_layer->name, sizeof(view_layer->name)); - BLI_strncpy(view_layer->name, oldname, sizeof(view_layer->name)); + STRNCPY(newname, view_layer->name); + STRNCPY(view_layer->name, oldname); /* Rename, preserving animation and compositing data. */ BKE_view_layer_rename(bmain, scene, view_layer, newname); diff --git a/source/blender/editors/space_outliner/outliner_tools.cc b/source/blender/editors/space_outliner/outliner_tools.cc index 3d92e7f8d1c..37c32aa46b8 100644 --- a/source/blender/editors/space_outliner/outliner_tools.cc +++ b/source/blender/editors/space_outliner/outliner_tools.cc @@ -730,7 +730,7 @@ static void merged_element_search_fn_recursive( if (tree_element_id_type_to_index(te) == type && tselem_type == tselem->type) { if (BLI_strcasestr(te->name, str)) { - BLI_strncpy(name, te->name, 64); + STRNCPY(name, te->name); iconid = tree_element_get_icon(tselem, te).icon; diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index e2d839db436..ccba832c877 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -179,7 +179,7 @@ static void sequencer_generic_invoke_path__internal(bContext *C, if (last_seq && last_seq->strip && SEQ_HAS_PATH(last_seq)) { Main *bmain = CTX_data_main(C); char path[FILE_MAX]; - BLI_strncpy(path, last_seq->strip->dir, sizeof(path)); + STRNCPY(path, last_seq->strip->dir); BLI_path_abs(path, BKE_main_blendfile_path(bmain)); RNA_string_set(op->ptr, identifier, path); } @@ -266,7 +266,7 @@ static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wm if ((prop = RNA_struct_find_property(op->ptr, "filepath"))) { RNA_property_string_get(op->ptr, prop, load_data->path); - BLI_strncpy(load_data->name, BLI_path_basename(load_data->path), sizeof(load_data->name)); + STRNCPY(load_data->name, BLI_path_basename(load_data->path)); } else if ((prop = RNA_struct_find_property(op->ptr, "directory"))) { char *directory = RNA_string_get_alloc(op->ptr, "directory", NULL, 0, NULL); @@ -274,7 +274,7 @@ static void load_data_init_from_operator(SeqLoadData *load_data, bContext *C, wm if ((prop = RNA_struct_find_property(op->ptr, "files"))) { RNA_PROP_BEGIN (op->ptr, itemptr, prop) { char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0, NULL); - BLI_strncpy(load_data->name, filename, sizeof(load_data->name)); + STRNCPY(load_data->name, filename); BLI_path_join(load_data->path, sizeof(load_data->path), directory, filename); MEM_freeN(filename); break; @@ -840,7 +840,7 @@ static void sequencer_add_movie_multiple_strips(bContext *C, RNA_string_get(op->ptr, "directory", dir_only); RNA_string_get(&itemptr, "name", file_only); BLI_path_join(load_data->path, sizeof(load_data->path), dir_only, file_only); - BLI_strncpy(load_data->name, file_only, sizeof(load_data->name)); + STRNCPY(load_data->name, file_only); Sequence *seq_movie = NULL; Sequence *seq_sound = NULL; @@ -1089,7 +1089,7 @@ static void sequencer_add_sound_multiple_strips(bContext *C, RNA_string_get(op->ptr, "directory", dir_only); RNA_string_get(&itemptr, "name", file_only); BLI_path_join(load_data->path, sizeof(load_data->path), dir_only, file_only); - BLI_strncpy(load_data->name, file_only, sizeof(load_data->name)); + STRNCPY(load_data->name, file_only); Sequence *seq = SEQ_add_sound_strip(bmain, scene, ed->seqbasep, load_data); if (seq == NULL) { BKE_reportf(op->reports, RPT_ERROR, "File '%s' could not be loaded", load_data->path); @@ -1252,9 +1252,9 @@ void sequencer_image_seq_reserve_frames( BLI_path_frame_strip(filename, ext, sizeof(ext)); for (int i = 0; i < len; i++, se++) { - BLI_strncpy(filename_stripped, filename, sizeof(filename_stripped)); + STRNCPY(filename_stripped, filename); BLI_path_frame(filename_stripped, sizeof(filename_stripped), minframe + i, numdigits); - BLI_snprintf(se->name, sizeof(se->name), "%s%s", filename_stripped, ext); + SNPRINTF(se->name, "%s%s", filename_stripped, ext); } MEM_freeN(filename); diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c index 0cadb1b3a39..6bc10e6641f 100644 --- a/source/blender/editors/space_sequencer/sequencer_draw.c +++ b/source/blender/editors/space_sequencer/sequencer_draw.c @@ -703,11 +703,10 @@ static void draw_seq_handle(const Scene *scene, BLF_set_default(); /* Calculate if strip is wide enough for showing the labels. */ - numstr_len = BLI_snprintf_rlen(numstr, - sizeof(numstr), - "%d%d", - SEQ_time_left_handle_frame_get(scene, seq), - SEQ_time_right_handle_frame_get(scene, seq)); + numstr_len = SNPRINTF_RLEN(numstr, + "%d%d", + SEQ_time_left_handle_frame_get(scene, seq), + SEQ_time_right_handle_frame_get(scene, seq)); float tot_width = BLF_width(fontid, numstr, numstr_len); if ((x2 - x1) / pixelx > 20 + tot_width) { @@ -715,14 +714,12 @@ static void draw_seq_handle(const Scene *scene, float text_margin = 1.2f * handsize_clamped; if (direction == SEQ_LEFTHANDLE) { - numstr_len = BLI_snprintf_rlen( - numstr, sizeof(numstr), "%d", SEQ_time_left_handle_frame_get(scene, seq)); + numstr_len = SNPRINTF_RLEN(numstr, "%d", SEQ_time_left_handle_frame_get(scene, seq)); x1 += text_margin; y1 += 0.09f; } else { - numstr_len = BLI_snprintf_rlen( - numstr, sizeof(numstr), "%d", SEQ_time_right_handle_frame_get(scene, seq) - 1); + numstr_len = SNPRINTF_RLEN(numstr, "%d", SEQ_time_right_handle_frame_get(scene, seq) - 1); x1 = x2 - (text_margin + pixelx * BLF_width(fontid, numstr, numstr_len)); y1 += 0.09f; } diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index db05e572911..1aecc6f4e4c 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -687,10 +687,10 @@ static void sequencer_slip_update_header(Scene *scene, ScrArea *area, SlipData * if (hasNumInput(&data->num_input)) { char num_str[NUM_STR_REP_LEN]; outputNumInput(&data->num_input, num_str, &scene->unit); - BLI_snprintf(msg, sizeof(msg), TIP_("Slip offset: %s"), num_str); + SNPRINTF(msg, TIP_("Slip offset: %s"), num_str); } else { - BLI_snprintf(msg, sizeof(msg), TIP_("Slip offset: %d"), offset); + SNPRINTF(msg, TIP_("Slip offset: %d"), offset); } } @@ -1879,7 +1879,7 @@ static int sequencer_separate_images_exec(bContext *C, wmOperator *op) /* Note this assume all elements (images) have the same dimension, * since we only copy the name here. */ se_new = MEM_reallocN(strip_new->stripdata, sizeof(*se_new)); - BLI_strncpy(se_new->name, se->name, sizeof(se_new->name)); + STRNCPY(se_new->name, se->name); strip_new->stripdata = se_new; if (step > 1) { @@ -2920,7 +2920,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) * but look into changing after 2.60. */ BLI_path_rel(directory, BKE_main_blendfile_path(bmain)); } - BLI_strncpy(seq->strip->dir, directory, sizeof(seq->strip->dir)); + STRNCPY(seq->strip->dir, directory); if (seq->strip->stripdata) { MEM_freeN(seq->strip->stripdata); @@ -2933,7 +2933,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) else { RNA_BEGIN (op->ptr, itemptr, "files") { char *filename = RNA_string_get_alloc(&itemptr, "name", NULL, 0, NULL); - BLI_strncpy(se->name, filename, sizeof(se->name)); + STRNCPY(se->name, filename); MEM_freeN(filename); se++; } @@ -2961,7 +2961,7 @@ static int sequencer_change_path_exec(bContext *C, wmOperator *op) } char filepath[FILE_MAX]; RNA_string_get(op->ptr, "filepath", filepath); - BLI_strncpy(sound->filepath, filepath, sizeof(sound->filepath)); + STRNCPY(sound->filepath, filepath); BKE_sound_load(bmain, sound); } else { diff --git a/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc b/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc index ece8557782e..26c5232bc97 100644 --- a/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc +++ b/source/blender/editors/space_sequencer/sequencer_gizmo_retime_type.cc @@ -388,8 +388,7 @@ static void retime_speed_text_draw(const bContext *C, const float speed = SEQ_retiming_handle_speed_get(seq, next_handle); char label_str[20]; - const size_t label_len = BLI_snprintf_rlen( - label_str, sizeof(label_str), "%d%%", round_fl_to_int(speed * 100.0f)); + const size_t label_len = SNPRINTF_RLEN(label_str, "%d%%", round_fl_to_int(speed * 100.0f)); const float width = pixels_to_view_width(C, BLF_width(BLF_default(), label_str, label_len)); diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c index f43ab6ed56b..27a88301307 100644 --- a/source/blender/editors/space_text/text_draw.c +++ b/source/blender/editors/space_text/text_draw.c @@ -1697,11 +1697,7 @@ void draw_text_main(SpaceText *st, ARegion *region) if (st->showlinenrs && !wrap_skip) { /* Draw line number. */ UI_FontThemeColor(tdc.font_id, (tmp == text->sell) ? TH_HILITE : TH_LINENUMBERS); - BLI_snprintf(linenr, - sizeof(linenr), - "%*d", - st->runtime.line_number_display_digits, - i + linecount + 1); + SNPRINTF(linenr, "%*d", st->runtime.line_number_display_digits, i + linecount + 1); text_font_draw(&tdc, TXT_NUMCOL_PAD * st->runtime.cwidth_px, y, linenr); /* Change back to text color. */ UI_FontThemeColor(tdc.font_id, TH_TEXT); diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 390a83314f0..a44789e442f 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -607,7 +607,7 @@ static void txt_write_file(Main *bmain, Text *text, ReportList *reports) BLI_stat_t st; char filepath[FILE_MAX]; - BLI_strncpy(filepath, text->filepath, FILE_MAX); + STRNCPY(filepath, text->filepath); BLI_path_abs(filepath, BKE_main_blendfile_path(bmain)); /* Check if file write permission is ok. */ @@ -3769,7 +3769,7 @@ static int text_find_set_selected_exec(bContext *C, wmOperator *op) char *tmp; tmp = txt_sel_to_buf(text, NULL); - BLI_strncpy(st->findstr, tmp, ST_MAX_FIND_STR); + STRNCPY(st->findstr, tmp); MEM_freeN(tmp); if (!st->findstr[0]) { @@ -3804,7 +3804,7 @@ static int text_replace_set_selected_exec(bContext *C, wmOperator *UNUSED(op)) char *tmp; tmp = txt_sel_to_buf(text, NULL); - BLI_strncpy(st->replacestr, tmp, ST_MAX_FIND_STR); + STRNCPY(st->replacestr, tmp); MEM_freeN(tmp); return OPERATOR_FINISHED; diff --git a/source/blender/editors/space_view3d/view3d_draw.cc b/source/blender/editors/space_view3d/view3d_draw.cc index c2d718641d9..8d5f6cb200d 100644 --- a/source/blender/editors/space_view3d/view3d_draw.cc +++ b/source/blender/editors/space_view3d/view3d_draw.cc @@ -1453,7 +1453,7 @@ static void draw_grid_unit_name( char numstr[32] = ""; UI_FontThemeColor(font_id, TH_TEXT_HI); if (v3d->grid != 1.0f) { - BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid); + SNPRINTF(numstr, "%s x %.4g", grid_unit, v3d->grid); } *yoffset -= VIEW3D_OVERLAY_LINEHEIGHT; @@ -2578,11 +2578,11 @@ void ED_scene_draw_fps(const Scene *scene, int xoffset, int *yoffset) /* Is this more than half a frame behind? */ if (fps + 0.5f < float(FPS)) { UI_FontThemeColor(font_id, TH_REDALERT); - BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %.2f"), fps); + SNPRINTF(printable, IFACE_("fps: %.2f"), fps); } else { UI_FontThemeColor(font_id, TH_TEXT_HI); - BLI_snprintf(printable, sizeof(printable), IFACE_("fps: %i"), int(fps + 0.5f)); + SNPRINTF(printable, IFACE_("fps: %i"), int(fps + 0.5f)); } BLF_enable(font_id, BLF_SHADOW); diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 74ba05dd837..dfa316304ad 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -125,13 +125,13 @@ static int view_lock_to_active_exec(bContext *C, wmOperator *UNUSED(op)) Object *obact_eval = DEG_get_evaluated_object(depsgraph, obact); bPoseChannel *pcham_act = BKE_pose_channel_active_if_layer_visible(obact_eval); if (pcham_act) { - BLI_strncpy(v3d->ob_center_bone, pcham_act->name, sizeof(v3d->ob_center_bone)); + STRNCPY(v3d->ob_center_bone, pcham_act->name); } } else { EditBone *ebone_act = ((bArmature *)obact->data)->act_edbone; if (ebone_act) { - BLI_strncpy(v3d->ob_center_bone, ebone_act->name, sizeof(v3d->ob_center_bone)); + STRNCPY(v3d->ob_center_bone, ebone_act->name); } } } diff --git a/source/blender/editors/transform/transform_constraints.c b/source/blender/editors/transform/transform_constraints.c index 3b94adc3bb8..c040230e800 100644 --- a/source/blender/editors/transform/transform_constraints.c +++ b/source/blender/editors/transform/transform_constraints.c @@ -706,7 +706,7 @@ void setUserConstraint(TransInfo *t, int mode, const char text_[]) char text[256]; const short orientation = transform_orientation_or_default(t); const char *spacename = transform_orientations_spacename_get(t, orientation); - BLI_snprintf(text, sizeof(text), text_, spacename); + SNPRINTF(text, text_, spacename); switch (orientation) { case V3D_ORIENT_LOCAL: @@ -1072,11 +1072,11 @@ static void setNearestAxis2d(TransInfo *t) /* no correction needed... just use whichever one is lower */ if (abs(t->mval[0] - t->con.imval[0]) < abs(t->mval[1] - t->con.imval[1])) { t->con.mode |= CON_AXIS1; - BLI_strncpy(t->con.text, TIP_(" along Y axis"), sizeof(t->con.text)); + STRNCPY(t->con.text, TIP_(" along Y axis")); } else { t->con.mode |= CON_AXIS0; - BLI_strncpy(t->con.text, TIP_(" along X axis"), sizeof(t->con.text)); + STRNCPY(t->con.text, TIP_(" along X axis")); } } @@ -1130,31 +1130,31 @@ static void setNearestAxis3d(TransInfo *t) if (len[0] <= len[1] && len[0] <= len[2]) { if (t->modifiers & MOD_CONSTRAINT_SELECT_PLANE) { t->con.mode |= (CON_AXIS1 | CON_AXIS2); - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" locking %s X axis"), t->spacename); + SNPRINTF(t->con.text, TIP_(" locking %s X axis"), t->spacename); } else { t->con.mode |= CON_AXIS0; - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s X axis"), t->spacename); + SNPRINTF(t->con.text, TIP_(" along %s X axis"), t->spacename); } } else if (len[1] <= len[0] && len[1] <= len[2]) { if (t->modifiers & MOD_CONSTRAINT_SELECT_PLANE) { t->con.mode |= (CON_AXIS0 | CON_AXIS2); - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" locking %s Y axis"), t->spacename); + SNPRINTF(t->con.text, TIP_(" locking %s Y axis"), t->spacename); } else { t->con.mode |= CON_AXIS1; - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s Y axis"), t->spacename); + SNPRINTF(t->con.text, TIP_(" along %s Y axis"), t->spacename); } } else if (len[2] <= len[1] && len[2] <= len[0]) { if (t->modifiers & MOD_CONSTRAINT_SELECT_PLANE) { t->con.mode |= (CON_AXIS0 | CON_AXIS1); - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" locking %s Z axis"), t->spacename); + SNPRINTF(t->con.text, TIP_(" locking %s Z axis"), t->spacename); } else { t->con.mode |= CON_AXIS2; - BLI_snprintf(t->con.text, sizeof(t->con.text), TIP_(" along %s Z axis"), t->spacename); + SNPRINTF(t->con.text, TIP_(" along %s Z axis"), t->spacename); } } } diff --git a/source/blender/editors/transform/transform_generics.c b/source/blender/editors/transform/transform_generics.c index f7238eac67e..a90865f14d3 100644 --- a/source/blender/editors/transform/transform_generics.c +++ b/source/blender/editors/transform/transform_generics.c @@ -1327,7 +1327,7 @@ void calculatePropRatio(TransInfo *t) } if (pet_id) { - BLI_strncpy(t->proptext, IFACE_(pet_id), sizeof(t->proptext)); + STRNCPY(t->proptext, IFACE_(pet_id)); } } else { diff --git a/source/blender/editors/transform/transform_mode_baketime.c b/source/blender/editors/transform/transform_mode_baketime.c index 293df9a7135..03fe54cb3d2 100644 --- a/source/blender/editors/transform/transform_mode_baketime.c +++ b/source/blender/editors/transform/transform_mode_baketime.c @@ -62,19 +62,19 @@ static void applyBakeTime(TransInfo *t, const int mval[2]) outputNumInput(&(t->num), c, &t->scene->unit); if (time >= 0.0f) { - BLI_snprintf(str, sizeof(str), TIP_("Time: +%s %s"), c, t->proptext); + SNPRINTF(str, TIP_("Time: +%s %s"), c, t->proptext); } else { - BLI_snprintf(str, sizeof(str), TIP_("Time: %s %s"), c, t->proptext); + SNPRINTF(str, TIP_("Time: %s %s"), c, t->proptext); } } else { /* default header print */ if (time >= 0.0f) { - BLI_snprintf(str, sizeof(str), TIP_("Time: +%.3f %s"), time, t->proptext); + SNPRINTF(str, TIP_("Time: +%.3f %s"), time, t->proptext); } else { - BLI_snprintf(str, sizeof(str), TIP_("Time: %.3f %s"), time, t->proptext); + SNPRINTF(str, TIP_("Time: %.3f %s"), time, t->proptext); } } diff --git a/source/blender/editors/transform/transform_mode_bend.c b/source/blender/editors/transform/transform_mode_bend.c index 0f51d667112..b9587d289d6 100644 --- a/source/blender/editors/transform/transform_mode_bend.c +++ b/source/blender/editors/transform/transform_mode_bend.c @@ -224,21 +224,19 @@ static void Bend(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, - sizeof(str), - TIP_("Bend Angle: %s Radius: %s Alt, Clamp %s"), - &c[0], - &c[NUM_STR_REP_LEN], - WM_bool_as_string(is_clamp)); + SNPRINTF(str, + TIP_("Bend Angle: %s Radius: %s Alt, Clamp %s"), + &c[0], + &c[NUM_STR_REP_LEN], + WM_bool_as_string(is_clamp)); } else { /* default header print */ - BLI_snprintf(str, - sizeof(str), - TIP_("Bend Angle: %.3f Radius: %.4f, Alt, Clamp %s"), - RAD2DEGF(values.angle), - values.scale * bend_data->warp_init_dist, - WM_bool_as_string(is_clamp)); + SNPRINTF(str, + TIP_("Bend Angle: %.3f Radius: %.4f, Alt, Clamp %s"), + RAD2DEGF(values.angle), + values.scale * bend_data->warp_init_dist, + WM_bool_as_string(is_clamp)); } values.angle *= -1.0f; diff --git a/source/blender/editors/transform/transform_mode_boneenvelope.c b/source/blender/editors/transform/transform_mode_boneenvelope.c index 80467dc35cb..2e622ae4f60 100644 --- a/source/blender/editors/transform/transform_mode_boneenvelope.c +++ b/source/blender/editors/transform/transform_mode_boneenvelope.c @@ -48,10 +48,10 @@ static void applyBoneEnvelope(TransInfo *t, const int UNUSED(mval[2])) char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Envelope: %s"), c); + SNPRINTF(str, TIP_("Envelope: %s"), c); } else { - BLI_snprintf(str, sizeof(str), TIP_("Envelope: %3f"), ratio); + SNPRINTF(str, TIP_("Envelope: %3f"), ratio); } FOREACH_TRANS_DATA_CONTAINER (t, tc) { diff --git a/source/blender/editors/transform/transform_mode_boneroll.c b/source/blender/editors/transform/transform_mode_boneroll.c index 96d967e2247..eb5a772c824 100644 --- a/source/blender/editors/transform/transform_mode_boneroll.c +++ b/source/blender/editors/transform/transform_mode_boneroll.c @@ -49,10 +49,10 @@ static void applyBoneRoll(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Roll: %s"), &c[0]); + SNPRINTF(str, TIP_("Roll: %s"), &c[0]); } else { - BLI_snprintf(str, sizeof(str), TIP_("Roll: %.2f"), RAD2DEGF(final)); + SNPRINTF(str, TIP_("Roll: %.2f"), RAD2DEGF(final)); } /* set roll values */ diff --git a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c index ce411ec25b6..5706669870b 100644 --- a/source/blender/editors/transform/transform_mode_curveshrinkfatten.c +++ b/source/blender/editors/transform/transform_mode_curveshrinkfatten.c @@ -49,10 +49,10 @@ static void applyCurveShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Shrink/Fatten: %s"), c); + SNPRINTF(str, TIP_("Shrink/Fatten: %s"), c); } else { - BLI_snprintf(str, sizeof(str), TIP_("Shrink/Fatten: %3f"), ratio); + SNPRINTF(str, TIP_("Shrink/Fatten: %3f"), ratio); } FOREACH_TRANS_DATA_CONTAINER (t, tc) { diff --git a/source/blender/editors/transform/transform_mode_customdata.c b/source/blender/editors/transform/transform_mode_customdata.c index fb4ee2484bc..2b16bea1226 100644 --- a/source/blender/editors/transform/transform_mode_customdata.c +++ b/source/blender/editors/transform/transform_mode_customdata.c @@ -93,19 +93,19 @@ static void apply_value_impl(TransInfo *t, const char *value_name) outputNumInput(&(t->num), c, &t->scene->unit); if (value >= 0.0f) { - BLI_snprintf(str, sizeof(str), "%s: +%s %s", value_name, c, t->proptext); + SNPRINTF(str, "%s: +%s %s", value_name, c, t->proptext); } else { - BLI_snprintf(str, sizeof(str), "%s: %s %s", value_name, c, t->proptext); + SNPRINTF(str, "%s: %s %s", value_name, c, t->proptext); } } else { /* default header print */ if (value >= 0.0f) { - BLI_snprintf(str, sizeof(str), "%s: +%.3f %s", value_name, value, t->proptext); + SNPRINTF(str, "%s: +%.3f %s", value_name, value, t->proptext); } else { - BLI_snprintf(str, sizeof(str), "%s: %.3f %s", value_name, value, t->proptext); + SNPRINTF(str, "%s: %.3f %s", value_name, value, t->proptext); } } diff --git a/source/blender/editors/transform/transform_mode_gpopacity.c b/source/blender/editors/transform/transform_mode_gpopacity.c index 4ee3c56e2f1..f3d8a4b1608 100644 --- a/source/blender/editors/transform/transform_mode_gpopacity.c +++ b/source/blender/editors/transform/transform_mode_gpopacity.c @@ -50,10 +50,10 @@ static void applyGPOpacity(TransInfo *t, const int UNUSED(mval[2])) char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Opacity: %s"), c); + SNPRINTF(str, TIP_("Opacity: %s"), c); } else { - BLI_snprintf(str, sizeof(str), TIP_("Opacity: %3f"), ratio); + SNPRINTF(str, TIP_("Opacity: %3f"), ratio); } bool recalc = false; diff --git a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c index e1a8f719ef6..9f77a4c0b09 100644 --- a/source/blender/editors/transform/transform_mode_gpshrinkfatten.c +++ b/source/blender/editors/transform/transform_mode_gpshrinkfatten.c @@ -50,10 +50,10 @@ static void applyGPShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Shrink/Fatten: %s"), c); + SNPRINTF(str, TIP_("Shrink/Fatten: %s"), c); } else { - BLI_snprintf(str, sizeof(str), TIP_("Shrink/Fatten: %3f"), ratio); + SNPRINTF(str, TIP_("Shrink/Fatten: %3f"), ratio); } bool recalc = false; diff --git a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c index 9e743f96f53..e56a3ddd2f4 100644 --- a/source/blender/editors/transform/transform_mode_maskshrinkfatten.c +++ b/source/blender/editors/transform/transform_mode_maskshrinkfatten.c @@ -49,10 +49,10 @@ static void applyMaskShrinkFatten(TransInfo *t, const int UNUSED(mval[2])) char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Feather Shrink/Fatten: %s"), c); + SNPRINTF(str, TIP_("Feather Shrink/Fatten: %s"), c); } else { - BLI_snprintf(str, sizeof(str), TIP_("Feather Shrink/Fatten: %3f"), ratio); + SNPRINTF(str, TIP_("Feather Shrink/Fatten: %3f"), ratio); } /* detect if no points have feather yet */ diff --git a/source/blender/editors/transform/transform_mode_mirror.c b/source/blender/editors/transform/transform_mode_mirror.c index 67fe3bddbae..02ae841d14c 100644 --- a/source/blender/editors/transform/transform_mode_mirror.c +++ b/source/blender/editors/transform/transform_mode_mirror.c @@ -175,7 +175,7 @@ static void applyMirror(TransInfo *t, const int UNUSED(mval[2])) special_axis = bitscan_forward_i(special_axis_bitmap); } - BLI_snprintf(str, sizeof(str), TIP_("Mirror%s"), t->con.text); + SNPRINTF(str, TIP_("Mirror%s"), t->con.text); FOREACH_TRANS_DATA_CONTAINER (t, tc) { TransData *td = tc->data; diff --git a/source/blender/editors/transform/transform_mode_push_pull.c b/source/blender/editors/transform/transform_mode_push_pull.c index b7806b3519e..330b3b8bb99 100644 --- a/source/blender/editors/transform/transform_mode_push_pull.c +++ b/source/blender/editors/transform/transform_mode_push_pull.c @@ -122,12 +122,11 @@ static void applyPushPull(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Push/Pull: %s%s %s"), c, t->con.text, t->proptext); + SNPRINTF(str, TIP_("Push/Pull: %s%s %s"), c, t->con.text, t->proptext); } else { /* default header print */ - BLI_snprintf( - str, sizeof(str), TIP_("Push/Pull: %.4f%s %s"), distance, t->con.text, t->proptext); + SNPRINTF(str, TIP_("Push/Pull: %.4f%s %s"), distance, t->con.text, t->proptext); } if (t->con.applyRot && t->con.mode & CON_APPLY) { diff --git a/source/blender/editors/transform/transform_mode_shear.c b/source/blender/editors/transform/transform_mode_shear.c index b9e0716fcec..f56d741b1cf 100644 --- a/source/blender/editors/transform/transform_mode_shear.c +++ b/source/blender/editors/transform/transform_mode_shear.c @@ -309,15 +309,11 @@ static void apply_shear(TransInfo *t, const int UNUSED(mval[2])) if (hasNumInput(&t->num)) { char c[NUM_STR_REP_LEN]; outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Shear: %s %s"), c, t->proptext); + SNPRINTF(str, TIP_("Shear: %s %s"), c, t->proptext); } else { /* default header print */ - BLI_snprintf(str, - sizeof(str), - TIP_("Shear: %.3f %s (Press X or Y to set shear axis)"), - value, - t->proptext); + SNPRINTF(str, TIP_("Shear: %.3f %s (Press X or Y to set shear axis)"), value, t->proptext); } ED_area_status_text(t->area, str); diff --git a/source/blender/editors/transform/transform_mode_tilt.c b/source/blender/editors/transform/transform_mode_tilt.c index 881ec760ae9..cd3f738fb86 100644 --- a/source/blender/editors/transform/transform_mode_tilt.c +++ b/source/blender/editors/transform/transform_mode_tilt.c @@ -49,13 +49,13 @@ static void applyTilt(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("Tilt: %s° %s"), &c[0], t->proptext); + SNPRINTF(str, TIP_("Tilt: %s° %s"), &c[0], t->proptext); /* XXX For some reason, this seems needed for this op, else RNA prop is not updated... :/ */ t->values_final[0] = final; } else { - BLI_snprintf(str, sizeof(str), TIP_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext); + SNPRINTF(str, TIP_("Tilt: %.2f° %s"), RAD2DEGF(final), t->proptext); } FOREACH_TRANS_DATA_CONTAINER (t, tc) { diff --git a/source/blender/editors/transform/transform_mode_tosphere.c b/source/blender/editors/transform/transform_mode_tosphere.c index 58890e7a67c..191149a461b 100644 --- a/source/blender/editors/transform/transform_mode_tosphere.c +++ b/source/blender/editors/transform/transform_mode_tosphere.c @@ -194,11 +194,11 @@ static void applyToSphere(TransInfo *t, const int UNUSED(mval[2])) outputNumInput(&(t->num), c, &t->scene->unit); - BLI_snprintf(str, sizeof(str), TIP_("To Sphere: %s %s"), c, t->proptext); + SNPRINTF(str, TIP_("To Sphere: %s %s"), c, t->proptext); } else { /* default header print */ - BLI_snprintf(str, sizeof(str), TIP_("To Sphere: %.4f %s"), ratio, t->proptext); + SNPRINTF(str, TIP_("To Sphere: %.4f %s"), ratio, t->proptext); } const struct ToSphereInfo *to_sphere_info = t->custom.mode.data; diff --git a/source/blender/editors/transform/transform_orientations.c b/source/blender/editors/transform/transform_orientations.c index 34c63b34d8d..c3a916b418d 100644 --- a/source/blender/editors/transform/transform_orientations.c +++ b/source/blender/editors/transform/transform_orientations.c @@ -477,7 +477,7 @@ TransformOrientation *addMatrixSpace(bContext *C, ts = findOrientationName(transform_orientations, name); } else { - BLI_strncpy(name_unique, name, sizeof(name_unique)); + STRNCPY(name_unique, name); uniqueOrientationName(transform_orientations, name_unique); name = name_unique; } @@ -486,7 +486,7 @@ TransformOrientation *addMatrixSpace(bContext *C, if (ts == NULL) { ts = MEM_callocN(sizeof(TransformOrientation), "UserTransSpace from matrix"); BLI_addtail(transform_orientations, ts); - BLI_strncpy(ts->name, name, sizeof(ts->name)); + STRNCPY(ts->name, name); } /* copy matrix into transform space */ @@ -800,7 +800,7 @@ void transform_orientations_current_set(TransInfo *t, const short orient_index) const short orientation = t->orient[orient_index].type; const char *spacename = transform_orientations_spacename_get(t, orientation); - BLI_strncpy(t->spacename, spacename, sizeof(t->spacename)); + STRNCPY(t->spacename, spacename); copy_m3_m3(t->spacemtx, t->orient[orient_index].matrix); invert_m3_m3_safe_ortho(t->spacemtx_inv, t->spacemtx); t->orient_curr = orient_index; diff --git a/source/blender/editors/util/ed_draw.c b/source/blender/editors/util/ed_draw.c index 70bfc97ad3a..f51bc6f0023 100644 --- a/source/blender/editors/util/ed_draw.c +++ b/source/blender/editors/util/ed_draw.c @@ -338,7 +338,7 @@ static void slider_draw(const struct bContext *UNUSED(C), ARegion *region, void }; UI_draw_roundbox_3ub_alpha(&handle_rect, true, 1, color_handle, 255); - BLI_snprintf(percentage_string, sizeof(percentage_string), "%.0f%%", slider->factor * 100); + SNPRINTF(percentage_string, "%.0f%%", slider->factor * 100); /* Draw percentage string. */ float percentage_string_pixel_size[2]; diff --git a/source/blender/editors/util/ed_util.cc b/source/blender/editors/util/ed_util.cc index 44fa3500252..f19aea3f1f2 100644 --- a/source/blender/editors/util/ed_util.cc +++ b/source/blender/editors/util/ed_util.cc @@ -384,14 +384,14 @@ void unpack_menu(bContext *C, if (!STREQ(abs_name, local_name)) { switch (BKE_packedfile_compare_to_file(blendfile_path, local_name, pf)) { case PF_CMP_NOFILE: - BLI_snprintf(line, sizeof(line), TIP_("Create %s"), local_name); + SNPRINTF(line, TIP_("Create %s"), local_name); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_CMP_EQUAL: - BLI_snprintf(line, sizeof(line), TIP_("Use %s (identical)"), local_name); + SNPRINTF(line, TIP_("Use %s (identical)"), local_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); @@ -399,13 +399,13 @@ void unpack_menu(bContext *C, break; case PF_CMP_DIFFERS: - BLI_snprintf(line, sizeof(line), TIP_("Use %s (differs)"), local_name); + SNPRINTF(line, TIP_("Use %s (differs)"), local_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_LOCAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL); RNA_string_set(&props_ptr, "id", id_name); - BLI_snprintf(line, sizeof(line), TIP_("Overwrite %s"), local_name); + SNPRINTF(line, TIP_("Overwrite %s"), local_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_LOCAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL); @@ -417,27 +417,27 @@ void unpack_menu(bContext *C, switch (BKE_packedfile_compare_to_file(blendfile_path, abs_name, pf)) { case PF_CMP_NOFILE: - BLI_snprintf(line, sizeof(line), TIP_("Create %s"), abs_name); + SNPRINTF(line, TIP_("Create %s"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_CMP_EQUAL: - BLI_snprintf(line, sizeof(line), TIP_("Use %s (identical)"), abs_name); + SNPRINTF(line, TIP_("Use %s (identical)"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); break; case PF_CMP_DIFFERS: - BLI_snprintf(line, sizeof(line), TIP_("Use %s (differs)"), abs_name); + SNPRINTF(line, TIP_("Use %s (differs)"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_USE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL); RNA_string_set(&props_ptr, "id", id_name); - BLI_snprintf(line, sizeof(line), TIP_("Overwrite %s"), abs_name); + SNPRINTF(line, TIP_("Overwrite %s"), abs_name); // uiItemEnumO_ptr(layout, ot, line, 0, "method", PF_WRITE_ORIGINAL); uiItemFullO_ptr(layout, ot, line, ICON_NONE, nullptr, WM_OP_EXEC_DEFAULT, 0, &props_ptr); RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL); diff --git a/source/blender/editors/util/numinput.c b/source/blender/editors/util/numinput.c index f535b91ec0e..bdd3149884c 100644 --- a/source/blender/editors/util/numinput.c +++ b/source/blender/editors/util/numinput.c @@ -119,7 +119,7 @@ void outputNumInput(NumInput *n, char *str, UnitSettings *unit_settings) #endif if (n->val_flag[i] & NUM_INVALID) { - BLI_strncpy(val, "Invalid", sizeof(val)); + STRNCPY(val, "Invalid"); } else { BKE_unit_value_as_string_adaptive(val, @@ -278,7 +278,7 @@ bool user_string_to_number(bContext *C, double unit_scale = BKE_scene_unit_scale(unit, type, 1.0); if (BKE_unit_string_contains_unit(str, type)) { char str_unit_convert[256]; - BLI_strncpy(str_unit_convert, str, sizeof(str_unit_convert)); + STRNCPY(str_unit_convert, str); BKE_unit_replace_string( str_unit_convert, sizeof(str_unit_convert), str, unit_scale, unit->system, type); diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 9503035436d..b809b2cc895 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -277,14 +277,13 @@ static void stitch_update_header(StitchStateContainer *ssc, bContext *C) ScrArea *area = CTX_wm_area(C); if (area) { - BLI_snprintf(msg, - sizeof(msg), - str, - ssc->mode == STITCH_VERT ? TIP_("Vertex") : TIP_("Edge"), - WM_bool_as_string(ssc->snap_islands), - WM_bool_as_string(ssc->midpoints), - ssc->limit_dist, - WM_bool_as_string(ssc->use_limit)); + SNPRINTF(msg, + str, + ssc->mode == STITCH_VERT ? TIP_("Vertex") : TIP_("Edge"), + WM_bool_as_string(ssc->snap_islands), + WM_bool_as_string(ssc->midpoints), + ssc->limit_dist, + WM_bool_as_string(ssc->use_limit)); ED_workspace_status_text(C, msg); } diff --git a/source/blender/editors/uvedit/uvedit_unwrap_ops.cc b/source/blender/editors/uvedit/uvedit_unwrap_ops.cc index ae05ed542b5..23763911772 100644 --- a/source/blender/editors/uvedit/uvedit_unwrap_ops.cc +++ b/source/blender/editors/uvedit/uvedit_unwrap_ops.cc @@ -824,7 +824,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, bool interac blender::geometry::uv_parametrizer_flush(ms->handle); if (area) { - BLI_snprintf(str, sizeof(str), TIP_("Minimize Stretch. Blend %.2f"), ms->blend); + SNPRINTF(str, TIP_("Minimize Stretch. Blend %.2f"), ms->blend); ED_area_status_text(area, str); ED_workspace_status_text(C, TIP_("Press + and -, or scroll wheel to set blending")); } diff --git a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp index 9b8689aa67d..f00e97d3321 100644 --- a/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp +++ b/source/blender/freestyle/intern/blender_interface/BlenderStrokeRenderer.cpp @@ -83,7 +83,7 @@ BlenderStrokeRenderer::BlenderStrokeRenderer(Render *re, int render_count) old_scene = re->scene; char name[MAX_ID_NAME - 2]; - BLI_snprintf(name, sizeof(name), "FRS%d_%s", render_count, re->scene->id.name + 2); + SNPRINTF(name, "FRS%d_%s", render_count, re->scene->id.name + 2); freestyle_scene = BKE_scene_add(freestyle_bmain, name); freestyle_scene->r.cfra = old_scene->r.cfra; freestyle_scene->r.mode = old_scene->r.mode & ~(R_EDGE_FRS | R_BORDER); @@ -235,7 +235,7 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain, input_attr_color->locx = 0.0f; input_attr_color->locy = -200.0f; storage = (NodeShaderAttribute *)input_attr_color->storage; - BLI_strncpy(storage->name, "Color", sizeof(storage->name)); + STRNCPY(storage->name, "Color"); bNode *mix_rgb_color = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_RGB_LEGACY); mix_rgb_color->custom1 = MA_RAMP_BLEND; // Mix @@ -249,7 +249,7 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain, input_attr_alpha->locx = 400.0f; input_attr_alpha->locy = 300.0f; storage = (NodeShaderAttribute *)input_attr_alpha->storage; - BLI_strncpy(storage->name, "Alpha", sizeof(storage->name)); + STRNCPY(storage->name, "Alpha"); bNode *mix_rgb_alpha = nodeAddStaticNode(nullptr, ntree, SH_NODE_MIX_RGB_LEGACY); mix_rgb_alpha->custom1 = MA_RAMP_BLEND; // Mix @@ -390,10 +390,10 @@ Material *BlenderStrokeRenderer::GetStrokeShader(Main *bmain, input_uvmap->locy = node->locy; NodeShaderUVMap *storage = (NodeShaderUVMap *)input_uvmap->storage; if (node->custom1 & 1) { // use_tips - BLI_strncpy(storage->uv_map, uvNames[1], sizeof(storage->uv_map)); + STRNCPY(storage->uv_map, uvNames[1]); } else { - BLI_strncpy(storage->uv_map, uvNames[0], sizeof(storage->uv_map)); + STRNCPY(storage->uv_map, uvNames[0]); } fromsock = (bNodeSocket *)BLI_findlink(&input_uvmap->outputs, 0); // UV @@ -816,9 +816,9 @@ Object *BlenderStrokeRenderer::NewMesh() const char name[MAX_ID_NAME]; uint mesh_id = get_stroke_mesh_id(); - BLI_snprintf(name, MAX_ID_NAME, "0%08xOB", mesh_id); + SNPRINTF(name, "0%08xOB", mesh_id); ob = BKE_object_add_only_object(freestyle_bmain, OB_MESH, name); - BLI_snprintf(name, MAX_ID_NAME, "0%08xME", mesh_id); + SNPRINTF(name, "0%08xME", mesh_id); ob->data = BKE_mesh_add(freestyle_bmain, name); Collection *collection_master = freestyle_scene->master_collection; diff --git a/source/blender/freestyle/intern/system/StringUtils.cpp b/source/blender/freestyle/intern/system/StringUtils.cpp index 0e0450033bc..6c94dbbc9d0 100644 --- a/source/blender/freestyle/intern/system/StringUtils.cpp +++ b/source/blender/freestyle/intern/system/StringUtils.cpp @@ -32,7 +32,7 @@ void getPathName(const string &path, const string &base, vector &pathnam dir = path.substr(pos, sep - pos); - BLI_strncpy(cleaned, dir.c_str(), FILE_MAX); + STRNCPY(cleaned, dir.c_str()); BLI_path_normalize(cleaned); res = string(cleaned); diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c index 11099aa9aa1..fdcaa2384d9 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_dash.c @@ -57,7 +57,7 @@ static void initData(GpencilModifierData *md) DashGpencilModifierSegment *ds = DNA_struct_default_alloc(DashGpencilModifierSegment); ds->dmd = dmd; - BLI_strncpy(ds->name, DATA_("Segment"), sizeof(ds->name)); + STRNCPY(ds->name, DATA_("Segment")); dmd->segments = ds; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c index 83d5da1ef2b..4039c1692a0 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_time.c @@ -58,7 +58,7 @@ static void initData(GpencilModifierData *md) MEMCPY_STRUCT_AFTER(gpmd, DNA_struct_default_get(TimeGpencilModifierData), modifier); TimeGpencilModifierSegment *ds = DNA_struct_default_alloc(TimeGpencilModifierSegment); ds->gpmd = gpmd; - BLI_strncpy(ds->name, DATA_("Segment"), sizeof(ds->name)); + STRNCPY(ds->name, DATA_("Segment")); gpmd->segments = ds; } diff --git a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.c b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.c index 424d2a37010..d85d0b6d0c3 100644 --- a/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.c +++ b/source/blender/gpencil_modifiers_legacy/intern/MOD_gpencil_legacy_ui_common.c @@ -352,9 +352,9 @@ PanelType *gpencil_modifier_panel_register(ARegionType *region_type, PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); BKE_gpencil_modifierType_panel_id(type, panel_type->idname); - BLI_strncpy(panel_type->label, "", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); + STRNCPY(panel_type->label, ""); + STRNCPY(panel_type->context, "modifier"); + STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); panel_type->draw_header = gpencil_modifier_panel_header; panel_type->draw = draw; @@ -381,10 +381,10 @@ PanelType *gpencil_modifier_subpanel_register(ARegionType *region_type, { PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); - BLI_snprintf(panel_type->idname, BKE_ST_MAXNAME, "%s_%s", parent->idname, name); - BLI_strncpy(panel_type->label, label, BKE_ST_MAXNAME); - BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); + SNPRINTF(panel_type->idname, "%s_%s", parent->idname, name); + STRNCPY(panel_type->label, label); + STRNCPY(panel_type->context, "modifier"); + STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); panel_type->draw_header = draw_header; panel_type->draw = draw; @@ -392,7 +392,7 @@ PanelType *gpencil_modifier_subpanel_register(ARegionType *region_type, panel_type->flag = PANEL_TYPE_DEFAULT_CLOSED; BLI_assert(parent != NULL); - BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME); + STRNCPY(panel_type->parent_id, parent->idname); panel_type->parent = parent; BLI_addtail(&parent->children, BLI_genericNodeN(panel_type)); BLI_addtail(®ion_type->paneltypes, panel_type); diff --git a/source/blender/gpu/GPU_matrix.h b/source/blender/gpu/GPU_matrix.h index 0b298a66436..138d206c93c 100644 --- a/source/blender/gpu/GPU_matrix.h +++ b/source/blender/gpu/GPU_matrix.h @@ -172,35 +172,13 @@ int GPU_matrix_stack_level_get_projection(void); # if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L) # define _GPU_MAT3_CONST_CAST(x) \ - (_Generic((x), \ - void *: (const float (*)[3])(x), \ - float *: (const float (*)[3])(x), \ - float (*)[4]: (const float (*)[3])(x), \ - const void *: (const float (*)[3])(x), \ - const float *: (const float (*)[3])(x), \ - const float (*)[3]: (const float (*)[3])(x)) \ -) + (_Generic((x), void * : (const float(*)[3])(x), float * : (const float(*)[3])(x), float(*)[4] : (const float(*)[3])(x), const void * : (const float(*)[3])(x), const float * : (const float(*)[3])(x), const float(*)[3] : (const float(*)[3])(x))) # define _GPU_MAT3_CAST(x) \ - (_Generic((x), \ - void *: (float (*)[3])(x), \ - float *: (float (*)[3])(x), \ - float (*)[3]: (float (*)[3])(x)) \ -) + (_Generic((x), void * : (float(*)[3])(x), float * : (float(*)[3])(x), float(*)[3] : (float(*)[3])(x))) # define _GPU_MAT4_CONST_CAST(x) \ - (_Generic((x), \ - void *: (const float (*)[4])(x), \ - float *: (const float (*)[4])(x), \ - float (*)[4]: (const float (*)[4])(x), \ - const void *: (const float (*)[4])(x), \ - const float *: (const float (*)[4])(x), \ - const float (*)[4]: (const float (*)[4])(x)) \ -) + (_Generic((x), void * : (const float(*)[4])(x), float * : (const float(*)[4])(x), float(*)[4] : (const float(*)[4])(x), const void * : (const float(*)[4])(x), const float * : (const float(*)[4])(x), const float(*)[4] : (const float(*)[4])(x))) # define _GPU_MAT4_CAST(x) \ - (_Generic((x), \ - void *: (float (*)[4])(x), \ - float *: (float (*)[4])(x), \ - float (*)[4]: (float (*)[4])(x)) \ -) + (_Generic((x), void * : (float(*)[4])(x), float * : (float(*)[4])(x), float(*)[4] : (float(*)[4])(x))) # else # define _GPU_MAT3_CONST_CAST(x) (const float(*)[3])(x) # define _GPU_MAT3_CAST(x) (float(*)[3])(x) diff --git a/source/blender/gpu/intern/gpu_framebuffer.cc b/source/blender/gpu/intern/gpu_framebuffer.cc index ff2c2cbf5a1..9ea1bdcdb41 100644 --- a/source/blender/gpu/intern/gpu_framebuffer.cc +++ b/source/blender/gpu/intern/gpu_framebuffer.cc @@ -30,7 +30,7 @@ namespace blender::gpu { FrameBuffer::FrameBuffer(const char *name) { if (name) { - BLI_strncpy(name_, name, sizeof(name_)); + STRNCPY(name_, name); } else { name_[0] = '\0'; diff --git a/source/blender/gpu/intern/gpu_node_graph.cc b/source/blender/gpu/intern/gpu_node_graph.cc index 09acd03fd9a..acd61e11218 100644 --- a/source/blender/gpu/intern/gpu_node_graph.cc +++ b/source/blender/gpu/intern/gpu_node_graph.cc @@ -503,10 +503,9 @@ static GPUMaterialTexture *gpu_node_graph_add_texture(GPUNodeGraph *graph, tex->colorband = colorband; tex->sky = sky; tex->sampler_state = sampler_state; - BLI_snprintf(tex->sampler_name, sizeof(tex->sampler_name), "samp%d", num_textures); + SNPRINTF(tex->sampler_name, "samp%d", num_textures); if (is_tiled) { - BLI_snprintf( - tex->tiled_mapping_name, sizeof(tex->tiled_mapping_name), "tsamp%d", num_textures); + SNPRINTF(tex->tiled_mapping_name, "tsamp%d", num_textures); } BLI_addtail(&graph->textures, tex); } diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc index 6bd5680cd8e..2216ca36fdf 100644 --- a/source/blender/gpu/intern/gpu_shader.cc +++ b/source/blender/gpu/intern/gpu_shader.cc @@ -52,7 +52,7 @@ using namespace blender::gpu; Shader::Shader(const char *sh_name) { - BLI_strncpy(this->name, sh_name, sizeof(this->name)); + STRNCPY(this->name, sh_name); } Shader::~Shader() diff --git a/source/blender/gpu/intern/gpu_storage_buffer.cc b/source/blender/gpu/intern/gpu_storage_buffer.cc index 932e8a0f264..bdfc318255a 100644 --- a/source/blender/gpu/intern/gpu_storage_buffer.cc +++ b/source/blender/gpu/intern/gpu_storage_buffer.cc @@ -33,7 +33,7 @@ StorageBuf::StorageBuf(size_t size, const char *name) size_in_bytes_ = size; - BLI_strncpy(name_, name, sizeof(name_)); + STRNCPY(name_, name); } StorageBuf::~StorageBuf() diff --git a/source/blender/gpu/intern/gpu_texture.cc b/source/blender/gpu/intern/gpu_texture.cc index 9d50ad2d681..35aab01be06 100644 --- a/source/blender/gpu/intern/gpu_texture.cc +++ b/source/blender/gpu/intern/gpu_texture.cc @@ -25,7 +25,7 @@ namespace blender::gpu { Texture::Texture(const char *name) { if (name) { - BLI_strncpy(name_, name, sizeof(name_)); + STRNCPY(name_, name); } else { name_[0] = '\0'; diff --git a/source/blender/gpu/intern/gpu_uniform_buffer.cc b/source/blender/gpu/intern/gpu_uniform_buffer.cc index b79abea3001..b702bc4d977 100644 --- a/source/blender/gpu/intern/gpu_uniform_buffer.cc +++ b/source/blender/gpu/intern/gpu_uniform_buffer.cc @@ -33,7 +33,7 @@ UniformBuf::UniformBuf(size_t size, const char *name) size_in_bytes_ = size; - BLI_strncpy(name_, name, sizeof(name_)); + STRNCPY(name_, name); } UniformBuf::~UniformBuf() diff --git a/source/blender/gpu/intern/gpu_vertex_format.cc b/source/blender/gpu/intern/gpu_vertex_format.cc index fb480326def..cadd935ee22 100644 --- a/source/blender/gpu/intern/gpu_vertex_format.cc +++ b/source/blender/gpu/intern/gpu_vertex_format.cc @@ -200,7 +200,7 @@ void GPU_vertformat_multiload_enable(GPUVertFormat *format, int load_count) const char *attr_name = GPU_vertformat_attr_name_get(format, attr, 0); for (int j = 1; j < load_count; j++) { char load_name[68 /* MAX_CUSTOMDATA_LAYER_NAME */]; - BLI_snprintf(load_name, sizeof(load_name), "%s%d", attr_name, j); + SNPRINTF(load_name, "%s%d", attr_name, j); GPUVertAttr *dst_attr = &format->attrs[format->attr_len++]; *dst_attr = *attr; diff --git a/source/blender/imbuf/intern/anim_movie.cc b/source/blender/imbuf/intern/anim_movie.cc index e671105da75..005aadaf1f5 100644 --- a/source/blender/imbuf/intern/anim_movie.cc +++ b/source/blender/imbuf/intern/anim_movie.cc @@ -285,14 +285,14 @@ struct anim *IMB_open_anim(const char *filepath, if (anim != nullptr) { if (colorspace) { colorspace_set_default_role(colorspace, IM_MAX_SPACE, COLOR_ROLE_DEFAULT_BYTE); - BLI_strncpy(anim->colorspace, colorspace, sizeof(anim->colorspace)); + STRNCPY(anim->colorspace, colorspace); } else { colorspace_set_default_role( anim->colorspace, sizeof(anim->colorspace), COLOR_ROLE_DEFAULT_BYTE); } - BLI_strncpy(anim->filepath, filepath, sizeof(anim->filepath)); + STRNCPY(anim->filepath, filepath); anim->ib_flags = ib_flags; anim->streamindex = streamindex; } @@ -320,7 +320,7 @@ bool IMB_anim_can_produce_frames(const struct anim *anim) void IMB_suffix_anim(struct anim *anim, const char *suffix) { - BLI_strncpy(anim->suffix, suffix, sizeof(anim->suffix)); + STRNCPY(anim->suffix, suffix); } #ifdef WITH_AVI @@ -1537,7 +1537,7 @@ static bool anim_getnew(struct anim *anim) case ANIM_SEQUENCE: { ImBuf *ibuf = IMB_loadiffname(anim->filepath, anim->ib_flags, anim->colorspace); if (ibuf) { - BLI_strncpy(anim->filepath_first, anim->filepath, sizeof(anim->filepath_first)); + STRNCPY(anim->filepath_first, anim->filepath); anim->duration_in_frames = 1; IMB_freeImBuf(ibuf); } @@ -1664,8 +1664,7 @@ struct ImBuf *IMB_anim_absolute(struct anim *anim, if (filter_y) { IMB_filtery(ibuf); } - BLI_snprintf( - ibuf->filepath, sizeof(ibuf->filepath), "%s.%04d", anim->filepath, anim->cur_position + 1); + SNPRINTF(ibuf->filepath, "%s.%04d", anim->filepath, anim->cur_position + 1); } return ibuf; } diff --git a/source/blender/imbuf/intern/colormanagement.cc b/source/blender/imbuf/intern/colormanagement.cc index 8b0929428de..1ded1983936 100644 --- a/source/blender/imbuf/intern/colormanagement.cc +++ b/source/blender/imbuf/intern/colormanagement.cc @@ -997,14 +997,13 @@ void IMB_colormanagement_init_default_view_settings( } } if (default_view != nullptr) { - BLI_strncpy( - view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform)); + STRNCPY(view_settings->view_transform, default_view->name); } else { view_settings->view_transform[0] = '\0'; } /* TODO(sergey): Find a way to safely/reliable un-hardcode this. */ - BLI_strncpy(view_settings->look, "None", sizeof(view_settings->look)); + STRNCPY(view_settings->look, "None"); /* Initialize rest of the settings. */ view_settings->flag = 0; view_settings->gamma = 1.0f; @@ -1080,9 +1079,7 @@ static void colormanage_check_display_settings(ColorManagedDisplaySettings *disp const ColorManagedDisplay *default_display) { if (display_settings->display_device[0] == '\0') { - BLI_strncpy(display_settings->display_device, - default_display->name, - sizeof(display_settings->display_device)); + STRNCPY(display_settings->display_device, default_display->name); } else { ColorManagedDisplay *display = colormanage_display_get_named(display_settings->display_device); @@ -1094,9 +1091,7 @@ static void colormanage_check_display_settings(ColorManagedDisplaySettings *disp what, default_display->name); - BLI_strncpy(display_settings->display_device, - default_display->name, - sizeof(display_settings->display_device)); + STRNCPY(display_settings->display_device, default_display->name); } } } @@ -1117,9 +1112,7 @@ static void colormanage_check_view_settings(ColorManagedDisplaySettings *display } if (default_view) { - BLI_strncpy(view_settings->view_transform, - default_view->name, - sizeof(view_settings->view_transform)); + STRNCPY(view_settings->view_transform, default_view->name); } } else { @@ -1138,15 +1131,13 @@ static void colormanage_check_view_settings(ColorManagedDisplaySettings *display view_settings->view_transform, default_view->name); - BLI_strncpy(view_settings->view_transform, - default_view->name, - sizeof(view_settings->view_transform)); + STRNCPY(view_settings->view_transform, default_view->name); } } } if (view_settings->look[0] == '\0') { - BLI_strncpy(view_settings->look, default_look->name, sizeof(view_settings->look)); + STRNCPY(view_settings->look, default_look->name); } else { ColorManagedLook *look = colormanage_look_get_named(view_settings->look); @@ -1156,7 +1147,7 @@ static void colormanage_check_view_settings(ColorManagedDisplaySettings *display view_settings->look, default_look->name); - BLI_strncpy(view_settings->look, default_look->name, sizeof(view_settings->look)); + STRNCPY(view_settings->look, default_look->name); } } @@ -1181,7 +1172,7 @@ static void colormanage_check_colorspace_settings( what, colorspace_settings->name); - BLI_strncpy(colorspace_settings->name, "", sizeof(colorspace_settings->name)); + STRNCPY(colorspace_settings->name, ""); } } @@ -1216,8 +1207,7 @@ void IMB_colormanagement_check_file_config(Main *bmain) colormanage_check_colorspace_settings(sequencer_colorspace_settings, "sequencer"); if (sequencer_colorspace_settings->name[0] == '\0') { - BLI_strncpy( - sequencer_colorspace_settings->name, global_role_default_sequencer, MAX_COLORSPACE_NAME); + STRNCPY(sequencer_colorspace_settings->name, global_role_default_sequencer); } /* check sequencer strip input color space settings */ @@ -1254,8 +1244,7 @@ void IMB_colormanagement_validate_settings(const ColorManagedDisplaySettings *di } if (!found && default_view) { - BLI_strncpy( - view_settings->view_transform, default_view->name, sizeof(view_settings->view_transform)); + STRNCPY(view_settings->view_transform, default_view->name); } } @@ -2863,7 +2852,7 @@ ColorManagedDisplay *colormanage_display_add(const char *name) display->index = index + 1; - BLI_strncpy(display->name, name, sizeof(display->name)); + STRNCPY(display->name, name); BLI_addtail(&global_displays, display); @@ -2974,7 +2963,7 @@ ColorManagedView *colormanage_view_add(const char *name) view = MEM_cnew("ColorManagedView"); view->index = index + 1; - BLI_strncpy(view->name, name, sizeof(view->name)); + STRNCPY(view->name, name); BLI_addtail(&global_views, view); @@ -3090,10 +3079,10 @@ ColorSpace *colormanage_colorspace_add(const char *name, colorspace = MEM_cnew("ColorSpace"); - BLI_strncpy(colorspace->name, name, sizeof(colorspace->name)); + STRNCPY(colorspace->name, name); if (description) { - BLI_strncpy(colorspace->description, description, sizeof(colorspace->description)); + STRNCPY(colorspace->description, description); colormanage_description_strip(colorspace->description); } @@ -3201,7 +3190,7 @@ void IMB_colormanagement_colorspace_from_ibuf_ftype( if (type->save != nullptr) { const char *role_colorspace = IMB_colormanagement_role_colorspace_name_get( type->default_save_role); - BLI_strncpy(colorspace_settings->name, role_colorspace, sizeof(colorspace_settings->name)); + STRNCPY(colorspace_settings->name, role_colorspace); } } } @@ -3219,16 +3208,16 @@ ColorManagedLook *colormanage_look_add(const char *name, const char *process_spa look = MEM_cnew("ColorManagedLook"); look->index = index + 1; - BLI_strncpy(look->name, name, sizeof(look->name)); - BLI_strncpy(look->ui_name, name, sizeof(look->ui_name)); - BLI_strncpy(look->process_space, process_space, sizeof(look->process_space)); + STRNCPY(look->name, name); + STRNCPY(look->ui_name, name); + STRNCPY(look->process_space, process_space); look->is_noop = is_noop; /* Detect view specific looks. */ const char *separator_offset = strstr(look->name, " - "); if (separator_offset) { BLI_strncpy(look->view, look->name, separator_offset - look->name + 1); - BLI_strncpy(look->ui_name, separator_offset + strlen(" - "), sizeof(look->ui_name)); + STRNCPY(look->ui_name, separator_offset + strlen(" - ")); } BLI_addtail(&global_looks, look); diff --git a/source/blender/imbuf/intern/indexer.cc b/source/blender/imbuf/intern/indexer.cc index 2c4274e32ca..c0e172acba6 100644 --- a/source/blender/imbuf/intern/indexer.cc +++ b/source/blender/imbuf/intern/indexer.cc @@ -70,9 +70,9 @@ anim_index_builder *IMB_index_builder_create(const char *filepath) fprintf(stderr, "Starting work on index: %s\n", filepath); - BLI_strncpy(rv->filepath, filepath, sizeof(rv->filepath)); + STRNCPY(rv->filepath, filepath); - BLI_strncpy(rv->filepath_temp, filepath, sizeof(rv->filepath_temp)); + STRNCPY(rv->filepath_temp, filepath); BLI_string_join(rv->filepath_temp, sizeof(rv->filepath_temp), filepath, temp_ext); BLI_file_ensure_parent_dir_exists(rv->filepath_temp); @@ -187,7 +187,7 @@ struct anim_index *IMB_indexer_open(const char *filepath) idx = MEM_cnew("anim_index"); - BLI_strncpy(idx->filepath, filepath, sizeof(idx->filepath)); + STRNCPY(idx->filepath, filepath); fseek(fp, 0, SEEK_END); @@ -413,11 +413,10 @@ static bool get_proxy_filepath(struct anim *anim, stream_suffix[0] = 0; if (anim->streamindex > 0) { - BLI_snprintf(stream_suffix, sizeof(stream_suffix), "_st%d", anim->streamindex); + SNPRINTF(stream_suffix, "_st%d", anim->streamindex); } - BLI_snprintf( - proxy_name, sizeof(proxy_name), name, int(proxy_fac[i] * 100), stream_suffix, anim->suffix); + SNPRINTF(proxy_name, name, int(proxy_fac[i] * 100), stream_suffix, anim->suffix); get_index_dir(anim, index_dir, sizeof(index_dir)); @@ -449,10 +448,10 @@ static void get_tc_filename(struct anim *anim, IMB_Timecode_Type tc, char *filep stream_suffix[0] = 0; if (anim->streamindex > 0) { - BLI_snprintf(stream_suffix, 20, "_st%d", anim->streamindex); + SNPRINTF(stream_suffix, "_st%d", anim->streamindex); } - BLI_snprintf(index_name, 256, index_names[i], stream_suffix, anim->suffix); + SNPRINTF(index_name, index_names[i], stream_suffix, anim->suffix); get_index_dir(anim, index_dir, sizeof(index_dir)); @@ -1568,7 +1567,7 @@ void IMB_anim_set_index_dir(struct anim *anim, const char *dir) if (STREQ(anim->index_dir, dir)) { return; } - BLI_strncpy(anim->index_dir, dir, sizeof(anim->index_dir)); + STRNCPY(anim->index_dir, dir); IMB_free_indices(anim); } diff --git a/source/blender/imbuf/intern/moviecache.cc b/source/blender/imbuf/intern/moviecache.cc index 06899b48525..ac9a670f3b8 100644 --- a/source/blender/imbuf/intern/moviecache.cc +++ b/source/blender/imbuf/intern/moviecache.cc @@ -273,7 +273,7 @@ MovieCache *IMB_moviecache_create(const char *name, cache = (MovieCache *)MEM_callocN(sizeof(MovieCache), "MovieCache"); - BLI_strncpy(cache->name, name, sizeof(cache->name)); + STRNCPY(cache->name, name); cache->keys_pool = BLI_mempool_create(sizeof(MovieCacheKey), 0, 64, BLI_MEMPOOL_NOP); cache->items_pool = BLI_mempool_create(sizeof(MovieCacheItem), 0, 64, BLI_MEMPOOL_NOP); diff --git a/source/blender/imbuf/intern/oiio/openimageio_support.cc b/source/blender/imbuf/intern/oiio/openimageio_support.cc index daf22bfda9a..962d625b028 100644 --- a/source/blender/imbuf/intern/oiio/openimageio_support.cc +++ b/source/blender/imbuf/intern/oiio/openimageio_support.cc @@ -161,7 +161,7 @@ static void set_colorspace_name(char colorspace[IM_MAX_SPACE], if (ctx.use_embedded_colorspace) { string ics = spec.get_string_attribute("oiio:ColorSpace"); char file_colorspace[IM_MAX_SPACE]; - BLI_strncpy(file_colorspace, ics.c_str(), IM_MAX_SPACE); + STRNCPY(file_colorspace, ics.c_str()); /* Only use color-spaces that exist. */ if (colormanage_colorspace_get_named(file_colorspace)) { diff --git a/source/blender/imbuf/intern/openexr/openexr_api.cpp b/source/blender/imbuf/intern/openexr/openexr_api.cpp index 0f8b9240442..3da47fdeeeb 100644 --- a/source/blender/imbuf/intern/openexr/openexr_api.cpp +++ b/source/blender/imbuf/intern/openexr/openexr_api.cpp @@ -880,10 +880,10 @@ void IMB_exr_add_channel(void *handle, } else if (!data->multiView->empty()) { std::string raw_name = insertViewName(echan->m->name, *data->multiView, echan->view_id); - BLI_strncpy(echan->name, raw_name.c_str(), sizeof(echan->name)); + STRNCPY(echan->name, raw_name.c_str()); } else { - BLI_strncpy(echan->name, echan->m->name.c_str(), sizeof(echan->name)); + STRNCPY(echan->name, echan->m->name.c_str()); } echan->xstride = xstride; @@ -1100,7 +1100,7 @@ void IMB_exr_set_channel( BLI_strncpy(lay, layname, EXR_LAY_MAXNAME); BLI_strncpy(pass, passname, EXR_PASS_MAXNAME); - BLI_snprintf(name, sizeof(name), "%s.%s", lay, pass); + SNPRINTF(name, "%s.%s", lay, pass); } else { BLI_strncpy(name, passname, EXR_TOT_MAXNAME - 1); @@ -1132,7 +1132,7 @@ float *IMB_exr_channel_rect(void *handle, BLI_strncpy(lay, layname, EXR_LAY_MAXNAME); BLI_strncpy(pass, passname, EXR_PASS_MAXNAME); - BLI_snprintf(name, sizeof(name), "%s.%s", lay, pass); + SNPRINTF(name, "%s.%s", lay, pass); } else { BLI_strncpy(name, passname, EXR_TOT_MAXNAME - 1); @@ -1142,12 +1142,12 @@ float *IMB_exr_channel_rect(void *handle, if (layname && layname[0] != '\0') { char temp_buf[EXR_PASS_MAXNAME]; imb_exr_insert_view_name(temp_buf, name, viewname); - BLI_strncpy(name, temp_buf, sizeof(name)); + STRNCPY(name, temp_buf); } else if (!data->multiView->empty()) { const int view_id = std::max(0, imb_exr_get_multiView_id(*data->multiView, viewname)); std::string raw_name = insertViewName(name, *data->multiView, view_id); - BLI_strncpy(name, raw_name.c_str(), sizeof(name)); + STRNCPY(name, raw_name.c_str()); } echan = (ExrChannel *)BLI_findstring(&data->channels, name, offsetof(ExrChannel, name)); @@ -1605,7 +1605,7 @@ static ExrPass *imb_exr_get_pass(ListBase *lb, char *passname) } } - BLI_strncpy(pass->name, passname, EXR_LAY_MAXNAME); + STRNCPY(pass->name, passname); return pass; } @@ -1638,12 +1638,12 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *data) const char *view = echan->m->view.c_str(); char internal_name[EXR_PASS_MAXNAME]; - BLI_strncpy(internal_name, passname, EXR_PASS_MAXNAME); + STRNCPY(internal_name, passname); if (view[0] != '\0') { char tmp_pass[EXR_PASS_MAXNAME]; - BLI_snprintf(tmp_pass, sizeof(tmp_pass), "%s.%s", passname, view); - BLI_strncpy(passname, tmp_pass, sizeof(passname)); + SNPRINTF(tmp_pass, "%s.%s", passname, view); + STRNCPY(passname, tmp_pass); } ExrLayer *lay = imb_exr_get_layer(&data->layers, layname); @@ -1652,8 +1652,8 @@ static bool imb_exr_multilayer_parse_channels_from_file(ExrHandle *data) pass->chan[pass->totchan] = echan; pass->totchan++; pass->view_id = echan->view_id; - BLI_strncpy(pass->view, view, sizeof(pass->view)); - BLI_strncpy(pass->internal_name, internal_name, EXR_PASS_MAXNAME); + STRNCPY(pass->view, view); + STRNCPY(pass->internal_name, internal_name); if (pass->totchan >= EXR_PASS_MAXCHAN) { break; diff --git a/source/blender/imbuf/intern/readimage.cc b/source/blender/imbuf/intern/readimage.cc index 1e8bae62ac7..ac4fd2ddbb2 100644 --- a/source/blender/imbuf/intern/readimage.cc +++ b/source/blender/imbuf/intern/readimage.cc @@ -94,7 +94,7 @@ ImBuf *IMB_ibImageFromMemory( } if (colorspace) { - BLI_strncpy(effective_colorspace, colorspace, sizeof(effective_colorspace)); + STRNCPY(effective_colorspace, colorspace); } for (type = IMB_FILE_TYPES; type < IMB_FILE_TYPES_LAST; type++) { @@ -160,7 +160,7 @@ ImBuf *IMB_loadiffname(const char *filepath, int flags, char colorspace[IM_MAX_S ibuf = IMB_loadifffile(file, flags, colorspace, filepath); if (ibuf) { - BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); + STRNCPY(ibuf->filepath, filepath); } close(file); @@ -185,7 +185,7 @@ struct ImBuf *IMB_thumb_load_image(const char *filepath, char effective_colorspace[IM_MAX_SPACE] = ""; if (colorspace) { - BLI_strncpy(effective_colorspace, colorspace, sizeof(effective_colorspace)); + STRNCPY(effective_colorspace, colorspace); } if (type->load_filepath_thumbnail) { @@ -239,7 +239,7 @@ ImBuf *IMB_testiffname(const char *filepath, int flags) ibuf = IMB_loadifffile(file, flags | IB_test | IB_multilayer, colorspace, filepath); if (ibuf) { - BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); + STRNCPY(ibuf->filepath, filepath); } close(file); diff --git a/source/blender/imbuf/intern/thumbs.cc b/source/blender/imbuf/intern/thumbs.cc index 86b1f664eed..fe401287a4a 100644 --- a/source/blender/imbuf/intern/thumbs.cc +++ b/source/blender/imbuf/intern/thumbs.cc @@ -236,7 +236,7 @@ static bool uri_from_filename(const char *path, char *uri) strcat(orig_uri, dirstart); BLI_str_replace_char(orig_uri, '\\', '/'); #else - BLI_snprintf(orig_uri, URI_MAX, "file://%s", dirstart); + SNPRINTF(orig_uri, "file://%s", dirstart); #endif escape_uri_string(orig_uri, uri, URI_MAX, UNSAFE_PATH); @@ -336,9 +336,9 @@ static ImBuf *thumb_create_ex(const char *file_path, } if (get_thumb_dir(tdir, size)) { - BLI_snprintf(tpath, FILE_MAX, "%s%s", tdir, thumb); + SNPRINTF(tpath, "%s%s", tdir, thumb); // thumb[8] = '\0'; /* shorten for `temp` name, not needed anymore */ - BLI_snprintf(temp, FILE_MAX, "%sblender_%d_%s.png", tdir, abs(getpid()), thumb); + SNPRINTF(temp, "%sblender_%d_%s.png", tdir, abs(getpid()), thumb); if (BLI_path_ncmp(file_path, tdir, sizeof(tdir)) == 0) { return nullptr; } @@ -369,7 +369,7 @@ static ImBuf *thumb_create_ex(const char *file_path, if (img != nullptr) { if (BLI_stat(file_path, &info) != -1) { - BLI_snprintf(mtime, sizeof(mtime), "%ld", (long int)info.st_mtime); + SNPRINTF(mtime, "%ld", (long int)info.st_mtime); } } } @@ -388,7 +388,7 @@ static ImBuf *thumb_create_ex(const char *file_path, IMB_free_anim(anim); } if (BLI_stat(file_path, &info) != -1) { - BLI_snprintf(mtime, sizeof(mtime), "%ld", (long int)info.st_mtime); + SNPRINTF(mtime, "%ld", (long int)info.st_mtime); } } if (!img) { @@ -410,7 +410,7 @@ static ImBuf *thumb_create_ex(const char *file_path, IMB_scaleImBuf(img, ex, ey); } } - BLI_snprintf(desc, sizeof(desc), "Thumbnail for %s", uri); + SNPRINTF(desc, "Thumbnail for %s", uri); IMB_metadata_ensure(&img->metadata); IMB_metadata_set_field(img->metadata, "Software", "Blender"); IMB_metadata_set_field(img->metadata, "Thumb::URI", uri); diff --git a/source/blender/imbuf/intern/util.cc b/source/blender/imbuf/intern/util.cc index ed8a5358ef1..fb0b7346c2c 100644 --- a/source/blender/imbuf/intern/util.cc +++ b/source/blender/imbuf/intern/util.cc @@ -196,7 +196,7 @@ static void ffmpeg_log_callback(void *ptr, int level, const char *format, va_lis va_list args_cpy; va_copy(args_cpy, arg); - n = BLI_vsnprintf(ffmpeg_last_error, sizeof(ffmpeg_last_error), format, args_cpy); + n = VSNPRINTF(ffmpeg_last_error, format, args_cpy); va_end(args_cpy); /* strip trailing \n */ diff --git a/source/blender/io/alembic/exporter/abc_export_capi.cc b/source/blender/io/alembic/exporter/abc_export_capi.cc index d96e3cb6146..0eadeb6b201 100644 --- a/source/blender/io/alembic/exporter/abc_export_capi.cc +++ b/source/blender/io/alembic/exporter/abc_export_capi.cc @@ -207,7 +207,7 @@ bool ABC_export(Scene *scene, job->bmain = CTX_data_main(C); job->wm = CTX_wm_manager(C); job->export_ok = false; - BLI_strncpy(job->filename, filepath, sizeof(job->filename)); + STRNCPY(job->filename, filepath); job->depsgraph = DEG_graph_new(job->bmain, scene, view_layer, params->evaluation_mode); job->params = *params; diff --git a/source/blender/io/alembic/intern/abc_reader_archive.cc b/source/blender/io/alembic/intern/abc_reader_archive.cc index f826da0daa4..a11f5795bbe 100644 --- a/source/blender/io/alembic/intern/abc_reader_archive.cc +++ b/source/blender/io/alembic/intern/abc_reader_archive.cc @@ -105,7 +105,7 @@ ArchiveReader::ArchiveReader(const std::vector &readers) : m_re ArchiveReader::ArchiveReader(struct Main *bmain, const char *filename) { char abs_filename[FILE_MAX]; - BLI_strncpy(abs_filename, filename, FILE_MAX); + STRNCPY(abs_filename, filename); BLI_path_abs(abs_filename, BKE_main_blendfile_path(bmain)); #ifdef WIN32 diff --git a/source/blender/io/alembic/intern/abc_reader_object.cc b/source/blender/io/alembic/intern/abc_reader_object.cc index f3a07eaad3f..3059cfe01a4 100644 --- a/source/blender/io/alembic/intern/abc_reader_object.cc +++ b/source/blender/io/alembic/intern/abc_reader_object.cc @@ -171,7 +171,7 @@ void AbcObjectReader::setupObjectTransform(const chrono_t time) bConstraint *con = BKE_constraint_add_for_object( m_object, nullptr, CONSTRAINT_TYPE_TRANSFORM_CACHE); bTransformCacheConstraint *data = static_cast(con->data); - BLI_strncpy(data->object_path, m_iobject.getFullName().c_str(), FILE_MAX); + STRNCPY(data->object_path, m_iobject.getFullName().c_str()); data->cache_file = m_settings->cache_file; id_us_plus(&data->cache_file->id); @@ -267,7 +267,7 @@ void AbcObjectReader::addCacheModifier() mcmd->cache_file = m_settings->cache_file; id_us_plus(&mcmd->cache_file->id); - BLI_strncpy(mcmd->object_path, m_iobject.getFullName().c_str(), FILE_MAX); + STRNCPY(mcmd->object_path, m_iobject.getFullName().c_str()); } chrono_t AbcObjectReader::minTime() const diff --git a/source/blender/io/alembic/intern/alembic_capi.cc b/source/blender/io/alembic/intern/alembic_capi.cc index 1f281968eab..f466f9536d4 100644 --- a/source/blender/io/alembic/intern/alembic_capi.cc +++ b/source/blender/io/alembic/intern/alembic_capi.cc @@ -93,7 +93,7 @@ BLI_INLINE CacheArchiveHandle *handle_from_archive(ArchiveReader *archive) static void add_object_path(ListBase *object_paths, const IObject &object) { CacheObjectPath *abc_path = MEM_cnew("CacheObjectPath"); - BLI_strncpy(abc_path->path, object.getFullName().c_str(), sizeof(abc_path->path)); + STRNCPY(abc_path->path, object.getFullName().c_str()); BLI_addtail(object_paths, abc_path); } @@ -684,7 +684,7 @@ bool ABC_import(bContext *C, job->view_layer = CTX_data_view_layer(C); job->wm = CTX_wm_manager(C); job->import_ok = false; - BLI_strncpy(job->filename, filepath, 1024); + STRNCPY(job->filename, filepath); job->settings.scale = params->global_scale; job->settings.is_sequence = params->is_sequence; diff --git a/source/blender/io/avi/intern/avi_codecs.c b/source/blender/io/avi/intern/avi_codecs.c index ba897ef808a..c996f6d08dc 100644 --- a/source/blender/io/avi/intern/avi_codecs.c +++ b/source/blender/io/avi/intern/avi_codecs.c @@ -70,10 +70,10 @@ int avi_get_data_id(AviFormat format, int stream) char fcc[5]; if (avi_get_format_type(format) == FCC("vids")) { - BLI_snprintf(fcc, sizeof(fcc), "%2.2ddc", stream); + SNPRINTF(fcc, "%2.2ddc", stream); } else if (avi_get_format_type(format) == FCC("auds")) { - BLI_snprintf(fcc, sizeof(fcc), "%2.2ddc", stream); + SNPRINTF(fcc, "%2.2ddc", stream); } else { return 0; diff --git a/source/blender/io/collada/AnimationExporter.cpp b/source/blender/io/collada/AnimationExporter.cpp index 24d2072f840..0f3b07688af 100644 --- a/source/blender/io/collada/AnimationExporter.cpp +++ b/source/blender/io/collada/AnimationExporter.cpp @@ -43,8 +43,7 @@ bool AnimationExporter::open_animation_container(bool has_container, Object *ob) { if (!has_container) { char anim_id[200]; - BLI_snprintf( - anim_id, sizeof(anim_id), "action_container-%s", translate_id(id_name(ob)).c_str()); + SNPRINTF(anim_id, "action_container-%s", translate_id(id_name(ob)).c_str()); openAnimation(anim_id, encode_xml(id_name(ob))); } return true; diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 6c116a4ab17..6fb67e90150 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -227,7 +227,7 @@ void AnimationImporter::add_fcurves_to_object(Main *bmain, grp = MEM_cnew("bActionGroup"); grp->flag = AGRP_SELECTED; - BLI_strncpy(grp->name, bone_name, sizeof(grp->name)); + STRNCPY(grp->name, bone_name); BLI_addtail(&act->groups, grp); BLI_uniquename(&act->groups, @@ -542,10 +542,10 @@ void AnimationImporter::Assign_transform_animations( case COLLADAFW::Transformation::SCALE: { bool loc = tm_type == COLLADAFW::Transformation::TRANSLATE; if (is_joint) { - BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, loc ? "location" : "scale"); + SNPRINTF(rna_path, "%s.%s", joint_path, loc ? "location" : "scale"); } else { - BLI_strncpy(rna_path, loc ? "location" : "scale", sizeof(rna_path)); + STRNCPY(rna_path, loc ? "location" : "scale"); } switch (binding->animationClass) { @@ -573,10 +573,10 @@ void AnimationImporter::Assign_transform_animations( case COLLADAFW::Transformation::ROTATE: { if (is_joint) { - BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_euler", joint_path); + SNPRINTF(rna_path, "%s.rotation_euler", joint_path); } else { - BLI_strncpy(rna_path, "rotation_euler", sizeof(rna_path)); + STRNCPY(rna_path, "rotation_euler"); } std::vector::iterator iter; for (iter = curves->begin(); iter != curves->end(); iter++) { @@ -636,7 +636,7 @@ void AnimationImporter::Assign_color_animations(const COLLADAFW::UniqueId &listi const char *anim_type) { char rna_path[100]; - BLI_strncpy(rna_path, anim_type, sizeof(rna_path)); + STRNCPY(rna_path, anim_type); const COLLADAFW::AnimationList *animlist = animlist_map[listid]; if (animlist == nullptr) { @@ -703,7 +703,7 @@ void AnimationImporter::Assign_float_animations(const COLLADAFW::UniqueId &listi for (uint j = 0; j < bindings.getCount(); j++) { animcurves = curve_map[bindings[j].animation]; - BLI_strncpy(rna_path, anim_type, sizeof(rna_path)); + STRNCPY(rna_path, anim_type); modify_fcurve(&animcurves, rna_path, 0); std::vector::iterator iter; /* Add the curves of the current animation to the object */ @@ -761,7 +761,7 @@ void AnimationImporter::Assign_lens_animations(const COLLADAFW::UniqueId &listid for (uint j = 0; j < bindings.getCount(); j++) { animcurves = curve_map[bindings[j].animation]; - BLI_strncpy(rna_path, anim_type, sizeof(rna_path)); + STRNCPY(rna_path, anim_type); modify_fcurve(&animcurves, rna_path, 0); std::vector::iterator iter; @@ -840,10 +840,10 @@ void AnimationImporter::apply_matrix_curves(Object *ob, } if (is_joint) { - BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str); + SNPRINTF(rna_path, "%s.%s", joint_path, tm_str); } else { - BLI_strncpy(rna_path, tm_str, sizeof(rna_path)); + STRNCPY(rna_path, tm_str); } newcu[i] = create_fcurve(axis, rna_path); newcu[i]->totvert = frames.size(); @@ -1295,7 +1295,7 @@ void AnimationImporter::add_bone_animation_sampled(Object *ob, axis = i - 7; } - BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str); + SNPRINTF(rna_path, "%s.%s", joint_path, tm_str); newcu[i] = create_fcurve(axis, rna_path); newcu[i]->totvert = frames.size(); @@ -1657,10 +1657,10 @@ Object *AnimationImporter::translate_animation_OLD( } if (is_joint) { - BLI_snprintf(rna_path, sizeof(rna_path), "%s.%s", joint_path, tm_str); + SNPRINTF(rna_path, "%s.%s", joint_path, tm_str); } else { - BLI_strncpy(rna_path, tm_str, sizeof(rna_path)); + STRNCPY(rna_path, tm_str); } newcu[i] = create_fcurve(axis, rna_path); @@ -1924,16 +1924,16 @@ bool AnimationImporter::evaluate_animation(COLLADAFW::Transformation *tm, switch (type) { case COLLADAFW::Transformation::ROTATE: - BLI_snprintf(path, sizeof(path), "%s.rotate (binding %u)", node_id, index); + SNPRINTF(path, "%s.rotate (binding %u)", node_id, index); break; case COLLADAFW::Transformation::SCALE: - BLI_snprintf(path, sizeof(path), "%s.scale (binding %u)", node_id, index); + SNPRINTF(path, "%s.scale (binding %u)", node_id, index); break; case COLLADAFW::Transformation::TRANSLATE: - BLI_snprintf(path, sizeof(path), "%s.translate (binding %u)", node_id, index); + SNPRINTF(path, "%s.translate (binding %u)", node_id, index); break; case COLLADAFW::Transformation::MATRIX: - BLI_snprintf(path, sizeof(path), "%s.matrix (binding %u)", node_id, index); + SNPRINTF(path, "%s.matrix (binding %u)", node_id, index); break; default: break; @@ -2173,7 +2173,7 @@ void AnimationImporter::add_bone_fcurve(Object *ob, COLLADAFW::Node *node, FCurv grp = MEM_cnew("bActionGroup"); grp->flag = AGRP_SELECTED; - BLI_strncpy(grp->name, bone_name, sizeof(grp->name)); + STRNCPY(grp->name, bone_name); BLI_addtail(&act->groups, grp); BLI_uniquename(&act->groups, diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index 7339dbfe273..0a3edc9fc21 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -236,7 +236,7 @@ int DocumentExporter::exportCurrentScene() build_commit_time, build_hash); #else - BLI_snprintf(version_buf, sizeof(version_buf), "Blender %s", BKE_blender_version_string()); + SNPRINTF(version_buf, "Blender %s", BKE_blender_version_string()); #endif asset.getContributor().mAuthoringTool = version_buf; asset.add(); diff --git a/source/blender/io/collada/ExportSettings.h b/source/blender/io/collada/ExportSettings.h index e4c1b41fdde..c09416c3920 100644 --- a/source/blender/io/collada/ExportSettings.h +++ b/source/blender/io/collada/ExportSettings.h @@ -98,7 +98,6 @@ class BCExportSettings { : export_settings(*exportSettings), blender_context(blenderContext), global_transform(BCMatrix(exportSettings->global_forward, exportSettings->global_up)) - { } diff --git a/source/blender/io/collada/GeometryExporter.cpp b/source/blender/io/collada/GeometryExporter.cpp index 0f22bdfbf61..41fc987aa07 100644 --- a/source/blender/io/collada/GeometryExporter.cpp +++ b/source/blender/io/collada/GeometryExporter.cpp @@ -527,7 +527,7 @@ std::string GeometryExporter::makeTexcoordSourceId(std::string &geom_id, suffix[0] = '\0'; } else { - BLI_snprintf(suffix, sizeof(suffix), "-%d", layer_index); + SNPRINTF(suffix, "-%d", layer_index); } return getIdBySemantics(geom_id, COLLADASW::InputSemantic::TEXCOORD) + suffix; } diff --git a/source/blender/io/collada/ImageExporter.cpp b/source/blender/io/collada/ImageExporter.cpp index 4cc2b3e68ff..eb534ea9988 100644 --- a/source/blender/io/collada/ImageExporter.cpp +++ b/source/blender/io/collada/ImageExporter.cpp @@ -67,7 +67,7 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) /* make absolute destination path */ - BLI_strncpy(export_file, name.c_str(), sizeof(export_file)); + STRNCPY(export_file, name.c_str()); BKE_image_path_ext_from_imformat_ensure(export_file, sizeof(export_file), &imageFormat); BLI_path_join(export_path, sizeof(export_path), export_dir, export_file); @@ -85,12 +85,12 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) fprintf(stderr, "Collada export: Cannot export image to:\n%s\n", export_path); return; } - BLI_strncpy(export_path, export_file, sizeof(export_path)); + STRNCPY(export_path, export_file); } else { /* make absolute source path */ - BLI_strncpy(source_path, image->filepath, sizeof(source_path)); + STRNCPY(source_path, image->filepath); BLI_path_abs(source_path, ID_BLEND_PATH_FROM_GLOBAL(&image->id)); BLI_path_normalize(source_path); @@ -112,14 +112,14 @@ void ImagesExporter::export_UV_Image(Image *image, bool use_copies) } } - BLI_strncpy(export_path, export_file, sizeof(export_path)); + STRNCPY(export_path, export_file); } else { /* Do not make any copies, but use the source path directly as reference * to the original image */ - BLI_strncpy(export_path, source_path, sizeof(export_path)); + STRNCPY(export_path, source_path); } } diff --git a/source/blender/io/collada/collada_utils.cpp b/source/blender/io/collada/collada_utils.cpp index 1e83c8be72a..0324d55ea0e 100644 --- a/source/blender/io/collada/collada_utils.cpp +++ b/source/blender/io/collada/collada_utils.cpp @@ -516,7 +516,7 @@ char *BoneExtended::get_name() void BoneExtended::set_name(char *aName) { - BLI_strncpy(name, aName, MAXBONENAME); + STRNCPY(name, aName); } int BoneExtended::get_chain_length() @@ -771,7 +771,7 @@ void bc_enable_fcurves(bAction *act, char *bone_name) if (bone_name) { char bone_name_esc[sizeof(Bone::name) * 2]; BLI_str_escape(bone_name_esc, bone_name, sizeof(bone_name_esc)); - BLI_snprintf(prefix, sizeof(prefix), "pose.bones[\"%s\"]", bone_name_esc); + SNPRINTF(prefix, "pose.bones[\"%s\"]", bone_name_esc); } for (fcu = (FCurve *)act->curves.first; fcu; fcu = fcu->next) { diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc index 737f22ebcd4..1722bd036d1 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator.cc @@ -169,9 +169,7 @@ AbstractHierarchyIterator::~AbstractHierarchyIterator() /* release_writers() cannot be called here directly, as it calls into the pure-virtual * release_writer() function. By the time this destructor is called, the subclass that implements * that pure-virtual function is already destructed. */ - BLI_assert( - writers_.empty() || - !"release_writers() should be called before the AbstractHierarchyIterator goes out of scope"); + BLI_assert(writers_.empty() || !"release_writers() should be called before the AbstractHierarchyIterator goes out of scope"); } void AbstractHierarchyIterator::iterate_and_write() diff --git a/source/blender/io/common/intern/path_util.cc b/source/blender/io/common/intern/path_util.cc index 5ca6d2b1979..363f3bd79b1 100644 --- a/source/blender/io/common/intern/path_util.cc +++ b/source/blender/io/common/intern/path_util.cc @@ -14,7 +14,7 @@ std::string path_reference(StringRefNull filepath, { const bool is_relative = BLI_path_is_rel(filepath.c_str()); char filepath_abs[PATH_MAX]; - BLI_strncpy(filepath_abs, filepath.c_str(), PATH_MAX); + STRNCPY(filepath_abs, filepath.c_str()); BLI_path_abs(filepath_abs, base_src.c_str()); BLI_path_normalize(filepath_abs); @@ -30,7 +30,7 @@ std::string path_reference(StringRefNull filepath, char filepath_cpy[PATH_MAX]; BLI_path_join(filepath_cpy, PATH_MAX, base_dst.c_str(), BLI_path_basename(filepath_abs)); copy_set->add(std::make_pair(filepath_abs, filepath_cpy)); - BLI_strncpy(filepath_abs, filepath_cpy, PATH_MAX); + STRNCPY(filepath_abs, filepath_cpy); mode = PATH_REFERENCE_RELATIVE; } @@ -40,7 +40,7 @@ std::string path_reference(StringRefNull filepath, } if (mode == PATH_REFERENCE_RELATIVE) { char rel_path[PATH_MAX]; - BLI_strncpy(rel_path, filepath_abs, PATH_MAX); + STRNCPY(rel_path, filepath_abs); BLI_path_rel(rel_path, base_dst.c_str()); /* Can't always find relative path (e.g. between different drives). */ if (!BLI_path_is_rel(rel_path)) { diff --git a/source/blender/io/gpencil/intern/gpencil_io_base.cc b/source/blender/io/gpencil/intern/gpencil_io_base.cc index d8d5e27ad44..ccfb0c715eb 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_base.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_base.cc @@ -177,7 +177,7 @@ void GpencilIO::create_object_list() void GpencilIO::filepath_set(const char *filepath) { - BLI_strncpy(filepath_, filepath, FILE_MAX); + STRNCPY(filepath_, filepath); BLI_path_abs(filepath_, BKE_main_blendfile_path(bmain_)); } diff --git a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc index 1e6f688837d..8430f417b6e 100644 --- a/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc +++ b/source/blender/io/gpencil/intern/gpencil_io_export_svg.cc @@ -90,8 +90,7 @@ void GpencilExporterSVG::create_document_header() pugi::xml_node comment = main_doc_.append_child(pugi::node_comment); char txt[128]; - BLI_snprintf( - txt, sizeof(txt), " Generator: Blender, %s - %s ", SVG_EXPORTER_NAME, SVG_EXPORTER_VERSION); + SNPRINTF(txt, " Generator: Blender, %s - %s ", SVG_EXPORTER_NAME, SVG_EXPORTER_VERSION); comment.set_value(txt); pugi::xml_node doctype = main_doc_.append_child(pugi::node_doctype); @@ -148,7 +147,7 @@ void GpencilExporterSVG::export_gpencil_layers() pugi::xml_node ob_node = frame_node_.append_child("g"); char obtxt[96]; - BLI_snprintf(obtxt, sizeof(obtxt), "blender_object_%s", ob->id.name + 2); + SNPRINTF(obtxt, "blender_object_%s", ob->id.name + 2); ob_node.append_attribute("id").set_value(obtxt); /* Use evaluated version to get strokes with modifiers. */ @@ -406,7 +405,7 @@ std::string GpencilExporterSVG::rgb_to_hexstr(const float color[3]) uint8_t g = color[1] * 255.0f; uint8_t b = color[2] * 255.0f; char hex_string[20]; - BLI_snprintf(hex_string, sizeof(hex_string), "#%02X%02X%02X", r, g, b); + SNPRINTF(hex_string, "#%02X%02X%02X", r, g, b); std::string hexstr = hex_string; diff --git a/source/blender/io/ply/importer/ply_import.cc b/source/blender/io/ply/importer/ply_import.cc index cee1ad6d469..0d8d7e64383 100644 --- a/source/blender/io/ply/importer/ply_import.cc +++ b/source/blender/io/ply/importer/ply_import.cc @@ -170,7 +170,7 @@ void importer_main(Main *bmain, { /* File base name used for both mesh and object. */ char ob_name[FILE_MAX]; - BLI_strncpy(ob_name, BLI_path_basename(import_params.filepath), FILE_MAX); + STRNCPY(ob_name, BLI_path_basename(import_params.filepath)); BLI_path_extension_strip(ob_name); /* Parse header. */ diff --git a/source/blender/io/ply/tests/io_ply_exporter_test.cc b/source/blender/io/ply/tests/io_ply_exporter_test.cc index ae88906ee58..414bc65a011 100644 --- a/source/blender/io/ply/tests/io_ply_exporter_test.cc +++ b/source/blender/io/ply/tests/io_ply_exporter_test.cc @@ -134,7 +134,7 @@ TEST_F(ply_export_test, WriteHeaderAscii) _params.ascii_format = true; _params.export_normals = false; _params.vertex_colors = PLY_VERTEX_COLOR_NONE; - BLI_strncpy(_params.filepath, filePath.c_str(), 1024); + STRNCPY(_params.filepath, filePath.c_str()); std::unique_ptr plyData = load_cube(_params); @@ -172,7 +172,7 @@ TEST_F(ply_export_test, WriteHeaderBinary) _params.ascii_format = false; _params.export_normals = false; _params.vertex_colors = PLY_VERTEX_COLOR_NONE; - BLI_strncpy(_params.filepath, filePath.c_str(), 1024); + STRNCPY(_params.filepath, filePath.c_str()); std::unique_ptr plyData = load_cube(_params); @@ -210,7 +210,7 @@ TEST_F(ply_export_test, WriteVerticesAscii) _params.ascii_format = true; _params.export_normals = false; _params.vertex_colors = PLY_VERTEX_COLOR_NONE; - BLI_strncpy(_params.filepath, filePath.c_str(), 1024); + STRNCPY(_params.filepath, filePath.c_str()); std::unique_ptr plyData = load_cube(_params); @@ -242,7 +242,7 @@ TEST_F(ply_export_test, WriteVerticesBinary) _params.ascii_format = false; _params.export_normals = false; _params.vertex_colors = PLY_VERTEX_COLOR_NONE; - BLI_strncpy(_params.filepath, filePath.c_str(), 1024); + STRNCPY(_params.filepath, filePath.c_str()); std::unique_ptr plyData = load_cube(_params); @@ -278,7 +278,7 @@ TEST_F(ply_export_test, WriteFacesAscii) _params.ascii_format = true; _params.export_normals = false; _params.vertex_colors = PLY_VERTEX_COLOR_NONE; - BLI_strncpy(_params.filepath, filePath.c_str(), 1024); + STRNCPY(_params.filepath, filePath.c_str()); std::unique_ptr plyData = load_cube(_params); @@ -308,7 +308,7 @@ TEST_F(ply_export_test, WriteFacesBinary) _params.ascii_format = false; _params.export_normals = false; _params.vertex_colors = PLY_VERTEX_COLOR_NONE; - BLI_strncpy(_params.filepath, filePath.c_str(), 1024); + STRNCPY(_params.filepath, filePath.c_str()); std::unique_ptr plyData = load_cube(_params); @@ -344,7 +344,7 @@ TEST_F(ply_export_test, WriteVertexNormalsAscii) _params.ascii_format = true; _params.export_normals = true; _params.vertex_colors = PLY_VERTEX_COLOR_NONE; - BLI_strncpy(_params.filepath, filePath.c_str(), 1024); + STRNCPY(_params.filepath, filePath.c_str()); std::unique_ptr plyData = load_cube(_params); @@ -376,7 +376,7 @@ TEST_F(ply_export_test, WriteVertexNormalsBinary) _params.ascii_format = false; _params.export_normals = true; _params.vertex_colors = PLY_VERTEX_COLOR_NONE; - BLI_strncpy(_params.filepath, filePath.c_str(), 1024); + STRNCPY(_params.filepath, filePath.c_str()); std::unique_ptr plyData = load_cube(_params); diff --git a/source/blender/io/stl/importer/stl_import.cc b/source/blender/io/stl/importer/stl_import.cc index 628b3603a1f..d8eb210dc0c 100644 --- a/source/blender/io/stl/importer/stl_import.cc +++ b/source/blender/io/stl/importer/stl_import.cc @@ -75,7 +75,7 @@ void importer_main(Main *bmain, /* Name used for both mesh and object. */ char ob_name[FILE_MAX]; - BLI_strncpy(ob_name, BLI_path_basename(import_params.filepath), FILE_MAX); + STRNCPY(ob_name, BLI_path_basename(import_params.filepath)); BLI_path_extension_strip(ob_name); Mesh *mesh = is_ascii_stl ? diff --git a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc index da2625f6e51..db92890df59 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_export_mtl.cc @@ -149,7 +149,7 @@ static std::string get_image_filepath(const bNode *tex_node) } char path[FILE_MAX]; - BLI_strncpy(path, tex_image->filepath, FILE_MAX); + STRNCPY(path, tex_image->filepath); if (tex_image->source == IMA_SRC_SEQUENCE) { char head[FILE_MAX], tail[FILE_MAX]; diff --git a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc index 235d7eaa6e6..60c249f3a9a 100644 --- a/source/blender/io/wavefront_obj/exporter/obj_exporter.cc +++ b/source/blender/io/wavefront_obj/exporter/obj_exporter.cc @@ -289,7 +289,7 @@ void export_frame(Depsgraph *depsgraph, const OBJExportParams &export_params, co BLI_path_split_dir_part(export_params.filepath, dest_dir, PATH_MAX); } else { - BLI_strncpy(dest_dir, export_params.file_base_for_tests, PATH_MAX); + STRNCPY(dest_dir, export_params.file_base_for_tests); } BLI_path_slash_native(dest_dir); BLI_path_normalize(dest_dir); diff --git a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc index 881afc8009c..968be3e2512 100644 --- a/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc +++ b/source/blender/io/wavefront_obj/importer/obj_import_file_reader.cc @@ -492,7 +492,7 @@ void OBJParser::parse(Vector> &r_all_geometries, /* Use the filename as the default name given to the initial object. */ char ob_name[FILE_MAXFILE]; - BLI_strncpy(ob_name, BLI_path_basename(import_params_.filepath), FILE_MAXFILE); + STRNCPY(ob_name, BLI_path_basename(import_params_.filepath)); BLI_path_extension_strip(ob_name); Geometry *curr_geom = create_geometry(nullptr, GEOM_MESH, ob_name, r_all_geometries); @@ -837,7 +837,7 @@ void OBJParser::add_default_mtl_library() * that contain "mtllib bar.mtl" for a foo.obj, and depend on finding materials * from foo.mtl (see #97757). */ char mtl_file_path[FILE_MAX]; - BLI_strncpy(mtl_file_path, import_params_.filepath, sizeof(mtl_file_path)); + STRNCPY(mtl_file_path, import_params_.filepath); BLI_path_extension_replace(mtl_file_path, sizeof(mtl_file_path), ".mtl"); if (BLI_exists(mtl_file_path)) { char mtl_file_base[FILE_MAX]; diff --git a/source/blender/makesrna/intern/rna_access.cc b/source/blender/makesrna/intern/rna_access.cc index 75255dfdd7b..688ed8900bb 100644 --- a/source/blender/makesrna/intern/rna_access.cc +++ b/source/blender/makesrna/intern/rna_access.cc @@ -6975,7 +6975,7 @@ static char rna_struct_state_owner[64]; void RNA_struct_state_owner_set(const char *name) { if (name) { - BLI_strncpy(rna_struct_state_owner, name, sizeof(rna_struct_state_owner)); + STRNCPY(rna_struct_state_owner, name); } else { rna_struct_state_owner[0] = '\0'; diff --git a/source/blender/makesrna/intern/rna_action.c b/source/blender/makesrna/intern/rna_action.c index 79d6ba0e442..e5a6d833970 100644 --- a/source/blender/makesrna/intern/rna_action.c +++ b/source/blender/makesrna/intern/rna_action.c @@ -179,7 +179,7 @@ static TimeMarker *rna_Action_pose_markers_new(bAction *act, const char name[]) TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); marker->flag = SELECT; marker->frame = 1; - BLI_strncpy_utf8(marker->name, name, sizeof(marker->name)); + STRNCPY_UTF8(marker->name, name); BLI_addtail(&act->markers, marker); return marker; } diff --git a/source/blender/makesrna/intern/rna_animation.c b/source/blender/makesrna/intern/rna_animation.c index d2919143f56..77a91622b89 100644 --- a/source/blender/makesrna/intern/rna_animation.c +++ b/source/blender/makesrna/intern/rna_animation.c @@ -440,7 +440,7 @@ static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value) for (agrp = adt->action->groups.first; agrp; agrp = agrp->next) { if (STREQ(ks->name, agrp->name)) { /* there should only be one of these in the action, so can stop... */ - BLI_strncpy(agrp->name, value, sizeof(agrp->name)); + STRNCPY(agrp->name, value); break; } } @@ -450,7 +450,7 @@ static void rna_KeyingSet_name_set(PointerRNA *ptr, const char *value) } /* finally, update name to new value */ - BLI_strncpy(ks->name, value, sizeof(ks->name)); + STRNCPY(ks->name, value); } static int rna_KeyingSet_active_ksPath_editable(PointerRNA *ptr, const char **UNUSED(r_info)) diff --git a/source/blender/makesrna/intern/rna_armature.c b/source/blender/makesrna/intern/rna_armature.c index b11595bb8b9..2f015a5b862 100644 --- a/source/blender/makesrna/intern/rna_armature.c +++ b/source/blender/makesrna/intern/rna_armature.c @@ -359,8 +359,8 @@ static void rna_EditBone_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(ebone->name)], newname[sizeof(ebone->name)]; /* need to be on the stack */ - BLI_strncpy_utf8(newname, value, sizeof(ebone->name)); - BLI_strncpy(oldname, ebone->name, sizeof(ebone->name)); + STRNCPY_UTF8(newname, value); + STRNCPY(oldname, ebone->name); BLI_assert(BKE_id_is_in_global_main(&arm->id)); ED_armature_bone_rename(G_MAIN, arm, oldname, newname); @@ -373,8 +373,8 @@ static void rna_Bone_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(bone->name)], newname[sizeof(bone->name)]; /* need to be on the stack */ - BLI_strncpy_utf8(newname, value, sizeof(bone->name)); - BLI_strncpy(oldname, bone->name, sizeof(bone->name)); + STRNCPY_UTF8(newname, value); + STRNCPY(oldname, bone->name); BLI_assert(BKE_id_is_in_global_main(&arm->id)); ED_armature_bone_rename(G_MAIN, arm, oldname, newname); diff --git a/source/blender/makesrna/intern/rna_color.c b/source/blender/makesrna/intern/rna_color.c index 3c1df5ed112..bfca8ba631e 100644 --- a/source/blender/makesrna/intern/rna_color.c +++ b/source/blender/makesrna/intern/rna_color.c @@ -407,7 +407,7 @@ static void rna_ColorManagedDisplaySettings_display_device_set(struct PointerRNA const char *name = IMB_colormanagement_display_get_indexed_name(value); if (name) { - BLI_strncpy(display->display_device, name, sizeof(display->display_device)); + STRNCPY(display->display_device, name); } } @@ -469,7 +469,7 @@ static void rna_ColorManagedViewSettings_view_transform_set(PointerRNA *ptr, int const char *name = IMB_colormanagement_view_get_indexed_name(value); if (name) { - BLI_strncpy(view->view_transform, name, sizeof(view->view_transform)); + STRNCPY(view->view_transform, name); } } @@ -502,7 +502,7 @@ static void rna_ColorManagedViewSettings_look_set(PointerRNA *ptr, int value) const char *name = IMB_colormanagement_look_get_indexed_name(value); if (name) { - BLI_strncpy(view->look, name, sizeof(view->look)); + STRNCPY(view->look, name); } } @@ -572,7 +572,7 @@ static void rna_ColorManagedColorspaceSettings_colorspace_set(struct PointerRNA const char *name = IMB_colormanagement_colorspace_get_indexed_name(value); if (name && name[0]) { - BLI_strncpy(colorspace->name, name, sizeof(colorspace->name)); + STRNCPY(colorspace->name, name); } } diff --git a/source/blender/makesrna/intern/rna_constraint.c b/source/blender/makesrna/intern/rna_constraint.c index 7e883cabe92..d0d3d67038b 100644 --- a/source/blender/makesrna/intern/rna_constraint.c +++ b/source/blender/makesrna/intern/rna_constraint.c @@ -416,10 +416,10 @@ static void rna_Constraint_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(con->name)]; /* make a copy of the old name first */ - BLI_strncpy(oldname, con->name, sizeof(con->name)); + STRNCPY(oldname, con->name); /* copy the new name into the name slot */ - BLI_strncpy_utf8(con->name, value, sizeof(con->name)); + STRNCPY_UTF8(con->name, value); /* make sure name is unique */ if (ptr->owner_id) { diff --git a/source/blender/makesrna/intern/rna_fcurve.c b/source/blender/makesrna/intern/rna_fcurve.c index a0c65a48fe1..46a422c0644 100644 --- a/source/blender/makesrna/intern/rna_fcurve.c +++ b/source/blender/makesrna/intern/rna_fcurve.c @@ -452,7 +452,7 @@ void rna_DriverVariable_name_set(PointerRNA *ptr, const char *value) { DriverVar *data = (DriverVar *)(ptr->data); - BLI_strncpy_utf8(data->name, value, 64); + STRNCPY_UTF8(data->name, value); driver_variable_name_validate(data); driver_variable_unique_name(data); } diff --git a/source/blender/makesrna/intern/rna_fluid.c b/source/blender/makesrna/intern/rna_fluid.c index 4b9849d4177..f63d116ee11 100644 --- a/source/blender/makesrna/intern/rna_fluid.c +++ b/source/blender/makesrna/intern/rna_fluid.c @@ -658,7 +658,7 @@ static void rna_Fluid_cache_directory_set(struct PointerRNA *ptr, const char *va return; } - BLI_strncpy(settings->cache_directory, value, sizeof(settings->cache_directory)); + STRNCPY(settings->cache_directory, value); /* TODO(sebbas): Read cache state in order to set cache bake flags and cache pause frames * correctly. */ diff --git a/source/blender/makesrna/intern/rna_gpencil_legacy.c b/source/blender/makesrna/intern/rna_gpencil_legacy.c index c3c77bc07b9..029add6a242 100644 --- a/source/blender/makesrna/intern/rna_gpencil_legacy.c +++ b/source/blender/makesrna/intern/rna_gpencil_legacy.c @@ -354,7 +354,7 @@ static void set_parent(bGPDlayer *gpl, Object *par, const int type, const char * invert_m4_m4(gpl->inverse, tmp_mat); gpl->parent = par; gpl->partype |= PARBONE; - BLI_strncpy(gpl->parsubstr, substr, sizeof(gpl->parsubstr)); + STRNCPY(gpl->parsubstr, substr); } else { invert_m4_m4(gpl->inverse, par->object_to_world); @@ -600,10 +600,10 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) bGPDlayer *gpl = ptr->data; char oldname[128] = ""; - BLI_strncpy(oldname, gpl->info, sizeof(oldname)); + STRNCPY(oldname, gpl->info); /* copy the new name into the name slot */ - BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info)); + STRNCPY_UTF8(gpl->info, value); BLI_uniquename( &gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); @@ -615,7 +615,7 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value) LISTBASE_FOREACH (bGPDlayer *, gpl_, &gpd->layers) { LISTBASE_FOREACH (bGPDlayer_Mask *, mask, &gpl_->mask_layers) { if (STREQ(mask->name, oldname)) { - BLI_strncpy(mask->name, gpl->info, sizeof(mask->name)); + STRNCPY(mask->name, gpl->info); } } } @@ -626,13 +626,13 @@ static void rna_GPencilLayer_mask_info_set(PointerRNA *ptr, const char *value) bGPdata *gpd = (bGPdata *)ptr->owner_id; bGPDlayer_Mask *mask = ptr->data; char oldname[128] = ""; - BLI_strncpy(oldname, mask->name, sizeof(oldname)); + STRNCPY(oldname, mask->name); /* Really is changing the layer name. */ bGPDlayer *gpl = BKE_gpencil_layer_named_get(gpd, oldname); if (gpl) { /* copy the new name into the name slot */ - BLI_strncpy_utf8(gpl->info, value, sizeof(gpl->info)); + STRNCPY_UTF8(gpl->info, value); BLI_uniquename( &gpd->layers, gpl, DATA_("GP_Layer"), '.', offsetof(bGPDlayer, info), sizeof(gpl->info)); @@ -644,7 +644,7 @@ static void rna_GPencilLayer_mask_info_set(PointerRNA *ptr, const char *value) LISTBASE_FOREACH (bGPDlayer *, gpl_, &gpd->layers) { LISTBASE_FOREACH (bGPDlayer_Mask *, mask_, &gpl_->mask_layers) { if (STREQ(mask_->name, oldname)) { - BLI_strncpy(mask_->name, gpl->info, sizeof(mask_->name)); + STRNCPY(mask_->name, gpl->info); } } } diff --git a/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c index 24903f7c254..fff69389d02 100644 --- a/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c +++ b/source/blender/makesrna/intern/rna_gpencil_legacy_modifier.c @@ -355,10 +355,10 @@ static void rna_GpencilModifier_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(gmd->name)]; /* Make a copy of the old name first. */ - BLI_strncpy(oldname, gmd->name, sizeof(gmd->name)); + STRNCPY(oldname, gmd->name); /* Copy the new name into the name slot. */ - BLI_strncpy_utf8(gmd->name, value, sizeof(gmd->name)); + STRNCPY_UTF8(gmd->name, value); /* Make sure the name is truly unique. */ if (ptr->owner_id) { @@ -881,9 +881,9 @@ static void rna_DashGpencilModifierSegment_name_set(PointerRNA *ptr, const char DashGpencilModifierSegment *ds = ptr->data; char oldname[sizeof(ds->name)]; - BLI_strncpy(oldname, ds->name, sizeof(ds->name)); + STRNCPY(oldname, ds->name); - BLI_strncpy_utf8(ds->name, value, sizeof(ds->name)); + STRNCPY_UTF8(ds->name, value); BLI_assert(ds->dmd != NULL); BLI_uniquename_cb( @@ -904,9 +904,9 @@ static void rna_TimeGpencilModifierSegment_name_set(PointerRNA *ptr, const char TimeGpencilModifierSegment *ds = ptr->data; char oldname[sizeof(ds->name)]; - BLI_strncpy(oldname, ds->name, sizeof(ds->name)); + STRNCPY(oldname, ds->name); - BLI_strncpy_utf8(ds->name, value, sizeof(ds->name)); + STRNCPY_UTF8(ds->name, value); BLI_assert(ds->gpmd != NULL); BLI_uniquename_cb( diff --git a/source/blender/makesrna/intern/rna_key.c b/source/blender/makesrna/intern/rna_key.c index d8511224f6e..928e5d922cd 100644 --- a/source/blender/makesrna/intern/rna_key.c +++ b/source/blender/makesrna/intern/rna_key.c @@ -76,10 +76,10 @@ static void rna_ShapeKey_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(kb->name)]; /* make a copy of the old name first */ - BLI_strncpy(oldname, kb->name, sizeof(kb->name)); + STRNCPY(oldname, kb->name); /* copy the new name into the name slot */ - BLI_strncpy_utf8(kb->name, value, sizeof(kb->name)); + STRNCPY_UTF8(kb->name, value); /* make sure the name is truly unique */ if (ptr->owner_id) { diff --git a/source/blender/makesrna/intern/rna_lattice.c b/source/blender/makesrna/intern/rna_lattice.c index f94804cb609..488f929ad29 100644 --- a/source/blender/makesrna/intern/rna_lattice.c +++ b/source/blender/makesrna/intern/rna_lattice.c @@ -105,7 +105,7 @@ static void rna_Lattice_update_data_editlatt(Main *UNUSED(bmain), lt_em->typev = lt->typev; lt_em->typew = lt->typew; lt_em->flag = lt->flag; - BLI_strncpy(lt_em->vgroup, lt->vgroup, sizeof(lt_em->vgroup)); + STRNCPY(lt_em->vgroup, lt->vgroup); } DEG_id_tag_update(id, 0); @@ -201,10 +201,10 @@ static void rna_Lattice_points_w_set(PointerRNA *ptr, int value) static void rna_Lattice_vg_name_set(PointerRNA *ptr, const char *value) { Lattice *lt = ptr->data; - BLI_strncpy(lt->vgroup, value, sizeof(lt->vgroup)); + STRNCPY(lt->vgroup, value); if (lt->editlatt) { - BLI_strncpy(lt->editlatt->latt->vgroup, value, sizeof(lt->editlatt->latt->vgroup)); + STRNCPY(lt->editlatt->latt->vgroup, value); } } diff --git a/source/blender/makesrna/intern/rna_linestyle.c b/source/blender/makesrna/intern/rna_linestyle.c index c18ee461fae..855d7f13c0a 100644 --- a/source/blender/makesrna/intern/rna_linestyle.c +++ b/source/blender/makesrna/intern/rna_linestyle.c @@ -276,7 +276,7 @@ static void rna_LineStyleColorModifier_name_set(PointerRNA *ptr, const char *val FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id; LineStyleModifier *m = (LineStyleModifier *)ptr->data; - BLI_strncpy_utf8(m->name, value, sizeof(m->name)); + STRNCPY_UTF8(m->name, value); BLI_uniquename(&linestyle->color_modifiers, m, "ColorModifier", @@ -290,7 +290,7 @@ static void rna_LineStyleAlphaModifier_name_set(PointerRNA *ptr, const char *val FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id; LineStyleModifier *m = (LineStyleModifier *)ptr->data; - BLI_strncpy_utf8(m->name, value, sizeof(m->name)); + STRNCPY_UTF8(m->name, value); BLI_uniquename(&linestyle->alpha_modifiers, m, "AlphaModifier", @@ -304,7 +304,7 @@ static void rna_LineStyleThicknessModifier_name_set(PointerRNA *ptr, const char FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id; LineStyleModifier *m = (LineStyleModifier *)ptr->data; - BLI_strncpy_utf8(m->name, value, sizeof(m->name)); + STRNCPY_UTF8(m->name, value); BLI_uniquename(&linestyle->thickness_modifiers, m, "ThicknessModifier", @@ -318,7 +318,7 @@ static void rna_LineStyleGeometryModifier_name_set(PointerRNA *ptr, const char * FreestyleLineStyle *linestyle = (FreestyleLineStyle *)ptr->owner_id; LineStyleModifier *m = (LineStyleModifier *)ptr->data; - BLI_strncpy_utf8(m->name, value, sizeof(m->name)); + STRNCPY_UTF8(m->name, value); BLI_uniquename(&linestyle->geometry_modifiers, m, "GeometryModifier", diff --git a/source/blender/makesrna/intern/rna_mask.c b/source/blender/makesrna/intern/rna_mask.c index 8de81b9cc89..9e4a41a5403 100644 --- a/source/blender/makesrna/intern/rna_mask.c +++ b/source/blender/makesrna/intern/rna_mask.c @@ -206,8 +206,8 @@ static void rna_MaskLayer_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(masklay->name)], newname[sizeof(masklay->name)]; /* need to be on the stack */ - BLI_strncpy(oldname, masklay->name, sizeof(masklay->name)); - BLI_strncpy_utf8(newname, value, sizeof(masklay->name)); + STRNCPY(oldname, masklay->name); + STRNCPY_UTF8(newname, value); BKE_mask_layer_rename(mask, masklay, oldname, newname); } diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 6da6c4134c1..6f80bfa99ab 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -133,7 +133,7 @@ static CustomData *rna_mesh_ldata(const PointerRNA *ptr) static void rna_cd_layer_name_set(CustomData *cdata, CustomDataLayer *cdl, const char *value) { - BLI_strncpy_utf8(cdl->name, value, sizeof(cdl->name)); + STRNCPY_UTF8(cdl->name, value); CustomData_set_layer_unique_name(cdata, cdl - cdata->layers); } @@ -2502,7 +2502,7 @@ int rna_MeshStringProperty_s_length(PointerRNA *ptr) void rna_MeshStringProperty_s_set(PointerRNA *ptr, const char *value) { MStringProperty *ms = (MStringProperty *)ptr->data; - BLI_strncpy(ms->s, value, sizeof(ms->s)); + STRNCPY(ms->s, value); } static char *rna_MeshFaceMap_path(const PointerRNA *ptr) diff --git a/source/blender/makesrna/intern/rna_modifier.c b/source/blender/makesrna/intern/rna_modifier.c index 5486da2cd86..ddc5427a300 100644 --- a/source/blender/makesrna/intern/rna_modifier.c +++ b/source/blender/makesrna/intern/rna_modifier.c @@ -710,10 +710,10 @@ static void rna_Modifier_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(md->name)]; /* make a copy of the old name first */ - BLI_strncpy(oldname, md->name, sizeof(md->name)); + STRNCPY(oldname, md->name); /* copy the new name into the name slot */ - BLI_strncpy_utf8(md->name, value, sizeof(md->name)); + STRNCPY_UTF8(md->name, value); /* make sure the name is truly unique */ if (ptr->owner_id) { @@ -951,7 +951,7 @@ static void rna_HookModifier_subtarget_set(PointerRNA *ptr, const char *value) Object *owner = (Object *)ptr->owner_id; HookModifierData *hmd = ptr->data; - BLI_strncpy(hmd->subtarget, value, sizeof(hmd->subtarget)); + STRNCPY(hmd->subtarget, value); BKE_object_modifier_hook_reset(owner, hmd); } @@ -1093,7 +1093,7 @@ static void rna_MultiresModifier_filepath_set(PointerRNA *ptr, const char *value CustomDataExternal *external = ((Mesh *)ob->data)->ldata.external; if (external && !STREQ(external->filepath, value)) { - BLI_strncpy(external->filepath, value, sizeof(external->filepath)); + STRNCPY(external->filepath, value); multires_force_external_reload(ob); } } diff --git a/source/blender/makesrna/intern/rna_nla.c b/source/blender/makesrna/intern/rna_nla.c index 8bbee711be7..6ba6973de26 100644 --- a/source/blender/makesrna/intern/rna_nla.c +++ b/source/blender/makesrna/intern/rna_nla.c @@ -89,7 +89,7 @@ static void rna_NlaStrip_name_set(PointerRNA *ptr, const char *value) NlaStrip *data = (NlaStrip *)ptr->data; /* copy the name first */ - BLI_strncpy_utf8(data->name, value, sizeof(data->name)); + STRNCPY_UTF8(data->name, value); /* validate if there's enough info to do so */ if (ptr->owner_id) { diff --git a/source/blender/makesrna/intern/rna_nodetree.c b/source/blender/makesrna/intern/rna_nodetree.c index 87b0a28df2a..0718b8ee06f 100644 --- a/source/blender/makesrna/intern/rna_nodetree.c +++ b/source/blender/makesrna/intern/rna_nodetree.c @@ -2475,9 +2475,9 @@ static void rna_Node_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(node->name)]; /* make a copy of the old name first */ - BLI_strncpy(oldname, node->name, sizeof(node->name)); + STRNCPY(oldname, node->name); /* set new name */ - BLI_strncpy_utf8(node->name, value, sizeof(node->name)); + STRNCPY_UTF8(node->name, value); nodeUniqueName(ntree, node); @@ -4353,7 +4353,7 @@ static void rna_ShaderNodeTexIES_mode_set(PointerRNA *ptr, int value) Text *text = (Text *)node->id; if (value == NODE_IES_EXTERNAL && text->filepath) { - BLI_strncpy(nss->filepath, text->filepath, sizeof(nss->filepath)); + STRNCPY(nss->filepath, text->filepath); BLI_path_rel(nss->filepath, BKE_main_blendfile_path_from_global()); } @@ -4378,7 +4378,7 @@ static void rna_ShaderNodeScript_mode_set(PointerRNA *ptr, int value) Text *text = (Text *)node->id; if (value == NODE_SCRIPT_EXTERNAL && text->filepath) { - BLI_strncpy(nss->filepath, text->filepath, sizeof(nss->filepath)); + STRNCPY(nss->filepath, text->filepath); BLI_path_rel(nss->filepath, BKE_main_blendfile_path_from_global()); } @@ -4595,9 +4595,7 @@ void rna_ShaderNodePointDensity_density_cache(bNode *self, Depsgraph *depsgraph) pd->source = TEX_PD_OBJECT; pd->ob_cache_space = TEX_PD_OBJECTSPACE; pd->ob_color_source = point_density_vertex_color_source_from_shader(shader_point_density); - BLI_strncpy(pd->vertex_attribute_name, - shader_point_density->vertex_attribute_name, - sizeof(pd->vertex_attribute_name)); + STRNCPY(pd->vertex_attribute_name, shader_point_density->vertex_attribute_name); } /* Store resolution, so it can be changed in the UI. */ @@ -4675,7 +4673,7 @@ static void rna_NodeConvertColorSpace_from_color_space_set(struct PointerRNA *pt const char *name = IMB_colormanagement_colorspace_get_indexed_name(value); if (name && name[0]) { - BLI_strncpy(node_storage->from_color_space, name, sizeof(node_storage->from_color_space)); + STRNCPY(node_storage->from_color_space, name); } } static int rna_NodeConvertColorSpace_to_color_space_get(struct PointerRNA *ptr) @@ -4692,7 +4690,7 @@ static void rna_NodeConvertColorSpace_to_color_space_set(struct PointerRNA *ptr, const char *name = IMB_colormanagement_colorspace_get_indexed_name(value); if (name && name[0]) { - BLI_strncpy(node_storage->to_color_space, name, sizeof(node_storage->to_color_space)); + STRNCPY(node_storage->to_color_space, name); } } diff --git a/source/blender/makesrna/intern/rna_object.c b/source/blender/makesrna/intern/rna_object.c index 0b4397905a3..1d763c5bb17 100644 --- a/source/blender/makesrna/intern/rna_object.c +++ b/source/blender/makesrna/intern/rna_object.c @@ -811,7 +811,7 @@ static void rna_VertexGroup_name_set(PointerRNA *ptr, const char *value) } bDeformGroup *dg = (bDeformGroup *)ptr->data; - BLI_strncpy_utf8(dg->name, value, sizeof(dg->name)); + STRNCPY_UTF8(dg->name, value); BKE_object_defgroup_unique_name(dg, ob); } @@ -964,7 +964,7 @@ static void rna_FaceMap_name_set(PointerRNA *ptr, const char *value) { Object *ob = (Object *)ptr->owner_id; bFaceMap *fmap = (bFaceMap *)ptr->data; - BLI_strncpy_utf8(fmap->name, value, sizeof(fmap->name)); + STRNCPY_UTF8(fmap->name, value); BKE_object_facemap_unique_name(ob, fmap); } diff --git a/source/blender/makesrna/intern/rna_object_force.c b/source/blender/makesrna/intern/rna_object_force.c index 6208f0984e7..04e49b402c7 100644 --- a/source/blender/makesrna/intern/rna_object_force.c +++ b/source/blender/makesrna/intern/rna_object_force.c @@ -304,7 +304,7 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P } else if (cache->name[0] != '\0' && STREQ(cache->name, pid->cache->name)) { /* TODO: report "name exists" to user. */ - BLI_strncpy(cache->name, cache->prev_name, sizeof(cache->name)); + STRNCPY(cache->name, cache->prev_name); use_new_name = false; } } @@ -316,13 +316,13 @@ static void rna_Cache_idname_change(Main *UNUSED(bmain), Scene *UNUSED(scene), P char old_name[80]; char new_name[80]; - BLI_strncpy(old_name, cache->prev_name, sizeof(old_name)); - BLI_strncpy(new_name, cache->name, sizeof(new_name)); + STRNCPY(old_name, cache->prev_name); + STRNCPY(new_name, cache->name); BKE_ptcache_disk_cache_rename(pid2, old_name, new_name); } - BLI_strncpy(cache->prev_name, cache->name, sizeof(cache->prev_name)); + STRNCPY(cache->prev_name, cache->name); } BLI_freelistN(&pidlist); diff --git a/source/blender/makesrna/intern/rna_particle.c b/source/blender/makesrna/intern/rna_particle.c index 2dbca3d6acb..6fceface1c9 100644 --- a/source/blender/makesrna/intern/rna_particle.c +++ b/source/blender/makesrna/intern/rna_particle.c @@ -1106,7 +1106,7 @@ static void rna_ParticleSystem_name_set(PointerRNA *ptr, const char *value) ParticleSystem *part = (ParticleSystem *)ptr->data; /* copy the new name into the name slot */ - BLI_strncpy_utf8(part->name, value, sizeof(part->name)); + STRNCPY_UTF8(part->name, value); BLI_uniquename(&ob->particlesystem, part, diff --git a/source/blender/makesrna/intern/rna_path.cc b/source/blender/makesrna/intern/rna_path.cc index 8539f8d628b..dfe7e82ef86 100644 --- a/source/blender/makesrna/intern/rna_path.cc +++ b/source/blender/makesrna/intern/rna_path.cc @@ -619,7 +619,7 @@ char *RNA_path_append(const char *path, } else { char appendstr[128]; - BLI_snprintf(appendstr, sizeof(appendstr), "%d", intkey); + SNPRINTF(appendstr, "%d", intkey); BLI_dynstr_append(dynstr, appendstr); } diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c index 79b47aefb0e..c209a321efa 100644 --- a/source/blender/makesrna/intern/rna_pose.c +++ b/source/blender/makesrna/intern/rna_pose.c @@ -200,7 +200,7 @@ static void rna_BoneGroup_name_set(PointerRNA *ptr, const char *value) bActionGroup *agrp = ptr->data; /* copy the new name into the name slot */ - BLI_strncpy_utf8(agrp->name, value, sizeof(agrp->name)); + STRNCPY_UTF8(agrp->name, value); BLI_uniquename(&ob->pose->agroups, agrp, @@ -294,8 +294,8 @@ static void rna_PoseChannel_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(pchan->name)], newname[sizeof(pchan->name)]; /* need to be on the stack */ - BLI_strncpy_utf8(newname, value, sizeof(pchan->name)); - BLI_strncpy(oldname, pchan->name, sizeof(pchan->name)); + STRNCPY_UTF8(newname, value); + STRNCPY(oldname, pchan->name); BLI_assert(BKE_id_is_in_global_main(&ob->id)); BLI_assert(BKE_id_is_in_global_main(ob->data)); diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index d0839c48c9a..75398996fe3 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -1633,7 +1633,7 @@ static void rna_RenderSettings_engine_set(PointerRNA *ptr, int value) RenderEngineType *type = BLI_findlink(&R_engines, value); if (type) { - BLI_strncpy_utf8(rd->engine, type->idname, sizeof(rd->engine)); + STRNCPY_UTF8(rd->engine, type->idname); DEG_id_tag_update(ptr->owner_id, ID_RECALC_COPY_ON_WRITE); } } @@ -1768,7 +1768,7 @@ static void rna_SceneRenderView_name_set(PointerRNA *ptr, const char *value) { Scene *scene = (Scene *)ptr->owner_id; SceneRenderView *rv = (SceneRenderView *)ptr->data; - BLI_strncpy_utf8(rv->name, value, sizeof(rv->name)); + STRNCPY_UTF8(rv->name, value); BLI_uniquename(&scene->r.views, rv, DATA_("RenderView"), @@ -2139,7 +2139,7 @@ static TimeMarker *rna_TimeLine_add(Scene *scene, const char name[], int frame) TimeMarker *marker = MEM_callocN(sizeof(TimeMarker), "TimeMarker"); marker->flag = SELECT; marker->frame = frame; - BLI_strncpy_utf8(marker->name, name, sizeof(marker->name)); + STRNCPY_UTF8(marker->name, name); BLI_addtail(&scene->markers, marker); WM_main_add_notifier(NC_SCENE | ND_MARKERS, NULL); diff --git a/source/blender/makesrna/intern/rna_sequencer.c b/source/blender/makesrna/intern/rna_sequencer.c index a0528163de6..26d265e0031 100644 --- a/source/blender/makesrna/intern/rna_sequencer.c +++ b/source/blender/makesrna/intern/rna_sequencer.c @@ -1310,10 +1310,10 @@ static void rna_SequenceModifier_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(smd->name)]; /* make a copy of the old name first */ - BLI_strncpy(oldname, smd->name, sizeof(smd->name)); + STRNCPY(oldname, smd->name); /* copy the new name into the name slot */ - BLI_strncpy_utf8(smd->name, value, sizeof(smd->name)); + STRNCPY_UTF8(smd->name, value); /* make sure the name is truly unique */ SEQ_modifier_unique_name(seq, smd); @@ -1326,8 +1326,7 @@ static void rna_SequenceModifier_name_set(PointerRNA *ptr, const char *value) char seq_name_esc[(sizeof(seq->name) - 2) * 2]; BLI_str_escape(seq_name_esc, seq->name + 2, sizeof(seq_name_esc)); - BLI_snprintf( - path, sizeof(path), "sequence_editor.sequences_all[\"%s\"].modifiers", seq_name_esc); + SNPRINTF(path, "sequence_editor.sequences_all[\"%s\"].modifiers", seq_name_esc); BKE_animdata_fix_paths_rename(&scene->id, adt, NULL, path, oldname, smd->name, 0, 0, 1); } } @@ -1487,7 +1486,7 @@ static void rna_SequenceTimelineChannel_name_set(PointerRNA *ptr, const char *va channels_base = &channel_owner->channels; } - BLI_strncpy_utf8(channel->name, value, sizeof(channel->name)); + STRNCPY_UTF8(channel->name, value); BLI_uniquename(channels_base, channel, "Channel", diff --git a/source/blender/makesrna/intern/rna_sequencer_api.c b/source/blender/makesrna/intern/rna_sequencer_api.c index bb0888d756b..0fe9307f2ce 100644 --- a/source/blender/makesrna/intern/rna_sequencer_api.c +++ b/source/blender/makesrna/intern/rna_sequencer_api.c @@ -577,7 +577,7 @@ static StripElem *rna_SequenceElements_append(ID *id, Sequence *seq, const char seq->strip->stripdata = se = MEM_reallocN(seq->strip->stripdata, sizeof(StripElem) * (seq->len + 1)); se += seq->len; - BLI_strncpy(se->name, filename, sizeof(se->name)); + STRNCPY(se->name, filename); seq->len++; seq->flag &= ~SEQ_SINGLE_FRAME_CONTENT; diff --git a/source/blender/makesrna/intern/rna_shader_fx.c b/source/blender/makesrna/intern/rna_shader_fx.c index 6a2dff121d9..d4dcc8dcc5f 100644 --- a/source/blender/makesrna/intern/rna_shader_fx.c +++ b/source/blender/makesrna/intern/rna_shader_fx.c @@ -127,10 +127,10 @@ static void rna_ShaderFx_name_set(PointerRNA *ptr, const char *value) char oldname[sizeof(gmd->name)]; /* make a copy of the old name first */ - BLI_strncpy(oldname, gmd->name, sizeof(gmd->name)); + STRNCPY(oldname, gmd->name); /* copy the new name into the name slot */ - BLI_strncpy_utf8(gmd->name, value, sizeof(gmd->name)); + STRNCPY_UTF8(gmd->name, value); /* make sure the name is truly unique */ if (ptr->owner_id) { diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index b8cf054aeb4..8de72517ade 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -1538,7 +1538,7 @@ static void rna_3DViewShading_render_pass_set(PointerRNA *ptr, int value) } shading->render_pass = EEVEE_RENDER_PASS_AOV; - BLI_strncpy(shading->aov_name, aov->name, sizeof(aov->name)); + STRNCPY(shading->aov_name, aov->name); } else if (value == EEVEE_RENDER_PASS_BLOOM && ((scene->eevee.flag & SCE_EEVEE_BLOOM_ENABLED) == 0)) { @@ -2754,7 +2754,7 @@ static void rna_FileSelectPrams_filter_glob_set(PointerRNA *ptr, const char *val { FileSelectParams *params = ptr->data; - BLI_strncpy(params->filter_glob, value, sizeof(params->filter_glob)); + STRNCPY(params->filter_glob, value); /* Remove stupid things like last group being a wildcard-only one. */ BLI_path_extension_glob_validate(params->filter_glob); @@ -3130,7 +3130,7 @@ static void rna_FileBrowser_FSMenu_active_set(PointerRNA *ptr, break; } - BLI_strncpy(sf->params->dir, fsm->path, sizeof(sf->params->dir)); + STRNCPY(sf->params->dir, fsm->path); } } diff --git a/source/blender/makesrna/intern/rna_tracking.c b/source/blender/makesrna/intern/rna_tracking.c index b0c5dd9c1f5..25c3d4c4da4 100644 --- a/source/blender/makesrna/intern/rna_tracking.c +++ b/source/blender/makesrna/intern/rna_tracking.c @@ -264,9 +264,9 @@ static void rna_trackingTrack_name_set(PointerRNA *ptr, const char *value) track); /* Store old name, for the animation fix later. */ char old_name[sizeof(track->name)]; - BLI_strncpy(old_name, track->name, sizeof(track->name)); + STRNCPY(old_name, track->name); /* Update the name, */ - BLI_strncpy(track->name, value, sizeof(track->name)); + STRNCPY(track->name, value); BKE_tracking_track_unique_name(&tracking_object->tracks, track); /* Fix animation paths. */ AnimData *adt = BKE_animdata_from_id(&clip->id); @@ -350,9 +350,9 @@ static void rna_trackingPlaneTrack_name_set(PointerRNA *ptr, const char *value) plane_track); /* Store old name, for the animation fix later. */ char old_name[sizeof(plane_track->name)]; - BLI_strncpy(old_name, plane_track->name, sizeof(plane_track->name)); + STRNCPY(old_name, plane_track->name); /* Update the name, */ - BLI_strncpy(plane_track->name, value, sizeof(plane_track->name)); + STRNCPY(plane_track->name, value); BKE_tracking_plane_track_unique_name(&tracking_object->plane_tracks, plane_track); /* Fix animation paths. */ AnimData *adt = BKE_animdata_from_id(&clip->id); @@ -571,7 +571,7 @@ static void rna_trackingObject_name_set(PointerRNA *ptr, const char *value) MovieClip *clip = (MovieClip *)ptr->owner_id; MovieTrackingObject *tracking_object = (MovieTrackingObject *)ptr->data; - BLI_strncpy(tracking_object->name, value, sizeof(tracking_object->name)); + STRNCPY(tracking_object->name, value); BKE_tracking_object_unique_name(&clip->tracking, tracking_object); } @@ -670,7 +670,7 @@ static MovieTrackingTrack *add_track_to_base( track = BKE_tracking_track_add(tracking, tracksbase, 0, 0, frame, width, height); if (name && name[0]) { - BLI_strncpy(track->name, name, sizeof(track->name)); + STRNCPY(track->name, name); BKE_tracking_track_unique_name(tracksbase, track); } diff --git a/source/blender/makesrna/intern/rna_ui.c b/source/blender/makesrna/intern/rna_ui.c index 743c6ca3f46..0c116847be1 100644 --- a/source/blender/makesrna/intern/rna_ui.c +++ b/source/blender/makesrna/intern/rna_ui.c @@ -418,7 +418,7 @@ static StructRNA *rna_Panel_register(Main *bmain, { const char *owner_id = RNA_struct_state_owner_get(); if (owner_id) { - BLI_strncpy(pt->owner_id, owner_id, sizeof(pt->owner_id)); + STRNCPY(pt->owner_id, owner_id); } } @@ -1050,7 +1050,7 @@ static StructRNA *rna_Menu_register(Main *bmain, { const char *owner_id = RNA_struct_state_owner_get(); if (owner_id) { - BLI_strncpy(mt->owner_id, owner_id, sizeof(mt->owner_id)); + STRNCPY(mt->owner_id, owner_id); } } diff --git a/source/blender/makesrna/intern/rna_userdef.c b/source/blender/makesrna/intern/rna_userdef.c index fefccabd9a3..a4410936454 100644 --- a/source/blender/makesrna/intern/rna_userdef.c +++ b/source/blender/makesrna/intern/rna_userdef.c @@ -361,7 +361,7 @@ static void rna_userdef_script_directory_name_set(PointerRNA *ptr, const char *v value = DATA_("Untitled"); } - BLI_strncpy_utf8(script_dir->name, value, sizeof(script_dir->name)); + STRNCPY_UTF8(script_dir->name, value); BLI_uniquename(&U.script_directories, script_dir, value, @@ -880,7 +880,7 @@ static StructRNA *rna_AddonPref_register(Main *bmain, return NULL; } - BLI_strncpy(dummy_apt.idname, dummy_addon.module, sizeof(dummy_apt.idname)); + STRNCPY(dummy_apt.idname, dummy_addon.module); if (strlen(identifier) >= sizeof(dummy_apt.idname)) { BKE_reportf(reports, RPT_ERROR, diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index d3afc731a22..07abecceffe 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -1237,7 +1237,7 @@ static void rna_wmKeyMapItem_idname_set(PointerRNA *ptr, const char *value) WM_operator_bl_idname(idname, value); if (!STREQ(idname, kmi->idname)) { - BLI_strncpy(kmi->idname, idname, sizeof(kmi->idname)); + STRNCPY(kmi->idname, idname); WM_keymap_item_properties_reset(kmi, NULL); } diff --git a/source/blender/makesrna/intern/rna_wm_gizmo.c b/source/blender/makesrna/intern/rna_wm_gizmo.c index f92da9d74c8..42294529836 100644 --- a/source/blender/makesrna/intern/rna_wm_gizmo.c +++ b/source/blender/makesrna/intern/rna_wm_gizmo.c @@ -917,7 +917,7 @@ static StructRNA *rna_GizmoGroup_register(Main *bmain, { const char *owner_id = RNA_struct_state_owner_get(); if (owner_id) { - BLI_strncpy(gzgt->owner_id, owner_id, sizeof(gzgt->owner_id)); + STRNCPY(gzgt->owner_id, owner_id); } } diff --git a/source/blender/makesrna/intern/rna_workspace.c b/source/blender/makesrna/intern/rna_workspace.c index b72a4d56a03..cef8e698e5e 100644 --- a/source/blender/makesrna/intern/rna_workspace.c +++ b/source/blender/makesrna/intern/rna_workspace.c @@ -65,7 +65,7 @@ static wmOwnerID *rna_WorkSpace_owner_ids_new(WorkSpace *workspace, const char * { wmOwnerID *owner_id = MEM_callocN(sizeof(*owner_id), __func__); BLI_addtail(&workspace->owner_ids, owner_id); - BLI_strncpy(owner_id->name, name, sizeof(owner_id->name)); + STRNCPY(owner_id->name, name); WM_main_add_notifier(NC_WINDOW, NULL); return owner_id; } diff --git a/source/blender/makesrna/intern/rna_xr.c b/source/blender/makesrna/intern/rna_xr.c index c803e5dc9a8..efb1c556e52 100644 --- a/source/blender/makesrna/intern/rna_xr.c +++ b/source/blender/makesrna/intern/rna_xr.c @@ -50,7 +50,7 @@ static XrComponentPath *rna_XrComponentPath_new(XrActionMapBinding *amb, const c { # ifdef WITH_XR_OPENXR XrComponentPath *component_path = MEM_callocN(sizeof(XrComponentPath), __func__); - BLI_strncpy(component_path->path, path_str, sizeof(component_path->path)); + STRNCPY(component_path->path, path_str); BLI_addtail(&amb->component_paths, component_path); return component_path; # else @@ -237,7 +237,7 @@ static XrUserPath *rna_XrUserPath_new(XrActionMapItem *ami, const char *path_str { # ifdef WITH_XR_OPENXR XrUserPath *user_path = MEM_callocN(sizeof(XrUserPath), __func__); - BLI_strncpy(user_path->path, path_str, sizeof(user_path->path)); + STRNCPY(user_path->path, path_str); BLI_addtail(&ami->user_paths, user_path); return user_path; # else diff --git a/source/blender/modifiers/intern/MOD_laplaciandeform.cc b/source/blender/modifiers/intern/MOD_laplaciandeform.cc index 2eb99885c1e..d61357991b0 100644 --- a/source/blender/modifiers/intern/MOD_laplaciandeform.cc +++ b/source/blender/modifiers/intern/MOD_laplaciandeform.cc @@ -109,7 +109,7 @@ static LaplacianSystem *initLaplacianSystem(int verts_num, sys->tris_num = tris_num; sys->anchors_num = anchors_num; sys->repeat = iterations; - BLI_strncpy(sys->anchor_grp_name, defgrpName, sizeof(sys->anchor_grp_name)); + STRNCPY(sys->anchor_grp_name, defgrpName); sys->co = static_cast(MEM_malloc_arrayN(verts_num, sizeof(float[3]), __func__)); sys->no = static_cast(MEM_calloc_arrayN(verts_num, sizeof(float[3]), __func__)); sys->delta = static_cast(MEM_calloc_arrayN(verts_num, sizeof(float[3]), __func__)); diff --git a/source/blender/modifiers/intern/MOD_meshcache.cc b/source/blender/modifiers/intern/MOD_meshcache.cc index 450d2fd53f9..93ae7f3ecac 100644 --- a/source/blender/modifiers/intern/MOD_meshcache.cc +++ b/source/blender/modifiers/intern/MOD_meshcache.cc @@ -141,7 +141,7 @@ static void meshcache_do(MeshCacheModifierData *mcmd, /* Read the File (or error out when the file is bad) */ /* would be nice if we could avoid doing this _every_ frame */ - BLI_strncpy(filepath, mcmd->filepath, sizeof(filepath)); + STRNCPY(filepath, mcmd->filepath); BLI_path_abs(filepath, ID_BLEND_PATH_FROM_GLOBAL((ID *)ob)); switch (mcmd->type) { diff --git a/source/blender/modifiers/intern/MOD_nodes.cc b/source/blender/modifiers/intern/MOD_nodes.cc index b44481ec2e8..e7f1885bcd3 100644 --- a/source/blender/modifiers/intern/MOD_nodes.cc +++ b/source/blender/modifiers/intern/MOD_nodes.cc @@ -1754,7 +1754,7 @@ static void draw_property_for_socket(const bContext &C, BLI_str_escape(socket_id_esc, socket.identifier, sizeof(socket_id_esc)); char rna_path[sizeof(socket_id_esc) + 4]; - BLI_snprintf(rna_path, ARRAY_SIZE(rna_path), "[\"%s\"]", socket_id_esc); + SNPRINTF(rna_path, "[\"%s\"]", socket_id_esc); uiLayout *row = uiLayoutRow(layout, true); uiLayoutSetPropDecorate(row, true); diff --git a/source/blender/modifiers/intern/MOD_subsurf.cc b/source/blender/modifiers/intern/MOD_subsurf.cc index b954d1f7c8e..a480041ff6c 100644 --- a/source/blender/modifiers/intern/MOD_subsurf.cc +++ b/source/blender/modifiers/intern/MOD_subsurf.cc @@ -402,11 +402,7 @@ static void panel_draw(const bContext *C, Panel *panel) RNA_float_get(&ob_cycles_ptr, "dicing_rate"), 0.1f); char output[256]; - BLI_snprintf(output, - sizeof(output), - TIP_("Final Scale: Render %.2f px, Viewport %.2f px"), - render, - preview); + SNPRINTF(output, TIP_("Final Scale: Render %.2f px, Viewport %.2f px"), render, preview); uiItemL(layout, output, ICON_NONE); uiItemS(layout); diff --git a/source/blender/modifiers/intern/MOD_ui_common.cc b/source/blender/modifiers/intern/MOD_ui_common.cc index 75452ce5ab9..16283bce932 100644 --- a/source/blender/modifiers/intern/MOD_ui_common.cc +++ b/source/blender/modifiers/intern/MOD_ui_common.cc @@ -456,10 +456,10 @@ PanelType *modifier_panel_register(ARegionType *region_type, ModifierType type, PanelType *panel_type = MEM_cnew(__func__); BKE_modifier_type_panel_id(type, panel_type->idname); - BLI_strncpy(panel_type->label, "", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); - BLI_strncpy(panel_type->active_property, "is_active", BKE_ST_MAXNAME); + STRNCPY(panel_type->label, ""); + STRNCPY(panel_type->context, "modifier"); + STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + STRNCPY(panel_type->active_property, "is_active"); panel_type->draw_header = modifier_panel_header; panel_type->draw = draw; @@ -486,11 +486,11 @@ PanelType *modifier_subpanel_register(ARegionType *region_type, { PanelType *panel_type = MEM_cnew(__func__); - BLI_snprintf(panel_type->idname, BKE_ST_MAXNAME, "%s_%s", parent->idname, name); - BLI_strncpy(panel_type->label, label, BKE_ST_MAXNAME); - BLI_strncpy(panel_type->context, "modifier", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); - BLI_strncpy(panel_type->active_property, "is_active", BKE_ST_MAXNAME); + SNPRINTF(panel_type->idname, "%s_%s", parent->idname, name); + STRNCPY(panel_type->label, label); + STRNCPY(panel_type->context, "modifier"); + STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); + STRNCPY(panel_type->active_property, "is_active"); panel_type->draw_header = draw_header; panel_type->draw = draw; @@ -498,7 +498,7 @@ PanelType *modifier_subpanel_register(ARegionType *region_type, panel_type->flag = PANEL_TYPE_DEFAULT_CLOSED; BLI_assert(parent != nullptr); - BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME); + STRNCPY(panel_type->parent_id, parent->idname); panel_type->parent = parent; BLI_addtail(&parent->children, BLI_genericNodeN(panel_type)); BLI_addtail(®ion_type->paneltypes, panel_type); diff --git a/source/blender/modifiers/intern/MOD_weightvg_util.cc b/source/blender/modifiers/intern/MOD_weightvg_util.cc index eccb3330e06..def70d0b5d4 100644 --- a/source/blender/modifiers/intern/MOD_weightvg_util.cc +++ b/source/blender/modifiers/intern/MOD_weightvg_util.cc @@ -145,8 +145,8 @@ void weightvg_do_mask(const ModifierEvalContext *ctx, */ t_map.texture = texture; t_map.map_object = tex_map_object; - BLI_strncpy(t_map.map_bone, text_map_bone, sizeof(t_map.map_bone)); - BLI_strncpy(t_map.uvlayer_name, tex_uvlayer_name, sizeof(t_map.uvlayer_name)); + STRNCPY(t_map.map_bone, text_map_bone); + STRNCPY(t_map.uvlayer_name, tex_uvlayer_name); t_map.texmapping = tex_mapping; tex_co = static_cast(MEM_calloc_arrayN(verts_num, sizeof(*tex_co), __func__)); diff --git a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc index fcd21f40a21..62c68f35f69 100644 --- a/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc +++ b/source/blender/nodes/composite/nodes/node_composite_cryptomatte.cc @@ -361,7 +361,7 @@ bNodeSocket *ntreeCompositCryptomatteAddSocket(bNodeTree *ntree, bNode *node) NodeCryptomatte *n = static_cast(node->storage); char sockname[32]; n->inputs_num++; - BLI_snprintf(sockname, sizeof(sockname), "Crypto %.2d", n->inputs_num - 1); + SNPRINTF(sockname, "Crypto %.2d", n->inputs_num - 1); bNodeSocket *sock = nodeAddStaticSocket( ntree, node, SOCK_IN, SOCK_RGBA, PROP_NONE, nullptr, sockname); return sock; diff --git a/source/blender/nodes/composite/nodes/node_composite_image.cc b/source/blender/nodes/composite/nodes/node_composite_image.cc index 76ba859621c..af5f4e75ad0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_image.cc +++ b/source/blender/nodes/composite/nodes/node_composite_image.cc @@ -113,7 +113,7 @@ static void cmp_node_image_add_pass_output(bNodeTree *ntree, NodeImageLayer *sockdata = (NodeImageLayer *)sock->storage; if (sockdata) { - BLI_strncpy(sockdata->pass_name, passname, sizeof(sockdata->pass_name)); + STRNCPY(sockdata->pass_name, passname); } /* Reorder sockets according to order that passes are added. */ @@ -710,9 +710,7 @@ static void node_composit_init_rlayers(const bContext *C, PointerRNA *ptr) NodeImageLayer *sockdata = MEM_cnew(__func__); sock->storage = sockdata; - BLI_strncpy(sockdata->pass_name, - node_cmp_rlayers_sock_to_pass(sock_index), - sizeof(sockdata->pass_name)); + STRNCPY(sockdata->pass_name, node_cmp_rlayers_sock_to_pass(sock_index)); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc index b7db13b4880..20162c57fd0 100644 --- a/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc +++ b/source/blender/nodes/composite/nodes/node_composite_keyingscreen.cc @@ -52,7 +52,7 @@ static void node_composit_init_keyingscreen(const bContext *C, PointerRNA *ptr) id_us_plus(&clip->id); const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(&clip->tracking); - BLI_strncpy(data->tracking_object, tracking_object->name, sizeof(data->tracking_object)); + STRNCPY(data->tracking_object, tracking_object->name); } } diff --git a/source/blender/nodes/composite/nodes/node_composite_output_file.cc b/source/blender/nodes/composite/nodes/node_composite_output_file.cc index ddd2453b278..efc06c80a8a 100644 --- a/source/blender/nodes/composite/nodes/node_composite_output_file.cc +++ b/source/blender/nodes/composite/nodes/node_composite_output_file.cc @@ -128,9 +128,9 @@ bNodeSocket *ntreeCompositOutputFileAddSocket(bNodeTree *ntree, NodeImageMultiFileSocket *sockdata = MEM_cnew(__func__); sock->storage = sockdata; - BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path)); + STRNCPY_UTF8(sockdata->path, name); ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_'); - BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer)); + STRNCPY_UTF8(sockdata->layer, name); ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_'); if (im_format) { @@ -176,14 +176,14 @@ int ntreeCompositOutputFileRemoveActiveSocket(bNodeTree *ntree, bNode *node) void ntreeCompositOutputFileSetPath(bNode *node, bNodeSocket *sock, const char *name) { NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)sock->storage; - BLI_strncpy_utf8(sockdata->path, name, sizeof(sockdata->path)); + STRNCPY_UTF8(sockdata->path, name); ntreeCompositOutputFileUniquePath(&node->inputs, sock, name, '_'); } void ntreeCompositOutputFileSetLayer(bNode *node, bNodeSocket *sock, const char *name) { NodeImageMultiFileSocket *sockdata = (NodeImageMultiFileSocket *)sock->storage; - BLI_strncpy_utf8(sockdata->layer, name, sizeof(sockdata->layer)); + STRNCPY_UTF8(sockdata->layer, name); ntreeCompositOutputFileUniqueLayer(&node->inputs, sock, name, '_'); } @@ -202,7 +202,7 @@ static void init_output_file(const bContext *C, PointerRNA *ptr) if (scene) { RenderData *rd = &scene->r; - BLI_strncpy(nimf->base_path, rd->pic, sizeof(nimf->base_path)); + STRNCPY(nimf->base_path, rd->pic); BKE_image_format_copy(&nimf->format, &rd->im_format); nimf->format.color_management = R_IMF_COLOR_MANAGEMENT_FOLLOW_SCENE; if (BKE_imtype_is_movie(nimf->format.imtype)) { diff --git a/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc b/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc index d1ff550479a..b4a11dbf25c 100644 --- a/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc +++ b/source/blender/nodes/composite/nodes/node_composite_planetrackdeform.cc @@ -51,12 +51,10 @@ static void init(const bContext *C, PointerRNA *ptr) id_us_plus(&clip->id); const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); - BLI_strncpy(data->tracking_object, tracking_object->name, sizeof(data->tracking_object)); + STRNCPY(data->tracking_object, tracking_object->name); if (tracking_object->active_plane_track) { - BLI_strncpy(data->plane_track_name, - tracking_object->active_plane_track->name, - sizeof(data->plane_track_name)); + STRNCPY(data->plane_track_name, tracking_object->active_plane_track->name); } } } diff --git a/source/blender/nodes/composite/nodes/node_composite_trackpos.cc b/source/blender/nodes/composite/nodes/node_composite_trackpos.cc index 66468a654e3..9cc6cf9d493 100644 --- a/source/blender/nodes/composite/nodes/node_composite_trackpos.cc +++ b/source/blender/nodes/composite/nodes/node_composite_trackpos.cc @@ -54,10 +54,10 @@ static void init(const bContext *C, PointerRNA *ptr) id_us_plus(&clip->id); const MovieTrackingObject *tracking_object = BKE_tracking_object_get_active(tracking); - BLI_strncpy(data->tracking_object, tracking_object->name, sizeof(data->tracking_object)); + STRNCPY(data->tracking_object, tracking_object->name); if (tracking_object->active_track) { - BLI_strncpy(data->track_name, tracking_object->active_track->name, sizeof(data->track_name)); + STRNCPY(data->track_name, tracking_object->active_track->name); } } } diff --git a/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc b/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc index cda46948bc9..45062284cda 100644 --- a/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc +++ b/source/blender/nodes/geometry/nodes/node_geo_simulation_output.cc @@ -731,7 +731,7 @@ bool NOD_geometry_simulation_output_item_set_unique_name(NodeGeometrySimulationO const char *defname) { char unique_name[MAX_NAME + 4]; - BLI_strncpy(unique_name, name, sizeof(unique_name)); + STRNCPY(unique_name, name); blender::nodes::SimulationItemsUniqueNameArgs args{sim, item}; const bool name_changed = BLI_uniquename_cb(blender::nodes::simulation_items_unique_name_check, diff --git a/source/blender/nodes/intern/node_register.cc b/source/blender/nodes/intern/node_register.cc index 69a20098514..9653ded3438 100644 --- a/source/blender/nodes/intern/node_register.cc +++ b/source/blender/nodes/intern/node_register.cc @@ -34,9 +34,7 @@ static void register_undefined_types() node_type_base_custom(&NodeTypeUndefined, "NodeUndefined", "Undefined", 0); NodeTypeUndefined.poll = node_undefined_poll; - BLI_strncpy(NodeSocketTypeUndefined.idname, - "NodeSocketUndefined", - sizeof(NodeSocketTypeUndefined.idname)); + STRNCPY(NodeSocketTypeUndefined.idname, "NodeSocketUndefined"); /* extra type info for standard socket types */ NodeSocketTypeUndefined.type = SOCK_CUSTOM; NodeSocketTypeUndefined.subtype = PROP_NONE; diff --git a/source/blender/nodes/intern/node_socket.cc b/source/blender/nodes/intern/node_socket.cc index 367897160ff..e4f6e08dbcb 100644 --- a/source/blender/nodes/intern/node_socket.cc +++ b/source/blender/nodes/intern/node_socket.cc @@ -423,7 +423,7 @@ void node_socket_copy_default_value(bNodeSocket *to, const bNodeSocket *from) /* use label instead of name if it has been set */ if (from->label[0] != '\0') { - BLI_strncpy(to->name, from->label, NODE_MAXSTR); + STRNCPY(to->name, from->label); } switch (from->typeinfo->type) { @@ -543,9 +543,9 @@ static bNodeSocketType *make_standard_socket_type(int type, int subtype) stype = MEM_cnew("node socket C type"); stype->free_self = (void (*)(bNodeSocketType * stype)) MEM_freeN; - BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname)); - BLI_strncpy(stype->label, socket_label, sizeof(stype->label)); - BLI_strncpy(stype->subtype_label, socket_subtype_label, sizeof(stype->subtype_label)); + STRNCPY(stype->idname, socket_idname); + STRNCPY(stype->label, socket_label); + STRNCPY(stype->subtype_label, socket_subtype_label); /* set the RNA type * uses the exact same identifier as the socket type idname */ @@ -587,7 +587,7 @@ static bNodeSocketType *make_socket_type_virtual() stype = MEM_cnew("node socket C type"); stype->free_self = (void (*)(bNodeSocketType * stype)) MEM_freeN; - BLI_strncpy(stype->idname, socket_idname, sizeof(stype->idname)); + STRNCPY(stype->idname, socket_idname); /* set the RNA type * uses the exact same identifier as the socket type idname */ diff --git a/source/blender/nodes/intern/node_socket_declarations.cc b/source/blender/nodes/intern/node_socket_declarations.cc index ec4049519e3..018be8eb896 100644 --- a/source/blender/nodes/intern/node_socket_declarations.cc +++ b/source/blender/nodes/intern/node_socket_declarations.cc @@ -60,7 +60,7 @@ static bool basic_types_can_connect(const SocketDeclaration & /*socket_decl*/, static void modify_subtype_except_for_storage(bNodeSocket &socket, int new_subtype) { const char *idname = nodeStaticSocketType(socket.type, new_subtype); - BLI_strncpy(socket.idname, idname, sizeof(socket.idname)); + STRNCPY(socket.idname, idname); bNodeSocketType *socktype = nodeSocketTypeFind(idname); socket.typeinfo = socktype; } diff --git a/source/blender/nodes/intern/node_util.cc b/source/blender/nodes/intern/node_util.cc index c6196d481a4..1072714c8be 100644 --- a/source/blender/nodes/intern/node_util.cc +++ b/source/blender/nodes/intern/node_util.cc @@ -74,7 +74,7 @@ void *node_initexec_curves(bNodeExecContext * /*context*/, bNode *node, bNodeIns void node_sock_label(bNodeSocket *sock, const char *name) { - BLI_strncpy(sock->label, name, MAX_NAME); + STRNCPY(sock->label, name); } void node_sock_label_clear(bNodeSocket *sock) diff --git a/source/blender/nodes/texture/nodes/node_texture_output.cc b/source/blender/nodes/texture/nodes/node_texture_output.cc index 2ba5440d88d..fe53d237896 100644 --- a/source/blender/nodes/texture/nodes/node_texture_output.cc +++ b/source/blender/nodes/texture/nodes/node_texture_output.cc @@ -80,14 +80,14 @@ static void unique_name(bNode *node) } } - BLI_strncpy(new_name, name, sizeof(tno->name)); + STRNCPY(new_name, name); name = new_name; } BLI_sprintf(new_name + new_len - 4, ".%03d", ++suffix); } if (new_name[0] != '\0') { - BLI_strncpy(tno->name, new_name, sizeof(tno->name)); + STRNCPY(tno->name, new_name); } } diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c index d0deae67415..bf001f062ec 100644 --- a/source/blender/python/generic/imbuf_py_api.c +++ b/source/blender/python/generic/imbuf_py_api.c @@ -496,7 +496,7 @@ static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject * return NULL; } - BLI_strncpy(ibuf->filepath, filepath, sizeof(ibuf->filepath)); + STRNCPY(ibuf->filepath, filepath); return Py_ImBuf_CreatePyObject(ibuf); } diff --git a/source/blender/python/gpu/gpu_py_shader_create_info.cc b/source/blender/python/gpu/gpu_py_shader_create_info.cc index b60cbbf918a..02725e3f676 100644 --- a/source/blender/python/gpu/gpu_py_shader_create_info.cc +++ b/source/blender/python/gpu/gpu_py_shader_create_info.cc @@ -794,9 +794,7 @@ static PyObject *pygpu_shader_info_push_constant(BPyGPUShaderCreateInfo *self, #define VULKAN_LIMIT 128 int size = constants_calc_size(info); if (size > VULKAN_LIMIT) { - printf("Push constants have a minimum supported size of " - STRINGIFY(VULKAN_LIMIT) - " bytes, however the constants added so far already reach %d bytes. Consider using UBO.\n", size); + printf("Push constants have a minimum supported size of " STRINGIFY(VULKAN_LIMIT) " bytes, however the constants added so far already reach %d bytes. Consider using UBO.\n", size); } #undef VULKAN_LIMIT diff --git a/source/blender/python/intern/bpy_app_translations.c b/source/blender/python/intern/bpy_app_translations.c index 99beeb5ac63..782a2a3de09 100644 --- a/source/blender/python/intern/bpy_app_translations.c +++ b/source/blender/python/intern/bpy_app_translations.c @@ -267,7 +267,7 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms if (!STREQ(tmp, locale) || !_translations_cache) { PyGILState_STATE _py_state; - BLI_strncpy(locale, tmp, STATIC_LOCALE_SIZE); + STRNCPY(locale, tmp); /* Locale changed or cache does not exist, refresh the whole cache! */ /* This func may be called from C (i.e. outside of python interpreter 'context'). */ diff --git a/source/blender/python/intern/bpy_driver.c b/source/blender/python/intern/bpy_driver.c index 402bc6408f8..ba28891dfe0 100644 --- a/source/blender/python/intern/bpy_driver.c +++ b/source/blender/python/intern/bpy_driver.c @@ -598,7 +598,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) { if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) { G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL; - BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Driver '%s'", expr); + SNPRINTF(G.autoexec_fail, "Driver '%s'", expr); printf("skipping driver '%s', automatic scripts are disabled\n", expr); } @@ -759,7 +759,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna, { if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) { G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL; - BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Driver '%s'", expr); + SNPRINTF(G.autoexec_fail, "Driver '%s'", expr); } Py_DECREF(expr_code); diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 8ec4a91b822..81d1137d053 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -656,7 +656,7 @@ void BPY_modules_load_user(bContext *C) if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) { if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) { G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL; - BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Text '%s'", text->id.name + 2); + SNPRINTF(G.autoexec_fail, "Text '%s'", text->id.name + 2); printf("scripts disabled for \"%s\", skipping '%s'\n", BKE_main_blendfile_path(bmain), diff --git a/source/blender/python/intern/bpy_library_load.c b/source/blender/python/intern/bpy_library_load.c index 0f554fc1536..3322d9a610a 100644 --- a/source/blender/python/intern/bpy_library_load.c +++ b/source/blender/python/intern/bpy_library_load.c @@ -241,8 +241,8 @@ static PyObject *bpy_lib_load(BPy_PropertyRNA *self, PyObject *args, PyObject *k ret = PyObject_New(BPy_Library, &bpy_lib_Type); - BLI_strncpy(ret->relpath, filepath, sizeof(ret->relpath)); - BLI_strncpy(ret->abspath, filepath, sizeof(ret->abspath)); + STRNCPY(ret->relpath, filepath); + STRNCPY(ret->abspath, filepath); BLI_path_abs(ret->abspath, BKE_main_blendfile_path(bmain)); ret->bmain = bmain; @@ -324,8 +324,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self) /* create a dummy */ self_from = PyObject_New(BPy_Library, &bpy_lib_Type); - BLI_strncpy(self_from->relpath, self->relpath, sizeof(self_from->relpath)); - BLI_strncpy(self_from->abspath, self->abspath, sizeof(self_from->abspath)); + STRNCPY(self_from->relpath, self->relpath); + STRNCPY(self_from->abspath, self->abspath); self_from->blo_handle = NULL; self_from->flag = 0; diff --git a/source/blender/python/intern/bpy_library_write.c b/source/blender/python/intern/bpy_library_write.c index 6b5cae45222..6e71b22f4bd 100644 --- a/source/blender/python/intern/bpy_library_write.c +++ b/source/blender/python/intern/bpy_library_write.c @@ -117,7 +117,7 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject * write_flags |= G_FILE_COMPRESS; } - BLI_strncpy(filepath_abs, filepath, FILE_MAX); + STRNCPY(filepath_abs, filepath); BLI_path_abs(filepath_abs, BKE_main_blendfile_path_from_global()); BKE_blendfile_write_partial_begin(bmain_src); diff --git a/source/blender/python/intern/bpy_rna_array.c b/source/blender/python/intern/bpy_rna_array.c index fbc981689d5..d86e8de750c 100644 --- a/source/blender/python/intern/bpy_rna_array.c +++ b/source/blender/python/intern/bpy_rna_array.c @@ -192,8 +192,8 @@ static int validate_array_type(PyObject *seq, Py_DECREF(item); #if 0 - BLI_snprintf( - error_str, error_str_size, "sequence items should be of type %s", item_type_str); + SNPRINTF( + error_str, "sequence items should be of type %s", item_type_str); #endif PyErr_Format(PyExc_TypeError, "%s expected sequence items of type %s, not %s", diff --git a/source/blender/python/mathutils/mathutils_Matrix.c b/source/blender/python/mathutils/mathutils_Matrix.c index 84ee3a9db57..c5b4c1ddd5e 100644 --- a/source/blender/python/mathutils/mathutils_Matrix.c +++ b/source/blender/python/mathutils/mathutils_Matrix.c @@ -2288,8 +2288,7 @@ static PyObject *Matrix_str(MatrixObject *self) for (col = 0; col < self->col_num; col++) { maxsize[col] = 0; for (row = 0; row < self->row_num; row++) { - const int size = BLI_snprintf_rlen( - dummy_buf, sizeof(dummy_buf), "%.4f", MATRIX_ITEM(self, row, col)); + const int size = SNPRINTF_RLEN(dummy_buf, "%.4f", MATRIX_ITEM(self, row, col)); maxsize[col] = max_ii(maxsize[col], size); } } diff --git a/source/blender/render/intern/engine.cc b/source/blender/render/intern/engine.cc index f70558bf3bd..e49cf35059d 100644 --- a/source/blender/render/intern/engine.cc +++ b/source/blender/render/intern/engine.cc @@ -522,13 +522,13 @@ void RE_engine_update_stats(RenderEngine *engine, const char *stats, const char engine->text[0] = '\0'; if (stats && stats[0] && info && info[0]) { - BLI_snprintf(engine->text, sizeof(engine->text), "%s | %s", stats, info); + SNPRINTF(engine->text, "%s | %s", stats, info); } else if (info && info[0]) { - BLI_strncpy(engine->text, info, sizeof(engine->text)); + STRNCPY(engine->text, info); } else if (stats && stats[0]) { - BLI_strncpy(engine->text, stats, sizeof(engine->text)); + STRNCPY(engine->text, stats); } } @@ -1079,7 +1079,7 @@ bool RE_engine_render(Render *re, bool do_all) /* set render info */ re->i.cfra = re->scene->r.cfra; - BLI_strncpy(re->i.scene_name, re->scene->id.name + 2, sizeof(re->i.scene_name)); + STRNCPY(re->i.scene_name, re->scene->id.name + 2); engine->flag |= RE_ENGINE_RENDERING; diff --git a/source/blender/render/intern/pipeline.cc b/source/blender/render/intern/pipeline.cc index 2a8a06b59d3..2ab3e5f1e2b 100644 --- a/source/blender/render/intern/pipeline.cc +++ b/source/blender/render/intern/pipeline.cc @@ -504,7 +504,7 @@ Render *RE_NewRender(const char *name) /* new render data struct */ re = MEM_cnew("new render"); BLI_addtail(&RenderGlobal.renderlist, re); - BLI_strncpy(re->name, name, RE_MAXNAME); + STRNCPY(re->name, name); BLI_rw_mutex_init(&re->resultmutex); BLI_mutex_init(&re->engine_draw_mutex); BLI_mutex_init(&re->highlighted_tiles_mutex); @@ -1598,7 +1598,7 @@ static void update_physics_cache(Render *re, void RE_SetActiveRenderView(Render *re, const char *viewname) { - BLI_strncpy(re->viewname, viewname, sizeof(re->viewname)); + STRNCPY(re->viewname, viewname); } const char *RE_GetActiveRenderView(Render *re) @@ -1822,7 +1822,7 @@ static void change_renderdata_engine(Render *re, const char *new_engine) RE_engine_free(re->engine); re->engine = nullptr; } - BLI_strncpy(re->r.engine, new_engine, sizeof(re->r.engine)); + STRNCPY(re->r.engine, new_engine); } } @@ -1838,7 +1838,7 @@ void RE_RenderFreestyleStrokes(Render *re, Main *bmain, Scene *scene, const bool if (render_init_from_main(re, &scene->r, bmain, scene, nullptr, nullptr, false, false)) { if (render) { char scene_engine[32]; - BLI_strncpy(scene_engine, re->r.engine, sizeof(scene_engine)); + STRNCPY(scene_engine, re->r.engine); if (use_eevee_for_freestyle_render(re)) { change_renderdata_engine(re, RE_engine_id_BLENDER_EEVEE); } @@ -1999,7 +1999,7 @@ static bool do_write_image_or_movie(Render *re, } else { if (filepath_override) { - BLI_strncpy(filepath, filepath_override, sizeof(filepath)); + STRNCPY(filepath, filepath_override); } else { BKE_image_path_from_imformat(filepath, @@ -2594,7 +2594,7 @@ RenderPass *RE_create_gp_pass(RenderResult *rr, const char *layername, const cha if (!rl) { rl = MEM_cnew(layername); BLI_addtail(&rr->layers, rl); - BLI_strncpy(rl->name, layername, sizeof(rl->name)); + STRNCPY(rl->name, layername); rl->layflag = SCE_LAY_SOLID; rl->passflag = SCE_PASS_COMBINED; rl->rectx = rr->rectx; diff --git a/source/blender/render/intern/render_result.cc b/source/blender/render/intern/render_result.cc index 010ef2c0cc1..d343b4f0f3a 100644 --- a/source/blender/render/intern/render_result.cc +++ b/source/blender/render/intern/render_result.cc @@ -141,7 +141,7 @@ void render_result_views_shallowcopy(RenderResult *dst, RenderResult *src) rv = MEM_cnew("new render view"); BLI_addtail(&dst->views, rv); - BLI_strncpy(rv->name, rview->name, sizeof(rv->name)); + STRNCPY(rv->name, rview->name); rv->rectf = rview->rectf; rv->rectz = rview->rectz; rv->rect32 = rview->rect32; @@ -203,9 +203,9 @@ RenderPass *render_layer_add_pass(RenderResult *rr, rpass->recty = rl->recty; rpass->view_id = view_id; - BLI_strncpy(rpass->name, name, sizeof(rpass->name)); - BLI_strncpy(rpass->chan_id, chan_id, sizeof(rpass->chan_id)); - BLI_strncpy(rpass->view, viewname, sizeof(rpass->view)); + STRNCPY(rpass->name, name); + STRNCPY(rpass->chan_id, chan_id); + STRNCPY(rpass->view, viewname); RE_render_result_full_channel_name( rpass->fullname, nullptr, rpass->name, rpass->view, rpass->chan_id, -1); @@ -273,7 +273,7 @@ RenderResult *render_result_new(Render *re, rl = MEM_cnew("new render layer"); BLI_addtail(&rr->layers, rl); - BLI_strncpy(rl->name, view_layer->name, sizeof(rl->name)); + STRNCPY(rl->name, view_layer->name); rl->layflag = view_layer->layflag; rl->passflag = view_layer->passflag; @@ -513,11 +513,11 @@ static void ml_addpass_cb(void *base, rl->passflag |= passtype_from_name(name); /* channel id chars */ - BLI_strncpy(rpass->chan_id, chan_id, sizeof(rpass->chan_id)); + STRNCPY(rpass->chan_id, chan_id); rpass->rect = rect; - BLI_strncpy(rpass->name, name, EXR_PASS_MAXNAME); - BLI_strncpy(rpass->view, view, sizeof(rpass->view)); + STRNCPY(rpass->name, name); + STRNCPY(rpass->view, view); RE_render_result_full_channel_name(rpass->fullname, nullptr, name, view, rpass->chan_id, -1); if (view[0] != '\0') { @@ -533,7 +533,7 @@ static void *ml_addview_cb(void *base, const char *str) RenderResult *rr = static_cast(base); RenderView *rv = MEM_cnew("new render view"); - BLI_strncpy(rv->name, str, EXR_VIEW_MAXNAME); + STRNCPY(rv->name, str); /* For stereo drawing we need to ensure: * STEREO_LEFT_NAME == STEREO_LEFT_ID and @@ -656,7 +656,7 @@ void render_result_view_new(RenderResult *rr, const char *viewname) { RenderView *rv = MEM_cnew("new render view"); BLI_addtail(&rr->views, rv); - BLI_strncpy(rv->name, viewname, sizeof(rv->name)); + STRNCPY(rv->name, viewname); } void render_result_views_new(RenderResult *rr, const RenderData *rd) @@ -857,8 +857,8 @@ static void render_result_exr_file_cache_path(Scene *sce, BLI_hash_md5_buffer(blendfile_path, strlen(blendfile_path), path_digest); } else { - BLI_strncpy(dirname, BKE_tempdir_base(), sizeof(dirname)); - BLI_strncpy(filename, "UNSAVED", sizeof(filename)); + STRNCPY(dirname, BKE_tempdir_base()); + STRNCPY(filename, "UNSAVED"); } BLI_hash_md5_to_hexdigest(path_digest, path_hexdigest); @@ -867,12 +867,7 @@ static void render_result_exr_file_cache_path(Scene *sce, root = BKE_tempdir_base(); } - BLI_snprintf(filename_full, - sizeof(filename_full), - "cached_RR_%s_%s_%s.exr", - filename, - sce->id.name + 2, - path_hexdigest); + SNPRINTF(filename_full, "cached_RR_%s_%s_%s.exr", filename, sce->id.name + 2, path_hexdigest); BLI_path_join(r_path, FILE_CACHE_MAX, root, filename_full); if (BLI_path_is_rel(r_path)) { diff --git a/source/blender/sequencer/intern/channels.c b/source/blender/sequencer/intern/channels.c index 70e681aa564..bdb0f0ab62c 100644 --- a/source/blender/sequencer/intern/channels.c +++ b/source/blender/sequencer/intern/channels.c @@ -35,7 +35,7 @@ void SEQ_channels_ensure(ListBase *channels) /* Allocate channels. Channel 0 is never used, but allocated to prevent off by 1 issues. */ for (int i = 0; i < MAXSEQ + 1; i++) { SeqTimelineChannel *channel = MEM_callocN(sizeof(SeqTimelineChannel), "seq timeline channel"); - BLI_snprintf(channel->name, sizeof(channel->name), "Channel %d", i); + SNPRINTF(channel->name, "Channel %d", i); channel->index = i; BLI_addtail(channels, channel); } diff --git a/source/blender/sequencer/intern/disk_cache.c b/source/blender/sequencer/intern/disk_cache.c index d20aacf1d46..f76b1891435 100644 --- a/source/blender/sequencer/intern/disk_cache.c +++ b/source/blender/sequencer/intern/disk_cache.c @@ -142,9 +142,9 @@ static DiskCacheFile *seq_disk_cache_add_file_to_list(SeqDiskCache *disk_cache, DiskCacheFile *cache_file = MEM_callocN(sizeof(DiskCacheFile), "SeqDiskCacheFile"); char dir[FILE_MAXDIR], file[FILE_MAX]; BLI_path_split_dir_file(path, dir, sizeof(dir), file, sizeof(file)); - BLI_strncpy(cache_file->path, path, sizeof(cache_file->path)); - BLI_strncpy(cache_file->dir, dir, sizeof(cache_file->dir)); - BLI_strncpy(cache_file->file, file, sizeof(cache_file->file)); + STRNCPY(cache_file->path, path); + STRNCPY(cache_file->dir, dir); + STRNCPY(cache_file->file, file); sscanf(file, DCACHE_FNAME_FORMAT, &cache_file->cache_type, @@ -181,7 +181,7 @@ static void seq_disk_cache_get_files(SeqDiskCache *disk_cache, char *path) bool is_dir = BLI_is_dir(fl->path); if (is_dir && !FILENAME_IS_CURRPAR(file)) { char subpath[FILE_MAX]; - BLI_strncpy(subpath, fl->path, sizeof(subpath)); + STRNCPY(subpath, fl->path); BLI_path_slash_ensure(subpath, sizeof(sizeof(subpath))); seq_disk_cache_get_files(disk_cache, subpath); } @@ -304,9 +304,8 @@ static void seq_disk_cache_get_dir( char project_dir[FILE_MAX]; seq_disk_cache_get_project_dir(disk_cache, project_dir, sizeof(project_dir)); - BLI_snprintf( - scene_name, sizeof(scene_name), "%s-%" PRId64, scene->id.name, disk_cache->timestamp); - BLI_strncpy(seq_name, seq->name, sizeof(seq_name)); + SNPRINTF(scene_name, "%s-%" PRId64, scene->id.name, disk_cache->timestamp); + STRNCPY(seq_name, seq->name); BLI_path_make_safe_filename(scene_name); BLI_path_make_safe_filename(seq_name); @@ -321,15 +320,14 @@ static void seq_disk_cache_get_file_path(SeqDiskCache *disk_cache, seq_disk_cache_get_dir(disk_cache, key->context.scene, key->seq, path, path_len); int frameno = (int)key->frame_index / DCACHE_IMAGES_PER_FILE; char cache_filename[FILE_MAXFILE]; - BLI_snprintf(cache_filename, - sizeof(cache_filename), - DCACHE_FNAME_FORMAT, - key->type, - key->context.rectx, - key->context.recty, - key->context.preview_render_size, - key->context.view_id, - frameno); + SNPRINTF(cache_filename, + DCACHE_FNAME_FORMAT, + key->type, + key->context.rectx, + key->context.recty, + key->context.preview_render_size, + key->context.view_id, + frameno); BLI_path_append(path, path_len, cache_filename); } @@ -529,8 +527,7 @@ static int seq_disk_cache_add_header_entry(SeqCacheKey *key, ImBuf *ibuf, DiskCa header->entry[i].size_raw = ibuf->x * ibuf->y * ibuf->channels * 4; colorspace_name = IMB_colormanagement_get_float_colorspace(ibuf); } - BLI_strncpy( - header->entry[i].colorspace_name, colorspace_name, sizeof(header->entry[i].colorspace_name)); + STRNCPY(header->entry[i].colorspace_name, colorspace_name); return i; } diff --git a/source/blender/sequencer/intern/effects.c b/source/blender/sequencer/intern/effects.c index c6e84e9d0a7..afbe74da4b5 100644 --- a/source/blender/sequencer/intern/effects.c +++ b/source/blender/sequencer/intern/effects.c @@ -3191,7 +3191,7 @@ static void init_text_effect(Sequence *seq) data->box_color[3] = 0.7f; data->box_margin = 0.01f; - BLI_strncpy(data->text, "Text", sizeof(data->text)); + STRNCPY(data->text, "Text"); data->loc[0] = 0.5f; data->loc[1] = 0.5f; diff --git a/source/blender/sequencer/intern/modifier.c b/source/blender/sequencer/intern/modifier.c index 06e2b276533..690f982c5b8 100644 --- a/source/blender/sequencer/intern/modifier.c +++ b/source/blender/sequencer/intern/modifier.c @@ -1412,10 +1412,10 @@ SequenceModifierData *SEQ_modifier_new(Sequence *seq, const char *name, int type smd->flag |= SEQUENCE_MODIFIER_EXPANDED; if (!name || !name[0]) { - BLI_strncpy(smd->name, smti->name, sizeof(smd->name)); + STRNCPY(smd->name, smti->name); } else { - BLI_strncpy(smd->name, name, sizeof(smd->name)); + STRNCPY(smd->name, name); } BLI_addtail(&seq->modifiers, smd); diff --git a/source/blender/sequencer/intern/proxy.c b/source/blender/sequencer/intern/proxy.c index de4eb123b01..85e36b41e56 100644 --- a/source/blender/sequencer/intern/proxy.c +++ b/source/blender/sequencer/intern/proxy.c @@ -110,7 +110,7 @@ bool seq_proxy_get_custom_file_fname(Sequence *seq, char *filepath, const int vi BLI_path_abs(filepath_temp, BKE_main_blendfile_path_from_global()); if (view_id > 0) { - BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id); + SNPRINTF(suffix, "_%d", view_id); /* TODO(sergey): This will actually append suffix after extension * which is weird but how was originally coded in multi-view branch. */ @@ -141,7 +141,7 @@ static bool seq_proxy_get_fname(Scene *scene, /* Multi-view suffix. */ if (view_id > 0) { - BLI_snprintf(suffix, sizeof(suffix), "_%d", view_id); + SNPRINTF(suffix, "_%d", view_id); } /* Per strip with Custom file situation is handled separately. */ @@ -156,20 +156,20 @@ static bool seq_proxy_get_fname(Scene *scene, if (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) { /* Per project default. */ if (ed->proxy_dir[0] == 0) { - BLI_strncpy(dir, "//BL_proxy", sizeof(dir)); + STRNCPY(dir, "//BL_proxy"); } else { /* Per project with custom dir. */ - BLI_strncpy(dir, ed->proxy_dir, sizeof(dir)); + STRNCPY(dir, ed->proxy_dir); } BLI_path_abs(filepath, BKE_main_blendfile_path_from_global()); } else { /* Pre strip with custom dir. */ if (proxy->storage & SEQ_STORAGE_PROXY_CUSTOM_DIR) { - BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); + STRNCPY(dir, seq->strip->proxy->dir); } else { /* Per strip default. */ - BLI_snprintf(dir, PROXY_MAXFILE, "%s" SEP_STR "BL_proxy", seq->strip->dir); + SNPRINTF(dir, "%s" SEP_STR "BL_proxy", seq->strip->dir); } } diff --git a/source/blender/sequencer/intern/strip_add.c b/source/blender/sequencer/intern/strip_add.c index a790794b360..8418b30a0b9 100644 --- a/source/blender/sequencer/intern/strip_add.c +++ b/source/blender/sequencer/intern/strip_add.c @@ -63,10 +63,10 @@ void SEQ_add_load_data_init(SeqLoadData *load_data, { memset(load_data, 0, sizeof(SeqLoadData)); if (name != NULL) { - BLI_strncpy(load_data->name, name, sizeof(load_data->name)); + STRNCPY(load_data->name, name); } if (path != NULL) { - BLI_strncpy(load_data->path, path, sizeof(load_data->path)); + STRNCPY(load_data->path, path); } load_data->start_frame = start_frame; load_data->channel = channel; @@ -189,14 +189,14 @@ Sequence *SEQ_add_effect_strip(Scene *scene, ListBase *seqbase, struct SeqLoadDa void SEQ_add_image_set_directory(Sequence *seq, char *path) { - BLI_strncpy(seq->strip->dir, path, sizeof(seq->strip->dir)); + STRNCPY(seq->strip->dir, path); } void SEQ_add_image_load_file(Scene *scene, Sequence *seq, size_t strip_frame, char *filename) { StripElem *se = SEQ_render_give_stripelem( scene, seq, SEQ_time_start_frame_get(seq) + strip_frame); - BLI_strncpy(se->name, filename, sizeof(se->name)); + STRNCPY(se->name, filename); } void SEQ_add_image_init_alpha_mode(Sequence *seq) @@ -251,7 +251,7 @@ Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL /* Set initial scale based on load_data->fit_method. */ char file_path[FILE_MAX]; - BLI_strncpy(file_path, load_data->path, sizeof(file_path)); + STRNCPY(file_path, load_data->path); BLI_path_abs(file_path, BKE_main_blendfile_path(bmain)); ImBuf *ibuf = IMB_loadiffname(file_path, IB_rect, seq->strip->colorspace_settings.name); if (ibuf != NULL) { @@ -270,7 +270,7 @@ Sequence *SEQ_add_image_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL } /* Set Last active directory. */ - BLI_strncpy(scene->ed->act_imagedir, seq->strip->dir, sizeof(scene->ed->act_imagedir)); + STRNCPY(scene->ed->act_imagedir, seq->strip->dir); seq_add_set_view_transform(scene, seq, load_data); seq_add_set_name(scene, seq, load_data); seq_add_generic_update(scene, seq); @@ -381,7 +381,7 @@ Sequence *SEQ_add_meta_strip(Scene *scene, ListBase *seqbase, SeqLoadData *load_ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqLoadData *load_data) { char path[sizeof(load_data->path)]; - BLI_strncpy(path, load_data->path, sizeof(path)); + STRNCPY(path, load_data->path); BLI_path_abs(path, BKE_main_blendfile_path(bmain)); char colorspace[64] = "\0"; /* MAX_COLORSPACE_NAME */ @@ -491,9 +491,7 @@ Sequence *SEQ_add_movie_strip(Main *bmain, Scene *scene, ListBase *seqbase, SeqL seq->flag |= SEQ_AUTO_PLAYBACK_RATE; } - BLI_strncpy(seq->strip->colorspace_settings.name, - colorspace, - sizeof(seq->strip->colorspace_settings.name)); + STRNCPY(seq->strip->colorspace_settings.name, colorspace); Strip *strip = seq->strip; /* We only need 1 element for MOVIE strips. */ diff --git a/source/blender/sequencer/intern/strip_edit.c b/source/blender/sequencer/intern/strip_edit.c index b5d4f44cb39..3f62e17d1d4 100644 --- a/source/blender/sequencer/intern/strip_edit.c +++ b/source/blender/sequencer/intern/strip_edit.c @@ -70,7 +70,7 @@ bool SEQ_edit_sequence_swap(Scene *scene, Sequence *seq_a, Sequence *seq_b, cons SWAP(Sequence, *seq_a, *seq_b); /* swap back names so animation fcurves don't get swapped */ - BLI_strncpy(name, seq_a->name + 2, sizeof(name)); + STRNCPY(name, seq_a->name + 2); BLI_strncpy(seq_a->name + 2, seq_b->name + 2, sizeof(seq_b->name) - 2); BLI_strncpy(seq_b->name + 2, name, sizeof(seq_b->name) - 2); diff --git a/source/blender/sequencer/intern/utils.c b/source/blender/sequencer/intern/utils.c index 10e9ccd4d7f..936b0ecc0f9 100644 --- a/source/blender/sequencer/intern/utils.c +++ b/source/blender/sequencer/intern/utils.c @@ -56,12 +56,8 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui) for (seq = seqbasep->first; seq; seq = seq->next) { if ((sui->seq != seq) && STREQ(sui->name_dest, seq->name + 2)) { /* SEQ_NAME_MAXSTR -4 for the number, -1 for \0, - 2 for r_prefix */ - BLI_snprintf(sui->name_dest, - sizeof(sui->name_dest), - "%.*s.%03d", - SEQ_NAME_MAXSTR - 4 - 1 - 2, - sui->name_src, - sui->count++); + SNPRINTF( + sui->name_dest, "%.*s.%03d", SEQ_NAME_MAXSTR - 4 - 1 - 2, sui->name_src, sui->count++); sui->match = 1; /* be sure to re-scan */ } } @@ -82,8 +78,8 @@ void SEQ_sequence_base_unique_name_recursive(struct Scene *scene, SeqUniqueInfo sui; char *dot; sui.seq = seq; - BLI_strncpy(sui.name_src, seq->name + 2, sizeof(sui.name_src)); - BLI_strncpy(sui.name_dest, seq->name + 2, sizeof(sui.name_dest)); + STRNCPY(sui.name_src, seq->name + 2); + STRNCPY(sui.name_dest, seq->name + 2); sui.count = 1; sui.match = 1; /* assume the worst to start the loop */ @@ -235,14 +231,14 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) if (use_proxy) { if (ed->proxy_storage == SEQ_EDIT_PROXY_DIR_STORAGE) { if (ed->proxy_dir[0] == 0) { - BLI_strncpy(dir, "//BL_proxy", sizeof(dir)); + STRNCPY(dir, "//BL_proxy"); } else { - BLI_strncpy(dir, ed->proxy_dir, sizeof(dir)); + STRNCPY(dir, ed->proxy_dir); } } else { - BLI_strncpy(dir, seq->strip->proxy->dir, sizeof(dir)); + STRNCPY(dir, seq->strip->proxy->dir); } BLI_path_abs(dir, BKE_main_blendfile_path_from_global()); } @@ -263,7 +259,7 @@ void seq_open_anim_file(Scene *scene, Sequence *seq, bool openfile) BLI_addtail(&seq->anims, sanim); - BLI_snprintf(str, sizeof(str), "%s%s%s", prefix, suffix, ext); + SNPRINTF(str, "%s%s%s", prefix, suffix, ext); if (openfile) { sanim->anim = openanim(str, @@ -527,7 +523,7 @@ void SEQ_ensure_unique_name(Sequence *seq, Scene *scene) { char name[SEQ_NAME_MAXSTR]; - BLI_strncpy_utf8(name, seq->name + 2, sizeof(name)); + STRNCPY_UTF8(name, seq->name + 2); SEQ_sequence_base_unique_name_recursive(scene, &scene->ed->seqbase, seq); BKE_animdata_fix_paths_rename( &scene->id, scene->adt, NULL, "sequence_editor.sequences_all", name, seq->name + 2, 0, 0, 0); diff --git a/source/blender/shader_fx/intern/FX_ui_common.c b/source/blender/shader_fx/intern/FX_ui_common.c index ffb70843016..4e8affc59e1 100644 --- a/source/blender/shader_fx/intern/FX_ui_common.c +++ b/source/blender/shader_fx/intern/FX_ui_common.c @@ -223,9 +223,9 @@ PanelType *shaderfx_panel_register(ARegionType *region_type, ShaderFxType type, PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); BKE_shaderfxType_panel_id(type, panel_type->idname); - BLI_strncpy(panel_type->label, "", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->context, "shaderfx", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); + STRNCPY(panel_type->label, ""); + STRNCPY(panel_type->context, "shaderfx"); + STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); panel_type->draw_header = shaderfx_panel_header; panel_type->draw = draw; @@ -252,10 +252,10 @@ PanelType *shaderfx_subpanel_register(ARegionType *region_type, { PanelType *panel_type = MEM_callocN(sizeof(PanelType), __func__); - BLI_snprintf(panel_type->idname, BKE_ST_MAXNAME, "%s_%s", parent->idname, name); - BLI_strncpy(panel_type->label, label, BKE_ST_MAXNAME); - BLI_strncpy(panel_type->context, "shaderfx", BKE_ST_MAXNAME); - BLI_strncpy(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA, BKE_ST_MAXNAME); + SNPRINTF(panel_type->idname, "%s_%s", parent->idname, name); + STRNCPY(panel_type->label, label); + STRNCPY(panel_type->context, "shaderfx"); + STRNCPY(panel_type->translation_context, BLT_I18NCONTEXT_DEFAULT_BPYRNA); panel_type->draw_header = draw_header; panel_type->draw = draw; @@ -263,7 +263,7 @@ PanelType *shaderfx_subpanel_register(ARegionType *region_type, panel_type->flag = PANEL_TYPE_DEFAULT_CLOSED; BLI_assert(parent != NULL); - BLI_strncpy(panel_type->parent_id, parent->idname, BKE_ST_MAXNAME); + STRNCPY(panel_type->parent_id, parent->idname); panel_type->parent = parent; BLI_addtail(&parent->children, BLI_genericNodeN(panel_type)); BLI_addtail(®ion_type->paneltypes, panel_type); diff --git a/source/blender/windowmanager/intern/wm_dragdrop.cc b/source/blender/windowmanager/intern/wm_dragdrop.cc index c0f03791a90..68d3e1d414c 100644 --- a/source/blender/windowmanager/intern/wm_dragdrop.cc +++ b/source/blender/windowmanager/intern/wm_dragdrop.cc @@ -87,7 +87,7 @@ ListBase *WM_dropboxmap_find(const char *idname, int spaceid, int regionid) } wmDropBoxMap *dm = MEM_cnew(__func__); - BLI_strncpy(dm->idname, idname, KMAP_MAX_NAME); + STRNCPY(dm->idname, idname); dm->spaceid = spaceid; dm->regionid = regionid; BLI_addtail(&dropboxes, dm); @@ -567,7 +567,7 @@ wmDragAsset *WM_drag_create_asset_data(const AssetHandle *asset, const char *pat { wmDragAsset *asset_drag = MEM_new(__func__); - BLI_strncpy(asset_drag->name, ED_asset_handle_get_name(asset), sizeof(asset_drag->name)); + STRNCPY(asset_drag->name, ED_asset_handle_get_name(asset)); asset_drag->metadata = ED_asset_handle_get_metadata(asset); asset_drag->path = path; asset_drag->id_type = ED_asset_handle_get_id_type(asset); diff --git a/source/blender/windowmanager/intern/wm_event_system.cc b/source/blender/windowmanager/intern/wm_event_system.cc index 90869667e2b..c6717538142 100644 --- a/source/blender/windowmanager/intern/wm_event_system.cc +++ b/source/blender/windowmanager/intern/wm_event_system.cc @@ -1353,7 +1353,7 @@ static wmOperator *wm_operator_create(wmWindowManager *wm, /* Adding new operator could be function, only happens here now. */ op->type = ot; - BLI_strncpy(op->idname, ot->idname, OP_MAX_TYPENAME); + STRNCPY(op->idname, ot->idname); /* Initialize properties, either copy or create. */ op->ptr = MEM_cnew("wmOperatorPtrRNA"); diff --git a/source/blender/windowmanager/intern/wm_files.cc b/source/blender/windowmanager/intern/wm_files.cc index a08918b3c78..106c78227fc 100644 --- a/source/blender/windowmanager/intern/wm_files.cc +++ b/source/blender/windowmanager/intern/wm_files.cc @@ -1240,7 +1240,7 @@ void wm_homefile_read_ex(bContext *C, } if (filepath_startup_override) { - BLI_strncpy(filepath_startup, filepath_startup_override, FILE_MAX); + STRNCPY(filepath_startup, filepath_startup_override); filepath_startup_is_factory = false; } } @@ -1387,7 +1387,7 @@ void wm_homefile_read_ex(bContext *C, } if (app_template_override) { - BLI_strncpy(U.app_template, app_template_override, sizeof(U.app_template)); + STRNCPY(U.app_template, app_template_override); } Main *bmain = CTX_data_main(C); @@ -1801,7 +1801,7 @@ bool write_crash_blend(void) { char filepath[FILE_MAX]; - BLI_strncpy(filepath, BKE_main_blendfile_path_from_global(), sizeof(filepath)); + STRNCPY(filepath, BKE_main_blendfile_path_from_global()); BLI_path_extension_replace(filepath, sizeof(filepath), "_crash.blend"); BlendFileWriteParams params{}; const bool success = BLO_write_file(G_MAIN, filepath, G.fileflags, ¶ms, nullptr); @@ -2005,10 +2005,10 @@ static void wm_autosave_location(char filepath[FILE_MAX]) if (blendfile_path && (blendfile_path[0] != '\0')) { const char *basename = BLI_path_basename(blendfile_path); int len = strlen(basename) - 6; - BLI_snprintf(filename, sizeof(filename), "%.*s_%d_autosave.blend", len, basename, pid); + SNPRINTF(filename, "%.*s_%d_autosave.blend", len, basename, pid); } else { - BLI_snprintf(filename, sizeof(filename), "%d_autosave.blend", pid); + SNPRINTF(filename, "%d_autosave.blend", pid); } const char *tempdir_base = BKE_tempdir_base(); @@ -2843,7 +2843,7 @@ static char *wm_open_mainfile_description(struct bContext * /*C*/, BLI_filelist_entry_datetime_to_string( nullptr, int64_t(stats.st_mtime), false, time_st, date_st, &is_today, &is_yesterday); if (is_today || is_yesterday) { - BLI_strncpy(date_st, is_today ? TIP_("Today") : TIP_("Yesterday"), sizeof(date_st)); + STRNCPY(date_st, is_today ? TIP_("Today") : TIP_("Yesterday")); } /* Size. */ @@ -2976,7 +2976,7 @@ static int wm_revert_mainfile_exec(bContext *C, wmOperator *op) SET_FLAG_FROM_TEST(G.f, RNA_boolean_get(op->ptr, "use_scripts"), G_FLAG_SCRIPT_AUTOEXEC); - BLI_strncpy(filepath, BKE_main_blendfile_path(bmain), sizeof(filepath)); + STRNCPY(filepath, BKE_main_blendfile_path(bmain)); success = wm_file_read_opwrap(C, filepath, op->reports); if (success) { @@ -3811,7 +3811,7 @@ static uiBlock *block_create__close_file_dialog(struct bContext *C, /* Modified Images Checkbox. */ if (modified_images_count > 0) { char message[64]; - BLI_snprintf(message, sizeof(message), "Save %u modified image(s)", modified_images_count); + SNPRINTF(message, "Save %u modified image(s)", modified_images_count); /* Only the first checkbox should get extra separation. */ if (!has_extra_checkboxes) { uiItemS(layout); diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index 1473d4ae7e5..8da049e46da 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -382,7 +382,7 @@ static int wm_link_append_exec(bContext *C, wmOperator *op) DEG_relations_tag_update(bmain); /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */ - BLI_strncpy(G.lib, root, FILE_MAX); + STRNCPY(G.lib, root); WM_event_add_notifier(C, NC_WINDOW, NULL); @@ -779,7 +779,7 @@ static int wm_lib_relocate_exec_do(bContext *C, wmOperator *op, bool do_reload) BKE_blendfile_link_append_context_free(lapp_context); /* XXX TODO: align G.lib with other directory storage (like last opened image etc...) */ - BLI_strncpy(G.lib, root, FILE_MAX); + STRNCPY(G.lib, root); BKE_main_lib_objects_recalc_all(bmain); IMB_colormanagement_check_file_config(bmain); diff --git a/source/blender/windowmanager/intern/wm_init_exit.cc b/source/blender/windowmanager/intern/wm_init_exit.cc index 4cf6e5939c0..fdcdcef488d 100644 --- a/source/blender/windowmanager/intern/wm_init_exit.cc +++ b/source/blender/windowmanager/intern/wm_init_exit.cc @@ -354,7 +354,7 @@ void WM_init(bContext *C, int argc, const char **argv) wm_history_file_read(); - BLI_strncpy(G.lib, BKE_main_blendfile_path_from_global(), sizeof(G.lib)); + STRNCPY(G.lib, BKE_main_blendfile_path_from_global()); wm_homefile_read_post(C, params_file_read_post); } diff --git a/source/blender/windowmanager/intern/wm_jobs.c b/source/blender/windowmanager/intern/wm_jobs.c index 5ec13cf2a8b..727f8166d6a 100644 --- a/source/blender/windowmanager/intern/wm_jobs.c +++ b/source/blender/windowmanager/intern/wm_jobs.c @@ -200,7 +200,7 @@ wmJob *WM_jobs_get(wmWindowManager *wm, wm_job->owner = owner; wm_job->flag = flag; wm_job->job_type = job_type; - BLI_strncpy(wm_job->name, name, sizeof(wm_job->name)); + STRNCPY(wm_job->name, name); wm_job->main_thread_mutex = BLI_ticket_mutex_alloc(); WM_job_main_thread_lock_acquire(wm_job); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 4528e8ee366..b0053fdaa23 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -279,7 +279,7 @@ wmKeyConfig *WM_keyconfig_new(wmWindowManager *wm, const char *idname, bool user /* Create new configuration. */ keyconf = MEM_callocN(sizeof(wmKeyConfig), "wmKeyConfig"); - BLI_strncpy(keyconf->idname, idname, sizeof(keyconf->idname)); + STRNCPY(keyconf->idname, idname); BLI_addtail(&wm->keyconfigs, keyconf); if (user_defined) { @@ -298,7 +298,7 @@ bool WM_keyconfig_remove(wmWindowManager *wm, wmKeyConfig *keyconf) { if (BLI_findindex(&wm->keyconfigs, keyconf) != -1) { if (STREQLEN(U.keyconfigstr, keyconf->idname, sizeof(U.keyconfigstr))) { - BLI_strncpy(U.keyconfigstr, wm->defaultconf->idname, sizeof(U.keyconfigstr)); + STRNCPY(U.keyconfigstr, wm->defaultconf->idname); U.runtime.is_dirty = true; WM_keyconfig_update_tag(NULL, NULL); } @@ -347,7 +347,7 @@ void WM_keyconfig_set_active(wmWindowManager *wm, const char *idname) WM_keyconfig_update(wm); - BLI_strncpy(U.keyconfigstr, idname, sizeof(U.keyconfigstr)); + STRNCPY(U.keyconfigstr, idname); if (wm->initialized & WM_KEYCONFIG_IS_INIT) { U.runtime.is_dirty = true; } @@ -368,14 +368,14 @@ static wmKeyMap *wm_keymap_new(const char *idname, int spaceid, int regionid) { wmKeyMap *km = MEM_callocN(sizeof(struct wmKeyMap), "keymap list"); - BLI_strncpy(km->idname, idname, KMAP_MAX_NAME); + STRNCPY(km->idname, idname); km->spaceid = spaceid; km->regionid = regionid; { const char *owner_id = RNA_struct_state_owner_get(); if (owner_id) { - BLI_strncpy(km->owner_id, owner_id, sizeof(km->owner_id)); + STRNCPY(km->owner_id, owner_id); } } return km; @@ -512,7 +512,7 @@ wmKeyMapItem *WM_keymap_add_item(wmKeyMap *keymap, wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); BLI_addtail(&keymap->items, kmi); - BLI_strncpy(kmi->idname, idname, OP_MAX_TYPENAME); + STRNCPY(kmi->idname, idname); keymap_event_set(kmi, params); wm_keymap_item_properties_set(kmi); @@ -950,7 +950,7 @@ wmKeyMapItem *WM_modalkeymap_add_item_str(wmKeyMap *km, wmKeyMapItem *kmi = MEM_callocN(sizeof(wmKeyMapItem), "keymap entry"); BLI_addtail(&km->items, kmi); - BLI_strncpy(kmi->propvalue_str, value, sizeof(kmi->propvalue_str)); + STRNCPY(kmi->propvalue_str, value); keymap_event_set(kmi, params); @@ -2004,7 +2004,7 @@ void WM_keymap_item_restore_to_default(wmWindowManager *wm, wmKeyMap *keymap, wm if (orig) { /* restore to original */ if (!STREQ(orig->idname, kmi->idname)) { - BLI_strncpy(kmi->idname, orig->idname, sizeof(kmi->idname)); + STRNCPY(kmi->idname, orig->idname); WM_keymap_item_properties_reset(kmi, NULL); } diff --git a/source/blender/windowmanager/intern/wm_operator_type.c b/source/blender/windowmanager/intern/wm_operator_type.c index d71f60c8a4b..38ead0b891b 100644 --- a/source/blender/windowmanager/intern/wm_operator_type.c +++ b/source/blender/windowmanager/intern/wm_operator_type.c @@ -537,7 +537,7 @@ wmOperatorTypeMacro *WM_operatortype_macro_define(wmOperatorType *ot, const char { wmOperatorTypeMacro *otmacro = MEM_callocN(sizeof(wmOperatorTypeMacro), "wmOperatorTypeMacro"); - BLI_strncpy(otmacro->idname, idname, OP_MAX_TYPENAME); + STRNCPY(otmacro->idname, idname); /* do this on first use, since operatordefinitions might have been not done yet */ WM_operator_properties_alloc(&(otmacro->ptr), &(otmacro->properties), idname); diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 3e86265305a..093f7ca45ab 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2213,33 +2213,29 @@ static void radial_control_update_header(wmOperator *op, bContext *C) if (hasNumInput(&rc->num_input)) { char num_str[NUM_STR_REP_LEN]; outputNumInput(&rc->num_input, num_str, &scene->unit); - BLI_snprintf(msg, sizeof(msg), "%s: %s", RNA_property_ui_name(rc->prop), num_str); + SNPRINTF(msg, "%s: %s", RNA_property_ui_name(rc->prop), num_str); } else { const char *ui_name = RNA_property_ui_name(rc->prop); switch (rc->subtype) { case PROP_NONE: case PROP_DISTANCE: - BLI_snprintf(msg, sizeof(msg), "%s: %0.4f", ui_name, rc->current_value); + SNPRINTF(msg, "%s: %0.4f", ui_name, rc->current_value); break; case PROP_PIXEL: - BLI_snprintf(msg, - sizeof(msg), - "%s: %d", - ui_name, - (int)rc->current_value); /* XXX: round to nearest? */ + SNPRINTF(msg, "%s: %d", ui_name, (int)rc->current_value); /* XXX: round to nearest? */ break; case PROP_PERCENTAGE: - BLI_snprintf(msg, sizeof(msg), "%s: %3.1f%%", ui_name, rc->current_value); + SNPRINTF(msg, "%s: %3.1f%%", ui_name, rc->current_value); break; case PROP_FACTOR: - BLI_snprintf(msg, sizeof(msg), "%s: %1.3f", ui_name, rc->current_value); + SNPRINTF(msg, "%s: %1.3f", ui_name, rc->current_value); break; case PROP_ANGLE: - BLI_snprintf(msg, sizeof(msg), "%s: %3.2f", ui_name, RAD2DEGF(rc->current_value)); + SNPRINTF(msg, "%s: %3.2f", ui_name, RAD2DEGF(rc->current_value)); break; default: - BLI_snprintf(msg, sizeof(msg), "%s", ui_name); /* XXX: No value? */ + SNPRINTF(msg, "%s", ui_name); /* XXX: No value? */ break; } } @@ -2448,7 +2444,7 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE; r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; rmin = WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE; - BLI_snprintf(str, WM_RADIAL_MAX_STR, "%3.1f%%", rc->current_value); + SNPRINTF(str, "%3.1f%%", rc->current_value); strdrawlen = BLI_strlen_utf8(str); tex_radius = r1; alpha = 0.75; @@ -2459,14 +2455,14 @@ static void radial_control_paint_cursor(bContext *UNUSED(C), int x, int y, void r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; rmin = WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE; alpha = rc->current_value / 2.0f + 0.5f; - BLI_snprintf(str, WM_RADIAL_MAX_STR, "%1.3f", rc->current_value); + SNPRINTF(str, "%1.3f", rc->current_value); strdrawlen = BLI_strlen_utf8(str); break; case PROP_ANGLE: r1 = r2 = tex_radius = WM_RADIAL_CONTROL_DISPLAY_SIZE; alpha = 0.75; rmin = WM_RADIAL_CONTROL_DISPLAY_MIN_SIZE; - BLI_snprintf(str, WM_RADIAL_MAX_STR, "%3.2f", RAD2DEGF(rc->current_value)); + SNPRINTF(str, "%3.2f", RAD2DEGF(rc->current_value)); strdrawlen = BLI_strlen_utf8(str); break; default: diff --git a/source/blender/windowmanager/intern/wm_playanim.c b/source/blender/windowmanager/intern/wm_playanim.c index 88a4d821c83..0a3b291ffdb 100644 --- a/source/blender/windowmanager/intern/wm_playanim.c +++ b/source/blender/windowmanager/intern/wm_playanim.c @@ -580,7 +580,7 @@ static void playanim_toscreen( int sizex, sizey; float fsizex_inv, fsizey_inv; char str[32 + FILE_MAX]; - BLI_snprintf(str, sizeof(str), "%s | %.2f frames/s", picture->filepath, fstep / swaptime); + SNPRINTF(str, "%s | %.2f frames/s", picture->filepath, fstep / swaptime); playanim_window_get_size(&sizex, &sizey); fsizex_inv = 1.0f / sizex; @@ -667,7 +667,7 @@ static void build_pict_list_ex( } fp_decoded; char filepath[FILE_MAX]; - BLI_strncpy(filepath, filepath_first, sizeof(filepath)); + STRNCPY(filepath, filepath_first); fp_framenr = BLI_path_sequence_decode(filepath, fp_decoded.head, sizeof(fp_decoded.head), @@ -1334,7 +1334,7 @@ static bool ghost_event_proc(GHOST_EventHandle evt, GHOST_TUserDataPtr ps_void) int a; for (a = 0; a < stra->count; a++) { - BLI_strncpy(ps->dropped_file, (char *)stra->strings[a], sizeof(ps->dropped_file)); + STRNCPY(ps->dropped_file, (char *)stra->strings[a]); ps->go = false; printf("drop file %s\n", stra->strings[a]); break; /* only one drop element supported now */ @@ -1514,7 +1514,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) } if (argc > 1) { - BLI_strncpy(filepath, argv[1], sizeof(filepath)); + STRNCPY(filepath, argv[1]); } else { printf("%s: no filepath argument given\n", __func__); @@ -1629,7 +1629,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) #endif for (i = 2; i < argc; i++) { - BLI_strncpy(filepath, argv[i], sizeof(filepath)); + STRNCPY(filepath, argv[i]); build_pict_list(&ps, filepath, (efra - sfra) + 1, ps.fstep, ps.fontid); } @@ -1704,7 +1704,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) #endif /* USE_FRAME_CACHE_LIMIT */ - BLI_strncpy(ibuf->filepath, ps.picture->filepath, sizeof(ibuf->filepath)); + STRNCPY(ibuf->filepath, ps.picture->filepath); /* why only windows? (from 2.4x) - campbell */ #ifdef _WIN32 @@ -1849,7 +1849,7 @@ static char *wm_main_playanim_intern(int argc, const char **argv) /* early exit, IMB and BKE should be exited only in end */ if (ps.dropped_file[0]) { - BLI_strncpy(filepath, ps.dropped_file, sizeof(filepath)); + STRNCPY(filepath, ps.dropped_file); return filepath; } diff --git a/source/blender/windowmanager/intern/wm_window.c b/source/blender/windowmanager/intern/wm_window.c index 017b1d86bba..709c3f458bb 100644 --- a/source/blender/windowmanager/intern/wm_window.c +++ b/source/blender/windowmanager/intern/wm_window.c @@ -473,12 +473,11 @@ void wm_window_title(wmWindowManager *wm, wmWindow *win) const char *blendfile_path = BKE_main_blendfile_path_from_global(); if (blendfile_path[0] != '\0') { char str[sizeof(((Main *)NULL)->filepath) + 24]; - BLI_snprintf(str, - sizeof(str), - "Blender%s [%s%s]", - wm->file_saved ? "" : "*", - blendfile_path, - G_MAIN->recovered ? " (Recovered)" : ""); + SNPRINTF(str, + "Blender%s [%s%s]", + wm->file_saved ? "" : "*", + blendfile_path, + G_MAIN->recovered ? " (Recovered)" : ""); GHOST_SetTitle(win->ghostwin, str); } else { diff --git a/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c b/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c index 8a1982fa8b5..3f384d9f2c9 100644 --- a/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c +++ b/source/blender/windowmanager/xr/intern/wm_xr_actionmap.c @@ -46,7 +46,7 @@ XrActionMapBinding *WM_xr_actionmap_binding_new(XrActionMapItem *ami, } XrActionMapBinding *amb = MEM_callocN(sizeof(XrActionMapBinding), __func__); - BLI_strncpy(amb->name, name, MAX_NAME); + STRNCPY(amb->name, name); if (amb_prev) { WM_xr_actionmap_binding_ensure_unique(ami, amb); } @@ -78,14 +78,14 @@ void WM_xr_actionmap_binding_ensure_unique(XrActionMapItem *ami, XrActionMapBind size_t baselen; size_t idx = 0; - BLI_strncpy(name, amb->name, MAX_NAME); + STRNCPY(name, amb->name); baselen = BLI_strnlen(name, MAX_NAME); suffix = &name[baselen]; while (wm_xr_actionmap_binding_find_except(ami, name, amb)) { if ((baselen + 1) + (log10(++idx) + 1) > MAX_NAME) { /* Use default base name. */ - BLI_strncpy(name, WM_XR_ACTIONMAP_BINDING_STR_DEFAULT, MAX_NAME); + STRNCPY(name, WM_XR_ACTIONMAP_BINDING_STR_DEFAULT); baselen = BLI_strnlen(name, MAX_NAME); suffix = &name[baselen]; idx = 0; @@ -95,7 +95,7 @@ void WM_xr_actionmap_binding_ensure_unique(XrActionMapItem *ami, XrActionMapBind } } - BLI_strncpy(amb->name, name, MAX_NAME); + STRNCPY(amb->name, name); } static XrActionMapBinding *wm_xr_actionmap_binding_copy(XrActionMapBinding *amb_src) @@ -250,7 +250,7 @@ XrActionMapItem *WM_xr_actionmap_item_new(XrActionMap *actionmap, } XrActionMapItem *ami = MEM_callocN(sizeof(XrActionMapItem), __func__); - BLI_strncpy(ami->name, name, MAX_NAME); + STRNCPY(ami->name, name); if (ami_prev) { WM_xr_actionmap_item_ensure_unique(actionmap, ami); } @@ -282,14 +282,14 @@ void WM_xr_actionmap_item_ensure_unique(XrActionMap *actionmap, XrActionMapItem size_t baselen; size_t idx = 0; - BLI_strncpy(name, ami->name, MAX_NAME); + STRNCPY(name, ami->name); baselen = BLI_strnlen(name, MAX_NAME); suffix = &name[baselen]; while (wm_xr_actionmap_item_find_except(actionmap, name, ami)) { if ((baselen + 1) + (log10(++idx) + 1) > MAX_NAME) { /* Use default base name. */ - BLI_strncpy(name, WM_XR_ACTIONMAP_ITEM_STR_DEFAULT, MAX_NAME); + STRNCPY(name, WM_XR_ACTIONMAP_ITEM_STR_DEFAULT); baselen = BLI_strnlen(name, MAX_NAME); suffix = &name[baselen]; idx = 0; @@ -299,7 +299,7 @@ void WM_xr_actionmap_item_ensure_unique(XrActionMap *actionmap, XrActionMapItem } } - BLI_strncpy(ami->name, name, MAX_NAME); + STRNCPY(ami->name, name); } static XrActionMapItem *wm_xr_actionmap_item_copy(XrActionMapItem *ami_src) @@ -391,7 +391,7 @@ XrActionMap *WM_xr_actionmap_new(wmXrRuntimeData *runtime, const char *name, boo } XrActionMap *am = MEM_callocN(sizeof(struct XrActionMap), __func__); - BLI_strncpy(am->name, name, MAX_NAME); + STRNCPY(am->name, name); if (am_prev) { WM_xr_actionmap_ensure_unique(runtime, am); } @@ -421,14 +421,14 @@ void WM_xr_actionmap_ensure_unique(wmXrRuntimeData *runtime, XrActionMap *action size_t baselen; size_t idx = 0; - BLI_strncpy(name, actionmap->name, MAX_NAME); + STRNCPY(name, actionmap->name); baselen = BLI_strnlen(name, MAX_NAME); suffix = &name[baselen]; while (wm_xr_actionmap_find_except(runtime, name, actionmap)) { if ((baselen + 1) + (log10(++idx) + 1) > MAX_NAME) { /* Use default base name. */ - BLI_strncpy(name, WM_XR_ACTIONMAP_STR_DEFAULT, MAX_NAME); + STRNCPY(name, WM_XR_ACTIONMAP_STR_DEFAULT); baselen = BLI_strnlen(name, MAX_NAME); suffix = &name[baselen]; idx = 0; @@ -438,7 +438,7 @@ void WM_xr_actionmap_ensure_unique(wmXrRuntimeData *runtime, XrActionMap *action } } - BLI_strncpy(actionmap->name, name, MAX_NAME); + STRNCPY(actionmap->name, name); } static XrActionMap *wm_xr_actionmap_copy(XrActionMap *am_src) diff --git a/source/creator/creator_args.c b/source/creator/creator_args.c index e30dd772675..820dc28533a 100644 --- a/source/creator/creator_args.c +++ b/source/creator/creator_args.c @@ -1465,7 +1465,7 @@ static int arg_handle_output_set(int argc, const char **argv, void *data) if (argc > 1) { Scene *scene = CTX_data_scene(C); if (scene) { - BLI_strncpy(scene->r.pic, argv[1], sizeof(scene->r.pic)); + STRNCPY(scene->r.pic, argv[1]); DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); } else { @@ -1497,7 +1497,7 @@ static int arg_handle_engine_set(int argc, const char **argv, void *data) Scene *scene = CTX_data_scene(C); if (scene) { if (BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) { - BLI_strncpy_utf8(scene->r.engine, argv[1], sizeof(scene->r.engine)); + STRNCPY_UTF8(scene->r.engine, argv[1]); DEG_id_tag_update(&scene->id, ID_RECALC_COPY_ON_WRITE); } else { @@ -1865,7 +1865,7 @@ static int arg_handle_python_file_run(int argc, const char **argv, void *data) if (argc > 1) { /* Make the path absolute because its needed for relative linked blends to be found */ char filepath[FILE_MAX]; - BLI_strncpy(filepath, argv[1], sizeof(filepath)); + STRNCPY(filepath, argv[1]); BLI_path_abs_from_cwd(filepath, sizeof(filepath)); bool ok; @@ -2062,7 +2062,7 @@ static int arg_handle_load_file(int UNUSED(argc), const char **argv, void *data) fprintf(stderr, "unknown argument, loading as file: %s\n", argv[0]); } - BLI_strncpy(filepath, argv[0], sizeof(filepath)); + STRNCPY(filepath, argv[0]); BLI_path_slash_native(filepath); BLI_path_abs_from_cwd(filepath, sizeof(filepath)); BLI_path_normalize(filepath); diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c index 0912aa12019..45a65663c20 100644 --- a/source/creator/creator_signals.c +++ b/source/creator/creator_signals.c @@ -134,8 +134,7 @@ static void sig_handle_crash(int signum) fflush(stdout); # ifndef BUILD_DATE - BLI_snprintf( - header, sizeof(header), "# " BLEND_VERSION_FMT ", Unknown revision\n", BLEND_VERSION_ARG); + SNPRINTF(header, "# " BLEND_VERSION_FMT ", Unknown revision\n", BLEND_VERSION_ARG); # else BLI_snprintf(header, sizeof(header),