[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40872] trunk/blender/source/blender: replace sprintf with strcpy where no formatting is done and return value isn 't used.

Campbell Barton ideasman42 at gmail.com
Sun Oct 9 08:03:39 CEST 2011


Revision: 40872
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40872
Author:   campbellbarton
Date:     2011-10-09 06:03:38 +0000 (Sun, 09 Oct 2011)
Log Message:
-----------
replace sprintf with strcpy where no formatting is done and return value isn't used.

Modified Paths:
--------------
    trunk/blender/source/blender/blenkernel/intern/gpencil.c
    trunk/blender/source/blender/blenkernel/intern/library.c
    trunk/blender/source/blender/blenkernel/intern/nla.c
    trunk/blender/source/blender/blenlib/intern/winstuff.c
    trunk/blender/source/blender/editors/animation/anim_draw.c
    trunk/blender/source/blender/editors/animation/anim_ipo_utils.c
    trunk/blender/source/blender/editors/util/ed_util.c
    trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c
    trunk/blender/source/blender/makesrna/intern/rna_modifier.c

Modified: trunk/blender/source/blender/blenkernel/intern/gpencil.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/gpencil.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/blenkernel/intern/gpencil.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -182,7 +182,7 @@
 	gpl->thickness = 3;
 	
 	/* auto-name */
-	sprintf(gpl->info, "GP_Layer");
+	strcpy(gpl->info, "GP_Layer");
 	BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), sizeof(gpl->info));
 	
 	/* make this one the active one */

Modified: trunk/blender/source/blender/blenkernel/intern/library.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/library.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/blenkernel/intern/library.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -941,9 +941,9 @@
 		isnode= ((Tex *)id)->use_nodes;
 	
 	if (id->us<0)
-		sprintf(buf, "-1W ");
+		strcpy(buf, "-1W ");
 	else if (!id->lib && !isfake && id->us && !isnode)
-		sprintf(buf, "     ");
+		strcpy(buf, "     ");
 	else if(isnode)
 		sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
 	else

Modified: trunk/blender/source/blender/blenkernel/intern/nla.c
===================================================================
--- trunk/blender/source/blender/blenkernel/intern/nla.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/blenkernel/intern/nla.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -1284,16 +1284,16 @@
 	if (strip->name[0]==0) {
 		switch (strip->type) {
 			case NLASTRIP_TYPE_CLIP: /* act-clip */
-				sprintf(strip->name, "%s", (strip->act)?(strip->act->id.name+2):("<No Action>"));
+				BLI_strncpy(strip->name, (strip->act)?(strip->act->id.name+2):("<No Action>"), sizeof(strip->name));
 				break;
 			case NLASTRIP_TYPE_TRANSITION: /* transition */
-				sprintf(strip->name, "Transition");
+				BLI_strncpy(strip->name, "Transition", sizeof(strip->name));
 				break;
 			case NLASTRIP_TYPE_META: /* meta */
-				sprintf(strip->name, "Meta");
+				BLI_strncpy(strip->name, "Meta", sizeof(strip->name));
 				break;
 			default:
-				sprintf(strip->name, "NLA Strip");
+				BLI_strncpy(strip->name, "NLA Strip", sizeof(strip->name));
 				break;
 		}
 	}

Modified: trunk/blender/source/blender/blenlib/intern/winstuff.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/winstuff.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/blenlib/intern/winstuff.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -109,7 +109,7 @@
 	lresult = RegCreateKeyEx(root, "blendfile", 0,
 		NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
 	if (lresult == ERROR_SUCCESS) {
-		sprintf(buffer,"%s","Blender File");
+		strcpy(buffer,"Blender File");
 		lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
 		RegCloseKey(hkey);
 	}

Modified: trunk/blender/source/blender/editors/animation/anim_draw.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_draw.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/editors/animation/anim_draw.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -71,12 +71,12 @@
 	if (timecodes) {
 		int hours=0, minutes=0, seconds=0, frames=0;
 		float raw_seconds= cfra;
-		char neg[2]= "";
+		char neg[2]= {'\0'};
 		
 		/* get cframes */
 		if (cfra < 0) {
 			/* correction for negative cfraues */
-			sprintf(neg, "-");
+			neg[0]= '-';
 			cfra = -cfra;
 		}
 		if (cfra >= 3600) {

Modified: trunk/blender/source/blender/editors/animation/anim_ipo_utils.c
===================================================================
--- trunk/blender/source/blender/editors/animation/anim_ipo_utils.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/editors/animation/anim_ipo_utils.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -63,9 +63,9 @@
 		return icon;
 	else if ELEM3(NULL, id, fcu, fcu->rna_path) {
 		if (fcu == NULL)
-			sprintf(name, "<invalid>");
+			strcpy(name, "<invalid>");
 		else if (fcu->rna_path == NULL)
-			sprintf(name, "<no path>");
+			strcpy(name, "<no path>");
 		else /* id == NULL */
 			BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index);
 	}

Modified: trunk/blender/source/blender/editors/util/ed_util.c
===================================================================
--- trunk/blender/source/blender/editors/util/ed_util.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/editors/util/ed_util.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -171,7 +171,7 @@
 	pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE);
 	layout= uiPupMenuLayout(pup);
 
-	sprintf(line, "Remove Pack");
+	strcpy(line, "Remove Pack");
 	props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
 	RNA_enum_set(&props_ptr, "method", PF_REMOVE);
 	RNA_string_set(&props_ptr, "id", id_name);

Modified: trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/makesrna/intern/rna_fluidsim.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -141,12 +141,12 @@
 			psys->part= part;
 			psys->pointcache= BKE_ptcache_add(&psys->ptcaches);
 			psys->flag |= PSYS_ENABLED;
-			sprintf(psys->name, "FluidParticles");
+			BLI_strncpy(psys->name, "FluidParticles", sizeof(psys->name));
 			BLI_addtail(&ob->particlesystem,psys);
 
 			/* add modifier */
 			psmd= (ParticleSystemModifierData*)modifier_new(eModifierType_ParticleSystem);
-			sprintf(psmd->modifier.name, "FluidParticleSystem" );
+			BLI_strncpy(psmd->modifier.name, "FluidParticleSystem", sizeof(psmd->modifier.name));
 			psmd->psys= psys;
 			BLI_addtail(&ob->modifiers, psmd);
 			modifier_unique_name(&ob->modifiers, (ModifierData *)psmd);

Modified: trunk/blender/source/blender/makesrna/intern/rna_modifier.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_modifier.c	2011-10-09 04:11:18 UTC (rev 40871)
+++ trunk/blender/source/blender/makesrna/intern/rna_modifier.c	2011-10-09 06:03:38 UTC (rev 40872)
@@ -275,7 +275,7 @@
 					part->end = 250.0f;
 					part->ren_as = PART_DRAW_NOT;
 					part->draw_as = PART_DRAW_DOT;
-					sprintf(psys->name, "SmokeParticles");
+					BLI_strncpy(psys->name, "SmokeParticles", sizeof(psys->name));
 					psys->recalc |= (PSYS_RECALC_RESET|PSYS_RECALC_PHYS);
 					DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
 				}




More information about the Bf-blender-cvs mailing list