quiet some clang warnings & fix for bugs in exceptional cases.
authorCampbell Barton <ideasman42@gmail.com>
Sat, 23 Apr 2011 12:57:03 +0000 (12:57 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 23 Apr 2011 12:57:03 +0000 (12:57 +0000)
- ghost C api, BLI_get_folder_version() could assign garbage values.
- pointcache ptcache_find_frames_around() had a superfluous NULL check which would have crashed anyway if actually NULL.

intern/ghost/intern/GHOST_C-api.cpp
source/blender/blenkernel/intern/pointcache.c
source/blender/blenlib/intern/path_util.c
source/blender/editors/animation/anim_channels_defines.c
source/blender/editors/interface/interface.c
source/blender/editors/interface/interface_regions.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_view3d/view3d_header.c

index 28058c6..a1e1baf 100644 (file)
@@ -403,7 +403,7 @@ GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
 {
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
        GHOST_TSuccess result;
-       bool isdown;
+       bool isdown= false;
        
        result = system->getModifierKeyState(mask, isdown);
        *isDown = (int) isdown;
@@ -419,7 +419,7 @@ GHOST_TSuccess GHOST_GetButtonState(GHOST_SystemHandle systemhandle,
 {
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
        GHOST_TSuccess result;
-       bool isdown;
+       bool isdown= false;
        
        result = system->getButtonState(mask, isdown);
        *isDown = (int) isdown;
index a8c7266..179aab0 100644 (file)
@@ -1373,11 +1373,13 @@ static void ptcache_find_frames_around(PTCacheID *pid, unsigned int frame, int *
                while(pm->next && pm->next->frame < frame)
                        pm= pm->next;
 
-               if(pm2 && pm2->frame < frame)
+               if(pm2->frame < frame) {
                        pm2 = NULL;
+               }
                else {
-                       while(pm2->prev && pm2->prev->frame > frame)
+                       while(pm2->prev && pm2->prev->frame > frame) {
                                pm2= pm2->prev;
+                       }
                }
 
                if(pm && !pm2) {
index 73d6588..1a47a93 100644 (file)
@@ -1144,6 +1144,8 @@ char *BLI_get_folder_version(const int id, const int ver, const int do_check)
                ok= get_path_system(path, NULL, NULL, NULL, ver);
                break;
        default:
+               path[0]= '\0'; /* incase do_check is false */
+               ok= FALSE;
                BLI_assert(!"incorrect ID");
        }
 
index 383e35a..3374b3c 100644 (file)
@@ -3224,7 +3224,7 @@ void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *b
 {
        bAnimChannelType *acf= ANIM_channel_get_typeinfo(ale);
        View2D *v2d= &ac->ar->v2d;
-       float y, ymid, ytext;
+       float y, ymid /*, ytext*/;
        short offset;
        
        /* sanity checks - don't draw anything */
@@ -3243,7 +3243,7 @@ void ANIM_channel_draw_widgets (bAnimContext *ac, bAnimListElem *ale, uiBlock *b
        y= (ymaxc - yminc)/2 + yminc;
        ymid= y - 7;
        /* y-coordinates for text is only 4 down from middle */
-       ytext= y - 4;
+       /* ytext= y - 4; */
        
        /* no button backdrop behind icons */
        uiBlockSetEmboss(block, UI_EMBOSSN);
index b07baf4..108f06a 100644 (file)
@@ -2093,6 +2093,8 @@ void ui_check_but(uiBut *but)
                                        str= strcat(str, "Alt ");
                                if(but->modifier_key & KM_OSKEY)
                                        str= strcat(str, "Cmd ");
+
+                               (void)str; /* UNUSED */
                        }
                        else
                                strcat(but->drawstr, "Press a key  ");
index 4457ec6..1a240f3 100644 (file)
@@ -2326,6 +2326,7 @@ static void confirm_operator(bContext *C, wmOperator *op, const char *title, con
        
        s= buf;
        if (title) s+= sprintf(s, "%s%%t|%s", title, item);
+       (void)s;
        
        handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
 
index b866a21..0f361b4 100644 (file)
@@ -332,6 +332,8 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
        }
+
+       (void)dx;
 }
 
 /* image drawing */
index 445d2f4..939c44a 100644 (file)
@@ -313,7 +313,7 @@ static char *view3d_modeselect_pup(Scene *scene)
        if (ob->particlesystem.first || modifiers_findByType(ob, eModifierType_Cloth) || modifiers_findByType(ob, eModifierType_Softbody)) {
                str += sprintf(str, formatstr, "Particle Mode", OB_MODE_PARTICLE_EDIT, ICON_PARTICLEMODE);
        }
-
+       (void)str;
        return (string);
 }