From d5592fe254c7061ca8bbcea93b6098dc9bf3d683 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 26 Dec 2009 20:23:13 +0000 Subject: fixes for errors/warnings found with cppcheck --- source/blender/editors/mesh/editmesh_loop.c | 8 ++--- source/blender/editors/physics/particle_edit.c | 6 ++-- .../editors/space_buttons/buttons_context.c | 2 -- source/blender/editors/space_view3d/drawobject.c | 36 ++++++++++++---------- source/blender/editors/space_view3d/view3d_draw.c | 2 +- 5 files changed, 25 insertions(+), 29 deletions(-) (limited to 'source/blender/editors') diff --git a/source/blender/editors/mesh/editmesh_loop.c b/source/blender/editors/mesh/editmesh_loop.c index fd665f07767..ea444b2d014 100644 --- a/source/blender/editors/mesh/editmesh_loop.c +++ b/source/blender/editors/mesh/editmesh_loop.c @@ -230,12 +230,8 @@ void CutEdgeloop(Object *obedit, wmOperator *op, EditMesh *em, int numcuts) nearest = findnearestedge(&vc, &dist); // returns actual distance in dist // scrarea_do_windraw(curarea); // after findnearestedge, backbuf! - sprintf(msg,"Number of Cuts: %d",numcuts); - if(smooth){ - sprintf(msg,"%s (S)mooth: on",msg); - } else { - sprintf(msg,"%s (S)mooth: off",msg); - } + sprintf(msg,"Number of Cuts: %d (S)mooth: ",numcuts); + strcat(msg, smooth ? "on":"off"); // headerprint(msg); /* Need to figure preview */ diff --git a/source/blender/editors/physics/particle_edit.c b/source/blender/editors/physics/particle_edit.c index c29214f4633..eccb257dab5 100644 --- a/source/blender/editors/physics/particle_edit.c +++ b/source/blender/editors/physics/particle_edit.c @@ -3803,15 +3803,15 @@ int PE_minmax(Scene *scene, float *min, float *max) { Object *ob= OBACT; PTCacheEdit *edit= PE_get_current(scene, ob); - ParticleSystem *psys = edit->psys; + ParticleSystem *psys; ParticleSystemModifierData *psmd = NULL; POINT_P; KEY_K; float co[3], mat[4][4]; int ok= 0; if(!edit) return ok; - - if(psys) + + if((psys = edit->psys)) psmd= psys_get_modifier(ob, psys); else unit_m4(mat); diff --git a/source/blender/editors/space_buttons/buttons_context.c b/source/blender/editors/space_buttons/buttons_context.c index ade906ce678..18ba149d7ed 100644 --- a/source/blender/editors/space_buttons/buttons_context.c +++ b/source/blender/editors/space_buttons/buttons_context.c @@ -298,7 +298,6 @@ static int buttons_context_path_particle(ButsContextPath *path) static int buttons_context_path_brush(const bContext *C, ButsContextPath *path) { Scene *scene; - ToolSettings *ts; Brush *br= NULL; 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 */ else if(buttons_context_path_scene(path)) { scene= path->ptr[path->len-1].data; - ts= scene->toolsettings; if(scene) br= paint_brush(paint_get_active(scene)); diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index 8060514accd..8f20b53c296 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -402,12 +402,12 @@ void drawaxes(float size, int flag, char drawtype) break; case OB_EMPTY_SPHERE: - draw_empty_sphere(size); - break; + draw_empty_sphere(size); + break; case OB_EMPTY_CONE: - draw_empty_cone(size); - break; + draw_empty_cone(size); + break; case OB_ARROWS: 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]); if (data->clipVerts==2) { - if (!(s[0][0]>=0 && s[0][1]>= 0 && s[0][0]vc.ar->winx && s[0][1]vc.ar->winy)) + if (!(s[0][0]>=0 && s[0][1]>= 0 && s[0][0]vc.ar->winx && s[0][1]vc.ar->winy)) if (!(s[1][0]>=0 && s[1][1]>= 0 && s[1][0]vc.ar->winx && s[1][1]vc.ar->winy)) return; } @@ -2399,7 +2399,7 @@ static void draw_em_measure_stats(View3D *v3d, RegionView3D *rv3d, Object *ob, E } } } - } + } if(v3d->zbuf) { 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); else cageDM = editmesh_get_derived_cage_and_final(scene, ob, em, &finalDM, - v3d->customdata_mask); + v3d->customdata_mask); if(dt>OB_WIRE) { // 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); if(part->draw&PART_DRAW_NUM && part->draw&PART_DRAW_HEALTH) - sprintf(val, "%s:", val); - - if(part->draw&PART_DRAW_HEALTH && a < totpart && part->phystype==PART_PHYS_BOIDS) - sprintf(val, "%s %.2f", val, pa_health); + strcat(val, ":"); + 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 */ 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) { float cent=0; - float radius; + float radius; GLUquadricObj *qobj = gluNewQuadric(); 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) { - float x, y; + float x, y; short degrees; glBegin(GL_LINE_LOOP); - + /* coordinates are: cos(degrees*11.25)=x, sin(degrees*11.25)=y, 0.0f=z */ for (degrees=0; degrees<32; degrees++) { x= *(cosval + degrees); @@ -5824,7 +5826,7 @@ void draw_object(Scene *scene, ARegion *ar, View3D *v3d, Base *base, int flag) float selboxw; cpack(0xffffff); - set_inverted_drawing(1); + set_inverted_drawing(1); for (i=0; i<(selend-selstart+1); 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); 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, sb->y+sb->h, 0.001); glEnd(); } - set_inverted_drawing(0); + set_inverted_drawing(0); } } else if(dt==OB_BOUNDBOX) diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index a680a3bd40d..be607d7ea77 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -829,7 +829,7 @@ static void draw_selected_name(Scene *scene, Object *ob, View3D *v3d) if(kb){ sprintf(shapes, ": %s ", kb->name); if(ob->shapeflag == OB_SHAPE_LOCK){ - sprintf(shapes, "%s (Pinned)",shapes); + strcat(shapes, " (Pinned)"); } } } -- cgit v1.2.3