diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2015-05-15 00:58:08 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2015-05-15 02:08:41 +0300 |
commit | 7549ec7301cf051931878180eba52da16bc4c4ad (patch) | |
tree | a21a700ec2cd79eb9a2ebd61ea3cab0ec7672bab /source | |
parent | 3c10ec96b5ec1c705362ccdaeaac8007050d081f (diff) |
Fix some issues found by Coverity Scan
Some of them are just brain dead code, some are potential bugs.
Diffstat (limited to 'source')
13 files changed, 39 insertions, 24 deletions
diff --git a/source/blender/editors/animation/anim_channels_edit.c b/source/blender/editors/animation/anim_channels_edit.c index fd7551abab3..d08a32c6e6b 100644 --- a/source/blender/editors/animation/anim_channels_edit.c +++ b/source/blender/editors/animation/anim_channels_edit.c @@ -3055,7 +3055,7 @@ static bool select_anim_channel_keys(bAnimContext *ac, int channel_index, bool e ANIM_animdata_freelist(&anim_data); /* F-Curve may not have any keyframes */ - if (fcu->bezt) { + if (fcu && fcu->bezt) { BezTriple *bezt; if (!extend) { diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index d77cf8658fd..7e970a13e03 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -9077,6 +9077,9 @@ static int ui_handle_menu_return_submenu(bContext *C, const wmEvent *event, uiPo block = ar->uiblocks.first; but = ui_but_find_active_in_region(ar); + + BLI_assert(but); + data = but->active; submenu = data->menu; diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 95fca10d60b..4b0585c34b3 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -1215,7 +1215,6 @@ static void ui_panel_drag_collapse(bContext *C, uiPanelDragCollapseHandle *dragc rect.ymin = rect.ymax; rect.ymax = rect.ymin + PNL_HEADER; if (pa->flag & PNL_CLOSEDX) { - rect.xmin = rect.xmin; rect.xmax = rect.xmin + PNL_HEADER; } diff --git a/source/blender/editors/interface/interface_regions.c b/source/blender/editors/interface/interface_regions.c index 9f5aa37351a..4b90abed82b 100644 --- a/source/blender/editors/interface/interface_regions.c +++ b/source/blender/editors/interface/interface_regions.c @@ -1427,7 +1427,8 @@ static void ui_block_position(wmWindow *window, ARegion *butregion, uiBut *but, if (down || top) { if (dir1 == UI_DIR_UP && top == 0) dir1 = UI_DIR_DOWN; if (dir1 == UI_DIR_DOWN && down == 0) dir1 = UI_DIR_UP; - if (dir2 == UI_DIR_UP && top == 0) dir2 = UI_DIR_DOWN; + /* dir2 is never set to UI_DIR_UP here */ +// if (dir2 == UI_DIR_UP && top == 0) dir2 = UI_DIR_DOWN; if (dir2 == UI_DIR_DOWN && down == 0) dir2 = UI_DIR_UP; } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 2f46c0906ae..4b683f3fcc2 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -323,10 +323,14 @@ void UI_fontstyle_draw_simple_backdrop( /* XXX: read a style configure */ uiStyle *UI_style_get(void) { +#if 0 uiStyle *style = NULL; /* offset is two struct uiStyle pointers */ - /* style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2) */; + style = BLI_findstring(&U.uistyles, "Unifont Style", sizeof(style) * 2); return (style != NULL) ? style : U.uistyles.first; +#else + return U.uistyles.first; +#endif } /* for drawing, scaled with DPI setting */ diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index ccbd30d1230..2cab1aea83f 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -3214,7 +3214,6 @@ void uiTemplateList( /* add scrollbar */ if (len > layoutdata.visual_items) { - col = uiLayoutColumn(row, false); uiDefButI(block, UI_BTYPE_SCROLL, 0, "", 0, 0, UI_UNIT_X * 0.75, UI_UNIT_Y * dyn_data->visual_height, &ui_list->list_scroll, 0, dyn_data->height - dyn_data->visual_height, dyn_data->visual_height, 0, ""); diff --git a/source/blender/editors/screen/area.c b/source/blender/editors/screen/area.c index 3a4034d9074..7fe6518134e 100644 --- a/source/blender/editors/screen/area.c +++ b/source/blender/editors/screen/area.c @@ -1263,16 +1263,22 @@ static void region_rect_recursive(wmWindow *win, ScrArea *sa, ARegion *ar, rcti if (ar->flag & (RGN_FLAG_HIDDEN | RGN_FLAG_TOO_SMALL)) { ar->winrct = *remainder; - if (alignment == RGN_ALIGN_TOP) - ar->winrct.ymin = ar->winrct.ymax; - else if (alignment == RGN_ALIGN_BOTTOM) - ar->winrct.ymax = ar->winrct.ymin; - else if (alignment == RGN_ALIGN_RIGHT) - ar->winrct.xmin = ar->winrct.xmax; - else if (alignment == RGN_ALIGN_LEFT) - ar->winrct.xmax = ar->winrct.xmin; - else /* prevent winrct to be valid */ - ar->winrct.xmax = ar->winrct.xmin; + switch (alignment) { + case RGN_ALIGN_TOP: + ar->winrct.ymin = ar->winrct.ymax; + break; + case RGN_ALIGN_BOTTOM: + ar->winrct.ymax = ar->winrct.ymin; + break; + case RGN_ALIGN_RIGHT: + ar->winrct.xmin = ar->winrct.xmax; + break; + case RGN_ALIGN_LEFT: + default: + /* prevent winrct to be valid */ + ar->winrct.xmax = ar->winrct.xmin; + break; + } } /* restore prev-split exception */ @@ -2161,7 +2167,7 @@ static void metadata_draw_imbuf(ImBuf *ibuf, rctf rect, int fontid, const bool i static float metadata_box_height_get(ImBuf *ibuf, int fontid, const bool is_top) { - char str[MAX_METADATA_STR]; + char str[MAX_METADATA_STR] = ""; short i, count = 0; const float height = BLF_height_max(fontid) + 0.1f * U.widget_unit; diff --git a/source/blender/editors/screen/screen_edit.c b/source/blender/editors/screen/screen_edit.c index 3d76070f197..d9bd9cc4f51 100644 --- a/source/blender/editors/screen/screen_edit.c +++ b/source/blender/editors/screen/screen_edit.c @@ -1748,7 +1748,9 @@ ScrArea *ED_screen_full_newspace(bContext *C, ScrArea *sa, int type) newsa = sa; } } - + + BLI_assert(newsa); + if (sa && (sa->spacetype != type)) { newsa->flag |= AREA_FLAG_TEMP_TYPE; } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 2853ee9c053..af65149ff9c 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -1234,7 +1234,7 @@ static void filelist_from_main(struct FileList *filelist) files = filelist->filelist; - if (!filelist->filter_data.hide_parent) { + if (files && !filelist->filter_data.hide_parent) { memset(&(filelist->filelist[0]), 0, sizeof(struct direntry)); filelist->filelist[0].relname = BLI_strdup(FILENAME_PARENT); filelist->filelist[0].type |= S_IFDIR; @@ -1246,7 +1246,7 @@ static void filelist_from_main(struct FileList *filelist) for (id = lb->first; id; id = id->next) { ok = 1; if (ok) { - if (!filelist->filter_data.hide_dot || id->name[2] != '.') { + if (files && (!filelist->filter_data.hide_dot || id->name[2] != '.')) { memset(files, 0, sizeof(struct direntry)); if (id->lib == NULL) { files->relname = BLI_strdup(id->name + 2); diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c index 57b417ef1d7..fb0f437884a 100644 --- a/source/blender/editors/space_view3d/view3d_draw.c +++ b/source/blender/editors/space_view3d/view3d_draw.c @@ -3262,6 +3262,9 @@ ImBuf *ED_view3d_draw_offscreen_imbuf(Scene *scene, View3D *v3d, ARegion *ar, in GPUOffScreen *ofs; bool draw_sky = (alpha_mode == R_ADDSKY) && v3d && (v3d->flag3 & V3D_SHOW_WORLD); + if (UNLIKELY(v3d == NULL)) + return NULL; + /* state changes make normal drawing go weird otherwise */ glPushAttrib(GL_LIGHTING_BIT); diff --git a/source/blender/editors/transform/transform_manipulator.c b/source/blender/editors/transform/transform_manipulator.c index ae8cbc721e3..b55a5ffbdbb 100644 --- a/source/blender/editors/transform/transform_manipulator.c +++ b/source/blender/editors/transform/transform_manipulator.c @@ -1056,8 +1056,6 @@ static void draw_manipulator_rotate( glRotatef(90.0, 1.0, 0.0, 0.0); postOrtho(ortho); } - - if (arcs) glDisable(GL_CLIP_PLANE0); } // donut arcs if (arcs) { diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 69bee8bab80..42fc0267625 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1173,7 +1173,7 @@ static int wm_operator_call_internal(bContext *C, wmOperatorType *ot, PointerRNA CTX_wm_operator_poll_msg_set(C, NULL); /* dummie test */ - if (ot && C) { + if (ot) { wmWindow *window = CTX_wm_window(C); switch (context) { @@ -2434,7 +2434,7 @@ void wm_event_do_handlers(bContext *C) /* XXX hrmf, this gives reliable previous mouse coord for area change, feels bad? * doing it on ghost queue gives errors when mousemoves go over area borders */ - if (doit && win->screen && win->screen->subwinactive != win->screen->mainwin) { + if (doit && win->screen->subwinactive != win->screen->mainwin) { win->eventstate->prevx = event->x; win->eventstate->prevy = event->y; //printf("win->eventstate->prev = %d %d\n", event->x, event->y); diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 0ee1f9f7eeb..c765587b7cb 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -546,7 +546,7 @@ static void wm_keymap_diff(wmKeyMap *diff_km, wmKeyMap *from_km, wmKeyMap *to_km if (to_kmi) { orig_kmi = WM_keymap_item_find_id(orig_km, kmi->id); - if (!orig_kmi) + if (!orig_kmi && addon_km) orig_kmi = wm_keymap_find_item_equals(addon_km, kmi); if (orig_kmi) { |