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 <ideasman42@gmail.com>2011-09-26 22:51:10 +0400
committerCampbell Barton <ideasman42@gmail.com>2011-09-26 22:51:10 +0400
commit58587a38818b0dba25886c97d584285fef4e9249 (patch)
tree38e00681d39ee6a0f588232c9ef70ec5f80e22df
parente897c8e83e1277767d9a44cb0ecb6f8a279dddc3 (diff)
replace strncpy with BLI_strncpy, in some cases strncpy was being misused since it doesnt ensure \0 termination.
also dont call CTX_data_scene() twice when checking for function arguments.
-rw-r--r--source/blender/blenfont/intern/blf_lang.c2
-rw-r--r--source/blender/blenkernel/intern/action.c2
-rw-r--r--source/blender/blenkernel/intern/blender.c2
-rw-r--r--source/blender/blenkernel/intern/ipo.c2
-rw-r--r--source/blender/blenkernel/intern/key.c6
-rw-r--r--source/blender/blenkernel/intern/node.c2
-rw-r--r--source/blender/blenkernel/intern/seqeffects.c5
-rw-r--r--source/blender/blenkernel/intern/sequencer.c2
-rw-r--r--source/blender/blenloader/intern/readfile.c8
-rw-r--r--source/blender/editors/armature/poselib.c2
-rw-r--r--source/blender/editors/physics/particle_edit.c2
-rw-r--r--source/blender/editors/sculpt_paint/paint_undo.c3
-rw-r--r--source/blender/editors/space_sequencer/sequencer_select.c8
-rw-r--r--source/blender/editors/space_text/text_draw.c3
-rw-r--r--source/blender/editors/util/editmode_undo.c2
-rw-r--r--source/blender/modifiers/intern/MOD_armature.c3
-rw-r--r--source/blender/modifiers/intern/MOD_bevel.c2
-rw-r--r--source/blender/modifiers/intern/MOD_cast.c3
-rw-r--r--source/blender/modifiers/intern/MOD_curve.c3
-rw-r--r--source/blender/modifiers/intern/MOD_displace.c5
-rw-r--r--source/blender/modifiers/intern/MOD_hook.c5
-rw-r--r--source/blender/modifiers/intern/MOD_lattice.c3
-rw-r--r--source/blender/modifiers/intern/MOD_smooth.c3
-rw-r--r--source/blender/modifiers/intern/MOD_warp.c5
-rw-r--r--source/blender/modifiers/intern/MOD_wave.c3
-rw-r--r--source/blender/nodes/intern/node_common.c2
-rw-r--r--source/blender/python/generic/bpy_internal_import.c2
-rw-r--r--source/blender/render/intern/source/convertblender.c2
-rw-r--r--source/blender/render/intern/source/pipeline.c2
-rw-r--r--source/creator/creator.c53
30 files changed, 79 insertions, 68 deletions
diff --git a/source/blender/blenfont/intern/blf_lang.c b/source/blender/blenfont/intern/blf_lang.c
index b5c6b5bd68c..0a102884969 100644
--- a/source/blender/blenfont/intern/blf_lang.c
+++ b/source/blender/blenfont/intern/blf_lang.c
@@ -158,7 +158,7 @@ void BLF_lang_set(const char *str)
char *s;
/* store defaul locale */
- strncpy(default_locale, env_language, sizeof(default_locale));
+ BLI_strncpy(default_locale, env_language, sizeof(default_locale));
/* use first language as default */
s= strchr(default_locale, ':');
diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index 73ddcbecf94..8d18a1c27e7 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -270,7 +270,7 @@ bActionGroup *action_groups_add_new (bAction *act, const char name[])
/* make it selected, with default name */
agrp->flag = AGRP_SELECTED;
- strncpy(agrp->name, name[0] ? name : "Group", sizeof(agrp->name));
+ BLI_strncpy(agrp->name, name[0] ? name : "Group", sizeof(agrp->name));
/* add to action, and validate */
BLI_addtail(&act->groups, agrp);
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 27ea1585e4b..1c729470da4 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -518,7 +518,7 @@ void BKE_write_undo(bContext *C, const char *name)
/* make new */
curundo= uel= MEM_callocN(sizeof(UndoElem), "undo file");
- strncpy(uel->name, name, MAXUNDONAME-1);
+ BLI_strncpy(uel->name, name, sizeof(uel->name));
BLI_addtail(&undobase, uel);
/* and limit amount to the maximum */
diff --git a/source/blender/blenkernel/intern/ipo.c b/source/blender/blenkernel/intern/ipo.c
index 71ca79706db..b885e608b15 100644
--- a/source/blender/blenkernel/intern/ipo.c
+++ b/source/blender/blenkernel/intern/ipo.c
@@ -1103,7 +1103,7 @@ static void fcurve_add_to_list (ListBase *groups, ListBase *list, FCurve *fcu, c
agrp->flag = AGRP_SELECTED;
if (muteipo) agrp->flag |= AGRP_MUTED;
- strncpy(agrp->name, grpname, sizeof(agrp->name));
+ BLI_strncpy(agrp->name, grpname, sizeof(agrp->name));
BLI_addtail(&tmp_act.groups, agrp);
BLI_uniquename(&tmp_act.groups, agrp, "Group", '.', offsetof(bActionGroup, name), sizeof(agrp->name));
diff --git a/source/blender/blenkernel/intern/key.c b/source/blender/blenkernel/intern/key.c
index 4b8209ab77e..656bb3ef853 100644
--- a/source/blender/blenkernel/intern/key.c
+++ b/source/blender/blenkernel/intern/key.c
@@ -1445,10 +1445,10 @@ KeyBlock *add_keyblock(Key *key, const char *name)
tot= BLI_countlist(&key->block);
if(name) {
- strncpy(kb->name, name, sizeof(kb->name));
+ BLI_strncpy(kb->name, name, sizeof(kb->name));
} else {
- if(tot==1) strcpy(kb->name, "Basis");
- else sprintf(kb->name, "Key %d", tot-1);
+ if(tot==1) BLI_strncpy(kb->name, "Basis", sizeof(kb->name));
+ else BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", tot-1);
}
BLI_uniquename(&key->block, kb, "Key", '.', offsetof(KeyBlock, name), sizeof(kb->name));
diff --git a/source/blender/blenkernel/intern/node.c b/source/blender/blenkernel/intern/node.c
index 524a63a8a95..f0be3c99f13 100644
--- a/source/blender/blenkernel/intern/node.c
+++ b/source/blender/blenkernel/intern/node.c
@@ -1682,7 +1682,7 @@ void node_type_size(struct bNodeType *ntype, int width, int minwidth, int maxwid
void node_type_storage(bNodeType *ntype, const char *storagename, void (*freestoragefunc)(struct bNode *), void (*copystoragefunc)(struct bNode *, struct bNode *))
{
if (storagename)
- strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
+ BLI_strncpy(ntype->storagename, storagename, sizeof(ntype->storagename));
else
ntype->storagename[0] = '\0';
ntype->copystoragefunc = copystoragefunc;
diff --git a/source/blender/blenkernel/intern/seqeffects.c b/source/blender/blenkernel/intern/seqeffects.c
index e5d74177c91..70b44792b30 100644
--- a/source/blender/blenkernel/intern/seqeffects.c
+++ b/source/blender/blenkernel/intern/seqeffects.c
@@ -41,6 +41,7 @@
#include "BLI_math.h" /* windows needs for M_PI */
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
@@ -177,7 +178,7 @@ static void open_plugin_seq(PluginSeq *pis, const char *seqname)
MEM_freeN(info);
cp= BLI_dynlib_find_symbol(pis->handle, "seqname");
- if(cp) strncpy(cp, seqname, 21);
+ if(cp) BLI_strncpy(cp, seqname, 21);
} else {
printf ("Plugin returned unrecognized version number\n");
return;
@@ -203,7 +204,7 @@ static PluginSeq *add_plugin_seq(const char *str, const char *seqname)
pis= MEM_callocN(sizeof(PluginSeq), "PluginSeq");
- strncpy(pis->name, str, FILE_MAXDIR+FILE_MAXFILE);
+ BLI_strncpy(pis->name, str, FILE_MAX);
open_plugin_seq(pis, seqname);
if(pis->doit==NULL) {
diff --git a/source/blender/blenkernel/intern/sequencer.c b/source/blender/blenkernel/intern/sequencer.c
index a3237da6234..743111b925f 100644
--- a/source/blender/blenkernel/intern/sequencer.c
+++ b/source/blender/blenkernel/intern/sequencer.c
@@ -3653,7 +3653,7 @@ Sequence *sequencer_add_sound_strip(bContext *C, ListBase *seqbasep, SeqLoadInfo
calc_sequence_disp(scene, seq);
/* last active name */
- strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_sounddir, strip->dir, FILE_MAXDIR);
seq_load_apply(scene, seq, seq_load);
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 6163fa015a8..f1f055b4004 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -516,7 +516,7 @@ static Main *blo_find_main(FileData *fd, ListBase *mainlist, const char *filepat
BLI_addtail(mainlist, m);
lib= alloc_libblock(&m->library, ID_LI, "lib");
- strncpy(lib->name, filepath, sizeof(lib->name)-1);
+ BLI_strncpy(lib->name, filepath, sizeof(lib->name));
BLI_strncpy(lib->filepath, name1, sizeof(lib->filepath));
m->curlib= lib;
@@ -5614,7 +5614,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 (strncmp(lib->name, "//", 2)==0) {
- strncpy(lib->name, lib->filepath, sizeof(lib->name));
+ BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
}
}
}
@@ -5623,7 +5623,7 @@ static void fix_relpaths_library(const char *basepath, Main *main)
/* Libraries store both relative and abs paths, recreate relative paths,
* relative to the blend file since indirectly linked libs will be relative to their direct linked library */
if (strncmp(lib->name, "//", 2)==0) { /* if this is relative to begin with? */
- strncpy(lib->name, lib->filepath, sizeof(lib->name));
+ BLI_strncpy(lib->name, lib->filepath, sizeof(lib->name));
BLI_path_rel(lib->name, basepath);
}
}
@@ -12240,7 +12240,7 @@ BlendFileData *blo_read_file_internal(FileData *fd, const char *filepath)
bfd->main->versionfile= fd->fileversion;
bfd->type= BLENFILETYPE_BLEND;
- strncpy(bfd->main->name, filepath, sizeof(bfd->main->name)-1);
+ BLI_strncpy(bfd->main->name, filepath, sizeof(bfd->main->name));
while(bhead) {
switch(bhead->code) {
diff --git a/source/blender/editors/armature/poselib.c b/source/blender/editors/armature/poselib.c
index 8a7d837d2a8..bf2e17c4e87 100644
--- a/source/blender/editors/armature/poselib.c
+++ b/source/blender/editors/armature/poselib.c
@@ -993,7 +993,7 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
memcpy(&tempstr[index+1], &pld->searchstr[index], 64-index);
}
else {
- strncpy(tempstr, pld->searchstr, 64);
+ BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr));
}
/* get marker name */
diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c
index 74e91cf32ea..019d6df9b73 100644
--- a/source/blender/editors/physics/particle_edit.c
+++ b/source/blender/editors/physics/particle_edit.c
@@ -3918,7 +3918,7 @@ void PE_undo_push(Scene *scene, const char *str)
/* make new */
edit->curundo= undo= MEM_callocN(sizeof(PTCacheUndo), "particle undo file");
- strncpy(undo->name, str, 64-1);
+ BLI_strncpy(undo->name, str, sizeof(undo->name));
BLI_addtail(&edit->undo, undo);
/* and limit amount to the maximum */
diff --git a/source/blender/editors/sculpt_paint/paint_undo.c b/source/blender/editors/sculpt_paint/paint_undo.c
index ba0c2c8be92..345cda63f5a 100644
--- a/source/blender/editors/sculpt_paint/paint_undo.c
+++ b/source/blender/editors/sculpt_paint/paint_undo.c
@@ -34,6 +34,7 @@
#include "BLI_listbase.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "DNA_userdef_types.h"
@@ -106,7 +107,7 @@ static void undo_stack_push_begin(UndoStack *stack, const char *name, UndoRestor
BLI_addtail(&stack->elems, uel);
/* name can be a dynamic string */
- strncpy(uel->name, name, MAXUNDONAME-1);
+ BLI_strncpy(uel->name, name, sizeof(uel->name));
/* limit amount to the maximum amount*/
nr= 0;
diff --git a/source/blender/editors/space_sequencer/sequencer_select.c b/source/blender/editors/space_sequencer/sequencer_select.c
index a6cc65017bb..c0919ef3043 100644
--- a/source/blender/editors/space_sequencer/sequencer_select.c
+++ b/source/blender/editors/space_sequencer/sequencer_select.c
@@ -169,11 +169,11 @@ static void UNUSED_FUNCTION(select_single_seq)(Scene *scene, Sequence *seq, int
if((seq->type==SEQ_IMAGE) || (seq->type==SEQ_MOVIE)) {
if(seq->strip)
- strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
}
else if(seq->type==SEQ_SOUND) {
if(seq->strip)
- strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
}
seq->flag|= SELECT;
recurs_sel_seq(seq);
@@ -389,12 +389,12 @@ static int sequencer_select_invoke(bContext *C, wmOperator *op, wmEvent *event)
if ((seq->type == SEQ_IMAGE) || (seq->type == SEQ_MOVIE)) {
if(seq->strip) {
- strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_imagedir, seq->strip->dir, FILE_MAXDIR);
}
} else
if (seq->type == SEQ_SOUND) {
if(seq->strip) {
- strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR-1);
+ BLI_strncpy(ed->act_sounddir, seq->strip->dir, FILE_MAXDIR);
}
}
diff --git a/source/blender/editors/space_text/text_draw.c b/source/blender/editors/space_text/text_draw.c
index 4c617115a3d..10d355bd0c3 100644
--- a/source/blender/editors/space_text/text_draw.c
+++ b/source/blender/editors/space_text/text_draw.c
@@ -1421,8 +1421,7 @@ static void draw_suggestion_list(SpaceText *st, ARegion *ar)
y -= st->lheight;
- strncpy(str, item->name, SUGG_LIST_WIDTH);
- str[SUGG_LIST_WIDTH] = '\0';
+ BLI_strncpy(str, item->name, SUGG_LIST_WIDTH);
w = text_font_width(st, str);
diff --git a/source/blender/editors/util/editmode_undo.c b/source/blender/editors/util/editmode_undo.c
index bcbc134d06d..f38ae136f71 100644
--- a/source/blender/editors/util/editmode_undo.c
+++ b/source/blender/editors/util/editmode_undo.c
@@ -142,7 +142,7 @@ void undo_editmode_push(bContext *C, const char *name,
/* make new */
curundo= uel= MEM_callocN(sizeof(UndoElem), "undo editmode");
- strncpy(uel->name, name, MAXUNDONAME-1);
+ BLI_strncpy(uel->name, name, sizeof(uel->name));
BLI_addtail(&undobase, uel);
uel->getdata= getdata;
diff --git a/source/blender/modifiers/intern/MOD_armature.c b/source/blender/modifiers/intern/MOD_armature.c
index 0b46d950950..0ef85a49899 100644
--- a/source/blender/modifiers/intern/MOD_armature.c
+++ b/source/blender/modifiers/intern/MOD_armature.c
@@ -42,6 +42,7 @@
#include "DNA_mesh_types.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
@@ -70,7 +71,7 @@ static void copyData(ModifierData *md, ModifierData *target)
tamd->object = amd->object;
tamd->deformflag = amd->deformflag;
tamd->multi = amd->multi;
- strncpy(tamd->defgrp_name, amd->defgrp_name, 32);
+ BLI_strncpy(tamd->defgrp_name, amd->defgrp_name, 32);
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *UNUSED(md))
diff --git a/source/blender/modifiers/intern/MOD_bevel.c b/source/blender/modifiers/intern/MOD_bevel.c
index 277f404f64d..197e6a24342 100644
--- a/source/blender/modifiers/intern/MOD_bevel.c
+++ b/source/blender/modifiers/intern/MOD_bevel.c
@@ -72,7 +72,7 @@ static void copyData(ModifierData *md, ModifierData *target)
tbmd->lim_flags = bmd->lim_flags;
tbmd->e_flags = bmd->e_flags;
tbmd->bevel_angle = bmd->bevel_angle;
- strncpy(tbmd->defgrp_name, bmd->defgrp_name, 32);
+ BLI_strncpy(tbmd->defgrp_name, bmd->defgrp_name, 32);
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_cast.c b/source/blender/modifiers/intern/MOD_cast.c
index 4061128b5ad..b0e001f0978 100644
--- a/source/blender/modifiers/intern/MOD_cast.c
+++ b/source/blender/modifiers/intern/MOD_cast.c
@@ -40,6 +40,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_deform.h"
@@ -77,7 +78,7 @@ static void copyData(ModifierData *md, ModifierData *target)
tcmd->flag = cmd->flag;
tcmd->type = cmd->type;
tcmd->object = cmd->object;
- strncpy(tcmd->defgrp_name, cmd->defgrp_name, 32);
+ BLI_strncpy(tcmd->defgrp_name, cmd->defgrp_name, 32);
}
static int isDisabled(ModifierData *md, int UNUSED(useRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_curve.c b/source/blender/modifiers/intern/MOD_curve.c
index d928c239eac..b732158358d 100644
--- a/source/blender/modifiers/intern/MOD_curve.c
+++ b/source/blender/modifiers/intern/MOD_curve.c
@@ -41,6 +41,7 @@
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
@@ -65,7 +66,7 @@ static void copyData(ModifierData *md, ModifierData *target)
tcmd->defaxis = cmd->defaxis;
tcmd->object = cmd->object;
- strncpy(tcmd->name, cmd->name, 32);
+ BLI_strncpy(tcmd->name, cmd->name, 32);
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_displace.c b/source/blender/modifiers/intern/MOD_displace.c
index fb7aeacecc8..b0d9892a8df 100644
--- a/source/blender/modifiers/intern/MOD_displace.c
+++ b/source/blender/modifiers/intern/MOD_displace.c
@@ -40,6 +40,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
@@ -75,11 +76,11 @@ static void copyData(ModifierData *md, ModifierData *target)
tdmd->texture = dmd->texture;
tdmd->strength = dmd->strength;
tdmd->direction = dmd->direction;
- strncpy(tdmd->defgrp_name, dmd->defgrp_name, 32);
+ BLI_strncpy(tdmd->defgrp_name, dmd->defgrp_name, 32);
tdmd->midlevel = dmd->midlevel;
tdmd->texmapping = dmd->texmapping;
tdmd->map_object = dmd->map_object;
- strncpy(tdmd->uvlayer_name, dmd->uvlayer_name, 32);
+ BLI_strncpy(tdmd->uvlayer_name, dmd->uvlayer_name, 32);
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_hook.c b/source/blender/modifiers/intern/MOD_hook.c
index 785abc7d4d1..ad97ee82ee2 100644
--- a/source/blender/modifiers/intern/MOD_hook.c
+++ b/source/blender/modifiers/intern/MOD_hook.c
@@ -41,6 +41,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_action.h"
#include "BKE_cdderivedmesh.h"
@@ -72,8 +73,8 @@ static void copyData(ModifierData *md, ModifierData *target)
thmd->totindex = hmd->totindex;
thmd->indexar = MEM_dupallocN(hmd->indexar);
memcpy(thmd->parentinv, hmd->parentinv, sizeof(hmd->parentinv));
- strncpy(thmd->name, hmd->name, 32);
- strncpy(thmd->subtarget, hmd->subtarget, 32);
+ BLI_strncpy(thmd->name, hmd->name, 32);
+ BLI_strncpy(thmd->subtarget, hmd->subtarget, 32);
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_lattice.c b/source/blender/modifiers/intern/MOD_lattice.c
index 31c17fb7376..4ff92e3c86d 100644
--- a/source/blender/modifiers/intern/MOD_lattice.c
+++ b/source/blender/modifiers/intern/MOD_lattice.c
@@ -40,6 +40,7 @@
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
@@ -57,7 +58,7 @@ static void copyData(ModifierData *md, ModifierData *target)
LatticeModifierData *tlmd = (LatticeModifierData*) target;
tlmd->object = lmd->object;
- strncpy(tlmd->name, lmd->name, 32);
+ BLI_strncpy(tlmd->name, lmd->name, 32);
}
static CustomDataMask requiredDataMask(Object *UNUSED(ob), ModifierData *md)
diff --git a/source/blender/modifiers/intern/MOD_smooth.c b/source/blender/modifiers/intern/MOD_smooth.c
index 16898a80b53..5e13b8a6d3c 100644
--- a/source/blender/modifiers/intern/MOD_smooth.c
+++ b/source/blender/modifiers/intern/MOD_smooth.c
@@ -39,6 +39,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_particle.h"
@@ -69,7 +70,7 @@ static void copyData(ModifierData *md, ModifierData *target)
tsmd->fac = smd->fac;
tsmd->repeat = smd->repeat;
tsmd->flag = smd->flag;
- strncpy(tsmd->defgrp_name, smd->defgrp_name, 32);
+ BLI_strncpy(tsmd->defgrp_name, smd->defgrp_name, 32);
}
static int isDisabled(ModifierData *md, int UNUSED(useRenderParams))
diff --git a/source/blender/modifiers/intern/MOD_warp.c b/source/blender/modifiers/intern/MOD_warp.c
index 36d3dc88b56..a088ba80b3d 100644
--- a/source/blender/modifiers/intern/MOD_warp.c
+++ b/source/blender/modifiers/intern/MOD_warp.c
@@ -33,6 +33,7 @@
#include "BLI_math.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_cdderivedmesh.h"
#include "BKE_modifier.h"
@@ -73,13 +74,13 @@ static void copyData(ModifierData *md, ModifierData *target)
twmd->strength = wmd->strength;
twmd->falloff_radius = wmd->falloff_radius;
twmd->falloff_type = wmd->falloff_type;
- strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name));
+ BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, sizeof(twmd->defgrp_name));
twmd->curfalloff = curvemapping_copy(wmd->curfalloff);
/* map info */
twmd->texture = wmd->texture;
twmd->map_object = wmd->map_object;
- strncpy(twmd->uvlayer_name, wmd->uvlayer_name, sizeof(twmd->uvlayer_name));
+ BLI_strncpy(twmd->uvlayer_name, wmd->uvlayer_name, sizeof(twmd->uvlayer_name));
twmd->texmapping= wmd->texmapping;
}
diff --git a/source/blender/modifiers/intern/MOD_wave.c b/source/blender/modifiers/intern/MOD_wave.c
index 4b5769ff603..820c7e16f53 100644
--- a/source/blender/modifiers/intern/MOD_wave.c
+++ b/source/blender/modifiers/intern/MOD_wave.c
@@ -42,6 +42,7 @@
#include "DNA_object_types.h"
#include "BLI_utildefines.h"
+#include "BLI_string.h"
#include "BKE_DerivedMesh.h"
@@ -98,7 +99,7 @@ static void copyData(ModifierData *md, ModifierData *target)
twmd->texture = wmd->texture;
twmd->map_object = wmd->map_object;
twmd->texmapping = wmd->texmapping;
- strncpy(twmd->defgrp_name, wmd->defgrp_name, 32);
+ BLI_strncpy(twmd->defgrp_name, wmd->defgrp_name, 32);
}
static int dependsOnTime(ModifierData *UNUSED(md))
diff --git a/source/blender/nodes/intern/node_common.c b/source/blender/nodes/intern/node_common.c
index 8225c986409..fa5a3c727c2 100644
--- a/source/blender/nodes/intern/node_common.c
+++ b/source/blender/nodes/intern/node_common.c
@@ -567,7 +567,7 @@ bNodeSocket *node_group_add_socket(bNodeTree *ngroup, const char *name, int type
bNodeSocketType *stype = ntreeGetSocketType(type);
bNodeSocket *gsock = MEM_callocN(sizeof(bNodeSocket), "bNodeSocket");
- strncpy(gsock->name, name, sizeof(gsock->name));
+ BLI_strncpy(gsock->name, name, sizeof(gsock->name));
gsock->type = type;
/* group sockets are dynamically added */
gsock->flag |= SOCK_DYNAMIC;
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index 67ed90c79eb..90260100c83 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -120,7 +120,7 @@ PyObject *bpy_text_import(Text *text)
}
len= strlen(text->id.name+2);
- strncpy(modulename, text->id.name+2, len);
+ BLI_strncpy(modulename, text->id.name+2, len);
modulename[len - 3]= '\0'; /* remove .py */
return PyImport_ExecCodeModule(modulename, text->compiled);
}
diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c
index b972569fdf6..f06707c94fe 100644
--- a/source/blender/render/intern/source/convertblender.c
+++ b/source/blender/render/intern/source/convertblender.c
@@ -5026,7 +5026,7 @@ void RE_Database_FromScene(Render *re, Main *bmain, Scene *scene, unsigned int l
/* per second, per object, stats print this */
re->i.infostr= "Preparing Scene data";
re->i.cfra= scene->r.cfra;
- strncpy(re->i.scenename, scene->id.name+2, 20);
+ BLI_strncpy(re->i.scenename, scene->id.name+2, sizeof(re->i.scenename));
/* XXX add test if dbase was filled already? */
diff --git a/source/blender/render/intern/source/pipeline.c b/source/blender/render/intern/source/pipeline.c
index 05bcc32a90a..7835ae6dcd3 100644
--- a/source/blender/render/intern/source/pipeline.c
+++ b/source/blender/render/intern/source/pipeline.c
@@ -1198,7 +1198,7 @@ Render *RE_NewRender(const char *name)
/* new render data struct */
re= MEM_callocN(sizeof(Render), "new render");
BLI_addtail(&RenderGlobal.renderlist, re);
- strncpy(re->name, name, RE_MAXNAME);
+ BLI_strncpy(re->name, name, RE_MAXNAME);
BLI_rw_mutex_init(&re->resultmutex);
}
diff --git a/source/creator/creator.c b/source/creator/creator.c
index d25b0be30d8..3ce469de4e8 100644
--- a/source/creator/creator.c
+++ b/source/creator/creator.c
@@ -520,8 +520,8 @@ static int set_output(int argc, const char **argv, void *data)
{
bContext *C = data;
if (argc >= 1){
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
BLI_strncpy(scene->r.pic, argv[1], sizeof(scene->r.pic));
} else {
printf("\nError: no blend loaded. cannot use '-o / --render-output'.\n");
@@ -546,17 +546,17 @@ static int set_engine(int argc, const char **argv, void *data)
exit(0);
}
else {
- if (CTX_data_scene(C)==NULL) {
- printf("\nError: no blend loaded. order the arguments so '-E / --engine ' is after a blend is loaded.\n");
- }
- else {
- Scene *scene= CTX_data_scene(C);
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
RenderData *rd = &scene->r;
if(BLI_findstring(&R_engines, argv[1], offsetof(RenderEngineType, idname))) {
BLI_strncpy_utf8(rd->engine, argv[1], sizeof(rd->engine));
}
}
+ else {
+ printf("\nError: no blend loaded. order the arguments so '-E / --engine ' is after a blend is loaded.\n");
+ }
}
return 1;
@@ -573,10 +573,8 @@ static int set_image_type(int argc, const char **argv, void *data)
bContext *C = data;
if (argc >= 1){
const char *imtype = argv[1];
- if (CTX_data_scene(C)==NULL) {
- printf("\nError: no blend loaded. order the arguments so '-F / --render-format' is after the blend is loaded.\n");
- } else {
- Scene *scene= CTX_data_scene(C);
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
if (!strcmp(imtype,"TGA")) scene->r.imtype = R_TARGA;
else if (!strcmp(imtype,"IRIS")) scene->r.imtype = R_IRIS;
#ifdef WITH_DDS
@@ -612,6 +610,9 @@ static int set_image_type(int argc, const char **argv, void *data)
#endif
else printf("\nError: Format from '-F / --render-format' not known or not compiled in this release.\n");
}
+ else {
+ printf("\nError: no blend loaded. order the arguments so '-F / --render-format' is after the blend is loaded.\n");
+ }
return 1;
} else {
printf("\nError: you must specify a format after '-F / --render-foramt'.\n");
@@ -638,8 +639,8 @@ static int set_extension(int argc, const char **argv, void *data)
{
bContext *C = data;
if (argc >= 1) {
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
if (argv[1][0] == '0') {
scene->r.scemode &= ~R_EXTENSION;
} else if (argv[1][0] == '1') {
@@ -721,9 +722,9 @@ example:
static int render_frame(int argc, const char **argv, void *data)
{
bContext *C = data;
- if (CTX_data_scene(C)) {
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
if (argc > 1) {
Render *re = RE_NewRender(scene->id.name);
@@ -763,9 +764,9 @@ static int render_frame(int argc, const char **argv, void *data)
static int render_animation(int UNUSED(argc), const char **UNUSED(argv), void *data)
{
bContext *C = data;
- if (CTX_data_scene(C)) {
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
Main *bmain= CTX_data_main(C);
- Scene *scene= CTX_data_scene(C);
Render *re= RE_NewRender(scene->id.name);
ReportList reports;
BKE_reports_init(&reports, RPT_PRINT);
@@ -782,9 +783,9 @@ static int set_scene(int argc, const char **argv, void *data)
{
if(argc > 1) {
bContext *C= data;
- Scene *sce= set_scene_name(CTX_data_main(C), argv[1]);
- if(sce) {
- CTX_data_scene_set(C, sce);
+ Scene *scene= set_scene_name(CTX_data_main(C), argv[1]);
+ if(scene) {
+ CTX_data_scene_set(C, scene);
}
return 1;
} else {
@@ -796,8 +797,8 @@ static int set_scene(int argc, const char **argv, void *data)
static int set_start_frame(int argc, const char **argv, void *data)
{
bContext *C = data;
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
if (argc > 1) {
int frame = atoi(argv[1]);
(scene->r.sfra) = CLAMPIS(frame, MINFRAME, MAXFRAME);
@@ -815,8 +816,8 @@ static int set_start_frame(int argc, const char **argv, void *data)
static int set_end_frame(int argc, const char **argv, void *data)
{
bContext *C = data;
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
if (argc > 1) {
int frame = atoi(argv[1]);
(scene->r.efra) = CLAMPIS(frame, MINFRAME, MAXFRAME);
@@ -834,8 +835,8 @@ static int set_end_frame(int argc, const char **argv, void *data)
static int set_skip_frame(int argc, const char **argv, void *data)
{
bContext *C = data;
- if (CTX_data_scene(C)) {
- Scene *scene= CTX_data_scene(C);
+ Scene *scene= CTX_data_scene(C);
+ if (scene) {
if (argc > 1) {
int frame = atoi(argv[1]);
(scene->r.frame_step) = CLAMPIS(frame, 1, MAXFRAME);