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/image.c
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/image.c')
-rw-r--r--source/blender/blenkernel/intern/image.c64
1 files changed, 22 insertions, 42 deletions
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';
}