qulogic/libgnt

Fix Finch clang scan-build warnings

2014-04-03, Tomasz Wasilczyk
c5116ded3b21
Parents bbbd569d727d
Children f062930b10d6
Fix Finch clang scan-build warnings
  • +11 -0
    gntbox.c
  • +2 -0
    gntmenu.c
  • +9 -0
    gnttextview.c
  • +2 -1
    gnttree.c
  • +6 -0
    gntwm.c
  • +3 -0
    wms/irssi.c
  • +3 -0
    wms/s.c
  • --- a/gntbox.c Sun Feb 23 01:23:52 2014 +0530
    +++ b/gntbox.c Thu Apr 03 18:45:27 2014 +0200
    @@ -731,6 +731,11 @@
    int height, width;
    int x, y;
    + if (G_UNLIKELY(w == NULL)) {
    + g_warn_if_reached();
    + continue;
    + }
    +
    if (GNT_WIDGET_IS_FLAG_SET(w, GNT_WIDGET_INVISIBLE))
    continue;
    @@ -819,6 +824,12 @@
    for (iter = box->list; iter; iter = iter->next)
    {
    GntWidget *w = iter->data;
    +
    + if (G_UNLIKELY(w == NULL)) {
    + g_warn_if_reached();
    + continue;
    + }
    +
    if (GNT_IS_BOX(w))
    gnt_box_readjust(GNT_BOX(w));
    else
    --- a/gntmenu.c Sun Feb 23 01:23:52 2014 +0530
    +++ b/gntmenu.c Thu Apr 03 18:45:27 2014 +0200
    @@ -121,6 +121,8 @@
    {
    char trigger[4] = "\0 )\0";
    + g_return_if_fail(item != NULL);
    +
    if ((trigger[1] = gnt_menuitem_get_trigger(item)) && trigger[1] != ' ')
    trigger[0] = '(';
    --- a/gnttextview.c Sun Feb 23 01:23:52 2014 +0530
    +++ b/gnttextview.c Thu Apr 03 18:45:27 2014 +0200
    @@ -335,6 +335,9 @@
    GntTextView *view = GNT_TEXT_VIEW(widget);
    if (text_view_contains(view, select_start)) {
    GString *clip;
    +
    + g_return_val_if_fail(select_start != NULL, TRUE);
    +
    select_end = gnt_text_view_get_p(view, x - widget->priv.x, y - widget->priv.y);
    if (select_end < select_start) {
    gchar *t = select_start;
    @@ -758,6 +761,12 @@
    GList *segs, *snext;
    GntTextLine *line = iter->data;
    inext = iter->next;
    +
    + if (line == NULL) {
    + g_warn_if_reached();
    + continue;
    + }
    +
    for (segs = line->segments; segs; segs = snext) {
    GntTextSegment *seg = segs->data;
    snext = segs->next;
    --- a/gnttree.c Sun Feb 23 01:23:52 2014 +0530
    +++ b/gnttree.c Thu Apr 03 18:45:27 2014 +0200
    @@ -1314,7 +1314,8 @@
    else
    tree->root = row;
    row->next = s;
    - s->prev = row; /* s cannot be NULL */
    + g_return_if_fail(s != NULL); /* s cannot be NULL */
    + s->prev = row;
    row->prev = NULL;
    newp = g_list_index(tree->list, s) - 1;
    } else {
    --- a/gntwm.c Sun Feb 23 01:23:52 2014 +0530
    +++ b/gntwm.c Thu Apr 03 18:45:27 2014 +0200
    @@ -2251,8 +2251,14 @@
    void gnt_wm_raise_window(GntWM *wm, GntWidget *widget)
    {
    GntWS *ws = gnt_wm_widget_find_workspace(wm, widget);
    +
    + g_return_if_fail(wm != NULL);
    +
    if (wm->cws != ws)
    gnt_wm_switch_workspace(wm, g_list_index(wm->workspaces, ws));
    +
    + g_return_if_fail(wm->cws != NULL);
    +
    if (widget != wm->cws->ordered->data) {
    GntWidget *wid = wm->cws->ordered->data;
    wm->cws->ordered = g_list_bring_to_front(wm->cws->ordered, widget);
    --- a/wms/irssi.c Sun Feb 23 01:23:52 2014 +0530
    +++ b/wms/irssi.c Thu Apr 03 18:45:27 2014 +0200
    @@ -155,6 +155,9 @@
    const char *name;
    int x, y, w, h;
    + g_return_if_fail(win != NULL);
    + g_return_if_fail(wm != NULL);
    +
    name = gnt_widget_get_name(win);
    if (!name || !strstr(name, "conversation-window")) {
    if (!GNT_IS_MENU(win) && !GNT_WIDGET_IS_FLAG_SET(win, GNT_WIDGET_TRANSIENT)) {
    --- a/wms/s.c Sun Feb 23 01:23:52 2014 +0530
    +++ b/wms/s.c Thu Apr 03 18:45:27 2014 +0200
    @@ -84,6 +84,9 @@
    const char *name;
    gboolean blist = FALSE;
    + g_return_if_fail(win != NULL);
    + g_return_if_fail(wm != NULL);
    +
    if (!GNT_IS_MENU(win)) {
    getmaxyx(stdscr, maxy, maxx);