Cleanup: use STRNCPY, SNPRINTF macros

This commit is contained in:
Campbell Barton 2023-05-09 12:50:37 +10:00
parent 2f9538a8c7
commit 3958ae7241
402 changed files with 1550 additions and 1822 deletions

View file

@ -14,7 +14,6 @@ PassAccessorGPU::PassAccessorGPU(DeviceQueue *queue,
float exposure,
int num_samples)
: PassAccessor(pass_access_info, exposure, num_samples), queue_(queue)
{
}

View file

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

View file

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

View file

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

View file

@ -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<ConstrWorkOb>", sizeof(workob->id.name));
STRNCPY(workob->id.name, "OB<ConstrWorkOb>");
/* If we're given a group to use, it's likely to be more efficient
* (though a bit more dangerous). */

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -82,7 +82,7 @@ TEST_F(BPathTest, rebase_on_relative)
text->filepath = BLI_strdup(TEXT_PATH_RELATIVE);
MovieClip *movie_clip = reinterpret_cast<MovieClip *>(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<MovieClip *>(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<MovieClip *>(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<MovieClip *>(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<MovieClip *>(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<eBPathForeachFlag>(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<eBPathForeachFlag>(0), path_list_handle);

View file

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

View file

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

View file

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

View file

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

View file

@ -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<RenderResult *>(
MEM_callocN(sizeof(RenderResult), __func__));
BKE_cryptomatte_store_metadata(session.get(), render_result2, &view_layer);

View file

@ -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<CustomDataExternal>(__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;
}

View file

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

View file

@ -48,7 +48,7 @@ bDeformGroup *BKE_object_defgroup_new(Object *ob, const char *name)
defgroup = MEM_cnew<bDeformGroup>(__func__);
BLI_strncpy(defgroup->name, name, sizeof(defgroup->name));
STRNCPY(defgroup->name, name);
ListBase *defbase = BKE_object_defgroup_list_mutable(ob);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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<RenderSlot>("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;

View file

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

View file

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

View file

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

View file

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

View file

@ -161,7 +161,7 @@ static ViewLayer *view_layer_add(const char *name)
ViewLayer *view_layer = MEM_cnew<ViewLayer>("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<bNode *>(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<ViewLayerAOV>(__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<ViewLayerLightgroup>(__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);
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -336,7 +336,7 @@ MaskLayer *BKE_mask_layer_new(Mask *mask, const char *name)
MaskLayer *masklay = MEM_cnew<MaskLayer>(__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<MaskLayer>("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");

View file

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

View file

@ -137,7 +137,7 @@ static ModifierData *modifier_allocate_and_init(ModifierType type)
ModifierData *md = static_cast<ModifierData *>(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;

View file

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

View file

@ -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) : ("<No Action>"),
sizeof(strip->name));
STRNCPY(strip->name, (strip->act) ? (strip->act->id.name + 2) : ("<No Action>"));
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));

View file

@ -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<bNodeSocketRuntime>(__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<bNodeSocket>("socket template");
sock->runtime = MEM_new<bNodeSocketRuntime>(__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';

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -52,7 +52,7 @@ TracksMap *tracks_map_new(const char *object_name, int num_tracks)
{
TracksMap *map = MEM_cnew<TracksMap>("TrackingsMap");
BLI_strncpy(map->object_name, object_name, sizeof(map->object_name));
STRNCPY(map->object_name, object_name);
map->num_tracks = num_tracks;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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",

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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, '/', '\\'); \

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -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<const NodeGeometrySimulationOutput *>(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<const NodeGeometrySimulationOutput *>(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) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

Some files were not shown because too many files have changed in this diff Show more