dtappbuilder: Coverity fixes mostly related to uninitialised variables
authorPeter Howkins <flibble@users.sf.net>
Tue, 1 May 2018 18:02:14 +0000 (19:02 +0100)
committerPeter Howkins <flibble@users.sf.net>
Tue, 1 May 2018 18:02:14 +0000 (19:02 +0100)
18 files changed:
cde/programs/dtappbuilder/src/ab/ab_utils.c
cde/programs/dtappbuilder/src/ab/abobj_set.c
cde/programs/dtappbuilder/src/ab/attch_ed_stubs.c
cde/programs/dtappbuilder/src/ab/brws.c
cde/programs/dtappbuilder/src/ab/conn_stubs.c
cde/programs/dtappbuilder/src/ab/message_ed_stubs.c
cde/programs/dtappbuilder/src/ab/pal_drawp.c
cde/programs/dtappbuilder/src/ab/prop.c
cde/programs/dtappbuilder/src/ab/prop_items.c
cde/programs/dtappbuilder/src/ab/ui_util.c
cde/programs/dtappbuilder/src/abmf/utils.c
cde/programs/dtappbuilder/src/libABil/abuil_load.c
cde/programs/dtappbuilder/src/libABil/abuil_resource_attr_map.c
cde/programs/dtappbuilder/src/libABil/bil.c
cde/programs/dtappbuilder/src/libABil/bil_loadatt.c
cde/programs/dtappbuilder/src/libABobj/obj_fields.c
cde/programs/dtappbuilder/src/libABobjXm/objxm_args.c
cde/programs/dtappbuilder/src/libABobjXm/objxm_config.c

index ddcbd7e4015afd67b535ec7b1a96d517ed34017a..31ae4197edc418a65d05bca4dd85f17a4a5f9ee6 100644 (file)
@@ -722,7 +722,7 @@ ab_update_stat_region(
     static Widget       obj_size = NULL;
     static Widget       curs_pos = NULL;
     static Widget       cur_module = NULL;
-    Widget              widget;
+    Widget              widget = NULL;
     String              nullstr = "        ";
 
     switch(type)
index e1e57fedca9399507c6614b978bd0b57447e1f79..3b46479824c0d9576a2764131c8febe125245b6d 100644 (file)
@@ -2139,7 +2139,7 @@ abobj_set_pattern_type(
 )
 {
     ABObj                      subObj;
-    unsigned char              value;
+    unsigned char              value = 0;
     AB_FILE_TYPE_MASK old_fmtype = obj_get_file_type_mask(obj);
 
     if (old_fmtype != fmtype)
index 97aa06b2fe6d284e9f8f8c339d6f8b4575cbfd68..1156e2199e5ea6e8547a51e4bada6d4418423c71 100644 (file)
@@ -1567,11 +1567,11 @@ create_obj_menu_dir(
 {
     DtbAttchEdAttchEdDialogInfo        attch_ed_cgen = &dtb_attch_ed_attch_ed_dialog;
     AttchEditorSettingsRec     *ats = &attch_editor_settings_rec;
-    PropOptionsSetting         option_setting;
+    PropOptionsSetting         option_setting = NULL;
     Widget                     label = NULL,
-                               optionbox,
-                               menu,
-                               changebar,
+                               optionbox = NULL,
+                               menu = NULL,
+                               changebar = NULL,
                                *item = NULL;
     int                                item_values = 0,
                                *item_val = NULL, 
@@ -3090,15 +3090,15 @@ change_opp_attach_type(
     int                                offset = 0,
                                position = 0;
     ABObj                      attach_obj = NULL;
-    AB_COMPASS_POINT           opp_dir;
+    AB_COMPASS_POINT           opp_dir = AB_CP_UNDEF;
     ATTCH_ED_ATTACH_TYPE       opp_attach_type;
-    PropOptionsSetting         opp_attach_type_setting,
-                               opp_objlist_setting;
-    PropFieldSetting           opp_offset_setting,
-                               opp_position_setting;
-    Widget                     opp_objlist_w,
-                               opp_offset_w,
-                               opp_position_w;
+    PropOptionsSetting         opp_attach_type_setting = NULL,
+                               opp_objlist_setting = NULL;
+    PropFieldSetting           opp_offset_setting = NULL,
+                               opp_position_setting = NULL;
+    Widget                     opp_objlist_w = NULL,
+                               opp_offset_w = NULL,
+                               opp_position_w = NULL;
     BOOL                       set_opp_attach = FALSE;
 
     /*
@@ -3279,10 +3279,10 @@ attach_obj_changed(
     DtbAttchEdAttchEdDialogInfo        attch_ed_cgen
                            = &dtb_attch_ed_attch_ed_dialog;
     AttchEditorSettingsRec     *ats = &attch_editor_settings_rec;
-    PropFieldSetting           offset_setting,
+    PropFieldSetting           offset_setting = NULL,
                                position_setting;
-    PropOptionsSetting         objlist_setting,
-                               attach_type_setting;
+    PropOptionsSetting         objlist_setting = NULL,
+                               attach_type_setting = NULL;
     AB_COMPASS_POINT           dir = (AB_COMPASS_POINT)client_data;
     ATTCH_ED_ATTACH_TYPE       attach_type = ATTCH_ED_NONE;
     ABObj                      attach_obj = NULL;
@@ -3323,6 +3323,9 @@ attach_obj_changed(
            position_setting = &(ats->bottom_attach_position);
            objlist_setting = &(ats->bottom_attach_obj);
        break;
+       
+       default:
+           return;
 
     }
 
index 11d16f68fe040289cdcbaa781feeafe00185d92e..4a30a2f8ed6c129ea92d8699deb146e39315c6b3 100644 (file)
@@ -1751,7 +1751,7 @@ destroy_browser_ui_handles(
 )
 {
     BrowserUiObjects   *ui;
-    DtbBrwsMainwindowInfo      instance;
+    DtbBrwsMainwindowInfo      instance = NULL;
 
     if (!b)
        return;
@@ -1811,8 +1811,7 @@ destroy_browser_ui_handles(
     /*
      * Free the ip structure
      */
-    if (instance)
-       free(instance);
+    free(instance);
 }
 
 
index 8daca41863b700bbf9f231ddd12050e5ca01410e..15618ea7e194c767c1f68f8b8e2da6e50ee69651 100644 (file)
@@ -1121,7 +1121,7 @@ select_connection(
 {
     XmListCallbackStruct       *list_cl = (XmListCallbackStruct *)call_data;
     ABObj                      *obj_list = (ABObj *)NULL;
-    ABObj                      cur_action;
+    ABObj                      cur_action = NULL;
     AB_ACTION_INFO             *cur_info;
 
     if (list_cl->reason != XmCR_BROWSE_SELECT)
@@ -1353,19 +1353,20 @@ get_cur_when(
 {
     Widget     label_wid = XmOptionButtonGadget(when_menu);
     XmString   xm_when_label   = (XmString)NULL;
-    char       *when_label;
+    char       *when_label = NULL;
     register int       i;
 
     XtVaGetValues(label_wid, XmNlabelString, &xm_when_label, NULL);
-    if (xm_when_label != NULL)
+    if (xm_when_label != NULL) {
        when_label = objxm_xmstr_to_str(xm_when_label);
 
-    for (i = 0; i < ConnP_num_conn_whens; i++)
-       if (!strcmp(when_label, ConnP_conn_whens[i].label))
-       {
-           XtFree(when_label);
-           return((int)ConnP_conn_whens[i].when_type);
+       for (i = 0; i < ConnP_num_conn_whens; i++) {
+           if (!strcmp(when_label, ConnP_conn_whens[i].label)) {
+               XtFree(when_label);
+               return((int)ConnP_conn_whens[i].when_type);
+           }
        }
+    }
 
     /*
      * Should never happen
@@ -1381,19 +1382,20 @@ get_cur_act(
 {
     Widget     label_wid = XmOptionButtonGadget(action_menu);
     XmString   xm_act_label    = (XmString)NULL;
-    char       *act_label;
+    char       *act_label = NULL;
     register int       i;
 
     XtVaGetValues(label_wid, XmNlabelString, &xm_act_label, NULL);
-    if (xm_act_label != NULL)
+    if (xm_act_label != NULL) {
        act_label = objxm_xmstr_to_str(xm_act_label);
 
-    for (i = 0; i < ConnP_num_conn_acts; i++)
-       if (!strcmp(act_label, ConnP_conn_acts[i].label))
-       {
-           XtFree(act_label);
-           return(ConnP_conn_acts[i].act_type);
+       for (i = 0; i < ConnP_num_conn_acts; i++) {
+           if (!strcmp(act_label, ConnP_conn_acts[i].label)) {
+               XtFree(act_label);
+               return(ConnP_conn_acts[i].act_type);
+           }
        }
+    }
 
     /*
      * Should never happen
@@ -3870,17 +3872,20 @@ get_cur_func_type(void)
 {
     Widget      label_wid = XmOptionButtonGadget(action_type_opmenu);
     XmString    xm_act_label    = (XmString)NULL;
-    char        *act_label;
+    char        *act_label = NULL;
     register int        i;
     AB_FUNC_TYPE       func_type = AB_FUNC_UNDEF;
  
     XtVaGetValues(label_wid, XmNlabelString, &xm_act_label, NULL);
-    if (xm_act_label != NULL)
-        act_label = objxm_xmstr_to_str(xm_act_label);
+    if (xm_act_label != NULL) {
+       act_label = objxm_xmstr_to_str(xm_act_label);
  
-    for (i = 0; i < ACTION_TYPE_NUM_VALUES; i++)
-        if (!strcmp(act_label, action_type_labels[i]))
-           break;
+       for (i = 0; i < ACTION_TYPE_NUM_VALUES; i++) {
+           if (!strcmp(act_label, action_type_labels[i])) {
+               break;
+           }
+       }
+    }
 
     switch (i)
     {
index 2112ba9e1c23d9a6755b4776c10ee931d5ea3cea..adb7b81c814b461436322f7778f8e81f8d48c3a0 100644 (file)
@@ -1925,7 +1925,7 @@ msgEdP_show_msgCB(
     ABObj                      project = obj_get_project(mes->current_obj);
     STRING                     str = (STRING) NULL;
     DTB_BUTTON                 default_btn = DTB_NONE;
-    unsigned char              dialogType;
+    unsigned char              dialogType = 0;
 
     /*** DTB_USER_CODE_END   ^^^ Add C variables and code above ^^^ ***/
     
index 840c29d15b021f59bf0dfc9e207bfdd731dad834..3159e5acf07a61641e9608dcbff6e5eb794853f7 100644 (file)
@@ -427,7 +427,7 @@ drawp_prop_load(
 )
 {
     PropDrawpSettingsRec       *pds = &(prop_drawp_settings_rec[type]);
-    AB_SCROLLBAR_POLICY                sb_policy;
+    AB_SCROLLBAR_POLICY                sb_policy = AB_SCROLLBAR_UNDEF;
     BOOL                       load_all = (loadkey & LoadAll);
  
     if (obj == NULL)
index fae58948a4f3f7b3a16d07f1b831f96f25dc1ba9..c1700cf0aa33a0e1b0a0c961e2c181627b45d8a4 100644 (file)
@@ -525,7 +525,7 @@ prop_load_obj(
 {
     PalItemInfo *palitem;
     PalItemInfo *viz_palitem;
-    Widget      dialog;
+    Widget      dialog = NULL;
     PropStateInfo *pstate;
     STRING     modname = NULL;
 
@@ -3819,7 +3819,7 @@ close_propsCB(
 )
 {
     AB_PROP_TYPE       type = (AB_PROP_TYPE)client_data;
-    DTB_MODAL_ANSWER   answer;
+    DTB_MODAL_ANSWER   answer = DTB_ANSWER_NONE;
     PalItemInfo                *palitem = NULL;
     PropStateInfo      *pstate;
     WidgetList         shell_child;
index 9901a8f7427e0f2ab4fe077c21223dea370336e7..aef076a0a60dfccfdd4f0693be0655d16f433c88 100644 (file)
@@ -679,7 +679,7 @@ prop_item_change(
 )  
 {  
     ABObj       current_obj;
-    STRING      newlabel, basename, graphic_path;
+    STRING      newlabel = NULL, basename = NULL, graphic_path;
     BOOL        label_type_chg = False;
     AB_LABEL_TYPE new_label_type;
     XmString    xmitem;
@@ -902,7 +902,7 @@ prop_item_insert(
                 *new_iobj_list;
     int         num_items;
     int         select_pos;
-    int         pos;
+    int         pos = 0;
     int         i, j;
 
     XtVaGetValues(pis->item_list,
index 0b1945be6b40da2b6c990e062a4bab9ebb5ebe2e..2f4e0a9619c09270b4399e67d7fde119246925c2 100644 (file)
@@ -530,7 +530,7 @@ ui_build_menu(
 )
 {
     Widget     menu,
-               cascade,
+               cascade = NULL,
                widget;
     Arg                args[4];
     int        i;
@@ -1647,7 +1647,7 @@ ui_obj_set_label_string(
                        Widget       parent = objxm_get_widget(p_obj);
                        AB_ITEM_TYPE itype = (AB_ITEM_TYPE)obj_get_subtype(obj);
                        int          pos;
-                       int          num_items;
+                       int          num_items = 0;
                        XmString     xmitem;
            
                        if (parent != NULL)
index f5963d624bf2c8dcbe73c9f4c02a1373a0fe39ba..6de3f0d1cb73fc3fdaa6327f2823ca6209a64148 100644 (file)
@@ -348,7 +348,7 @@ find_longest_label(STRING * label)
 {
     int                 len1,
                         len2,
-                        longest,
+                        longest = 0,
                         i = 0;
 
     len1 = len2 = 0;
index 5242261fde9451026ffdc6a94591e8bddc088e14..9537d427fd5989c84859e630daffc105029da709 100644 (file)
@@ -340,7 +340,7 @@ root_into_project(
 {
     sym_root_entry_type        *root_node;
     ABObjPtr           ab_module;
-    ABObjPtr           ret_val;
+    ABObjPtr           ret_val = NULL;
 
     if (uil_root == (sym_entry_type *)NULL ||
        uil_root->header.b_tag != sym_k_root_entry)
@@ -424,7 +424,7 @@ sections_into_module(
     sym_entry_type             *next_node;
     sym_section_entry_type     *section_node;
     short int                  done;
-    ABObjPtr                   ret_val;
+    ABObjPtr                   ret_val = NULL;
 
     /*
      * populate module;
index d1d0c27831b2926f380fea3ebe8d4c6931c588a0..29a80dca9f09e6effc60a719a1522462d87d5f10 100644 (file)
@@ -3355,7 +3355,7 @@ attach_context_store(
 {
     AttachmentContext  *attach_context = (AttachmentContext *)context;
     STRING             attach_str;
-    AB_ATTACH_TYPE     att_type;
+    AB_ATTACH_TYPE     att_type = AB_ATTACH_UNDEF;
     long               att_pos = 0, att_off = 0, offset = 0;
     void               *value  = NULL;
     BOOL               need_val = TRUE;
index ae22f09b579fe74ec76993e8bd84c8eb866486ab..feca036279bee550ae548c15023bc023895decea 100644 (file)
@@ -267,7 +267,7 @@ bilP_label_style_to_token(AB_LABEL_STYLE type)
 AB_LABEL_STYLE
 bilP_token_to_label_style(int type)
 {
-    AB_LABEL_STYLE      obj_type;
+    AB_LABEL_STYLE      obj_type = AB_STYLE_UNDEF;
 
     switch (type)
     {
index be1774c41217835ac8a71280b7afc95323301ef9..b7772daec7966d9c631709f1ff461710651b83b3 100644 (file)
@@ -979,7 +979,7 @@ STRING
 bilP_load_att_hspacing(BIL_TOKEN valueToken)
 {
     ABObj               obj = bilP_load.obj;
-    int                 tmp_int;
+    int                 tmp_int = 0;
     int                 type;
 
     nset_att(AB_BIL_HSPACING);
@@ -1000,7 +1000,7 @@ STRING
 bilP_load_att_hoffset(BIL_TOKEN valueToken)
 {
     ABObj               obj = bilP_load.obj;
-    int                 tmp_int;
+    int                 tmp_int = 0;
     int                 type;
 
     set_att(":hoffset");
@@ -1688,7 +1688,7 @@ STRING
 bilP_load_att_max_length(BIL_TOKEN valueToken)
 {
     ABObj               obj = bilP_load.obj;
-    int                 tmp_int;
+    int                 tmp_int = 0;
     int                 type;
 
     set_att(":max-length");
@@ -1710,7 +1710,7 @@ bilP_load_att_tear_off(BIL_TOKEN valueToken)
     ABObj               obj = bilP_load.obj;
     int                 type = AB_BIL_UNDEF;
     STRING              value = NULL;
-    BOOL                tear_off;
+    BOOL                tear_off = FALSE;
 
     set_att(":tear-off");
     if (!bilP_token_is_bool(valueToken))
@@ -1855,7 +1855,7 @@ STRING
 bilP_load_att_voffset(BIL_TOKEN valueToken)
 {
     ABObj               obj = bilP_load.obj;
-    int                 tmp_int;
+    int                 tmp_int = 0;
     int                 type;
 
     set_att(":voffset");
@@ -1908,7 +1908,7 @@ STRING
 bilP_load_att_vspacing(BIL_TOKEN valueToken)
 {
     ABObj               obj = bilP_load.obj;
-    int                 tmp_int;
+    int                 tmp_int = 0;
     int                 type;
 
     set_att(":vspacing");
index ee638155abb50ddaafb6938d79bc0ab3a870b179..e98fc00ba8ba1cc5daa039cf0558f47dac5268ca 100644 (file)
@@ -2992,7 +2992,7 @@ obj_set_attachment(
                   int offset
 )
 {
-    ABAttachment       *attachment;
+    ABAttachment       *attachment = NULL;
     verify_for_write(obj);
 
     if (obj->attachments == NULL)
@@ -3012,6 +3012,8 @@ obj_set_attachment(
     case AB_CP_EAST:
        attachment = &(obj->attachments->east);
        break;
+    default:
+       return 0;
     }
     attachment->type = type;
     attachment->value = value;
index e554d2cfe1731105776b771e75357c6440034730..ae51e0dca316b382b04c750c33dab574c82ef64a 100644 (file)
@@ -1629,6 +1629,8 @@ objxmP_set_attachment_arg(
            att_offset_resource = XmNbottomOffset;
            att_pos_resource    = XmNbottomPosition;
            break;
+       default:
+           return OK;
     }
     type   = obj_get_attach_type(obj, dir);
     value  = obj_get_attach_value(obj, dir);
index f656b4b49bb318b390a1b20446a88cf664a228b7..119a9911450faf1fa69e78ed19d78f554bf5e7eb 100644 (file)
@@ -411,7 +411,7 @@ config_attachment(
 )
 {
     ABObj        attobj;
-    ABAttachment *attachment;
+    ABAttachment *attachment = NULL;
 
     switch(dir)
     {
@@ -427,6 +427,8 @@ config_attachment(
         case AB_CP_SOUTH:
             attachment = &(obj->attachments->south);
             break;
+        default:
+            return;
     }
     if (attachment->type == AB_ATTACH_OBJ)
     {