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 28058c604999c9b2d92edbf45fbb96ee5c5ba947..a1e1bafa82fe05d84bd9b02d0fbdc5380ba54012 100644 (file)
@@ -403,7 +403,7 @@ GHOST_TSuccess GHOST_GetModifierKeyState(GHOST_SystemHandle systemhandle,
 {
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
        GHOST_TSuccess result;
 {
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
        GHOST_TSuccess result;
-       bool isdown;
+       bool isdown= false;
        
        result = system->getModifierKeyState(mask, isdown);
        *isDown = (int) isdown;
        
        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;
 {
        GHOST_ISystem* system = (GHOST_ISystem*) systemhandle;
        GHOST_TSuccess result;
-       bool isdown;
+       bool isdown= false;
        
        result = system->getButtonState(mask, isdown);
        *isDown = (int) isdown;
        
        result = system->getButtonState(mask, isdown);
        *isDown = (int) isdown;
index a8c7266b3fa44cd1f4df6024d248d79f16d8d4bc..179aab064b40e486ad77513b06b8b9ea478ccd28 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;
 
                while(pm->next && pm->next->frame < frame)
                        pm= pm->next;
 
-               if(pm2 && pm2->frame < frame)
+               if(pm2->frame < frame) {
                        pm2 = NULL;
                        pm2 = NULL;
+               }
                else {
                else {
-                       while(pm2->prev && pm2->prev->frame > frame)
+                       while(pm2->prev && pm2->prev->frame > frame) {
                                pm2= pm2->prev;
                                pm2= pm2->prev;
+                       }
                }
 
                if(pm && !pm2) {
                }
 
                if(pm && !pm2) {
index 73d6588b97fe9df8b45eec5eb7d9163b43e589ca..1a47a93ab510ac2776cf32c08317266663d433e5 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:
                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");
        }
 
                BLI_assert(!"incorrect ID");
        }
 
index 383e35a57600725a8e701ccf2131dbf039dafec2..3374b3c6f95e10852165c46c9443b6aec1071132 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;
 {
        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 */
        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 */
        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);
        
        /* no button backdrop behind icons */
        uiBlockSetEmboss(block, UI_EMBOSSN);
index b07baf45d236d0209dfd3ff5f1b8a24c2c5bf945..108f06a5cb624f294e420828a00189e915ab7a53 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 ");
                                        str= strcat(str, "Alt ");
                                if(but->modifier_key & KM_OSKEY)
                                        str= strcat(str, "Cmd ");
+
+                               (void)str; /* UNUSED */
                        }
                        else
                                strcat(but->drawstr, "Press a key  ");
                        }
                        else
                                strcat(but->drawstr, "Press a key  ");
index 4457ec6b3231ffb6aba50fe2a2b674c0810a0c27..1a240f347575aa3e26cdc4644a77e522fc373162 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);
        
        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);
 
        
        handle= ui_popup_menu_create(C, NULL, NULL, NULL, NULL, buf);
 
index b866a21d027b0263f494c904c1388e3660b8c96c..0f361b43de6557e99c15bb2de65ae2c8e394ac6a 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);
        }
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
        }
+
+       (void)dx;
 }
 
 /* image drawing */
 }
 
 /* image drawing */
index 445d2f434faec3c1b3d54030db77f32fdf491dc8..939c44a0514d0a598a043ea4ef3fb8509387695b 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);
        }
        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);
 }
 
        return (string);
 }