dtwm: Resolve coverity warnings
[oweals/cde.git] / cde / programs / dtwm / WmHelp.c
index 8e80b06fa13ce43021fb70f117dc9346d354cbdf..31e915e373ae6951810b8c7485e41f50fa402a26 100644 (file)
@@ -44,7 +44,10 @@ static char rcsid[] = ""
  
 #include "WmGlobal.h"
 #include "WmError.h"
+#include "WmFunction.h"
 #include "WmHelp.h"
+#include "WmCDecor.h"
+#include "WmResParse.h"
 #ifdef PANELIST
 #include "WmPanelP.h"
 #endif /* PANELIST */
@@ -834,7 +837,7 @@ static void WmDtPopupHelpCB (
            do
            {
                ptr = DtStrchr (pTemp->workspaces, '*');
-               if (ptr != NULL) *ptr = NULL;
+               if (ptr != NULL) *ptr = '\0';
                
                atom_names = 
                    (char **) XtRealloc ((char *)atom_names,
@@ -988,7 +991,9 @@ void WmDtHelpOnVersion (
     Widget helpButton = NULL;
     Widget backButton = NULL;
     Widget closeButton = NULL;
+#ifdef NO_MESSAGE_CATALOG
     XmString    label = NULL;
+#endif
 
    if((versionWidget != NULL) &&
        (XtIsManaged(versionWidget)))
@@ -1032,7 +1037,9 @@ void WmDtHelpOnVersion (
 #endif
 
        XtSetValues(closeButton, setArgs2, n2);
+#ifdef NO_MESSAGE_CATALOG
        if(label)XmStringFree(label);
+#endif
 
        printButton = DtHelpQuickDialogGetChild( versionWidget, 
                                             DtHELP_QUICK_PRINT_BUTTON );
@@ -1088,8 +1095,8 @@ WmDtHelp (String args)
     WmPanelistObject  pPanelist;
     char *theHelpVolume = WM_DT_HELP_VOLUME;
     char *theHelpTopic  = WM_DT_HELP_TOPIC;
-    char volume[MAXWMPATH + 1];
-    char topic[MAXWMPATH + 1];
+    unsigned char volume[MAXWMPATH + 1];
+    unsigned char topic[MAXWMPATH + 1];
     int  argCount = 0;
 
 
@@ -1100,27 +1107,27 @@ WmDtHelp (String args)
 
     pPanelist = (WmPanelistObject) pSD->wPanelist;
     
-    if (theWidget = O_Panel(pPanelist))
+    if ((theWidget = O_Panel(pPanelist)))
     {
        if (args )
        {
            /*
             * parse args for volume and topic 
             */
-           WmDtGetHelpArgs((unsigned char*)args, &volume, &topic, &argCount);
+           WmDtGetHelpArgs(args, volume, topic, &argCount);
            if (argCount == 1)
            {
                WmDtDisplayTopic(pSD->screenTopLevelW1, 
                                  theHelpVolume, 
-                                 topic, 
+                                 (char *)topic, 
                                  DtHELP_TYPE_TOPIC, theWidget, True,
                                  NULL, 0, NULL, False, NULL);
            }
            else
            {
                WmDtDisplayTopic(pSD->screenTopLevelW1, 
-                                 volume, 
-                                 topic, 
+                                 (char *)volume, 
+                                 (char *)topic, 
                                  DtHELP_TYPE_TOPIC, theWidget, False,
                                  NULL, 0, NULL, False, NULL);
            }
@@ -1171,7 +1178,7 @@ WmDtHelpMode (void)
     int iStatus;
     String sTmp, sMessage, sTitle;
 
-    iStatus = WmDtReturnSelectedWidget(wmGD.topLevelW, NULL
+    iStatus = WmDtReturnSelectedWidget(wmGD.topLevelW, None
                        &selectedWidget);
 
     switch (iStatus)
@@ -1661,7 +1668,7 @@ RestoreHelpDialogs(
     int wsCnt;    
     int cCount;
     int cachedCount=0;         
-    char dialogName[10];
+    char dialogName[18];
 
     ClientData *pCD = NULL;
     char *tTitle = NULL;
@@ -1690,7 +1697,7 @@ RestoreHelpDialogs(
        }
        xrm_name [0] = XrmStringToQuark ("wsHelp");
        xrm_name [1] = XrmStringToQuark ("onScreen");
-       xrm_name [2] = NULL;
+       xrm_name [2] = NULLQUARK;
        
        
        if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)) 
@@ -1870,7 +1877,7 @@ RestoreHelpDialogs(
 
        xrm_name [0] = XrmStringToQuark ("cachedHelp");
        xrm_name [1] = XrmStringToQuark ("cachedCount");
-       xrm_name [2] = NULL;
+       xrm_name [2] = NULLQUARK;
        
        
        if (XrmQGetResource (db, xrm_name, xrm_name, &rep_type, &value)) 
@@ -1881,8 +1888,8 @@ RestoreHelpDialogs(
            {
                sprintf (dialogName,  "oWsHelp%d", cCount);
                xrm_name [0] = XrmStringToQuark (dialogName);
-               xrm_name [1] = NULL;
-               xrm_name [2] = NULL;
+               xrm_name [1] = NULLQUARK;
+               xrm_name [2] = NULLQUARK;
 
                displayTopicInfo.xPos = 0;
                displayTopicInfo.xPos = 0;
@@ -2127,7 +2134,7 @@ SaveHelpResources(
         res_class = DT_WM_RESOURCE_CLASS;
     }
 
-    sprintf (screenName, "%d\0", pSD->screen);
+    sprintf (screenName, "%d", pSD->screen);
 
     sprintf (buffer, "%s*%s*%s:  \\n ", res_class,  screenName, 
             WmNhelpResources);
@@ -2341,7 +2348,7 @@ SaveHelpResources(
                if (pCDforHelp)
                {
                    thisCnt = 0;
-                   sprintf(workspaces,"");
+                   sprintf(workspaces, "%s", "");
                    for (wsCnt = 0; wsCnt < pSD->numWorkspaces;
                         wsCnt++)
                    {
@@ -2552,7 +2559,7 @@ wmDtHelpSetPosition(
     int n;
     XFontStruct *font;
     Dimension height;
-    Window wGroup;
+    Window wGroup = None;
     int x, y;
     ClientData *pCDforHelp;
 
@@ -2675,7 +2682,7 @@ wmDtHelpSetPosition(
     }
     else
     {
-        if (wGroup != 0)
+        if (wGroup != None)
        {
            HideHelpDialog (pSD, True);
        }
@@ -2784,7 +2791,9 @@ wmDtErrorDialog(
 
     if (pSD->dtHelp.errorDialog == NULL)
     {
+#ifdef NO_MESSAGE_CATALOG
        XmString tmpXmString = (XmString)NULL;
+#endif
 
        ac = 0;
        XtSetArg (al[ac], XmNmessageString, xmsMessage);        ac++;
@@ -2812,8 +2821,10 @@ wmDtErrorDialog(
         pSD->dtHelp.errorDialog =
            XmCreateErrorDialog (wParent, "Error Dialog", al, ac);
 
+#ifdef NO_MESSAGE_CATALOG
        if (tmpXmString)
            XmStringFree(tmpXmString);
+#endif
 
        wTemp = XmMessageBoxGetChild (pSD->dtHelp.errorDialog, 
                        XmDIALOG_HELP_BUTTON);