From: Peter Howkins Date: Tue, 1 May 2018 19:45:55 +0000 (+0100) Subject: dtwm: Resolve coverity warnings related to uninitialised variables and missing return... X-Git-Tag: 2.2.4a~43 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fa29d3776ec6967a5664fdea86d2650957be7422;p=oweals%2Fcde.git dtwm: Resolve coverity warnings related to uninitialised variables and missing return statements --- diff --git a/cde/programs/dtwm/Callback.c b/cde/programs/dtwm/Callback.c index 668d899e..56d3a038 100644 --- a/cde/programs/dtwm/Callback.c +++ b/cde/programs/dtwm/Callback.c @@ -973,7 +973,7 @@ SwitchRenameCB (Widget w, SwitchData * switch_data; Boolean valid; - int current_switch; + int current_switch = 0; int i; int ac; diff --git a/cde/programs/dtwm/DataBaseLoad.c b/cde/programs/dtwm/DataBaseLoad.c index 00901100..8619c469 100644 --- a/cde/programs/dtwm/DataBaseLoad.c +++ b/cde/programs/dtwm/DataBaseLoad.c @@ -1219,7 +1219,7 @@ ProcessRecord (DtDtsDbField * fields, int i, j; int entry; - int keyword_count; + int keyword_count = 0; char ** field_keywords; @@ -2318,6 +2318,7 @@ AddControlActionList (ControlData * control_data) { /* DtDTS_DA_ACTION_LIST */ case 0: + free(act_list); /* Remove any previous loop run through */ act_list = (char *) strdup(attr_list[i]->value); break; diff --git a/cde/programs/dtwm/PopupMenu.c b/cde/programs/dtwm/PopupMenu.c index 5c7c94e7..8216f50b 100644 --- a/cde/programs/dtwm/PopupMenu.c +++ b/cde/programs/dtwm/PopupMenu.c @@ -137,7 +137,7 @@ DeleteWorkspaceCB (Widget w, { long delete_workspace = (long) client_data; - SwitchData * switch_data; + SwitchData * switch_data = NULL; int i; @@ -152,9 +152,12 @@ DeleteWorkspaceCB (Widget w, break; } } - - _DtWsmDeleteWorkspace (panel.shell, - switch_data->atom_names[delete_workspace]); + + if(switch_data) + { + _DtWsmDeleteWorkspace (panel.shell, + switch_data->atom_names[delete_workspace]); + } } diff --git a/cde/programs/dtwm/UI.c b/cde/programs/dtwm/UI.c index 1209c451..a2e3d22b 100644 --- a/cde/programs/dtwm/UI.c +++ b/cde/programs/dtwm/UI.c @@ -2004,7 +2004,7 @@ SwitchCreate (BoxData * box_data) int switch_count = 1; Atom * atom_names; Atom current_workspace_atom; - int current_workspace; + int current_workspace = 0; Widget switch_button; @@ -3186,7 +3186,7 @@ AddSubpanel (ControlData * control_data) { ElementValue * element_values; - SubpanelData * subpanel_data; + SubpanelData * subpanel_data = NULL; BoxData * box_data = (BoxData *)control_data->parent_data; DtWmHints vHints; @@ -3259,7 +3259,9 @@ AddSubpanel (ControlData * control_data) box_data->subpanel_count++; - SubpanelCreate (control_data, subpanel_data); + if(subpanel_data) { + SubpanelCreate (control_data, subpanel_data); + } XtSetArg (al[0], XmNimageName, post_arrow_image); diff --git a/cde/programs/dtwm/WmBackdrop.c b/cde/programs/dtwm/WmBackdrop.c index b48591c2..dd4a7262 100644 --- a/cde/programs/dtwm/WmBackdrop.c +++ b/cde/programs/dtwm/WmBackdrop.c @@ -441,9 +441,12 @@ ProcessBackdropResources( pch = NULL; } free (pchImageName); /* temporary string */ + pchImageName = NULL; free (pchL); /* temporary string */ } } + + free (pchImageName); } diff --git a/cde/programs/dtwm/WmCDecor.c b/cde/programs/dtwm/WmCDecor.c index d97b2a60..58a1cb1e 100644 --- a/cde/programs/dtwm/WmCDecor.c +++ b/cde/programs/dtwm/WmCDecor.c @@ -566,9 +566,9 @@ void GenerateFrameDisplayLists (ClientData *pcd) int insideBevel, inset, diffBevel; unsigned int nTitleBevel, sTitleBevel, eTitleBevel, wTitleBevel; unsigned int meTitleBevel, inWidth; - int x, y, xAdj, yAdj; + int x, y, xAdj = 0, yAdj = 0; unsigned int width, height; - RList *prlTop, *prlBot; + RList *prlTop = NULL, *prlBot = NULL; int jX, jY; unsigned int jW, jH; diff --git a/cde/programs/dtwm/WmCEvent.c b/cde/programs/dtwm/WmCEvent.c index d55b883a..1483ff7d 100644 --- a/cde/programs/dtwm/WmCEvent.c +++ b/cde/programs/dtwm/WmCEvent.c @@ -2569,7 +2569,7 @@ void HandleCColormapNotify (ClientData *pCD, XColormapEvent *colorEvent) void HandleClientMessage (ClientData *pCD, XClientMessageEvent *clientEvent) { - unsigned int newState; + unsigned int newState = WITHDRAWN_STATE; /* * Process the client message event based on the message_type. diff --git a/cde/programs/dtwm/WmFP.c b/cde/programs/dtwm/WmFP.c index 5fa0d3e4..48a8b629 100644 --- a/cde/programs/dtwm/WmFP.c +++ b/cde/programs/dtwm/WmFP.c @@ -610,6 +610,9 @@ PushRecallGetData (char * client_name) for (i = 0; i < panel.push_recall_count; i++) if (strcmp (client_name, push_recall_list[i].pchResName) == 0) return (i); + + /* Should never get here */ + return 0; } diff --git a/cde/programs/dtwm/WmFunction.c b/cde/programs/dtwm/WmFunction.c index 1cf1cb94..52cfdad1 100644 --- a/cde/programs/dtwm/WmFunction.c +++ b/cde/programs/dtwm/WmFunction.c @@ -2285,7 +2285,7 @@ F_Push_Recall (String args, ClientData *pCD, XEvent *event) if (!bWaiting) { - long clientTimeout; + long clientTimeout = 0; Arg al[5]; int ac; WmPanelistObject pPanelist; diff --git a/cde/programs/dtwm/WmHelp.c b/cde/programs/dtwm/WmHelp.c index 1574d786..c66a2160 100644 --- a/cde/programs/dtwm/WmHelp.c +++ b/cde/programs/dtwm/WmHelp.c @@ -2044,6 +2044,8 @@ RestoreHelpDialogs( XrmDestroyDatabase(db); } #endif /* NO_DT */ + + return True; } /* END OF FUNCTION RestoreHelpDialogs */ /*************************************<->************************************* diff --git a/cde/programs/dtwm/WmIconBox.c b/cde/programs/dtwm/WmIconBox.c index dfcea3ff..166f0ddd 100644 --- a/cde/programs/dtwm/WmIconBox.c +++ b/cde/programs/dtwm/WmIconBox.c @@ -2887,7 +2887,7 @@ void PackIconBox (IconBoxData *pIBD, Boolean packVert, Boolean packHorz, int pas int ix1, ix2; int count; int newX, newY; - ClientData *pCD_tmp, *pMyCD; + ClientData *pCD_tmp = NULL, *pMyCD; int hasActiveText = 1; Arg args[4]; Dimension majorDimension, minorDimension; diff --git a/cde/programs/dtwm/WmWinConf.c b/cde/programs/dtwm/WmWinConf.c index a67da0c1..47874a4f 100644 --- a/cde/programs/dtwm/WmWinConf.c +++ b/cde/programs/dtwm/WmWinConf.c @@ -688,7 +688,7 @@ Boolean HandleResizeKeyPress (ClientData *pcd, XEvent *pev) { KeySym keysym; Boolean control; - int warpX, warpY, currentX, currentY, newX, newY; + int warpX, warpY, currentX = 0, currentY = 0, newX, newY; int junk, keyMult; Window junk_win; XEvent KeyEvent; diff --git a/cde/programs/dtwm/WmXSMP.c b/cde/programs/dtwm/WmXSMP.c index 04c68b59..5e6fc4d4 100644 --- a/cde/programs/dtwm/WmXSMP.c +++ b/cde/programs/dtwm/WmXSMP.c @@ -485,7 +485,7 @@ getClientWorkspaces(ClientData *pCD) /* Easy but slow way to do this would be to use XGetAtomName(). */ /* To avoid XServer round trips (and to weed out invalid WS names) */ /* we look through workspaces attached to this screen for ID matches. */ - char *cwsP, *tmpP, *wsNameP; + char *cwsP = NULL, *tmpP, *wsNameP; int pLen = 0; int i;