fixes for errors/warnings found with cppcheck

This commit is contained in:
2009-12-26 20:23:13 +00:00
parent 5689ab3975
commit d5592fe254
15 changed files with 38 additions and 50 deletions

View File

@@ -182,11 +182,11 @@ AviError AVI_print_error (AviError in_error) {
return in_error; return in_error;
} }
/*
void AVI_set_debug (int mode) { void AVI_set_debug (int mode) {
AVI_DEBUG= mode; AVI_DEBUG= mode;
} }
*/
/* /*
int AVI_is_avi (char *name) { int AVI_is_avi (char *name) {
FILE *fp; FILE *fp;

View File

@@ -352,7 +352,8 @@ int cdf_write_open(CDataFile *cdf, char *filename)
/* fill header */ /* fill header */
header= &cdf->header; header= &cdf->header;
strcpy(header->ID, "BCDF"); /* strcpy(, "BCDF"); // terminator out of range */
header->ID[0]= 'B'; header->ID[1]= 'C'; header->ID[2]= 'D'; header->ID[3]= 'F';
header->endian= cdf_endian(); header->endian= cdf_endian();
header->version= CDF_VERSION; header->version= CDF_VERSION;
header->subversion= CDF_SUBVERSION; header->subversion= CDF_SUBVERSION;

View File

@@ -52,13 +52,3 @@
* since we have to force clearing all Python related data before freeing * since we have to force clearing all Python related data before freeing
* Blender's library. Still testing, will decide later (Willian). */ * Blender's library. Still testing, will decide later (Willian). */
//XXX
#if 0
void free_script (Script *script)
{
if (!script) return;
#ifndef DISABLE_PYTHON
BPY_clear_script(script);
#endif
}
#endif

View File

@@ -159,7 +159,7 @@ int BLI_gzip(char *from, char *to) {
file = open(from,O_BINARY|O_RDONLY); file = open(from,O_BINARY|O_RDONLY);
if ( -1 == file ) return -2; if (file < 0) return -2;
while ( 1 ) while ( 1 )
{ {

View File

@@ -440,7 +440,7 @@ int BLI_filepathsize(const char *path)
{ {
int size, file = open(path, O_BINARY|O_RDONLY); int size, file = open(path, O_BINARY|O_RDONLY);
if (file <= 0) if (file < 0)
return -1; return -1;
size = BLI_filesize(file); size = BLI_filesize(file);

View File

@@ -230,12 +230,8 @@ void CutEdgeloop(Object *obedit, wmOperator *op, EditMesh *em, int numcuts)
nearest = findnearestedge(&vc, &dist); // returns actual distance in dist nearest = findnearestedge(&vc, &dist); // returns actual distance in dist
// scrarea_do_windraw(curarea); // after findnearestedge, backbuf! // scrarea_do_windraw(curarea); // after findnearestedge, backbuf!
sprintf(msg,"Number of Cuts: %d",numcuts); sprintf(msg,"Number of Cuts: %d (S)mooth: ",numcuts);
if(smooth){ strcat(msg, smooth ? "on":"off");
sprintf(msg,"%s (S)mooth: on",msg);
} else {
sprintf(msg,"%s (S)mooth: off",msg);
}
// headerprint(msg); // headerprint(msg);
/* Need to figure preview */ /* Need to figure preview */

View File

@@ -3803,15 +3803,15 @@ int PE_minmax(Scene *scene, float *min, float *max)
{ {
Object *ob= OBACT; Object *ob= OBACT;
PTCacheEdit *edit= PE_get_current(scene, ob); PTCacheEdit *edit= PE_get_current(scene, ob);
ParticleSystem *psys = edit->psys; ParticleSystem *psys;
ParticleSystemModifierData *psmd = NULL; ParticleSystemModifierData *psmd = NULL;
POINT_P; KEY_K; POINT_P; KEY_K;
float co[3], mat[4][4]; float co[3], mat[4][4];
int ok= 0; int ok= 0;
if(!edit) return ok; if(!edit) return ok;
if(psys) if((psys = edit->psys))
psmd= psys_get_modifier(ob, psys); psmd= psys_get_modifier(ob, psys);
else else
unit_m4(mat); unit_m4(mat);

View File

@@ -298,7 +298,6 @@ static int buttons_context_path_particle(ButsContextPath *path)
static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
{ {
Scene *scene; Scene *scene;
ToolSettings *ts;
Brush *br= NULL; Brush *br= NULL;
PointerRNA *ptr= &path->ptr[path->len-1]; PointerRNA *ptr= &path->ptr[path->len-1];
@@ -309,7 +308,6 @@ static int buttons_context_path_brush(const bContext *C, ButsContextPath *path)
/* if we have a scene, use the toolsettings brushes */ /* if we have a scene, use the toolsettings brushes */
else if(buttons_context_path_scene(path)) { else if(buttons_context_path_scene(path)) {
scene= path->ptr[path->len-1].data; scene= path->ptr[path->len-1].data;
ts= scene->toolsettings;
if(scene) if(scene)
br= paint_brush(paint_get_active(scene)); br= paint_brush(paint_get_active(scene));

View File

@@ -402,12 +402,12 @@ void drawaxes(float size, int flag, char drawtype)
break; break;
case OB_EMPTY_SPHERE: case OB_EMPTY_SPHERE:
draw_empty_sphere(size); draw_empty_sphere(size);
break; break;
case OB_EMPTY_CONE: case OB_EMPTY_CONE:
draw_empty_cone(size); draw_empty_cone(size);
break; break;
case OB_ARROWS: case OB_ARROWS:
default: default:
@@ -1361,7 +1361,7 @@ static void mesh_foreachScreenEdge__mapFunc(void *userData, int index, float *v0
view3d_project_short_noclip(data->vc.ar, v1co, s[1]); view3d_project_short_noclip(data->vc.ar, v1co, s[1]);
if (data->clipVerts==2) { if (data->clipVerts==2) {
if (!(s[0][0]>=0 && s[0][1]>= 0 && s[0][0]<data->vc.ar->winx && s[0][1]<data->vc.ar->winy)) if (!(s[0][0]>=0 && s[0][1]>= 0 && s[0][0]<data->vc.ar->winx && s[0][1]<data->vc.ar->winy))
if (!(s[1][0]>=0 && s[1][1]>= 0 && s[1][0]<data->vc.ar->winx && s[1][1]<data->vc.ar->winy)) if (!(s[1][0]>=0 && s[1][1]>= 0 && s[1][0]<data->vc.ar->winx && s[1][1]<data->vc.ar->winy))
return; return;
} }
@@ -2399,7 +2399,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E
} }
} }
} }
} }
if(v3d->zbuf) { if(v3d->zbuf) {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
@@ -2971,7 +2971,7 @@ static int draw_mesh_object(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D
finalDM = cageDM = editmesh_get_derived_base(ob, em); finalDM = cageDM = editmesh_get_derived_base(ob, em);
else else
cageDM = editmesh_get_derived_cage_and_final(scene, ob, em, &finalDM, cageDM = editmesh_get_derived_cage_and_final(scene, ob, em, &finalDM,
v3d->customdata_mask); v3d->customdata_mask);
if(dt>OB_WIRE) { if(dt>OB_WIRE) {
// no transp in editmode, the fancy draw over goes bad then // no transp in editmode, the fancy draw over goes bad then
@@ -4003,11 +4003,13 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
sprintf(val, " %i", a); sprintf(val, " %i", a);
if(part->draw&PART_DRAW_NUM && part->draw&PART_DRAW_HEALTH) if(part->draw&PART_DRAW_NUM && part->draw&PART_DRAW_HEALTH)
sprintf(val, "%s:", val); strcat(val, ":");
if(part->draw&PART_DRAW_HEALTH && a < totpart && part->phystype==PART_PHYS_BOIDS)
sprintf(val, "%s %.2f", val, pa_health);
if(part->draw&PART_DRAW_HEALTH && a < totpart && part->phystype==PART_PHYS_BOIDS) {
char tval[8];
sprintf(tval, " %.2f", pa_health);
strcat(val, tval);
}
/* in path drawing state.co is the end point */ /* in path drawing state.co is the end point */
view3d_cached_text_draw_add(state.co[0], state.co[1], state.co[2], val, 0); view3d_cached_text_draw_add(state.co[0], state.co[1], state.co[2], val, 0);
} }
@@ -4826,7 +4828,7 @@ static void draw_empty_sphere (float size)
static void draw_empty_cone (float size) static void draw_empty_cone (float size)
{ {
float cent=0; float cent=0;
float radius; float radius;
GLUquadricObj *qobj = gluNewQuadric(); GLUquadricObj *qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_SILHOUETTE); gluQuadricDrawStyle(qobj, GLU_SILHOUETTE);
@@ -4946,11 +4948,11 @@ static void drawspiral(float *cent, float rad, float tmat[][4], int start)
*/ */
static void drawcircle_size(float size) static void drawcircle_size(float size)
{ {
float x, y; float x, y;
short degrees; short degrees;
glBegin(GL_LINE_LOOP); glBegin(GL_LINE_LOOP);
/* coordinates are: cos(degrees*11.25)=x, sin(degrees*11.25)=y, 0.0f=z */ /* coordinates are: cos(degrees*11.25)=x, sin(degrees*11.25)=y, 0.0f=z */
for (degrees=0; degrees<32; degrees++) { for (degrees=0; degrees<32; degrees++) {
x= *(cosval + degrees); x= *(cosval + degrees);
@@ -5824,7 +5826,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
float selboxw; float selboxw;
cpack(0xffffff); cpack(0xffffff);
set_inverted_drawing(1); set_inverted_drawing(1);
for (i=0; i<(selend-selstart+1); i++) { for (i=0; i<(selend-selstart+1); i++) {
SelBox *sb = &(cu->selboxes[i]); SelBox *sb = &(cu->selboxes[i]);
@@ -5839,12 +5841,12 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag)
} }
glBegin(GL_QUADS); glBegin(GL_QUADS);
glVertex3f(sb->x, sb->y, 0.001); glVertex3f(sb->x, sb->y, 0.001);
glVertex3f(sb->x+selboxw, sb->y, 0.001); glVertex3f(sb->x+selboxw, sb->y, 0.001);
glVertex3f(sb->x+selboxw, sb->y+sb->h, 0.001); glVertex3f(sb->x+selboxw, sb->y+sb->h, 0.001);
glVertex3f(sb->x, sb->y+sb->h, 0.001); glVertex3f(sb->x, sb->y+sb->h, 0.001);
glEnd(); glEnd();
} }
set_inverted_drawing(0); set_inverted_drawing(0);
} }
} }
else if(dt==OB_BOUNDBOX) else if(dt==OB_BOUNDBOX)

View File

@@ -829,7 +829,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d)
if(kb){ if(kb){
sprintf(shapes, ": %s ", kb->name); sprintf(shapes, ": %s ", kb->name);
if(ob->shapeflag == OB_SHAPE_LOCK){ if(ob->shapeflag == OB_SHAPE_LOCK){
sprintf(shapes, "%s (Pinned)",shapes); strcat(shapes, " (Pinned)");
} }
} }
} }

View File

@@ -279,7 +279,7 @@ struct ImBuf *IMB_loadiffname(const char *naam, int flags) {
file = open(naam, O_BINARY|O_RDONLY); file = open(naam, O_BINARY|O_RDONLY);
if (file == -1) return (0); if (file < 0) return (0);
ibuf= IMB_loadifffile(file, flags); ibuf= IMB_loadifffile(file, flags);
@@ -304,7 +304,7 @@ struct ImBuf *IMB_testiffname(char *naam,int flags) {
flags |= IB_test; flags |= IB_test;
file = open(naam,O_BINARY|O_RDONLY); file = open(naam,O_BINARY|O_RDONLY);
if (file<=0) return (0); if (file < 0) return (0);
ibuf=IMB_loadifffile(file,flags); ibuf=IMB_loadifffile(file,flags);
if (ibuf) { if (ibuf) {

View File

@@ -296,7 +296,10 @@ short imb_savetarga(struct ImBuf * ibuf, char *name, int flags)
if (ibuf->cmap){ if (ibuf->cmap){
for (i = 0 ; i<ibuf->maxcol ; i++){ for (i = 0 ; i<ibuf->maxcol ; i++){
if (fwrite(((uchar *)(ibuf->cmap + i)) + 1,1,3,fildes) != 3) return (0); if (fwrite(((uchar *)(ibuf->cmap + i)) + 1,1,3,fildes) != 3) {
fclose(fildes);
return (0);
}
} }
} }

View File

@@ -129,7 +129,6 @@ extern "C" {
// void BPY_spacescript_do_pywin_draw( struct SpaceScript *sc ); // void BPY_spacescript_do_pywin_draw( struct SpaceScript *sc );
// void BPY_spacescript_do_pywin_event( struct SpaceScript *sc, // void BPY_spacescript_do_pywin_event( struct SpaceScript *sc,
// unsigned short event, short val, char ascii ); // unsigned short event, short val, char ascii );
// void BPY_clear_script( struct Script *script );
// void BPY_free_finished_script( struct Script *script ); // void BPY_free_finished_script( struct Script *script );
// void BPY_scripts_clear_pyobjects( void ); // void BPY_scripts_clear_pyobjects( void );
// //

View File

@@ -30,7 +30,6 @@
//void BPY_run_python_script() {} //void BPY_run_python_script() {}
//void BPY_start_python() {} //void BPY_start_python() {}
void BPY_call_importloader() {} void BPY_call_importloader() {}
void BPY_clear_script() {}
//void BPY_free_compiled_text() {} //void BPY_free_compiled_text() {}
void BPY_pyconstraint_eval() {} void BPY_pyconstraint_eval() {}
void BPY_pyconstraint_target() {} void BPY_pyconstraint_target() {}

View File

@@ -5200,7 +5200,7 @@ static int load_fluidsimspeedvectors(Render *re, ObjectInstanceRen *obi, float *
float mat[4][4], winmat[4][4]; float mat[4][4], winmat[4][4];
float imat[4][4]; float imat[4][4];
FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(fsob, eModifierType_Fluidsim); FluidsimModifierData *fluidmd = (FluidsimModifierData *)modifiers_findByType(fsob, eModifierType_Fluidsim);
FluidsimSettings *fss = fluidmd->fss; FluidsimSettings *fss;
float *velarray = NULL; float *velarray = NULL;
/* only one step needed */ /* only one step needed */