diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-04-29 10:59:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-04-29 10:59:18 +0400 |
commit | 3be303aa3e08c082a9963802137ebb4fd7922953 (patch) | |
tree | ef92012749acb4c2fdba2c161f828970898acdd3 /source | |
parent | 2cdb79239bdec497781baf7fe8309cf4b1a36308 (diff) |
corrections for redundant null checks & transform printing a string into its self.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/blenkernel/intern/particle.c | 2 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/pointcache.c | 5 | ||||
-rw-r--r-- | source/blender/editors/curve/editcurve.c | 3 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_graph/graph_select.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_time/time_ops.c | 16 | ||||
-rw-r--r-- | source/blender/editors/transform/transform.c | 42 | ||||
-rw-r--r-- | source/blender/editors/transform/transform_snap.c | 2 |
8 files changed, 43 insertions, 36 deletions
diff --git a/source/blender/blenkernel/intern/particle.c b/source/blender/blenkernel/intern/particle.c index 5b583720905..5ec4c36177f 100644 --- a/source/blender/blenkernel/intern/particle.c +++ b/source/blender/blenkernel/intern/particle.c @@ -3030,7 +3030,7 @@ void psys_cache_paths(ParticleSimulationData *sim, float cfra) psys->totcached = totpart; - if(psys && psys->lattice){ + if(psys->lattice){ end_latt_deform(psys->lattice); psys->lattice= NULL; } diff --git a/source/blender/blenkernel/intern/pointcache.c b/source/blender/blenkernel/intern/pointcache.c index 179aab064b4..a7dd98ff404 100644 --- a/source/blender/blenkernel/intern/pointcache.c +++ b/source/blender/blenkernel/intern/pointcache.c @@ -1382,7 +1382,7 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int * } } - if(pm && !pm2) { + if(!pm2) { *fra1 = 0; *fra2 = pm->frame; } @@ -1844,7 +1844,8 @@ static int ptcache_write(PTCacheID *pid, int cfra, int overwrite) if(cache->flag & PTCACHE_DISK_CACHE) { error += !ptcache_mem_frame_to_disk(pid, pm); - if(pm) { + // if(pm) /* pm is always set */ + { ptcache_data_free(pm); ptcache_extra_free(pm); MEM_freeN(pm); diff --git a/source/blender/editors/curve/editcurve.c b/source/blender/editors/curve/editcurve.c index 9bae4ea6569..cb73f20fe7b 100644 --- a/source/blender/editors/curve/editcurve.c +++ b/source/blender/editors/curve/editcurve.c @@ -1234,7 +1234,6 @@ void make_editNurb(Object *obedit) Nurb *nu, *newnu, *nu_act= NULL; KeyBlock *actkey; - if(obedit==NULL) return; set_actNurb(obedit, NULL); @@ -1591,7 +1590,7 @@ static int deleteflagNurb(bContext *C, wmOperator *UNUSED(op), int flag) BPoint *bp, *bpn, *newbp; int a, b, newu, newv, sel; - if(obedit && obedit->type==OB_SURF); + if(obedit->type==OB_SURF); else return OPERATOR_CANCELLED; cu->lastsel= NULL; diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index f8ce278814f..c9b5b9f2848 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -765,8 +765,6 @@ void ui_draw_but_HISTOGRAM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol) //float alpha; GLint scissor[4]; - if (hist==NULL) { printf("hist is null \n"); return; } - rect.xmin = (float)recti->xmin+1; rect.xmax = (float)recti->xmax-1; rect.ymin = (float)recti->ymin+SCOPE_RESIZE_PAD+2; diff --git a/source/blender/editors/space_graph/graph_select.c b/source/blender/editors/space_graph/graph_select.c index 920f477e7eb..6c713d6e469 100644 --- a/source/blender/editors/space_graph/graph_select.c +++ b/source/blender/editors/space_graph/graph_select.c @@ -484,11 +484,8 @@ static void columnselect_graph_keys (bAnimContext *ac, short mode) */ for (ce= ked.list.first; ce; ce= ce->next) { /* set frame for validation callback to refer to */ - if (ale) - ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); - else - ked.f1= ce->cfra; - + ked.f1= BKE_nla_tweakedit_remap(adt, ce->cfra, NLATIME_CONVERT_UNMAP); + /* select elements with frame number matching cfraelem */ ANIM_fcurve_keyframes_loop(&ked, ale->key_data, ok_cb, select_cb, NULL); } diff --git a/source/blender/editors/space_time/time_ops.c b/source/blender/editors/space_time/time_ops.c index 34380fe4fd6..e9559426b81 100644 --- a/source/blender/editors/space_time/time_ops.c +++ b/source/blender/editors/space_time/time_ops.c @@ -49,15 +49,15 @@ #include "time_intern.h" /* ****************** Start/End Frame Operators *******************************/ - static int time_set_sfra_exec (bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - int frame= CFRA; - + int frame; + if (scene == NULL) return OPERATOR_CANCELLED; - + + frame= CFRA; /* if 'end frame' (Preview Range or Actual) is less than 'frame', * clamp 'frame' to 'end frame' */ @@ -93,11 +93,13 @@ static void TIME_OT_start_frame_set (wmOperatorType *ot) static int time_set_efra_exec (bContext *C, wmOperator *UNUSED(op)) { Scene *scene= CTX_data_scene(C); - int frame= CFRA; - + int frame; + if (scene == NULL) return OPERATOR_CANCELLED; - + + frame= CFRA; + /* if 'start frame' (Preview Range or Actual) is greater than 'frame', * clamp 'frame' to 'end frame' */ diff --git a/source/blender/editors/transform/transform.c b/source/blender/editors/transform/transform.c index ae863efa9f7..5e227cba523 100644 --- a/source/blender/editors/transform/transform.c +++ b/source/blender/editors/transform/transform.c @@ -3151,7 +3151,7 @@ static void applyRotation(TransInfo *t, float angle, float axis[3]) int Rotation(TransInfo *t, const short UNUSED(mval[2])) { - char str[128]; + char str[128], *spos= str; float final; @@ -3177,18 +3177,20 @@ int Rotation(TransInfo *t, const short UNUSED(mval[2])) outputNumInput(&(t->num), c); - sprintf(str, "Rot: %s %s %s", &c[0], t->con.text, t->proptext); + spos+= sprintf(spos, "Rot: %s %s %s", &c[0], t->con.text, t->proptext); /* Clamp between -180 and 180 */ final= angle_wrap_rad(DEG2RADF(final)); } else { - sprintf(str, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext); + spos += sprintf(spos, "Rot: %.2f%s %s", RAD2DEGF(final), t->con.text, t->proptext); } - if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) - sprintf(str, "%s Proportional size: %.2f", str, t->prop_size); - + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) { + spos += sprintf(spos, " Proportional size: %.2f", t->prop_size); + } + (void)spos; + t->values[0] = final; applyRotation(t, final, t->axis); @@ -3257,7 +3259,7 @@ static void applyTrackball(TransInfo *t, float axis1[3], float axis2[3], float a int Trackball(TransInfo *t, const short UNUSED(mval[2])) { - char str[128]; + char str[128], *spos= str; float axis1[3], axis2[3]; float mat[3][3], totmat[3][3], smat[3][3]; float phi[2]; @@ -3281,14 +3283,19 @@ int Trackball(TransInfo *t, const short UNUSED(mval[2])) outputNumInput(&(t->num), c); - sprintf(str, "Trackball: %s %s %s", &c[0], &c[20], t->proptext); + spos += sprintf(spos, "Trackball: %s %s %s", &c[0], &c[20], t->proptext); phi[0] = DEG2RADF(phi[0]); phi[1] = DEG2RADF(phi[1]); } else { - sprintf(str, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext); + spos += sprintf(spos, "Trackball: %.2f %.2f %s", RAD2DEGF(phi[0]), RAD2DEGF(phi[1]), t->proptext); + } + + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) { + spos += sprintf(spos, " Proportional size: %.2f", t->prop_size); } + (void)spos; vec_rot_to_mat3( smat,axis1, phi[0]); vec_rot_to_mat3( totmat,axis2, phi[1]); @@ -3345,6 +3352,7 @@ void initTranslation(TransInfo *t) } static void headerTranslation(TransInfo *t, float vec[3], char *str) { + char *spos= str; char tvec[60]; char distvec[20]; char autoik[20]; @@ -3395,24 +3403,26 @@ static void headerTranslation(TransInfo *t, float vec[3], char *str) { if (t->con.mode & CON_APPLY) { switch(t->num.idx_max) { case 0: - sprintf(str, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]); + spos += sprintf(spos, "D: %s (%s)%s %s %s", &tvec[0], distvec, t->con.text, t->proptext, &autoik[0]); break; case 1: - sprintf(str, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]); + spos += sprintf(spos, "D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext, &autoik[0]); break; case 2: - sprintf(str, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); + spos += sprintf(spos, "D: %s D: %s D: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); } } else { if(t->flag & T_2D_EDIT) - sprintf(str, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext); + spos += sprintf(spos, "Dx: %s Dy: %s (%s)%s %s", &tvec[0], &tvec[20], distvec, t->con.text, t->proptext); else - sprintf(str, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); + spos += sprintf(spos, "Dx: %s Dy: %s Dz: %s (%s)%s %s %s", &tvec[0], &tvec[20], &tvec[40], distvec, t->con.text, t->proptext, &autoik[0]); } - if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) - sprintf(str, "%s Proportional size: %.2f", str, t->prop_size); + if (t->flag & (T_PROP_EDIT|T_PROP_CONNECTED)) { + spos += sprintf(spos, " Proportional size: %.2f", t->prop_size); + } + (void)spos; } static void applyTranslation(TransInfo *t, float vec[3]) { diff --git a/source/blender/editors/transform/transform_snap.c b/source/blender/editors/transform/transform_snap.c index 022e09b3da4..789a262f075 100644 --- a/source/blender/editors/transform/transform_snap.c +++ b/source/blender/editors/transform/transform_snap.c @@ -1670,7 +1670,7 @@ static void removeDoublesPeel(ListBase *depth_peels) { DepthPeel *next_peel = peel->next; - if (peel && next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f) + if (next_peel && ABS(peel->depth - next_peel->depth) < 0.0015f) { peel->next = next_peel->next; |