Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <campbell@blender.org>2022-09-10 09:51:15 +0300
committerCampbell Barton <campbell@blender.org>2022-09-10 09:54:21 +0300
commit8cb3b49e51469b9689bfa44b85349149e17699dc (patch)
tree04307341165e0ee87aca82190c760af241027c32
parent489cb7fd7eb0ab4e34c084acd2bf740a878498e9 (diff)
Cleanup: replace strncpy with BLI_strncpy
Also replace strncpy+strcat with BLI_string_join
-rw-r--r--source/blender/blenlib/intern/system.c4
-rw-r--r--source/blender/editors/screen/area.c10
-rw-r--r--source/blender/editors/space_action/space_action.c2
-rw-r--r--source/blender/editors/space_buttons/space_buttons.c2
-rw-r--r--source/blender/editors/space_clip/space_clip.c2
-rw-r--r--source/blender/editors/space_console/space_console.c2
-rw-r--r--source/blender/editors/space_file/space_file.c2
-rw-r--r--source/blender/editors/space_graph/space_graph.c2
-rw-r--r--source/blender/editors/space_image/space_image.c2
-rw-r--r--source/blender/editors/space_info/space_info.c2
-rw-r--r--source/blender/editors/space_nla/space_nla.c2
-rw-r--r--source/blender/editors/space_node/space_node.cc2
-rw-r--r--source/blender/editors/space_outliner/space_outliner.cc2
-rw-r--r--source/blender/editors/space_script/space_script.c2
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c2
-rw-r--r--source/blender/editors/space_spreadsheet/space_spreadsheet.cc2
-rw-r--r--source/blender/editors/space_statusbar/space_statusbar.c2
-rw-r--r--source/blender/editors/space_text/space_text.c2
-rw-r--r--source/blender/editors/space_text/text_draw.c2
-rw-r--r--source/blender/editors/space_topbar/space_topbar.c2
-rw-r--r--source/blender/editors/space_userpref/space_userpref.c2
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c2
-rw-r--r--source/blender/imbuf/intern/cineon/cineonlib.c9
-rw-r--r--source/blender/imbuf/intern/cineon/dpxlib.c7
-rw-r--r--source/blender/modifiers/intern/MOD_volume_to_mesh.cc2
25 files changed, 36 insertions, 36 deletions
diff --git a/source/blender/blenlib/intern/system.c b/source/blender/blenlib/intern/system.c
index 781b38f713a..f7249e491d7 100644
--- a/source/blender/blenlib/intern/system.c
+++ b/source/blender/blenlib/intern/system.c
@@ -154,12 +154,12 @@ void BLI_hostname_get(char *buffer, size_t bufsize)
if (gethostname(buffer, bufsize - 1) < 0) {
BLI_strncpy(buffer, "-unknown-", bufsize);
}
- /* When gethostname() truncates, it doesn't guarantee the trailing \0. */
+ /* When `gethostname()` truncates, it doesn't guarantee the trailing `\0`. */
buffer[bufsize - 1] = '\0';
#else
DWORD bufsize_inout = bufsize;
if (!GetComputerName(buffer, &bufsize_inout)) {
- strncpy(buffer, "-unknown-", bufsize);
+ BLI_strncpy(buffer, "-unknown-", bufsize);
}
#endif
}
diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c
index dc3aaea5e49..4e99e384f9f 100644
--- a/source/blender/editors/screen/area.c
+++ b/source/blender/editors/screen/area.c
@@ -16,6 +16,7 @@
#include "BLI_linklist_stack.h"
#include "BLI_math.h"
#include "BLI_rand.h"
+#include "BLI_string_utils.h"
#include "BLI_utildefines.h"
#include "BKE_context.h"
@@ -2687,12 +2688,13 @@ static void ed_panel_draw(const bContext *C,
const uiStyle *style = UI_style_get_dpi();
/* Draw panel. */
-
char block_name[BKE_ST_MAXNAME + INSTANCED_PANEL_UNIQUE_STR_LEN];
- strncpy(block_name, pt->idname, BKE_ST_MAXNAME);
- if (unique_panel_str != NULL) {
+ if (unique_panel_str) {
/* Instanced panels should have already been added at this point. */
- strncat(block_name, unique_panel_str, INSTANCED_PANEL_UNIQUE_STR_LEN);
+ BLI_string_join(block_name, sizeof(block_name), pt->idname, unique_panel_str);
+ }
+ else {
+ STRNCPY(block_name, pt->idname);
}
uiBlock *block = UI_block_begin(C, region, block_name, UI_EMBOSS);
diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c
index fc0588dbab5..98782ca15a8 100644
--- a/source/blender/editors/space_action/space_action.c
+++ b/source/blender/editors/space_action/space_action.c
@@ -840,7 +840,7 @@ void ED_spacetype_action(void)
ARegionType *art;
st->spaceid = SPACE_ACTION;
- strncpy(st->name, "Action", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Action");
st->create = action_create;
st->free = action_free;
diff --git a/source/blender/editors/space_buttons/space_buttons.c b/source/blender/editors/space_buttons/space_buttons.c
index 2bee60557b7..74b7fa3719a 100644
--- a/source/blender/editors/space_buttons/space_buttons.c
+++ b/source/blender/editors/space_buttons/space_buttons.c
@@ -917,7 +917,7 @@ void ED_spacetype_buttons(void)
ARegionType *art;
st->spaceid = SPACE_PROPERTIES;
- strncpy(st->name, "Buttons", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Buttons");
st->create = buttons_create;
st->free = buttons_free;
diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c
index f8bf1893d89..ab952470757 100644
--- a/source/blender/editors/space_clip/space_clip.c
+++ b/source/blender/editors/space_clip/space_clip.c
@@ -1251,7 +1251,7 @@ void ED_spacetype_clip(void)
ARegionType *art;
st->spaceid = SPACE_CLIP;
- strncpy(st->name, "Clip", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Clip");
st->create = clip_create;
st->free = clip_free;
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index a7ab6bc5169..8af0c1fc6ab 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -289,7 +289,7 @@ void ED_spacetype_console(void)
ARegionType *art;
st->spaceid = SPACE_CONSOLE;
- strncpy(st->name, "Console", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Console");
st->create = console_create;
st->free = console_free;
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index b5cad0f6ff8..bba0c27bb4d 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -992,7 +992,7 @@ void ED_spacetype_file(void)
ARegionType *art;
st->spaceid = SPACE_FILE;
- strncpy(st->name, "File", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "File");
st->create = file_create;
st->free = file_free;
diff --git a/source/blender/editors/space_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 3594c65c1cb..1434f204ee5 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -810,7 +810,7 @@ void ED_spacetype_ipo(void)
ARegionType *art;
st->spaceid = SPACE_GRAPH;
- strncpy(st->name, "Graph", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Graph");
st->create = graph_create;
st->free = graph_free;
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 67bff9677dc..08b7897ec5a 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -1029,7 +1029,7 @@ void ED_spacetype_image(void)
ARegionType *art;
st->spaceid = SPACE_IMAGE;
- strncpy(st->name, "Image", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Image");
st->create = image_create;
st->free = image_free;
diff --git a/source/blender/editors/space_info/space_info.c b/source/blender/editors/space_info/space_info.c
index 1513ba5e892..63c8d74c684 100644
--- a/source/blender/editors/space_info/space_info.c
+++ b/source/blender/editors/space_info/space_info.c
@@ -254,7 +254,7 @@ void ED_spacetype_info(void)
ARegionType *art;
st->spaceid = SPACE_INFO;
- strncpy(st->name, "Info", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Info");
st->create = info_create;
st->free = info_free;
diff --git a/source/blender/editors/space_nla/space_nla.c b/source/blender/editors/space_nla/space_nla.c
index ba7e8987dd5..c71e63e9dcd 100644
--- a/source/blender/editors/space_nla/space_nla.c
+++ b/source/blender/editors/space_nla/space_nla.c
@@ -568,7 +568,7 @@ void ED_spacetype_nla(void)
ARegionType *art;
st->spaceid = SPACE_NLA;
- strncpy(st->name, "NLA", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "NLA");
st->create = nla_create;
st->free = nla_free;
diff --git a/source/blender/editors/space_node/space_node.cc b/source/blender/editors/space_node/space_node.cc
index 17fc02e98a8..fae3eb1a143 100644
--- a/source/blender/editors/space_node/space_node.cc
+++ b/source/blender/editors/space_node/space_node.cc
@@ -1021,7 +1021,7 @@ void ED_spacetype_node()
ARegionType *art;
st->spaceid = SPACE_NODE;
- strncpy(st->name, "Node", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Node");
st->create = node_create;
st->free = node_free;
diff --git a/source/blender/editors/space_outliner/space_outliner.cc b/source/blender/editors/space_outliner/space_outliner.cc
index 76b7197b86a..365bcae3f5d 100644
--- a/source/blender/editors/space_outliner/space_outliner.cc
+++ b/source/blender/editors/space_outliner/space_outliner.cc
@@ -445,7 +445,7 @@ void ED_spacetype_outliner(void)
ARegionType *art;
st->spaceid = SPACE_OUTLINER;
- strncpy(st->name, "Outliner", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Outliner");
st->create = outliner_create;
st->free = outliner_free;
diff --git a/source/blender/editors/space_script/space_script.c b/source/blender/editors/space_script/space_script.c
index a623b98f1b1..c35b1e00184 100644
--- a/source/blender/editors/space_script/space_script.c
+++ b/source/blender/editors/space_script/space_script.c
@@ -152,7 +152,7 @@ void ED_spacetype_script(void)
ARegionType *art;
st->spaceid = SPACE_SCRIPT;
- strncpy(st->name, "Script", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Script");
st->create = script_create;
st->free = script_free;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 201f132052d..538cfad14f5 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -997,7 +997,7 @@ void ED_spacetype_sequencer(void)
ARegionType *art;
st->spaceid = SPACE_SEQ;
- strncpy(st->name, "Sequencer", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Sequencer");
st->create = sequencer_create;
st->free = sequencer_free;
diff --git a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
index 5c0f69905fa..435436611c5 100644
--- a/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
+++ b/source/blender/editors/space_spreadsheet/space_spreadsheet.cc
@@ -619,7 +619,7 @@ void ED_spacetype_spreadsheet()
ARegionType *art;
st->spaceid = SPACE_SPREADSHEET;
- strncpy(st->name, "Spreadsheet", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Spreadsheet");
st->create = spreadsheet_create;
st->free = spreadsheet_free;
diff --git a/source/blender/editors/space_statusbar/space_statusbar.c b/source/blender/editors/space_statusbar/space_statusbar.c
index 9c64235870c..e99e8f21364 100644
--- a/source/blender/editors/space_statusbar/space_statusbar.c
+++ b/source/blender/editors/space_statusbar/space_statusbar.c
@@ -136,7 +136,7 @@ void ED_spacetype_statusbar(void)
ARegionType *art;
st->spaceid = SPACE_STATUSBAR;
- strncpy(st->name, "Status Bar", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Status Bar");
st->create = statusbar_create;
st->free = statusbar_free;
diff --git a/source/blender/editors/space_text/space_text.c b/source/blender/editors/space_text/space_text.c
index 45cf557c4b4..be9bbdf109e 100644
--- a/source/blender/editors/space_text/space_text.c
+++ b/source/blender/editors/space_text/space_text.c
@@ -403,7 +403,7 @@ void ED_spacetype_text(void)
ARegionType *art;
st->spaceid = SPACE_TEXT;
- strncpy(st->name, "Text", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Text");
st->create = text_create;
st->free = text_free;
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 0f0ecb0e4bf..46c459dd0bc 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -706,7 +706,7 @@ static void text_update_drawcache(SpaceText *st, ARegion *region)
drawcache->showlinenrs = st->showlinenrs;
drawcache->tabnumber = st->tabnumber;
- strncpy(drawcache->text_id, txt->id.name, MAX_ID_NAME);
+ STRNCPY(drawcache->text_id, txt->id.name);
/* clear update flag */
drawcache->update_flag = 0;
diff --git a/source/blender/editors/space_topbar/space_topbar.c b/source/blender/editors/space_topbar/space_topbar.c
index ee0e0c3ef46..e4826ed5964 100644
--- a/source/blender/editors/space_topbar/space_topbar.c
+++ b/source/blender/editors/space_topbar/space_topbar.c
@@ -288,7 +288,7 @@ void ED_spacetype_topbar(void)
ARegionType *art;
st->spaceid = SPACE_TOPBAR;
- strncpy(st->name, "Top Bar", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Top Bar");
st->create = topbar_create;
st->free = topbar_free;
diff --git a/source/blender/editors/space_userpref/space_userpref.c b/source/blender/editors/space_userpref/space_userpref.c
index 1cda9cc0f0c..06a4c1d8702 100644
--- a/source/blender/editors/space_userpref/space_userpref.c
+++ b/source/blender/editors/space_userpref/space_userpref.c
@@ -189,7 +189,7 @@ void ED_spacetype_userpref(void)
ARegionType *art;
st->spaceid = SPACE_USERPREF;
- strncpy(st->name, "Userpref", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "Userpref");
st->create = userpref_create;
st->free = userpref_free;
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 30acfdbf7d8..860bb604270 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -1972,7 +1972,7 @@ void ED_spacetype_view3d(void)
ARegionType *art;
st->spaceid = SPACE_VIEW3D;
- strncpy(st->name, "View3D", BKE_ST_MAXNAME);
+ STRNCPY(st->name, "View3D");
st->create = view3d_create;
st->free = view3d_free;
diff --git a/source/blender/imbuf/intern/cineon/cineonlib.c b/source/blender/imbuf/intern/cineon/cineonlib.c
index 8312476bda0..fa05f155b30 100644
--- a/source/blender/imbuf/intern/cineon/cineonlib.c
+++ b/source/blender/imbuf/intern/cineon/cineonlib.c
@@ -18,6 +18,7 @@
#include <time.h>
#include "BLI_fileops.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
@@ -56,9 +57,8 @@ static void fillCineonMainHeader(LogImageFile *cineon,
cineon->height *
getRowLength(cineon->width, cineon->element[0]),
cineon->isMSB);
- strcpy(header->fileHeader.version, "v4.5");
- strncpy(header->fileHeader.file_name, filepath, 99);
- header->fileHeader.file_name[99] = 0;
+ STRNCPY(header->fileHeader.version, "v4.5");
+ STRNCPY(header->fileHeader.file_name, filepath);
fileClock = time(NULL);
fileTime = localtime(&fileClock);
strftime(header->fileHeader.creation_date, 12, "%Y:%m:%d", fileTime);
@@ -93,8 +93,7 @@ static void fillCineonMainHeader(LogImageFile *cineon,
header->imageHeader.green_primary_y = swap_float(0.0f, cineon->isMSB);
header->imageHeader.blue_primary_x = swap_float(0.0f, cineon->isMSB);
header->imageHeader.blue_primary_y = swap_float(0.0f, cineon->isMSB);
- strncpy(header->imageHeader.label, creator, 199);
- header->imageHeader.label[199] = 0;
+ STRNCPY(header->imageHeader.label, creator);
header->imageHeader.interleave = 0;
header->imageHeader.data_sign = 0;
header->imageHeader.sense = 0;
diff --git a/source/blender/imbuf/intern/cineon/dpxlib.c b/source/blender/imbuf/intern/cineon/dpxlib.c
index 28c19116361..4c780032f0b 100644
--- a/source/blender/imbuf/intern/cineon/dpxlib.c
+++ b/source/blender/imbuf/intern/cineon/dpxlib.c
@@ -18,6 +18,7 @@
#include <time.h>
#include "BLI_fileops.h"
+#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "MEM_guardedalloc.h"
@@ -60,14 +61,12 @@ static void fillDpxMainHeader(LogImageFile *dpx,
header->fileHeader.ind_hdr_size = swap_uint(sizeof(DpxFilmHeader) + sizeof(DpxTelevisionHeader),
dpx->isMSB);
header->fileHeader.user_data_size = DPX_UNDEFINED_U32;
- strncpy(header->fileHeader.file_name, filename, 99);
- header->fileHeader.file_name[99] = 0;
+ STRNCPY(header->fileHeader.file_name, filename);
fileClock = time(NULL);
fileTime = localtime(&fileClock);
strftime(header->fileHeader.creation_date, 24, "%Y:%m:%d:%H:%M:%S%Z", fileTime);
header->fileHeader.creation_date[23] = 0;
- strncpy(header->fileHeader.creator, creator, 99);
- header->fileHeader.creator[99] = 0;
+ STRNCPY(header->fileHeader.creator, creator);
header->fileHeader.project[0] = 0;
header->fileHeader.copyright[0] = 0;
header->fileHeader.key = 0xFFFFFFFF;
diff --git a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
index 215436e4a8d..0065012db97 100644
--- a/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
+++ b/source/blender/modifiers/intern/MOD_volume_to_mesh.cc
@@ -51,7 +51,7 @@ static void initData(ModifierData *md)
VolumeToMeshModifierData *vmmd = reinterpret_cast<VolumeToMeshModifierData *>(md);
vmmd->object = nullptr;
vmmd->threshold = 0.1f;
- strncpy(vmmd->grid_name, "density", MAX_NAME);
+ STRNCPY(vmmd->grid_name, "density");
vmmd->adaptivity = 0.0f;
vmmd->resolution_mode = VOLUME_TO_MESH_RESOLUTION_MODE_GRID;
vmmd->voxel_amount = 32;