replace sprintf with strcpy where no formatting is done and return value isn't used.

This commit is contained in:
Campbell Barton 2011-10-09 06:03:38 +00:00
parent 6778f7ae05
commit 8714fb7019
9 changed files with 16 additions and 16 deletions

@ -182,7 +182,7 @@ bGPDlayer *gpencil_layer_addnew (bGPdata *gpd)
gpl->thickness = 3; gpl->thickness = 3;
/* auto-name */ /* 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)); BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info[0]), sizeof(gpl->info));
/* make this one the active one */ /* make this one the active one */

@ -941,9 +941,9 @@ static void get_flags_for_id(ID *id, char *buf)
isnode= ((Tex *)id)->use_nodes; isnode= ((Tex *)id)->use_nodes;
if (id->us<0) if (id->us<0)
sprintf(buf, "-1W "); strcpy(buf, "-1W ");
else if (!id->lib && !isfake && id->us && !isnode) else if (!id->lib && !isfake && id->us && !isnode)
sprintf(buf, " "); strcpy(buf, " ");
else if(isnode) else if(isnode)
sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' '); sprintf(buf, "%c%cN%c ", id->lib?'L':' ', isfake?'F':' ', (id->us==0)?'O':' ');
else else

@ -1284,16 +1284,16 @@ void BKE_nlastrip_validate_name (AnimData *adt, NlaStrip *strip)
if (strip->name[0]==0) { if (strip->name[0]==0) {
switch (strip->type) { switch (strip->type) {
case NLASTRIP_TYPE_CLIP: /* act-clip */ 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; break;
case NLASTRIP_TYPE_TRANSITION: /* transition */ case NLASTRIP_TYPE_TRANSITION: /* transition */
sprintf(strip->name, "Transition"); BLI_strncpy(strip->name, "Transition", sizeof(strip->name));
break; break;
case NLASTRIP_TYPE_META: /* meta */ case NLASTRIP_TYPE_META: /* meta */
sprintf(strip->name, "Meta"); BLI_strncpy(strip->name, "Meta", sizeof(strip->name));
break; break;
default: default:
sprintf(strip->name, "NLA Strip"); BLI_strncpy(strip->name, "NLA Strip", sizeof(strip->name));
break; break;
} }
} }

@ -109,7 +109,7 @@ void RegisterBlendExtension(void) {
lresult = RegCreateKeyEx(root, "blendfile", 0, lresult = RegCreateKeyEx(root, "blendfile", 0,
NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd); NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkey, &dwd);
if (lresult == ERROR_SUCCESS) { 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); lresult = RegSetValueEx(hkey, NULL, 0, REG_SZ, (BYTE*)buffer, strlen(buffer) + 1);
RegCloseKey(hkey); RegCloseKey(hkey);
} }

@ -71,12 +71,12 @@ void ANIM_timecode_string_from_frame (char *str, Scene *scene, int power, short
if (timecodes) { if (timecodes) {
int hours=0, minutes=0, seconds=0, frames=0; int hours=0, minutes=0, seconds=0, frames=0;
float raw_seconds= cfra; float raw_seconds= cfra;
char neg[2]= ""; char neg[2]= {'\0'};
/* get cframes */ /* get cframes */
if (cfra < 0) { if (cfra < 0) {
/* correction for negative cfraues */ /* correction for negative cfraues */
sprintf(neg, "-"); neg[0]= '-';
cfra = -cfra; cfra = -cfra;
} }
if (cfra >= 3600) { if (cfra >= 3600) {

@ -63,9 +63,9 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
return icon; return icon;
else if ELEM3(NULL, id, fcu, fcu->rna_path) { else if ELEM3(NULL, id, fcu, fcu->rna_path) {
if (fcu == NULL) if (fcu == NULL)
sprintf(name, "<invalid>"); strcpy(name, "<invalid>");
else if (fcu->rna_path == NULL) else if (fcu->rna_path == NULL)
sprintf(name, "<no path>"); strcpy(name, "<no path>");
else /* id == NULL */ else /* id == NULL */
BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index); BLI_snprintf(name, 256, "%s[%d]", fcu->rna_path, fcu->array_index);
} }

@ -171,7 +171,7 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE); pup= uiPupMenuBegin(C, "Unpack file", ICON_NONE);
layout= uiPupMenuLayout(pup); 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); 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_enum_set(&props_ptr, "method", PF_REMOVE);
RNA_string_set(&props_ptr, "id", id_name); RNA_string_set(&props_ptr, "id", id_name);

@ -141,12 +141,12 @@ static void rna_FluidSettings_update_type(Main *bmain, Scene *scene, PointerRNA
psys->part= part; psys->part= part;
psys->pointcache= BKE_ptcache_add(&psys->ptcaches); psys->pointcache= BKE_ptcache_add(&psys->ptcaches);
psys->flag |= PSYS_ENABLED; psys->flag |= PSYS_ENABLED;
sprintf(psys->name, "FluidParticles"); BLI_strncpy(psys->name, "FluidParticles", sizeof(psys->name));
BLI_addtail(&ob->particlesystem,psys); BLI_addtail(&ob->particlesystem,psys);
/* add modifier */ /* add modifier */
psmd= (ParticleSystemModifierData*)modifier_new(eModifierType_ParticleSystem); psmd= (ParticleSystemModifierData*)modifier_new(eModifierType_ParticleSystem);
sprintf(psmd->modifier.name, "FluidParticleSystem" ); BLI_strncpy(psmd->modifier.name, "FluidParticleSystem", sizeof(psmd->modifier.name));
psmd->psys= psys; psmd->psys= psys;
BLI_addtail(&ob->modifiers, psmd); BLI_addtail(&ob->modifiers, psmd);
modifier_unique_name(&ob->modifiers, (ModifierData *)psmd); modifier_unique_name(&ob->modifiers, (ModifierData *)psmd);

@ -275,7 +275,7 @@ static void rna_Smoke_set_type(Main *bmain, Scene *scene, PointerRNA *ptr)
part->end = 250.0f; part->end = 250.0f;
part->ren_as = PART_DRAW_NOT; part->ren_as = PART_DRAW_NOT;
part->draw_as = PART_DRAW_DOT; 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); psys->recalc |= (PSYS_RECALC_RESET|PSYS_RECALC_PHYS);
DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA); DAG_id_tag_update(ptr->id.data, OB_RECALC_DATA);
} }