1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

dtwm: Resolve coverity warnings

This commit is contained in:
Peter Howkins 2018-04-02 18:08:40 +01:00
parent 4b9bcae29f
commit 8362f92ceb
14 changed files with 39 additions and 46 deletions

View file

@ -290,6 +290,7 @@ StringToAction (char * parse_source,
{ {
_DtSimpleError (panel.app_name, DtError, NULL, _DtSimpleError (panel.app_name, DtError, NULL,
"Invalid Action -- %s", parse_source); "Invalid Action -- %s", parse_source);
free (head_ptr);
return (False); return (False);
} }

View file

@ -179,7 +179,7 @@ RenameWorkspaceCB (Widget w,
{ {
long rename_ws = (long) client_data; long rename_ws = (long) client_data;
SwitchData * switch_data; SwitchData * switch_data = NULL;
int i; int i;
@ -195,7 +195,9 @@ RenameWorkspaceCB (Widget w,
} }
} }
SwitchRenameLabel (switch_data->buttons[rename_ws], panel.box_data[i]); if(switch_data) {
SwitchRenameLabel (switch_data->buttons[rename_ws], panel.box_data[i]);
}
} }

View file

@ -832,5 +832,7 @@ SessionDeleteAll(void)
strcpy(srcname + srclen, entry->d_name); strcpy(srcname + srclen, entry->d_name);
remove (srcname); remove (srcname);
} }
closedir(dir);
} }

View file

@ -440,14 +440,8 @@ ProcessBackdropResources(
} }
pch = NULL; pch = NULL;
} }
if (pchImageName) free (pchImageName); /* temporary string */
{ free (pchL); /* temporary string */
free (pchImageName); /* temporary string */
}
if (pchL)
{
free (pchL); /* temporary string */
}
} }
} }
} }

View file

@ -1239,7 +1239,7 @@ void CheckButtonPressBuiltin (XButtonEvent *buttonEvent, Context context, Contex
* the resources or the user has specifically requested * the resources or the user has specifically requested
* that "move" not be one of them. * that "move" not be one of them.
*/ */
if (pCD->clientFunctions & MWM_FUNC_MOVE) if (pCD && (pCD->clientFunctions & MWM_FUNC_MOVE))
{ {
wmGD.preMove = True; wmGD.preMove = True;
wmGD.preMoveX = buttonEvent->x_root; wmGD.preMoveX = buttonEvent->x_root;

View file

@ -292,7 +292,7 @@ EmbeddedClientRegister (ControlData * control_data,
if (embedded_client_list[i].wControl == control_data->icon) if (embedded_client_list[i].wControl == control_data->icon)
{ {
Position remove_y; Position remove_y;
Dimension adjust_y; Dimension adjust_y = 0;
/* This block will reparent the client window, move it */ /* This block will reparent the client window, move it */
@ -312,7 +312,9 @@ EmbeddedClientRegister (ControlData * control_data,
/* deleted control height plus 5 pixels of form offset */ /* deleted control height plus 5 pixels of form offset */
adjust_y = XtHeight (control_data->icon) + 5; if(control_data->icon) {
adjust_y = XtHeight (control_data->icon) + 5;
}
panel.embedded_client_count--; panel.embedded_client_count--;

View file

@ -991,7 +991,9 @@ void WmDtHelpOnVersion (
Widget helpButton = NULL; Widget helpButton = NULL;
Widget backButton = NULL; Widget backButton = NULL;
Widget closeButton = NULL; Widget closeButton = NULL;
#ifdef NO_MESSAGE_CATALOG
XmString label = NULL; XmString label = NULL;
#endif
if((versionWidget != NULL) && if((versionWidget != NULL) &&
(XtIsManaged(versionWidget))) (XtIsManaged(versionWidget)))
@ -1035,7 +1037,9 @@ void WmDtHelpOnVersion (
#endif #endif
XtSetValues(closeButton, setArgs2, n2); XtSetValues(closeButton, setArgs2, n2);
#ifdef NO_MESSAGE_CATALOG
if(label)XmStringFree(label); if(label)XmStringFree(label);
#endif
printButton = DtHelpQuickDialogGetChild( versionWidget, printButton = DtHelpQuickDialogGetChild( versionWidget,
DtHELP_QUICK_PRINT_BUTTON ); DtHELP_QUICK_PRINT_BUTTON );
@ -1664,7 +1668,7 @@ RestoreHelpDialogs(
int wsCnt; int wsCnt;
int cCount; int cCount;
int cachedCount=0; int cachedCount=0;
char dialogName[10]; char dialogName[18];
ClientData *pCD = NULL; ClientData *pCD = NULL;
char *tTitle = NULL; char *tTitle = NULL;
@ -2787,7 +2791,9 @@ wmDtErrorDialog(
if (pSD->dtHelp.errorDialog == NULL) if (pSD->dtHelp.errorDialog == NULL)
{ {
#ifdef NO_MESSAGE_CATALOG
XmString tmpXmString = (XmString)NULL; XmString tmpXmString = (XmString)NULL;
#endif
ac = 0; ac = 0;
XtSetArg (al[ac], XmNmessageString, xmsMessage); ac++; XtSetArg (al[ac], XmNmessageString, xmsMessage); ac++;
@ -2815,8 +2821,10 @@ wmDtErrorDialog(
pSD->dtHelp.errorDialog = pSD->dtHelp.errorDialog =
XmCreateErrorDialog (wParent, "Error Dialog", al, ac); XmCreateErrorDialog (wParent, "Error Dialog", al, ac);
#ifdef NO_MESSAGE_CATALOG
if (tmpXmString) if (tmpXmString)
XmStringFree(tmpXmString); XmStringFree(tmpXmString);
#endif
wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog, wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog,
XmDIALOG_HELP_BUTTON); XmDIALOG_HELP_BUTTON);

View file

@ -1081,7 +1081,7 @@ char *BitmapPathName (string)
strncat (fileName, &wmGD.bitmapDirectory[1], strncat (fileName, &wmGD.bitmapDirectory[1],
MAXWMPATH - strlen (fileName)); MAXWMPATH - strlen (fileName));
} else { } else {
strcpy (fileName, wmGD.bitmapDirectory); snprintf(fileName, sizeof(fileName), "%s", wmGD.bitmapDirectory);
} }
strncat (fileName, "/", MAXWMPATH - strlen (fileName)); strncat (fileName, "/", MAXWMPATH - strlen (fileName));
strncat (fileName, string, MAXWMPATH - strlen (fileName)); strncat (fileName, string, MAXWMPATH - strlen (fileName));

View file

@ -4050,7 +4050,7 @@ void PostMenu (MenuSpec *menuSpec, ClientData *pCD, int x, int y, unsigned int b
* Compute position if necessary (system menu). * Compute position if necessary (system menu).
*/ */
if (!(flags & POST_AT_XY)) if (pCD && !(flags & POST_AT_XY))
/* compute the position */ /* compute the position */
{ {
GetSystemMenuPosition (pCD, &x, &y, menuSpec->height, newContext); GetSystemMenuPosition (pCD, &x, &y, menuSpec->height, newContext);

View file

@ -108,6 +108,8 @@ WmHeadInfo_t *GetHeadInfo(const ClientData *pcd) {
return WmHI; return WmHI;
} }
free(WmHI);
/* No valid screen */ /* No valid screen */
return NULL; return NULL;
} }

View file

@ -2512,8 +2512,11 @@ FILE *FopenConfigFile (void)
* Run the file through the C-preprocessor * Run the file through the C-preprocessor
*/ */
PreprocessConfigFile (); PreprocessConfigFile ();
if (pConfigStackTop->cppName) if (pConfigStackTop && pConfigStackTop->cppName)
{ {
if(fileP) {
fclose(fileP);
}
/* open the result */ /* open the result */
fileP = fopen (pConfigStackTop->cppName, "r"); fileP = fopen (pConfigStackTop->cppName, "r");
} }

View file

@ -398,35 +398,17 @@ void InitBuiltinSystemMenu(void)
else else
{ {
/* put it together */ /* put it together */
strcpy(dsm, defaultSystemMenuName); snprintf(dsm, sizeof(dsm), "%s\n{\n%s)\n%s\n%s\n%s\n%s\n%s\n no-label f.separator\n",
strcat(dsm, "\n{\n"); defaultSystemMenuName, ResString, MovString,
strcat(dsm, ResString); SizString, MinString, MaxString, LowString);
strcat(dsm, "\n");
strcat(dsm, MovString);
strcat(dsm, "\n");
strcat(dsm, SizString);
strcat(dsm, "\n");
strcat(dsm, MinString);
strcat(dsm, "\n");
strcat(dsm, MaxString);
strcat(dsm, "\n");
strcat(dsm, LowString);
strcat(dsm, "\n");
strcat(dsm, " no-label f.separator\n");
#ifdef WSM #ifdef WSM
if (DtwmBehavior) if (DtwmBehavior)
{ {
strcat(dsm, OcpString); snprintf(dsm, sizeof(dsm), "%s%s\n%s\n%s\n no-label f.separator\n",
strcat(dsm, "\n"); dsm, OcpString, OcaString, RemString);
strcat(dsm, OcaString);
strcat(dsm, "\n");
strcat(dsm, RemString);
strcat(dsm, "\n");
strcat(dsm, " no-label f.separator\n");
} }
#endif /* WSM */ #endif /* WSM */
strcat(dsm, CloString); snprintf(dsm, sizeof(dsm), "%s%s\n}", dsm, CloString);
strcat(dsm, "\n}");
if ((builtinSystemMenu = if ((builtinSystemMenu =
(char *)XtMalloc ((unsigned int) (strlen(dsm) + 1))) == NULL) (char *)XtMalloc ((unsigned int) (strlen(dsm) + 1))) == NULL)

View file

@ -4202,7 +4202,7 @@ StartMarqueeSelect(WmScreenData *pSD, XEvent *pev)
/* /*
* Set up static variables for succeeding events * Set up static variables for succeeding events
*/ */
if ((pev->type == ButtonPress) || (pev->type == ButtonRelease)) if (pev && (pev->type == ButtonPress) || (pev->type == ButtonRelease))
{ {
pointerX = pev->xbutton.x_root; pointerX = pev->xbutton.x_root;
pointerY = pev->xbutton.y_root; pointerY = pev->xbutton.y_root;

View file

@ -3857,10 +3857,7 @@ SaveWorkspaceResources(
XtFree(data); XtFree(data);
} }
if (buffer) XtFree(buffer);
{
XtFree(buffer);
}
} /* END OF FUNCTION SaveWorkspaceResources */ } /* END OF FUNCTION SaveWorkspaceResources */