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-02-12 19:54:24 +0300
committerCampbell Barton <ideasman42@gmail.com>2011-02-12 19:54:24 +0300
commit55f68c36574779ae2fac3652466584628b22c633 (patch)
treee2f55301dda8897bf17f8b8459229d8fa5a67816 /source/blender/blenkernel/intern
parent9eee1f962d49f14d92c8da4e677e4ee140f4f440 (diff)
fix for more warnings.
- modifier code was using sizeof() without knowing the sizeof the array when clearing the modifier type array. - use BLI_snprintf rather then sprintf where the size of the string is known. - particle drawing code kept a reference to stack float values (not a problem at the moment but would crash if accessed later).
Diffstat (limited to 'source/blender/blenkernel/intern')
-rw-r--r--source/blender/blenkernel/intern/blender.c8
-rw-r--r--source/blender/blenkernel/intern/deform.c8
-rw-r--r--source/blender/blenkernel/intern/image.c64
-rw-r--r--source/blender/blenkernel/intern/library.c6
-rw-r--r--source/blender/blenkernel/intern/modifier.c7
5 files changed, 37 insertions, 56 deletions
diff --git a/source/blender/blenkernel/intern/blender.c b/source/blender/blenkernel/intern/blender.c
index 6e08df0f465..222d416e2f0 100644
--- a/source/blender/blenkernel/intern/blender.c
+++ b/source/blender/blenkernel/intern/blender.c
@@ -124,9 +124,9 @@ void initglobals(void)
ENDIAN_ORDER= (((char*)&ENDIAN_ORDER)[0])? L_ENDIAN: B_ENDIAN;
if(BLENDER_SUBVERSION)
- sprintf(versionstr, "www.blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
+ BLI_snprintf(versionstr, sizeof(versionstr), "www.blender.org %d.%d", BLENDER_VERSION, BLENDER_SUBVERSION);
else
- sprintf(versionstr, "www.blender.org %d", BLENDER_VERSION);
+ BLI_snprintf(versionstr, sizeof(versionstr), "www.blender.org %d", BLENDER_VERSION);
#ifdef _WIN32 // FULLSCREEN
G.windowstate = G_WINDOWSTATE_USERDEF;
@@ -314,7 +314,7 @@ static int handle_subversion_warning(Main *main)
char str[128];
- sprintf(str, "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
+ BLI_snprintf(str, sizeof(str), "File written by newer Blender binary: %d.%d , expect loss of data!", main->minversionfile, main->minsubversionfile);
// XXX error(str);
}
return 1;
@@ -520,7 +520,7 @@ void BKE_write_undo(bContext *C, const char *name)
counter++;
counter= counter % U.undosteps;
- sprintf(numstr, "%d.blend", counter);
+ BLI_snprintf(numstr, sizeof(numstr), "%d.blend", counter);
BLI_make_file_string("/", tstr, btempdir, numstr);
success= BLO_write_file(CTX_data_main(C), tstr, G.fileflags, NULL, NULL);
diff --git a/source/blender/blenkernel/intern/deform.c b/source/blender/blenkernel/intern/deform.c
index 937681fcdc3..1b63e4fd5d1 100644
--- a/source/blender/blenkernel/intern/deform.c
+++ b/source/blender/blenkernel/intern/deform.c
@@ -339,10 +339,10 @@ void defgroup_unique_name (bDeformGroup *dg, Object *ob)
void flip_side_name (char *name, const char *from_name, int strip_number)
{
int len;
- char prefix[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The part before the facing */
- char suffix[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The part after the facing */
- char replace[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The replacement string */
- char number[sizeof(((bDeformGroup *)NULL)->name)]= {""}; /* The number extension string */
+ char prefix[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The part before the facing */
+ char suffix[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The part after the facing */
+ char replace[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The replacement string */
+ char number[sizeof(((bDeformGroup *)NULL)->name)]= ""; /* The number extension string */
char *index=NULL;
len= strlen(from_name);
diff --git a/source/blender/blenkernel/intern/image.c b/source/blender/blenkernel/intern/image.c
index 37d1e65144d..4092abb07d4 100644
--- a/source/blender/blenkernel/intern/image.c
+++ b/source/blender/blenkernel/intern/image.c
@@ -873,32 +873,23 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
time_t t;
if (scene->r.stamp & R_STAMP_FILENAME) {
- if (G.relbase_valid) {
- if (do_prefix) sprintf(stamp_data->file, "File %s", G.main->name);
- else sprintf(stamp_data->file, "%s", G.main->name);
- } else {
- if (do_prefix) strcpy(stamp_data->file, "File <untitled>");
- else strcpy(stamp_data->file, "<untitled>");
- }
+ BLI_snprintf(stamp_data->file, sizeof(stamp_data->file), do_prefix ? "File %s":"%s", G.relbase_valid ? G.main->name:"<untitled>");
} else {
stamp_data->file[0] = '\0';
}
if (scene->r.stamp & R_STAMP_NOTE) {
/* Never do prefix for Note */
- sprintf(stamp_data->note, "%s", scene->r.stamp_udata);
+ BLI_snprintf(stamp_data->note, sizeof(stamp_data->note), "%s", scene->r.stamp_udata);
} else {
stamp_data->note[0] = '\0';
}
if (scene->r.stamp & R_STAMP_DATE) {
-
- t = time (NULL);
- tl = localtime (&t);
- sprintf (text, "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec);
-
- if (do_prefix) sprintf(stamp_data->date, "Date %s", text);
- else sprintf(stamp_data->date, "%s", text);
+ t = time(NULL);
+ tl = localtime(&t);
+ BLI_snprintf(text, sizeof(text), "%04d/%02d/%02d %02d:%02d:%02d", tl->tm_year+1900, tl->tm_mon+1, tl->tm_mday, tl->tm_hour, tl->tm_min, tl->tm_sec);
+ BLI_snprintf(stamp_data->date, sizeof(stamp_data->date), do_prefix ? "Date %s":"%s", text);
} else {
stamp_data->date[0] = '\0';
}
@@ -908,9 +899,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if (name) strcpy(text, name);
else strcpy(text, "<none>");
-
- if (do_prefix) sprintf(stamp_data->marker, "Marker %s", text);
- else sprintf(stamp_data->marker, "%s", text);
+
+ BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text);
} else {
stamp_data->marker[0] = '\0';
}
@@ -932,12 +922,11 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
}
if (scene->r.frs_sec < 100)
- sprintf (text, "%02d:%02d:%02d.%02d", h, m, s, f);
+ BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%02d", h, m, s, f);
else
- sprintf (text, "%02d:%02d:%02d.%03d", h, m, s, f);
-
- if (do_prefix) sprintf(stamp_data->time, "Time %s", text);
- else sprintf(stamp_data->time, "%s", text);
+ BLI_snprintf(text, sizeof(text), "%02d:%02d:%02d.%03d", h, m, s, f);
+
+ BLI_snprintf(stamp_data->time, sizeof(stamp_data->time), do_prefix ? "Time %s":"%s", text);
} else {
stamp_data->time[0] = '\0';
}
@@ -948,39 +937,32 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if(scene->r.efra>9)
digits= 1 + (int) log10(scene->r.efra);
-
- if (do_prefix) sprintf(format, "Frame %%0%di", digits);
- else sprintf(format, "%%0%di", digits);
- sprintf (stamp_data->frame, format, scene->r.cfra);
+
+ BLI_snprintf(format, sizeof(format), do_prefix ? "Frame %%0%di":"%%0%di", digits);
+ BLI_snprintf (stamp_data->frame, sizeof(stamp_data->frame), format, scene->r.cfra);
} else {
stamp_data->frame[0] = '\0';
}
if (scene->r.stamp & R_STAMP_CAMERA) {
- if (scene->camera) strcpy(text, scene->camera->id.name+2);
- else strcpy(text, "<none>");
-
- if (do_prefix) sprintf(stamp_data->camera, "Camera %s", text);
- else sprintf(stamp_data->camera, "%s", text);
+ BLI_snprintf(stamp_data->camera, sizeof(stamp_data->camera), do_prefix ? "Camera %s":"%s", scene->camera ? scene->camera->id.name+2 : "<none>");
} else {
stamp_data->camera[0] = '\0';
}
if (scene->r.stamp & R_STAMP_CAMERALENS) {
if (scene->camera && scene->camera->type == OB_CAMERA) {
- sprintf(text, "%.2f", ((Camera *)scene->camera->data)->lens);
+ BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)scene->camera->data)->lens);
}
else strcpy(text, "<none>");
- if (do_prefix) sprintf(stamp_data->cameralens, "Lens %s", text);
- else sprintf(stamp_data->cameralens, "%s", text);
+ BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s":"%s", text);
} else {
stamp_data->cameralens[0] = '\0';
}
if (scene->r.stamp & R_STAMP_SCENE) {
- if (do_prefix) sprintf(stamp_data->scene, "Scene %s", scene->id.name+2);
- else sprintf(stamp_data->scene, "%s", scene->id.name+2);
+ BLI_snprintf(stamp_data->scene, sizeof(stamp_data->scene), do_prefix ? "Scene %s":"%s", scene->id.name+2);
} else {
stamp_data->scene[0] = '\0';
}
@@ -990,9 +972,8 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if (seq) strcpy(text, seq->name+2);
else strcpy(text, "<none>");
-
- if (do_prefix) sprintf(stamp_data->strip, "Strip %s", text);
- else sprintf(stamp_data->strip, "%s", text);
+
+ BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text);
} else {
stamp_data->strip[0] = '\0';
}
@@ -1004,8 +985,7 @@ static void stampdata(Scene *scene, StampData *stamp_data, int do_prefix)
if (stats && (scene->r.stamp & R_STAMP_RENDERTIME)) {
BLI_timestr(stats->lastframetime, text);
- if (do_prefix) sprintf(stamp_data->rendertime, "RenderTime %s", text);
- else sprintf(stamp_data->rendertime, "%s", text);
+ BLI_snprintf(stamp_data->rendertime, sizeof(stamp_data->rendertime), do_prefix ? "RenderTime %s":"%s", text);
} else {
stamp_data->rendertime[0] = '\0';
}
diff --git a/source/blender/blenkernel/intern/library.c b/source/blender/blenkernel/intern/library.c
index 6eb5399404a..671f4d91922 100644
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@ -920,7 +920,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
BLI_dynstr_append(pupds, buf);
BLI_dynstr_append(pupds, id->name+2);
- sprintf(buf, "%%x%d", i+1);
+ BLI_snprintf(buf, sizeof(buf), "%%x%d", i+1);
BLI_dynstr_append(pupds, buf);
/* icon */
@@ -931,7 +931,7 @@ static void IDnames_to_dyn_pupstring(DynStr *pupds, ListBase *lb, ID *link, shor
case ID_IM: /* fall through */
case ID_WO: /* fall through */
case ID_LA: /* fall through */
- sprintf(buf, "%%i%d", BKE_icon_getid(id) );
+ BLI_snprintf(buf, sizeof(buf), "%%i%d", BKE_icon_getid(id) );
BLI_dynstr_append(pupds, buf);
break;
default:
@@ -1128,7 +1128,7 @@ static int check_for_dupid(ListBase *lb, ID *id, char *name)
continue;
}
/* this format specifier is from hell... */
- sprintf(name, "%s.%.3d", left, nr);
+ BLI_snprintf(name, sizeof(id->name) - 2,"%s.%.3d", left, nr);
return 1;
}
diff --git a/source/blender/blenkernel/intern/modifier.c b/source/blender/blenkernel/intern/modifier.c
index 03091b9b0a4..6f8075310c7 100644
--- a/source/blender/blenkernel/intern/modifier.c
+++ b/source/blender/blenkernel/intern/modifier.c
@@ -57,7 +57,7 @@
ModifierTypeInfo *modifierType_getInfo(ModifierType type)
{
- static ModifierTypeInfo *types[NUM_MODIFIER_TYPES];
+ static ModifierTypeInfo *types[NUM_MODIFIER_TYPES]= {0};
static int types_init = 1;
if (types_init) {
@@ -220,12 +220,13 @@ int modifier_sameTopology(ModifierData *md)
void modifier_setError(ModifierData *md, const char *format, ...)
{
- char buffer[2048];
+ char buffer[512];
va_list ap;
va_start(ap, format);
- vsprintf(buffer, format, ap);
+ vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
+ buffer[sizeof(buffer) - 1]= '\0';
if (md->error)
MEM_freeN(md->error);