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

@@ -267,7 +267,7 @@ const char *BPY_app_translations_py_pgettext(const char *msgctxt, const char *ms
if (!STREQ(tmp, locale) || !_translations_cache) {
PyGILState_STATE _py_state;
BLI_strncpy(locale, tmp, STATIC_LOCALE_SIZE);
STRNCPY(locale, tmp);
/* Locale changed or cache does not exist, refresh the whole cache! */
/* This func may be called from C (i.e. outside of python interpreter 'context'). */

View File

@@ -598,7 +598,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) {
if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) {
G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL;
BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Driver '%s'", expr);
SNPRINTF(G.autoexec_fail, "Driver '%s'", expr);
printf("skipping driver '%s', automatic scripts are disabled\n", expr);
}
@@ -759,7 +759,7 @@ float BPY_driver_exec(struct PathResolvedRNA *anim_rna,
{
if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) {
G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL;
BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Driver '%s'", expr);
SNPRINTF(G.autoexec_fail, "Driver '%s'", expr);
}
Py_DECREF(expr_code);

View File

@@ -656,7 +656,7 @@ void BPY_modules_load_user(bContext *C)
if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC)) {
if (!(G.f & G_FLAG_SCRIPT_AUTOEXEC_FAIL_QUIET)) {
G.f |= G_FLAG_SCRIPT_AUTOEXEC_FAIL;
BLI_snprintf(G.autoexec_fail, sizeof(G.autoexec_fail), "Text '%s'", text->id.name + 2);
SNPRINTF(G.autoexec_fail, "Text '%s'", text->id.name + 2);
printf("scripts disabled for \"%s\", skipping '%s'\n",
BKE_main_blendfile_path(bmain),

View File

@@ -241,8 +241,8 @@ static PyObject *bpy_lib_load(BPy_PropertyRNA *self, PyObject *args, PyObject *k
ret = PyObject_New(BPy_Library, &bpy_lib_Type);
BLI_strncpy(ret->relpath, filepath, sizeof(ret->relpath));
BLI_strncpy(ret->abspath, filepath, sizeof(ret->abspath));
STRNCPY(ret->relpath, filepath);
STRNCPY(ret->abspath, filepath);
BLI_path_abs(ret->abspath, BKE_main_blendfile_path(bmain));
ret->bmain = bmain;
@@ -324,8 +324,8 @@ static PyObject *bpy_lib_enter(BPy_Library *self)
/* create a dummy */
self_from = PyObject_New(BPy_Library, &bpy_lib_Type);
BLI_strncpy(self_from->relpath, self->relpath, sizeof(self_from->relpath));
BLI_strncpy(self_from->abspath, self->abspath, sizeof(self_from->abspath));
STRNCPY(self_from->relpath, self->relpath);
STRNCPY(self_from->abspath, self->abspath);
self_from->blo_handle = NULL;
self_from->flag = 0;

View File

@@ -117,7 +117,7 @@ static PyObject *bpy_lib_write(BPy_PropertyRNA *self, PyObject *args, PyObject *
write_flags |= G_FILE_COMPRESS;
}
BLI_strncpy(filepath_abs, filepath, FILE_MAX);
STRNCPY(filepath_abs, filepath);
BLI_path_abs(filepath_abs, BKE_main_blendfile_path_from_global());
BKE_blendfile_write_partial_begin(bmain_src);

View File

@@ -192,8 +192,8 @@ static int validate_array_type(PyObject *seq,
Py_DECREF(item);
#if 0
BLI_snprintf(
error_str, error_str_size, "sequence items should be of type %s", item_type_str);
SNPRINTF(
error_str, "sequence items should be of type %s", item_type_str);
#endif
PyErr_Format(PyExc_TypeError,
"%s expected sequence items of type %s, not %s",