code cleanup: remove paranoid NULL checks (these cases would crash earlier of the...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 15 Sep 2012 06:29:32 +0000 (06:29 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 15 Sep 2012 06:29:32 +0000 (06:29 +0000)
source/blender/avi/intern/avi.c
source/blender/compositor/intern/COM_ExecutionSystemHelper.cpp
source/blender/editors/armature/editarmature.c
source/blender/editors/object/object_hook.c
source/blender/editors/space_outliner/outliner_select.c
source/blender/editors/space_view3d/drawmesh.c
source/blender/editors/space_view3d/drawobject.c
source/blender/imbuf/intern/targa.c

index cda2cf303ebf1531f0ed9aaaa178ad10e761aca8..2845b2f95c9a17ae6888184b884c72284ca4728b 100644 (file)
@@ -734,16 +734,15 @@ AviError AVI_close(AviMovie *movie)
 
        fclose(movie->fp);
 
-       for (i = 0; movie->header && (i < movie->header->Streams); i++) {
-               if (movie->streams && (movie->streams[i].sf != NULL)) {
+       for (i = 0; i < movie->header->Streams; i++) {
+               if (movie->streams[i].sf != NULL) {
                        MEM_freeN(movie->streams[i].sf);
                }
        }
 
-       if (movie->header != NULL)
-               MEM_freeN(movie->header);
-       if (movie->streams != NULL)
-               MEM_freeN(movie->streams);
+       MEM_freeN(movie->header);
+       MEM_freeN(movie->streams);
+
        if (movie->entries != NULL)
                MEM_freeN(movie->entries);
        if (movie->offset_table != NULL)
@@ -1082,15 +1081,15 @@ AviError AVI_close_compress(AviMovie *movie)
 
        fclose(movie->fp);
 
-       for (i = 0; movie->header && (i < movie->header->Streams); i++) {
+       for (i = 0; i < movie->header->Streams; i++) {
                if (movie->streams && (movie->streams[i].sf != NULL)) {
                        MEM_freeN(movie->streams[i].sf);
                }
        }
-       if (movie->header != NULL)
-               MEM_freeN(movie->header);
-       if (movie->entries != NULL)
-               MEM_freeN(movie->entries);
+
+       MEM_freeN(movie->header);
+       MEM_freeN(movie->entries);
+
        if (movie->streams != NULL)
                MEM_freeN(movie->streams);
        if (movie->offset_table != NULL)
index e41361fcb2ef5d899b65917fe3a942748fb77fac..bedbfc7272259c3913f4772753a83c4b254112ed 100644 (file)
@@ -79,14 +79,10 @@ void ExecutionSystemHelper::addNode(vector<Node *>& nodes, Node *node)
 
 Node *ExecutionSystemHelper::addNode(vector<Node *>& nodes, bNode *b_node, bool inActiveGroup, bool fast)
 {
-       Node *node;
-       node = Converter::convert(b_node, fast);
+       Node *node = Converter::convert(b_node, fast);
        node->setIsInActiveGroup(inActiveGroup);
-       if (node != NULL) {
-               addNode(nodes, node);
-               return node;
-       }
-       return NULL;
+       addNode(nodes, node);
+       return node;
 }
 void ExecutionSystemHelper::addOperation(vector<NodeOperation *>& operations, NodeOperation *operation)
 {
index 738fdc229fbdbfd9d3311803687102746e2ecd40..cb52d88f9854b1448f2b38ae35459110207b4d09 100644 (file)
@@ -4589,7 +4589,9 @@ void ED_pose_deselectall(Object *ob, int test)
        int selectmode = 0;
        
        /* we call this from outliner too */
-       if (ELEM(NULL, ob, ob->pose)) return;
+       if (ob->pose == NULL) {
+               return;
+       }
        
        /*      Determine if we're selecting or deselecting     */
        if (test == 1) {
index 7c8386d55dcbd919bad086482dc6a6eb1064b2e2..a6afe6b2d044da24c33a805f684de1fde77530f9 100644 (file)
@@ -585,13 +585,11 @@ void OBJECT_OT_hook_add_newobj(wmOperatorType *ot)
 static int object_hook_remove_exec(bContext *C, wmOperator *op)
 {
        int num = RNA_enum_get(op->ptr, "modifier");
-       Object *ob = NULL;
+       Object *ob = CTX_data_edit_object(C);
        HookModifierData *hmd = NULL;
 
-       ob = CTX_data_edit_object(C);
        hmd = (HookModifierData *)BLI_findlink(&ob->modifiers, num);
-
-       if (!ob || !hmd) {
+       if (!hmd) {
                BKE_report(op->reports, RPT_ERROR, "Couldn't find hook modifier");
                return OPERATOR_CANCELLED;
        }
index 8b7cf406642fba3a339b75edaaa341f02ade5660..823de61d044268603ce67fb2bd613d7fd7902693 100644 (file)
@@ -433,8 +433,11 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
        
        if (set) {
                if (!(bone->flag & BONE_HIDDEN_P)) {
-                       if (set == 2) ED_pose_deselectall(OBACT, 2);  // 2 is clear active tag
-                       else ED_pose_deselectall(OBACT, 0);
+                       Object *ob = OBACT;
+                       if (ob) {
+                               if (set == 2) ED_pose_deselectall(ob, 2);  // 2 is clear active tag
+                               else ED_pose_deselectall(ob, 0);
+                       }
                        
                        if (set == 2 && (bone->flag & BONE_SELECTED)) {
                                bone->flag &= ~BONE_SELECTED;
@@ -444,7 +447,7 @@ static int tree_element_active_bone(bContext *C, Scene *scene, TreeElement *te,
                                arm->act_bone = bone;
                        }
                        
-                       WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, OBACT);
+                       WM_event_add_notifier(C, NC_OBJECT | ND_BONE_ACTIVE, ob);
                }
        }
        else {
index 6e42380fbce0994b1e665deaf50dd4004ef3265e..895b256ab84d723fcd166e9a471d81b338a8a13f 100644 (file)
@@ -507,7 +507,7 @@ static void update_tface_color_layer(DerivedMesh *dm)
                                        finalCol[i * 4 + j].r = 255;
                                }
                }
-               else if (tface && mface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
+               else if (tface && set_draw_settings_cached(0, tface, ma, Gtexdraw)) {
                        for (j = 0; j < 4; j++) {
                                finalCol[i * 4 + j].b = 255;
                                finalCol[i * 4 + j].g = 0;
index d1f0d8fa25e148875915a22fe90568eedc50a93d..a51ec15bd86d549c04e5a636c9de42a969dce548 100644 (file)
@@ -3305,7 +3305,8 @@ static void draw_em_fancy(Scene *scene, View3D *v3d, RegionView3D *rv3d,
 
                draw_em_fancy_edges(em, scene, v3d, me, cageDM, 0, eed_act);
        }
-       if (em) {
+
+       {
                draw_em_fancy_verts(scene, v3d, ob, em, cageDM, eve_act, rv3d);
 
                if (me->drawflag & ME_DRAWNORMALS) {
index 4df49386ce1cec8e72e94aeb42211acbafba0e62..2f7452772ef1ea4bcaaea9c47cd2519cce84a10d 100644 (file)
@@ -682,9 +682,11 @@ ImBuf *imb_loadtarga(unsigned char *mem, size_t mem_size, int flags)
                }
        }
        
-       if (tga.imgdes & 0x20) IMB_flipy(ibuf);
+       if (tga.imgdes & 0x20) {
+               IMB_flipy(ibuf);
+       }
 
-       if (ibuf && ibuf->rect)
+       if (ibuf->rect)
                IMB_convert_rgba_to_abgr(ibuf);
        
        return(ibuf);