diff --git a/source/blender/blenlib/intern/fileops.c b/source/blender/blenlib/intern/fileops.c index dfc8368cf6b..b2daa3f0be0 100644 --- a/source/blender/blenlib/intern/fileops.c +++ b/source/blender/blenlib/intern/fileops.c @@ -560,7 +560,7 @@ static bool delete_recursive(const char *dir) char path[FILE_MAXDIR]; /* dir listing produces dir path without trailing slash... */ - BLI_strncpy(path, fl->path, sizeof(path)); + STRNCPY(path, fl->path); BLI_path_slash_ensure(path, sizeof(path)); if (delete_recursive(path)) { @@ -627,7 +627,7 @@ int BLI_path_move(const char *file, const char *to) * it has to be 'mv filepath filepath' and not * 'mv filepath destination_directory' */ - BLI_strncpy(str, to, sizeof(str)); + STRNCPY(str, to); /* points 'to' to a directory ? */ if (BLI_path_slash_rfind(str) == (str + strlen(str) - 1)) { if (BLI_path_slash_rfind(file) != NULL) { @@ -658,7 +658,7 @@ int BLI_copy(const char *file, const char *to) * it has to be 'cp filepath filepath' and not * 'cp filepath destdir' */ - BLI_strncpy(str, to, sizeof(str)); + STRNCPY(str, to); /* points 'to' to a directory ? */ if (BLI_path_slash_rfind(str) == (str + strlen(str) - 1)) { if (BLI_path_slash_rfind(file) != NULL) { diff --git a/source/blender/blenlib/intern/winstuff.c b/source/blender/blenlib/intern/winstuff.c index a2d63861b77..835ba725562 100644 --- a/source/blender/blenlib/intern/winstuff.c +++ b/source/blender/blenlib/intern/winstuff.c @@ -112,7 +112,7 @@ bool BLI_windows_register_blend_extension(const bool background) &hkey, &dwd); if (lresult == ERROR_SUCCESS) { - BLI_snprintf(buffer, sizeof(buffer), "\"%s\" \"%%1\"", BlPath); + SNPRINTF(buffer, "\"%s\" \"%%1\"", BlPath); lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1); RegCloseKey(hkey); } @@ -131,7 +131,7 @@ bool BLI_windows_register_blend_extension(const bool background) &hkey, &dwd); if (lresult == ERROR_SUCCESS) { - BLI_snprintf(buffer, sizeof(buffer), "\"%s\", 1", BlPath); + SNPRINTF(buffer, "\"%s\", 1", BlPath); lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE *)buffer, strlen(buffer) + 1); RegCloseKey(hkey); } @@ -169,12 +169,10 @@ bool BLI_windows_register_blend_extension(const bool background) RegCloseKey(root); printf("success (%s)\n", usr_mode ? "user" : "system"); if (!background) { - BLI_snprintf(MBox, - sizeof(MBox), - "File extension registered for %s.", - usr_mode ? - "the current user. To register for all users, run as an administrator" : - "all users"); + SNPRINTF(MBox, + "File extension registered for %s.", + usr_mode ? "the current user. To register for all users, run as an administrator" : + "all users"); MessageBox(0, MBox, "Blender", MB_OK | MB_ICONINFORMATION); } return true; diff --git a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc index 1f87f2229fe..b7bc4d097a4 100644 --- a/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc +++ b/source/blender/blenlib/tests/BLI_polyfill_2d_test.cc @@ -335,7 +335,7 @@ static void polyfill_to_obj(const char *id, FILE *f; uint i; - BLI_snprintf(path, sizeof(path), "%s.obj", id); + SNPRINTF(path, "%s.obj", id); f = fopen(path, "w"); if (!f) { diff --git a/source/blender/blenloader/intern/writefile.cc b/source/blender/blenloader/intern/writefile.cc index d985622395f..47cfe63fafe 100644 --- a/source/blender/blenloader/intern/writefile.cc +++ b/source/blender/blenloader/intern/writefile.cc @@ -1063,7 +1063,7 @@ static void write_global(WriteData *wd, int fileflags, Main *mainvar) #ifdef WITH_BUILDINFO /* TODO(sergey): Add branch name to file as well? */ fg.build_commit_timestamp = build_commit_timestamp; - BLI_strncpy(fg.build_hash, build_hash, sizeof(fg.build_hash)); + STRNCPY(fg.build_hash, build_hash); #else fg.build_commit_timestamp = 0; STRNCPY(fg.build_hash, "unknown"); diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index a91ceaeb853..14199e9300c 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2841,7 +2841,7 @@ void file_directory_enter_handle(bContext *C, void *UNUSED(arg_unused), void *UN else if (!can_create_dir(params->dir)) { const char *lastdir = folderlist_peeklastdir(sfile->folders_prev); if (lastdir) { - BLI_strncpy(params->dir, lastdir, sizeof(params->dir)); + STRNCPY(params->dir, lastdir); } } #endif diff --git a/source/blender/io/collada/AnimationImporter.cpp b/source/blender/io/collada/AnimationImporter.cpp index 6fb67e90150..40f0411f0a7 100644 --- a/source/blender/io/collada/AnimationImporter.cpp +++ b/source/blender/io/collada/AnimationImporter.cpp @@ -368,8 +368,8 @@ virtual void AnimationImporter::change_eul_to_quat(Object *ob, bAction *act) char grp_name_esc[sizeof(grp->name) * 2]; BLI_str_escape(grp_name_esc, grp->name, sizeof(grp_name_esc)); - BLI_snprintf(joint_path, sizeof(joint_path), "pose.bones[\"%s\"]", grp_name_esc); - BLI_snprintf(rna_path, sizeof(rna_path), "%s.rotation_quaternion", joint_path); + SNPRINTF(joint_path, "pose.bones[\"%s\"]", grp_name_esc); + SNPRINTF(rna_path, "%s.rotation_quaternion", joint_path); FCurve *quatcu[4] = { create_fcurve(0, rna_path), diff --git a/source/blender/io/collada/DocumentExporter.cpp b/source/blender/io/collada/DocumentExporter.cpp index 0a3edc9fc21..16760731ede 100644 --- a/source/blender/io/collada/DocumentExporter.cpp +++ b/source/blender/io/collada/DocumentExporter.cpp @@ -228,13 +228,12 @@ int DocumentExporter::exportCurrentScene() asset.getContributor().mAuthor = "Blender User"; char version_buf[128]; #ifdef WITH_BUILDINFO - BLI_snprintf(version_buf, - sizeof(version_buf), - "Blender %s commit date:%s, commit time:%s, hash:%s", - BKE_blender_version_string(), - build_commit_date, - build_commit_time, - build_hash); + SNPRINTF(version_buf, + "Blender %s commit date:%s, commit time:%s, hash:%s", + BKE_blender_version_string(), + build_commit_date, + build_commit_time, + build_hash); #else SNPRINTF(version_buf, "Blender %s", BKE_blender_version_string()); #endif diff --git a/source/blender/python/intern/bpy_interface.c b/source/blender/python/intern/bpy_interface.c index 81d1137d053..0822aab738d 100644 --- a/source/blender/python/intern/bpy_interface.c +++ b/source/blender/python/intern/bpy_interface.c @@ -803,7 +803,7 @@ static void bpy_module_delay_init(PyObject *bpy_proxy) const char *filepath_rel = PyUnicode_AsUTF8(filepath_obj); /* can be relative */ char filepath_abs[1024]; - BLI_strncpy(filepath_abs, filepath_rel, sizeof(filepath_abs)); + STRNCPY(filepath_abs, filepath_rel); BLI_path_abs_from_cwd(filepath_abs, sizeof(filepath_abs)); Py_DECREF(filepath_obj); diff --git a/source/creator/creator.c b/source/creator/creator.c index b040c9fd433..957bf6c27c3 100644 --- a/source/creator/creator.c +++ b/source/creator/creator.c @@ -361,8 +361,8 @@ int main(int argc, } else { const char *unknown = "date-unknown"; - BLI_strncpy(build_commit_date, unknown, sizeof(build_commit_date)); - BLI_strncpy(build_commit_time, unknown, sizeof(build_commit_time)); + STRNCPY(build_commit_date, unknown); + STRNCPY(build_commit_time, unknown); } } #endif diff --git a/source/creator/creator_signals.c b/source/creator/creator_signals.c index 45a65663c20..ea4f94263f3 100644 --- a/source/creator/creator_signals.c +++ b/source/creator/creator_signals.c @@ -136,13 +136,12 @@ static void sig_handle_crash(int signum) # ifndef BUILD_DATE SNPRINTF(header, "# " BLEND_VERSION_FMT ", Unknown revision\n", BLEND_VERSION_ARG); # else - BLI_snprintf(header, - sizeof(header), - "# " BLEND_VERSION_FMT ", Commit date: %s %s, Hash %s\n", - BLEND_VERSION_ARG, - build_commit_date, - build_commit_time, - build_hash); + SNPRINTF(header, + "# " BLEND_VERSION_FMT ", Commit date: %s %s, Hash %s\n", + BLEND_VERSION_ARG, + build_commit_date, + build_commit_time, + build_hash); # endif /* open the crash log */