[Bf-blender-cvs] [8cb3b49e514] master: Cleanup: replace strncpy with BLI_strncpy

Campbell Barton noreply at git.blender.org
Sat Sep 10 08:56:09 CEST 2022


Commit: 8cb3b49e51469b9689bfa44b85349149e17699dc
Author: Campbell Barton
Date:   Sat Sep 10 16:51:15 2022 +1000
Branches: master
https://developer.blender.org/rB8cb3b49e51469b9689bfa44b85349149e17699dc

Cleanup: replace strncpy with BLI_strncpy

Also replace strncpy+strcat with BLI_string_join

===================================================================

M	source/blender/blenlib/intern/system.c
M	source/blender/editors/screen/area.c
M	source/blender/editors/space_action/space_action.c
M	source/blender/editors/space_buttons/space_buttons.c
M	source/blender/editors/space_clip/space_clip.c
M	source/blender/editors/space_console/space_console.c
M	source/blender/editors/space_file/space_file.c
M	source/blender/editors/space_graph/space_graph.c
M	source/blender/editors/space_image/space_image.c
M	source/blender/editors/space_info/space_info.c
M	source/blender/editors/space_nla/space_nla.c
M	source/blender/editors/space_node/space_node.cc
M	source/blender/editors/space_outliner/space_outliner.cc
M	source/blender/editors/space_script/space_script.c
M	source/blender/editors/space_sequencer/space_sequencer.c
M	source/blender/editors/space_spreadsheet/space_spreadsheet.cc
M	source/blender/editors/space_statusbar/space_statusbar.c
M	source/blender/editors/space_text/space_text.c
M	source/blender/editors/space_text/text_draw.c
M	source/blender/editors/space_topbar/space_topbar.c
M	source/blender/editors/space_userpref/space_userpref.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/imbuf/intern/cineon/cineonlib.c
M	source/blender/imbuf/intern/cineon/dpxlib.c
M	source/blender/modifiers/intern/MOD_volume_to_mesh.cc

===================================================================

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 1

@@ Diff output truncated at 10240 characters. @@



More information about the Bf-blender-cvs mailing list