fix for clang static check warnings.
authorCampbell Barton <ideasman42@gmail.com>
Thu, 6 Jan 2011 01:35:07 +0000 (01:35 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 6 Jan 2011 01:35:07 +0000 (01:35 +0000)
- convertblender.c, remove assignments to unused vars.
- readfile.c, fix 2 possible crashes. null pointers were being checked for then used later without checking.
- space_graph.c, use switch statement for automatic color assignment rather then a float array.

source/blender/blenloader/intern/readfile.c
source/blender/editors/space_graph/space_graph.c
source/blender/render/intern/source/convertblender.c

index 44aa8bbf4ccfdbf4b5abc29549469552ffe548c1..3d16242c42812df9c54e92884decc4cc67813884 100644 (file)
@@ -381,7 +381,7 @@ static void add_main_to_main(Main *mainvar, Main *from)
        ListBase *lbarray[MAX_LIBARRAY], *fromarray[MAX_LIBARRAY];
        int a;
 
-       a= set_listbasepointers(mainvar, lbarray);
+       set_listbasepointers(mainvar, lbarray);
        a= set_listbasepointers(from, fromarray);
        while(a--) {
                BLI_movelisttolist(lbarray[a], fromarray[a]);
@@ -3160,7 +3160,7 @@ static void direct_link_particlesystems(FileData *fd, ListBase *particles)
                        for(a=1,pa++; a<psys->totpart; a++, pa++)
                                pa->boid = (pa-1)->boid + 1;
                }
-               else {
+               else if(psys->particles) {
                        for(a=0,pa=psys->particles; a<psys->totpart; a++, pa++)
                                pa->boid = NULL;
                }
@@ -3810,9 +3810,10 @@ static void direct_link_modifiers(FileData *fd, ListBase *lb)
                                        clmd->sim_parms->presets = 0;
 
                                clmd->sim_parms->reset = 0;
+
+                               clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights);
                        }
 
-                       clmd->sim_parms->effector_weights = newdataadr(fd, clmd->sim_parms->effector_weights);
                        if(!clmd->sim_parms->effector_weights)
                                clmd->sim_parms->effector_weights = BKE_add_effector_weights(NULL);
                        
@@ -4316,9 +4317,8 @@ static void link_recurs_seq(FileData *fd, ListBase *lb)
 
 static void direct_link_paint(FileData *fd, Paint **paint)
 {
-       Paint *p;
 /* TODO. is this needed */
-       p= (*paint)= newdataadr(fd, (*paint));
+       (*paint)= newdataadr(fd, (*paint));
 }
 
 static void direct_link_scene(FileData *fd, Scene *sce)
@@ -12575,7 +12575,7 @@ static void append_do_cursor(Scene *scene, Library *curlib, short flag)
 
 static void library_append_end(const bContext *C, Main *mainl, FileData **fd, int idcode, short flag)
 {
-       Main *mainvar= CTX_data_main(C);
+       Main *mainvar;
        Scene *scene= CTX_data_scene(C);
        Library *curlib;
 
@@ -12678,7 +12678,7 @@ static int mainvar_count_libread_blocks(Main *mainvar)
 
        a= set_listbasepointers(mainvar, lbarray);
        while(a--) {
-               ID *id= lbarray[a]->first;
+               ID *id;
 
                for (id= lbarray[a]->first; id; id= id->next)
                        if (id->flag & LIB_READ)
index ff2d233ccdb1a908a6afaca7acd9298cd3e86266..b3636f6ccf2032f155282190be50090963e7e930 100644 (file)
@@ -538,24 +538,22 @@ static void graph_refresh(const bContext *C, ScrArea *sa)
                                        /* F-Curve's array index is automatically mapped to RGB values. This works best of 3-value vectors. 
                                         * TODO: find a way to module the hue so that not all curves have same color...
                                         */
-                                       
-                                       /* standard table of colors to use */
-                                       const float _colorsets[4][3]= 
-                                       {
-                                               {1.0f, 0.0f, 0.0f}, /* red */
-                                               {0.0f, 1.0f, 0.0f}, /* green */
-                                               {0.0f, 0.0f, 1.0f}, /* blue */
-                                               {0.3f, 0.8f, 1.0f}, /* 'unknown' color - bluish so as to not conflict with handles */
-                                       };
-                                       
-                                       /* simply copy the relevant color over to the F-Curve */
-                                       if ((fcu->array_index >= 0) && (fcu->array_index < 3)) {
-                                               /* if the index is within safe bounds, use index to access table */
-                                               VECCOPY(fcu->color, _colorsets[fcu->array_index]);
-                                       }
-                                       else {
-                                               /* use the 'unknown' color... */
-                                               VECCOPY(fcu->color, _colorsets[3]);
+                                       float *col= fcu->color;
+
+                                       switch(fcu->array_index) {
+                                       case 0:
+                                               col[0]= 1.0f; col[1]= 0.0f; col[2]= 0.0f;
+                                               break;
+                                       case 1:
+                                               col[0]= 0.0f; col[1]= 1.0f; col[2]= 0.0f;
+                                               break;
+                                       case 2:
+                                               col[0]= 0.0f; col[1]= 0.0f; col[2]= 1.0f;
+                                               break;
+                                       default:
+                                               /* 'unknown' color - bluish so as to not conflict with handles */
+                                               col[0]= 0.3f; col[1]= 0.8f; col[2]= 1.0f;
+                                               break;
                                        }
                                }
                                        break;
index adb386f80fb16d675794dbf15a73c9e59760853c..a70641a3dae1c22f01e62f5438e21d17ac791c92 100644 (file)
@@ -1493,11 +1493,12 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
        StrandBound *sbound= 0;
        StrandRen *strand=0;
        RNG *rng= 0;
-       float loc[3],loc1[3],loc0[3],mat[4][4],nmat[3][3],co[3],nor[3],time;
+       float loc[3],loc1[3],loc0[3],mat[4][4],nmat[3][3],co[3],nor[3];
        float strandlen=0.0f, curlen=0.0f;
-       float hasize, pa_size, r_tilt, r_length, cfra= BKE_curframe(re->scene);
+       float hasize, pa_size, r_tilt, r_length;
        float pa_time, pa_birthtime, pa_dietime;
        float random, simplify[2], pa_co[3];
+       const float cfra= BKE_curframe(re->scene);
        int i, a, k, max_k=0, totpart, dosimplify = 0, dosurfacecache = 0;
        int totchild=0;
        int seed, path_nbr=0, orco1=0, num;
@@ -1622,7 +1623,6 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
 
        if(part->flag & PART_GLOB_TIME)
 #endif // XXX old animation system
-       cfra = BKE_curframe(re->scene);
 
 ///* 2.4 setup reactors */
 //     if(part->type == PART_REACTOR){
@@ -1880,6 +1880,8 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                if(path_nbr) {
                        /* render strands */
                        for(k=0; k<=path_nbr; k++){
+                               float time;
+
                                if(k<=max_k){
                                        VECCOPY(state.co,(cache+k)->co);
                                        VECCOPY(state.vel,(cache+k)->vel);
@@ -1963,7 +1965,6 @@ static int render_new_particle_system(Render *re, ObjectRen *obr, ParticleSystem
                                }
                        }
                        else {
-                               time=0.0f;
                                state.time=cfra;
                                if(psys_get_particle_state(&sim,a,&state,0)==0)
                                        continue;
@@ -2595,18 +2596,14 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr,
        int a, a1, end, totvert, vertofs;
        VertRen *ver;
        VlakRen *vlr;
-       Curve *cu= NULL;
        MVert *mvert = NULL;
        MFace *mface;
        Material *ma;
+       /* Curve *cu= ELEM(ob->type, OB_FONT, OB_CURVE) ? ob->data : NULL; */
 
        mvert= dm->getVertArray(dm);
        totvert= dm->getNumVerts(dm);
 
-       if ELEM(ob->type, OB_FONT, OB_CURVE) {
-               cu= ob->data;
-       }
-
        for(a=0; a<totvert; a++, mvert++) {
                ver= RE_findOrAddVert(obr, obr->totvert++);
                VECCOPY(ver->co, mvert->co);
@@ -2703,7 +2700,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset)
        ListBase displist= {NULL, NULL};
        DispList *dl;
        Material **matar;
-       float *orco=NULL, *orcobase=NULL, mat[4][4];
+       float *orco=NULL, mat[4][4];
        int a, totmat, need_orco=0;
        DerivedMesh *dm= NULL;
 
@@ -2741,7 +2738,7 @@ static void init_render_surf(Render *re, ObjectRen *obr, int timeoffset)
                dm->release(dm);
        } else {
                if(need_orco) {
-                       orcobase= orco= get_object_orco(re, ob);
+                       orco= get_object_orco(re, ob);
                }
 
                /* walk along displaylist and create rendervertices/-faces */
@@ -2767,9 +2764,9 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
        DerivedMesh *dm = NULL;
        ListBase disp={NULL, NULL};
        Material **matar;
-       float len, *data, *fp, *orco=NULL, *orcobase= NULL;
+       float *data, *fp, *orco=NULL;
        float n[3], mat[4][4];
-       int nr, startvert, startvlak, a, b;
+       int nr, startvert, a, b;
        int need_orco=0, totmat;
 
        cu= ob->data;
@@ -2806,7 +2803,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
                dm->release(dm);
        } else {
                if(need_orco) {
-                 orcobase=orco= get_object_orco(re, ob);
+                 orco= get_object_orco(re, ob);
                }
 
                while(dl) {
@@ -2839,7 +2836,6 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
                                }
 
                                if(timeoffset==0) {
-                                       startvlak= obr->totvlak;
                                        index= dl->index;
                                        for(a=0; a<dl->parts; a++, index+=3) {
 
@@ -2884,7 +2880,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
                                        }
 
                                        if(dl->bevelSplitFlag || timeoffset==0) {
-                                               startvlak= obr->totvlak;
+                                               const int startvlak= obr->totvlak;
 
                                                for(a=0; a<dl->parts; a++) {
 
@@ -2935,7 +2931,7 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset)
                                                }
                                                for(a=startvert; a<obr->totvert; a++) {
                                                        ver= RE_findOrAddVert(obr, a);
-                                                       len= normalize_v3(ver->n);
+                                                       normalize_v3(ver->n);
                                                }
                                        }
                                }
@@ -3465,7 +3461,6 @@ static void initshadowbuf(Render *re, LampRen *lar, float mat[][4])
        /* bias is percentage, made 2x larger because of correction for angle of incidence */
        /* when a ray is closer to parallel of a face, bias value is increased during render */
        shb->bias= (0.02*lar->bias)*0x7FFFFFFF;
-       shb->bias= shb->bias;
        
        /* halfway method (average of first and 2nd z) reduces bias issues */
        if(ELEM(lar->buftype, LA_SHADBUF_HALFWAY, LA_SHADBUF_DEEP))