dtcm: Coverity 89287
[oweals/cde.git] / cde / programs / dtwm / WmHelp.c
index f37d2ec656e4097e6c34bb7e09614f44adfe7fbd..198c55b01a595c0cfe26da49c42b354ce3bd1a0c 100644 (file)
  * details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with these librararies and programs; if not, write
+ * License along with these libraries and programs; if not, write
  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  * Floor, Boston, MA 02110-1301 USA
  */
-/* $TOG: WmHelp.c /main/8 1997/06/18 17:30:51 samborn $ */
-#ifdef WSM
 /* 
  * (c) Copyright 1987, 1988, 1989, 1990, 1992, 1993 HEWLETT-PACKARD COMPANY 
  * (c) Copyright 1989, 1990, 1991, 1992 OPEN SOFTWARE FOUNDATION, INC. 
  * ALL RIGHTS RESERVED 
-*/ 
-#ifdef REV_INFO
-#ifndef lint
-static char rcsid[] = ""
-#endif
-#endif
+*/
 
 /*
  * Included Files:
@@ -48,9 +41,7 @@ static char rcsid[] = ""
 #include "WmHelp.h"
 #include "WmCDecor.h"
 #include "WmResParse.h"
-#ifdef PANELIST
 #include "WmPanelP.h"
-#endif /* PANELIST */
 #include "WmResNames.h"
 #include "WmWrkspace.h"
 #include "DataBaseLoad.h"
@@ -649,7 +640,7 @@ static void WmDtCloseHelpCB (
     pTemp = pSD->cachedHelp;
 
     /* Search our Cache List for the closed help dialog */
-    while ((pTemp->helpDialog != helpDialog) && (pTemp != NULL))
+    while (pTemp && (pTemp->helpDialog != helpDialog))
     {
        pTemp = pTemp->pNext;
     }
@@ -837,7 +828,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,
@@ -991,7 +982,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)))
@@ -1035,7 +1028,9 @@ void WmDtHelpOnVersion (
 #endif
 
        XtSetValues(closeButton, setArgs2, n2);
+#ifdef NO_MESSAGE_CATALOG
        if(label)XmStringFree(label);
+#endif
 
        printButton = DtHelpQuickDialogGetChild( versionWidget, 
                                             DtHELP_QUICK_PRINT_BUTTON );
@@ -1091,8 +1086,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;
 
 
@@ -1103,27 +1098,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);
            }
@@ -1174,7 +1169,7 @@ WmDtHelpMode (void)
     int iStatus;
     String sTmp, sMessage, sTitle;
 
-    iStatus = WmDtReturnSelectedWidget(wmGD.topLevelW, NULL
+    iStatus = WmDtReturnSelectedWidget(wmGD.topLevelW, None
                        &selectedWidget);
 
     switch (iStatus)
@@ -1664,7 +1659,7 @@ RestoreHelpDialogs(
     int wsCnt;    
     int cCount;
     int cachedCount=0;         
-    char dialogName[10];
+    char dialogName[18];
 
     ClientData *pCD = NULL;
     char *tTitle = NULL;
@@ -1693,7 +1688,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)) 
@@ -1873,7 +1868,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)) 
@@ -1884,8 +1879,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;
@@ -2040,6 +2035,8 @@ RestoreHelpDialogs(
        XrmDestroyDatabase(db);
     }
 #endif /* NO_DT */
+
+    return True;
 } /* END OF FUNCTION  RestoreHelpDialogs */
 
 /*************************************<->*************************************
@@ -2130,7 +2127,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);
@@ -2344,7 +2341,7 @@ SaveHelpResources(
                if (pCDforHelp)
                {
                    thisCnt = 0;
-                   sprintf(workspaces,"");
+                   sprintf(workspaces, "%s", "");
                    for (wsCnt = 0; wsCnt < pSD->numWorkspaces;
                         wsCnt++)
                    {
@@ -2555,7 +2552,7 @@ wmDtHelpSetPosition(
     int n;
     XFontStruct *font;
     Dimension height;
-    Window wGroup;
+    Window wGroup = None;
     int x, y;
     ClientData *pCDforHelp;
 
@@ -2678,7 +2675,7 @@ wmDtHelpSetPosition(
     }
     else
     {
-        if (wGroup != 0)
+        if (wGroup != None)
        {
            HideHelpDialog (pSD, True);
        }
@@ -2776,9 +2773,7 @@ wmDtErrorDialog(
     unsigned int mask;
     Dimension dWidth, dHeight;
     Position x, y;
-#ifdef PANELIST
     WmPanelistObject  pPanelist;
-#endif /* PANELIST */
 
     xmsMessage = 
            XmStringCreateLocalized (sMessage);
@@ -2787,7 +2782,9 @@ wmDtErrorDialog(
 
     if (pSD->dtHelp.errorDialog == NULL)
     {
+#ifdef NO_MESSAGE_CATALOG
        XmString tmpXmString = (XmString)NULL;
+#endif
 
        ac = 0;
        XtSetArg (al[ac], XmNmessageString, xmsMessage);        ac++;
@@ -2815,8 +2812,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);
@@ -3038,7 +3037,6 @@ wmDtErrorDialogPopupCB(
 } /* END OF FUNCTION wmDtErrorDialogPopupCB */
 
 /****************************   eof    ***************************/
-#endif /* WSM */