strlcpy restricted to array length.
[openafs.git] / src / afsmonitor / afsmon-win.c
index c9b120e..ed787a0 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Copyright 2000, International Business Machines Corporation and others.
  * All Rights Reserved.
- * 
+ *
  * This software has been released under the terms of the IBM Public
  * License.  For details, see the LICENSE file in the top-level source
  * directory or online at http://www.openafs.org/dl/license10.html
 #include <afsconfig.h>
 #include <afs/param.h>
 
-RCSID
-    ("$Header$");
-
 #include <stdio.h>
+#include <string.h>
 #include <signal.h>
 #include <math.h>
-#include <cmd.h>
+#include <afs/cmd.h>
 #include <string.h>
 #undef IN
 #include <time.h>
 
-#include <gtxwindows.h>                /*Generic window package */
-#include <gtxobjects.h>                /*Object definitions */
-#include <gtxkeymap.h>
-#if 0
-#include <gtxtextcb.h>         /*Text object circular buffer interface */
-#include <gtxtextobj.h>                /*Text object interface */
-#endif
-#include <gtxlightobj.h>       /*Light object interface */
-#include <gtxcurseswin.h>      /*Curses window package */
-#include <gtxdumbwin.h>                /*Dumb terminal window package */
-#include <gtxX11win.h>         /*X11 window package */
-#include <gtxframe.h>          /*Frame package */
+#include <afs/gtxwindows.h>            /*Generic window package */
+#include <afs/gtxobjects.h>            /*Object definitions */
+#include <afs/gtxkeymap.h>
+#include <afs/gtxlightobj.h>   /*Light object interface */
+#include <afs/gtxcurseswin.h>  /*Curses window package */
+#include <afs/gtxdumbwin.h>            /*Dumb terminal window package */
+#include <afs/gtxX11win.h>             /*X11 window package */
+#include <afs/gtxframe.h>              /*Frame package */
 
 #include <afs/xstat_fs.h>
 #include <afs/xstat_cm.h>
 
+#include <roken.h>
 
 #include "afsmonitor.h"
 #include "afsmon-labels.h"
@@ -331,8 +326,6 @@ initLightObject(char *a_name, int a_x, int a_y, int a_width,
 {                              /*initLightObject */
     struct onode *newlightp;   /*Ptr to new light onode */
     struct gator_light_crparams light_crparams;        /*Light creation params */
-    char *truncname;           /*Truncated name, if needed */
-    int name_len;              /*True length of name */
 
 /* the following debug statement floods the debug file */
 #ifdef DEBUG_DETAILED
@@ -351,20 +344,17 @@ initLightObject(char *a_name, int a_x, int a_y, int a_width,
      * received.
      */
     light_crparams.onode_params.cr_type = GATOR_OBJ_LIGHT;
-    name_len = strlen(a_name);
 
-    if (name_len <= a_width)
-       sprintf(light_crparams.onode_params.cr_name, "%s", a_name);
-    else {
-       /*
-        * We need to truncate the given name, leaving a `*' at the end to
-        * show us it's been truncated.
-        */
-       truncname = light_crparams.onode_params.cr_name;
-       strncpy(truncname, a_name, a_width - 1);
-       truncname[a_width - 1] = '*';
-       truncname[a_width] = 0;
-    }
+    if (a_width >= sizeof(light_crparams.onode_params.cr_name))
+       a_width = sizeof(light_crparams.onode_params.cr_name) - 1;
+
+    if (a_width < 1)
+       a_width = 1;
+
+    if (strlcpy(light_crparams.onode_params.cr_name, a_name, a_width + 1) >= a_width + 1)
+       /* The name is truncated, put a '*' at the end to note */
+       light_crparams.onode_params.cr_name[a_width - 1] = '*';
+
     light_crparams.onode_params.cr_x = a_x;
     light_crparams.onode_params.cr_y = a_y;
     light_crparams.onode_params.cr_width = a_width;
@@ -421,7 +411,7 @@ initLightObject(char *a_name, int a_x, int a_y, int a_width,
  *------------------------------------------------------------------------*/
 
 int
-justify_light(char *a_srcbuff, char *a_dstbuff, int a_dstwidth, 
+justify_light(char *a_srcbuff, char *a_dstbuff, int a_dstwidth,
              int a_justification, int a_rightTrunc)
 {                              /*justify_light */
 
@@ -449,7 +439,7 @@ justify_light(char *a_srcbuff, char *a_dstbuff, int a_dstwidth,
      * we automatically shorten up.
      */
     if (a_dstwidth > GATOR_LABEL_CHARS) {
-       /* 
+       /*
         * if (afsmon_debug) {
         * fprintf(debugFD,
         * "[%s] Dest width (%d) > gtx buflen (%d), shrinking dest width\n",
@@ -539,7 +529,7 @@ justify_light(char *a_srcbuff, char *a_dstbuff, int a_dstwidth,
  *
  * Description:
  *     Call the exit routine. This function is mapped
- *     to the keys Q and \ 3 in all the frames and is called by the 
+ *     to the keys Q and \ 3 in all the frames and is called by the
  *     gtx input server.
  *----------------------------------------------------------------------*/
 
@@ -577,8 +567,8 @@ int
 ovw_refresh(int a_pageNum,     /* page to refresh overview display */
            int a_updateType)   /* OVW_UPDATE_FS = update fs column only,
                                 * OVW_UPDATE_CM = update cm column only,
-                                * OVW_UPDATE_BOTH = update fs & cm columns. Note that 
-                                * we do not want to update a column until the 
+                                * OVW_UPDATE_BOTH = update fs & cm columns. Note that
+                                * we do not want to update a column until the
                                 * corresponding probe cycle has completed */
 {                              /* ovw_refresh */
 
@@ -602,7 +592,7 @@ ovw_refresh(int a_pageNum,  /* page to refresh overview display */
        fflush(debugFD);
     }
 
-    /* if the data is not yet available  ie., not one probe cycle has 
+    /* if the data is not yet available  ie., not one probe cycle has
      * completed, do nothing */
 
     if ((a_updateType & OVW_UPDATE_FS) && !fs_Data_Available)
@@ -774,9 +764,9 @@ ovw_refresh(int a_pageNum,  /* page to refresh overview display */
                /* highlighten if overflowed or probe failed */
 
                if (fsDataP->ovfCount || !fsDataP->probeOK)
-                   code = gator_light_set(*tmp_fsNames_o, 1);
+                   gator_light_set(*tmp_fsNames_o, 1);
                else
-                   code = gator_light_set(*tmp_fsNames_o, 0);
+                   gator_light_set(*tmp_fsNames_o, 0);
 
 
            } else {            /* no more hosts, blank the rest of the entries */
@@ -848,9 +838,9 @@ ovw_refresh(int a_pageNum,  /* page to refresh overview display */
 
                /* highlighten if overflow or if probe failed */
                if (cmDataP->ovfCount || !cmDataP->probeOK)
-                   code = gator_light_set(*tmp_cmNames_o, 1);
+                   gator_light_set(*tmp_cmNames_o, 1);
                else
-                   code = gator_light_set(*tmp_cmNames_o, 0);
+                   gator_light_set(*tmp_cmNames_o, 0);
 
 
            } else {            /* no more hosts, blank the rest of the entries */
@@ -1038,7 +1028,6 @@ create_ovwFrame_objects(void)
     int hostLines;             /* number of lines of host names to display */
     struct onode **ovw_fsNames_o_Ptr;  /* index to list of fs names onodes */
     struct onode **ovw_cmNames_o_Ptr;  /* index to list of cm names onodes */
-    int code;
     int i;
 
     if (afsmon_debug) {
@@ -1068,8 +1057,8 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create initMsg_o onode\n", rn);
        afsmon_Exit(250);
     }
-    code = gtxframe_AddToList(ovwFrame, initMsg_o);
-    code = gator_light_set(initMsg_o, HIGHLIGHT);
+    gtxframe_AddToList(ovwFrame, initMsg_o);
+    gator_light_set(initMsg_o, HIGHLIGHT);
     initMsg_on = 1;
 
 
@@ -1081,8 +1070,8 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create command onode\n", rn);
        afsmon_Exit(265);
     }
-    code = gtxframe_AddToList(ovwFrame, ovw_cmd_o);
-    code = gator_light_set(ovw_cmd_o, HIGHLIGHT);
+    gtxframe_AddToList(ovwFrame, ovw_cmd_o);
+    gator_light_set(ovw_cmd_o, HIGHLIGHT);
 
     /* create the program name object */
 
@@ -1091,8 +1080,8 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create programName onode\n", rn);
        afsmon_Exit(255);
     }
-    code = gtxframe_AddToList(ovwFrame, ovw_progName_o);
-    code = gator_light_set(ovw_progName_o, HIGHLIGHT);
+    gtxframe_AddToList(ovwFrame, ovw_progName_o);
+    gator_light_set(ovw_progName_o, HIGHLIGHT);
 
     /* create the page number object */
 
@@ -1103,8 +1092,8 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
        afsmon_Exit(260);
     }
-    code = gtxframe_AddToList(ovwFrame, ovw_pageNum_o);
-    code = gator_light_set(ovw_pageNum_o, HIGHLIGHT);
+    gtxframe_AddToList(ovwFrame, ovw_pageNum_o);
+    gator_light_set(ovw_pageNum_o, HIGHLIGHT);
 
     /* create the probe number object */
     ovw_probeNum_o =
@@ -1114,8 +1103,8 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create probe number onode\n", rn);
        afsmon_Exit(270);
     }
-    code = gtxframe_AddToList(ovwFrame, ovw_probeNum_o);
-    code = gator_light_set(ovw_probeNum_o, HIGHLIGHT);
+    gtxframe_AddToList(ovwFrame, ovw_probeNum_o);
+    gator_light_set(ovw_probeNum_o, HIGHLIGHT);
 
     /* create the numFS monitored object */
     ovw_numFS_o = initLightObject("", 0, 2, FC_NUMHOSTS_O_WIDTH, afsmon_win);
@@ -1123,7 +1112,7 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create numFS onode\n", rn);
        afsmon_Exit(275);
     }
-    code = gtxframe_AddToList(ovwFrame, ovw_numFS_o);
+    gtxframe_AddToList(ovwFrame, ovw_numFS_o);
 
     /* create the numCM monitored object */
     ovw_numCM_o =
@@ -1132,7 +1121,7 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create numCM_o onode\n", rn);
        afsmon_Exit(280);
     }
-    code = gtxframe_AddToList(ovwFrame, ovw_numCM_o);
+    gtxframe_AddToList(ovwFrame, ovw_numCM_o);
 
     /* create the number-of-FS-alerts object */
     ovw_FSalerts_o =
@@ -1141,7 +1130,7 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create FSalerts_o onode\n", rn);
        afsmon_Exit(285);
     }
-    code = gtxframe_AddToList(ovwFrame, ovw_FSalerts_o);
+    gtxframe_AddToList(ovwFrame, ovw_FSalerts_o);
 
     /* create the number-of-CM-alerts object */
     ovw_CMalerts_o =
@@ -1150,15 +1139,13 @@ create_ovwFrame_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create CMalerts_o onode\n", rn);
        afsmon_Exit(290);
     }
-    code = gtxframe_AddToList(ovwFrame, ovw_CMalerts_o);
+    gtxframe_AddToList(ovwFrame, ovw_CMalerts_o);
 
     /* create file-server-name and cache-manager-names objects */
     ovw_numHosts_perPage = maxY - OVW_NUM_FIXED_LINES;
 
     /* allocate memory for a list of onode pointers for file server names */
-    ovw_fsNames_o =
-       (struct onode **)malloc(sizeof(struct onode *) *
-                               ovw_numHosts_perPage);
+    ovw_fsNames_o = malloc(sizeof(struct onode *) * ovw_numHosts_perPage);
     if (ovw_fsNames_o == NULL) {
        sprintf(errMsg, "[ %s ] Failed to allocate memory for FS onodes\n",
                rn);
@@ -1182,16 +1169,14 @@ create_ovwFrame_objects(void)
         * fflush(debugFD);
         * }
         */
-       code = gtxframe_AddToList(ovwFrame, *ovw_fsNames_o_Ptr);
+       gtxframe_AddToList(ovwFrame, *ovw_fsNames_o_Ptr);
        ovw_fsNames_o_Ptr++;
 
     }
 
 
     /* allocate memory for a list of onode pointers for cache manager names */
-    ovw_cmNames_o =
-       (struct onode **)malloc(sizeof(struct onode *) *
-                               ovw_numHosts_perPage);
+    ovw_cmNames_o = malloc(sizeof(struct onode *) * ovw_numHosts_perPage);
     if (ovw_cmNames_o == NULL) {
        sprintf(errMsg, "[ %s ] Failed to allocate memory for CM onodes\n",
                rn);
@@ -1208,7 +1193,7 @@ create_ovwFrame_objects(void)
            sprintf(errMsg, "[ %s ] Failed to create a CM name onode\n", rn);
            afsmon_Exit(310);
        }
-       code = gtxframe_AddToList(ovwFrame, *ovw_cmNames_o_Ptr);
+       gtxframe_AddToList(ovwFrame, *ovw_cmNames_o_Ptr);
        ovw_cmNames_o_Ptr++;
     }
 
@@ -1359,9 +1344,9 @@ resolve_CmdLine(char *a_buffer,       /* buffer to copy command line */
  *     The data in the file server & cache manager frames are displayed
  *     in two objects, one below the other. If the data is too long to
  *     fit in the first object it will overflow into the next. This is
- *     to conserve real estate on the screen. This function copies the 
+ *     to conserve real estate on the screen. This function copies the
  *     contents of the source buffer adjusted to the two objects if the
- *     probe had succeded. Otherwise it enters "--" in the first object 
+ *     probe had succeded. Otherwise it enters "--" in the first object
  *     blanks out the second. If the object needs to be highlightned
  *     (due to a threshold crossing) it is done.
  *
@@ -1526,7 +1511,7 @@ display_Server_label(char *a_srcBuf,
        part[i][j] = '\0';
     }
 
-    /* 
+    /*
      * if (afsmon_debug) {
      * fprintf(debugFD,"[ %s ] LABELS %s -> %s %s %s\n",
      * rn, a_srcBuf, part[0], part[1], part[2]);
@@ -1564,12 +1549,12 @@ display_Server_label(char *a_srcBuf,
  *
  * Description:
  *     Refresh the File Servers screen with the given page number starting
- *     at the given left-column number. The appropriate contents of 
- *     prev_fsData are displayed. 
+ *     at the given left-column number. The appropriate contents of
+ *     prev_fsData are displayed.
  *     First the status labels at the four corners of the screen are
  *     updated. Next the column labels are updated and then each row
  *     of statistics.
- *     
+ *
  * Returns:
  *     Success: 0
  *     Failure: Exits afsmoitor on a severe error.
@@ -1598,7 +1583,7 @@ fs_refresh(int a_pageNum, /* page to display */
     int code;
     int fsIdx;
     int labelIdx;
-    int dataIndex;             /* index to the data[] field of 
+    int dataIndex;             /* index to the data[] field of
                                 * struct fs_Display_Data */
 
     if (afsmon_debug) {
@@ -1608,7 +1593,7 @@ fs_refresh(int a_pageNum, /* page to display */
     }
 
 
-    /* if the data is not yet available, ie., not one probe cycle has 
+    /* if the data is not yet available, ie., not one probe cycle has
      * completed, do nothing */
 
     if (!fs_Data_Available)
@@ -1659,7 +1644,7 @@ fs_refresh(int a_pageNum, /* page to display */
     /* command line */
 
     /* figure out what we need to show in the prompt & set the page type */
-    /* the fs_pageType variable is in turn used by the keyboard handler 
+    /* the fs_pageType variable is in turn used by the keyboard handler
      * routines to call fs_refresh() with the correct parameters */
 
     fs_pageType = resolve_CmdLine(cmdLine, 1 /* fs frame */ , a_pageNum,
@@ -1717,15 +1702,13 @@ fs_refresh(int a_pageNum,       /* page to display */
 
        if (labelIdx < fs_numCols) {
            dataIndex = fs_Display_map[labelIdx];
-           code =
-               display_Server_label(fs_labels[dataIndex], *fsLabels_o_Ptr1,
-                                    *fsLabels_o_Ptr2, *fsLabels_o_Ptr3);
+           display_Server_label(fs_labels[dataIndex], *fsLabels_o_Ptr1,
+                                *fsLabels_o_Ptr2, *fsLabels_o_Ptr3);
 
            labelIdx++;         /* next label */
        } else {
-           code =
-               display_Server_label("//", *fsLabels_o_Ptr1, *fsLabels_o_Ptr2,
-                                    *fsLabels_o_Ptr3);
+           display_Server_label("//", *fsLabels_o_Ptr1, *fsLabels_o_Ptr2,
+                                *fsLabels_o_Ptr3);
        }
 
        fsLabels_o_Ptr1++;      /* next onode in label row 1 */
@@ -1767,7 +1750,7 @@ fs_refresh(int a_pageNum, /* page to display */
 
            /* display the hostname , first names only please! */
 
-           sprintf(printBuf, fsDataP->hostName);
+           sprintf(printBuf, "%s", fsDataP->hostName);
            for (j = 0; j < strlen(printBuf); j++) {
                if (printBuf[j] == '.') {
                    printBuf[j] = '\0';
@@ -1791,7 +1774,7 @@ fs_refresh(int a_pageNum, /* page to display */
             * overflow flag is set and highlight if so. if the probe had failed
             * enter "--" is all columns */
 
-           /* each host has two rows of slots for datums. get the pointers to 
+           /* each host has two rows of slots for datums. get the pointers to
             * both the arrays */
 
            firstSlot_o_Ptr = tmp_fs_lines_P->data_o[0];
@@ -1806,17 +1789,16 @@ fs_refresh(int a_pageNum,       /* page to display */
 
                    dataIndex = fs_Display_map[fs_curr_RCol];
 
-                   code =
-                       display_Server_datum(fsDataP->data[dataIndex],
-                                            *firstSlot_o_Ptr,
-                                            *secondSlot_o_Ptr,
-                                            fsDataP->probeOK, RIGHT_JUSTIFY,
-                                            fsDataP->threshOvf[dataIndex]);
+                   display_Server_datum(fsDataP->data[dataIndex],
+                                        *firstSlot_o_Ptr,
+                                        *secondSlot_o_Ptr,
+                                        fsDataP->probeOK, RIGHT_JUSTIFY,
+                                        fsDataP->threshOvf[dataIndex]);
 
                    fs_curr_RCol++;
                } else {        /* no more data, blank out columns */
-                   code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1,     /* probe ok */
-                                               RIGHT_JUSTIFY, 0);      /* no overflow */
+                   display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1,    /* probe ok */
+                                        RIGHT_JUSTIFY, 0);     /* no overflow */
                }
 
 
@@ -1855,8 +1837,8 @@ fs_refresh(int a_pageNum, /* page to display */
            secondSlot_o_Ptr = tmp_fs_lines_P->data_o[1];
 
            for (k = 0; k < fs_cols_perPage; k++) {
-               code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
-                                           RIGHT_JUSTIFY, 0);  /* dont highlight */
+               display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1,        /* probe OK */
+                                    RIGHT_JUSTIFY, 0); /* dont highlight */
 
                firstSlot_o_Ptr++;
                secondSlot_o_Ptr++;
@@ -1905,7 +1887,7 @@ Switch_fs_2_ovw(void *d1, void *d2)
  * Switch_fs_2_cm()
  *
  * Description:
- *     Switch from the File Server screen to the Cache Managers screen. 
+ *     Switch from the File Server screen to the Cache Managers screen.
  *----------------------------------------------------------------------*/
 int
 Switch_fs_2_cm(void *d1, void *d2)
@@ -1921,7 +1903,7 @@ Switch_fs_2_cm(void *d1, void *d2)
  * Switch_fs_next()
  *
  * Description:
- *     Switch to next page of file server screen 
+ *     Switch to next page of file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_fs_next(void *d1, void *d2)
@@ -1938,7 +1920,7 @@ Switch_fs_next(void *d1, void *d2)
  * Switch_fs_last()
  *
  * Description:
- *     Switch to last page of file server screen 
+ *     Switch to last page of file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_fs_last(void *d1, void *d2)
@@ -1955,7 +1937,7 @@ Switch_fs_last(void *d1, void *d2)
  * Switch_fs_prev()
  *
  * Description:
- *     Switch to previous page of file server screen 
+ *     Switch to previous page of file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_fs_prev(void *d1, void *d2)
@@ -1971,7 +1953,7 @@ Switch_fs_prev(void *d1, void *d2)
  * Switch_fs_first()
  *
  * Description:
- *     Switch to first page of file server screen 
+ *     Switch to first page of file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_fs_first(void *d1, void *d2)
@@ -1987,7 +1969,7 @@ Switch_fs_first(void *d1, void *d2)
  * Switch_fs_left()
  *
  * Description:
- *     Scroll left on the file server screen 
+ *     Scroll left on the file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_fs_left(void *d1, void *d2)
@@ -2004,7 +1986,7 @@ Switch_fs_left(void *d1, void *d2)
  * Switch_fs_leftmost()
  *
  * Description:
- *     Scroll to first column on  the file server screen 
+ *     Scroll to first column on  the file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_fs_leftmost(void *d1, void *d2)
@@ -2020,7 +2002,7 @@ Switch_fs_leftmost(void *d1, void *d2)
  * Switch_fs_right()
  *
  * Description:
- *     Scroll right on the file server screen 
+ *     Scroll right on the file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_fs_right(void *d1, void *d2)
@@ -2036,7 +2018,7 @@ Switch_fs_right(void *d1, void *d2)
  * Switch_fs_rightmost()
  *
  * Description:
- *     Scroll to last column on the file server screen 
+ *     Scroll to last column on the file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_fs_rightmost(void *d1, void *d2)
@@ -2082,7 +2064,6 @@ create_FSframe_objects(void)
     struct onode **fsLabels_o_Ptr;
     int x_pos;
     int y_pos;
-    int code;
     int i;
     int j;
     int numBytes;
@@ -2102,13 +2083,13 @@ create_FSframe_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create fs command onode\n", rn);
        afsmon_Exit(340);
     }
-    code = gtxframe_AddToList(fsFrame, fs_cmd_o);
-    code = gator_light_set(fs_cmd_o, HIGHLIGHT);
+    gtxframe_AddToList(fsFrame, fs_cmd_o);
+    gator_light_set(fs_cmd_o, HIGHLIGHT);
 
     /* we already have the dimensions for the frame - same as the ovw frame */
     /* use the ovw program name object for the fs screen too */
 
-    code = gtxframe_AddToList(fsFrame, ovw_progName_o);
+    gtxframe_AddToList(fsFrame, ovw_progName_o);
 
 
     /* create the page number object */
@@ -2120,8 +2101,8 @@ create_FSframe_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
        afsmon_Exit(335);
     }
-    code = gtxframe_AddToList(fsFrame, fs_pageNum_o);
-    code = gator_light_set(fs_pageNum_o, HIGHLIGHT);
+    gtxframe_AddToList(fsFrame, fs_pageNum_o);
+    gator_light_set(fs_pageNum_o, HIGHLIGHT);
 
     /* create the probe number object */
     fs_probeNum_o =
@@ -2132,8 +2113,8 @@ create_FSframe_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create fs probeNum onode\n", rn);
        afsmon_Exit(345);
     }
-    code = gtxframe_AddToList(fsFrame, fs_probeNum_o);
-    code = gator_light_set(fs_probeNum_o, HIGHLIGHT);
+    gtxframe_AddToList(fsFrame, fs_probeNum_o);
+    gator_light_set(fs_probeNum_o, HIGHLIGHT);
 
 
     /* create the numFS monitored object */
@@ -2146,7 +2127,7 @@ create_FSframe_objects(void)
                "[ %s ] Failed to create numFS onode for the fs frame\n", rn);
        afsmon_Exit(350);
     }
-    code = gtxframe_AddToList(fsFrame, fs_numFS_o);
+    gtxframe_AddToList(fsFrame, fs_numFS_o);
 
     /* create the "more columns to left" indicator */
     fs_leftArrows_o =
@@ -2157,7 +2138,7 @@ create_FSframe_objects(void)
                rn);
        afsmon_Exit(355);
     }
-    code = gtxframe_AddToList(fsFrame, fs_leftArrows_o);
+    gtxframe_AddToList(fsFrame, fs_leftArrows_o);
 
     /* create the "more columns to right" indicator */
     fs_rightArrows_o =
@@ -2169,7 +2150,7 @@ create_FSframe_objects(void)
                rn);
        afsmon_Exit(360);
     }
-    code = gtxframe_AddToList(fsFrame, fs_rightArrows_o);
+    gtxframe_AddToList(fsFrame, fs_rightArrows_o);
 
 
 
@@ -2193,7 +2174,7 @@ create_FSframe_objects(void)
      * the file server statistics */
 
     numBytes = fs_numHosts_perPage * sizeof(struct ServerInfo_line);
-    fs_lines = (struct ServerInfo_line *)malloc(numBytes);
+    fs_lines = malloc(numBytes);
     if (fs_lines == (struct ServerInfo_line *)0) {
        sprintf(errMsg,
                "[ %s ] Failed to allocate %d bytes for FS data lines\n", rn,
@@ -2201,14 +2182,14 @@ create_FSframe_objects(void)
        afsmon_Exit(365);
     }
 
-    /* for each line of server statistics allocate memory to store two arrays 
+    /* for each line of server statistics allocate memory to store two arrays
      * of data onodes */
 
     fs_lines_Ptr = fs_lines;
     for (i = 0; i < fs_numHosts_perPage; i++) {
        for (arrIdx = 0; arrIdx < 2; arrIdx++) {
            numBytes = fs_cols_perPage * sizeof(struct onode *);
-           fs_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes);
+           fs_lines_Ptr->data_o[arrIdx] = malloc(numBytes);
            if (fs_lines_Ptr->data_o[arrIdx] == NULL) {
                sprintf(errMsg,
                        "[ %s ] Failed to allocate %d bytes for FS data onodes\n",
@@ -2232,7 +2213,7 @@ create_FSframe_objects(void)
            sprintf(errMsg, "[ %s ] Failed to create an FS name onode\n", rn);
            afsmon_Exit(375);
        }
-       code = gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o);
+       gtxframe_AddToList(fsFrame, fs_lines_Ptr->host_o);
 
        /* if (afsmon_debug) {
         * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
@@ -2263,7 +2244,7 @@ create_FSframe_objects(void)
                            "[ %s ] Failed to create an FS data onode\n", rn);
                    afsmon_Exit(380);
                }
-               code = gtxframe_AddToList(fsFrame, *fs_data_o_Ptr);
+               gtxframe_AddToList(fsFrame, *fs_data_o_Ptr);
 
                fs_data_o_Ptr++;
            }                   /* for each column */
@@ -2280,8 +2261,7 @@ create_FSframe_objects(void)
      * labels */
     for (arrIdx = 0; arrIdx < 3; arrIdx++) {
 
-       fsLabels_o[arrIdx] =
-           (struct onode **)malloc(sizeof(struct onode *) * fs_cols_perPage);
+       fsLabels_o[arrIdx] = malloc(sizeof(struct onode *) * fs_cols_perPage);
        if (fsLabels_o[arrIdx] == NULL) {
            sprintf(errMsg,
                    "[ %s ] Failed to allocate memory for FS label onodes\n",
@@ -2302,7 +2282,7 @@ create_FSframe_objects(void)
                        rn);
                afsmon_Exit(390);
            }
-           code = gtxframe_AddToList(fsFrame, *fsLabels_o_Ptr);
+           gtxframe_AddToList(fsFrame, *fsLabels_o_Ptr);
            fsLabels_o_Ptr++;
        }
 
@@ -2324,7 +2304,7 @@ create_FSframe_objects(void)
     keymap_BindToString(fsFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
     keymap_BindToString(fsFrame->keymap, "\ 3", afsmonExit_gtx, NULL, NULL);
 
-    /* o = overview, c = cm, n = next, p = prev, l = left, r = right 
+    /* o = overview, c = cm, n = next, p = prev, l = left, r = right
      * N = last page, P = first page, L = leftmost col, R = rightmost col */
 
     keymap_BindToString(fsFrame->keymap, "o", Switch_fs_2_ovw, NULL, NULL);
@@ -2348,12 +2328,12 @@ create_FSframe_objects(void)
  *
  * Description:
  *     Refresh the Cache Managers screen with the given page number starting
- *     at the given left-column number. The appropriate contents of 
- *     prev_cmData are displayed. 
+ *     at the given left-column number. The appropriate contents of
+ *     prev_cmData are displayed.
  *     First the status labels at the four corners of the screen are
  *     updated. Next the column labels are updated and then each row
  *     of statistics.
- *     
+ *
  * Returns:
  *     Success: 0
  *     Failure: Exits afsmoitor on a severe error.
@@ -2381,7 +2361,7 @@ cm_refresh(int a_pageNum,         /* page to display */
     int code;
     int cmIdx;
     int labelIdx;
-    int dataIndex;             /* index to the data[] field of 
+    int dataIndex;             /* index to the data[] field of
                                 * struct cm_Display_Data */
 
     if (afsmon_debug) {
@@ -2391,7 +2371,7 @@ cm_refresh(int a_pageNum,         /* page to display */
     }
 
 
-    /* if the data is not yet available, ie., not one probe cycle has 
+    /* if the data is not yet available, ie., not one probe cycle has
      * completed, do nothing */
 
     if (!cm_Data_Available)
@@ -2442,7 +2422,7 @@ cm_refresh(int a_pageNum,         /* page to display */
     /* command line */
 
     /* figure out what we need to show in the prompt & set the page type */
-    /* the cm_pageType variable is in turn used by the keyboard handler 
+    /* the cm_pageType variable is in turn used by the keyboard handler
      * routines to call cm_refresh() with the correct parameters */
 
     cm_pageType = resolve_CmdLine(cmdLine, 2 /* cm frame */ , a_pageNum,
@@ -2500,15 +2480,13 @@ cm_refresh(int a_pageNum,               /* page to display */
 
        if (labelIdx < cm_numCols) {
            dataIndex = cm_Display_map[labelIdx];
-           code =
-               display_Server_label(cm_labels[dataIndex], *cmLabels_o_Ptr1,
-                                    *cmLabels_o_Ptr2, *cmLabels_o_Ptr3);
+           display_Server_label(cm_labels[dataIndex], *cmLabels_o_Ptr1,
+                                *cmLabels_o_Ptr2, *cmLabels_o_Ptr3);
 
            labelIdx++;         /* next label */
        } else {
-           code =
-               display_Server_label("//", *cmLabels_o_Ptr1, *cmLabels_o_Ptr2,
-                                    *cmLabels_o_Ptr3);
+           display_Server_label("//", *cmLabels_o_Ptr1, *cmLabels_o_Ptr2,
+                                *cmLabels_o_Ptr3);
        }
 
        cmLabels_o_Ptr1++;      /* next onode in label row 1 */
@@ -2550,7 +2528,7 @@ cm_refresh(int a_pageNum,         /* page to display */
 
            /* display the hostname , first names only please! */
 
-           sprintf(printBuf, cmDataP->hostName);
+           sprintf(printBuf, "%s", cmDataP->hostName);
            for (j = 0; j < strlen(printBuf); j++) {
                if (printBuf[j] == '.') {
                    printBuf[j] = '\0';
@@ -2574,7 +2552,7 @@ cm_refresh(int a_pageNum,         /* page to display */
             * overflow flag is set and highlight if so. if the probe had failed
             * enter "--" is all columns */
 
-           /* each host has two rows of slots for datums. get the pointers to 
+           /* each host has two rows of slots for datums. get the pointers to
             * both the arrays */
 
            firstSlot_o_Ptr = tmp_cm_lines_P->data_o[0];
@@ -2589,17 +2567,16 @@ cm_refresh(int a_pageNum,               /* page to display */
 
                    dataIndex = cm_Display_map[cm_curr_RCol];
 
-                   code =
-                       display_Server_datum(cmDataP->data[dataIndex],
-                                            *firstSlot_o_Ptr,
-                                            *secondSlot_o_Ptr,
-                                            cmDataP->probeOK, RIGHT_JUSTIFY,
-                                            cmDataP->threshOvf[dataIndex]);
+                   display_Server_datum(cmDataP->data[dataIndex],
+                                        *firstSlot_o_Ptr,
+                                        *secondSlot_o_Ptr,
+                                        cmDataP->probeOK, RIGHT_JUSTIFY,
+                                        cmDataP->threshOvf[dataIndex]);
 
                    cm_curr_RCol++;
                } else {        /* no more data, blank out columns */
-                   code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1,     /* probe ok */
-                                               RIGHT_JUSTIFY, 0);      /* no overflow */
+                   display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1,    /* probe ok */
+                                        RIGHT_JUSTIFY, 0);     /* no overflow */
                }
 
 
@@ -2638,7 +2615,7 @@ cm_refresh(int a_pageNum,         /* page to display */
            secondSlot_o_Ptr = tmp_cm_lines_P->data_o[1];
 
            for (k = 0; k < cm_cols_perPage; k++) {
-               code = display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1, /* probe OK */
+               display_Server_datum("", *firstSlot_o_Ptr, *secondSlot_o_Ptr, 1,        /* probe OK */
                                            RIGHT_JUSTIFY, 0);  /* dont highlight */
 
                firstSlot_o_Ptr++;
@@ -2687,7 +2664,7 @@ Switch_cm_2_ovw(void *d1, void *d2)
  * Switch_cm_2_fs()
  *
  * Description:
- *     Switch from the Cache Manager screen to the File Servers screen 
+ *     Switch from the Cache Manager screen to the File Servers screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_2_fs(void *d1, void *d2)
@@ -2703,7 +2680,7 @@ Switch_cm_2_fs(void *d1, void *d2)
  * Switch_cm_next()
  *
  * Description:
- *     Switch to next page of cache managers screen 
+ *     Switch to next page of cache managers screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_next(void *d1, void *d2)
@@ -2720,7 +2697,7 @@ Switch_cm_next(void *d1, void *d2)
  * Switch_cm_last()
  *
  * Description:
- *     Switch to last page of file server screen 
+ *     Switch to last page of file server screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_last(void *d1, void *d2)
@@ -2737,7 +2714,7 @@ Switch_cm_last(void *d1, void *d2)
  * Switch_cm_prev()
  *
  * Description:
- *     Switch to previous page of cache managers screen 
+ *     Switch to previous page of cache managers screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_prev(void *d1, void *d2)
@@ -2753,7 +2730,7 @@ Switch_cm_prev(void *d1, void *d2)
  * Switch_cm_first()
  *
  * Description:
- *     Switch to first page of cache managers screen 
+ *     Switch to first page of cache managers screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_first(void *d1, void *d2)
@@ -2769,7 +2746,7 @@ Switch_cm_first(void *d1, void *d2)
  * Switch_cm_left()
  *
  * Description:
- *     Scroll left on the cache managers screen 
+ *     Scroll left on the cache managers screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_left(void *d1, void *d2)
@@ -2786,7 +2763,7 @@ Switch_cm_left(void *d1, void *d2)
  * Switch_cm_leftmost()
  *
  * Description:
- *     Scroll to first column on  the cache managers screen 
+ *     Scroll to first column on  the cache managers screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_leftmost(void *d1, void *d2)
@@ -2802,7 +2779,7 @@ Switch_cm_leftmost(void *d1, void *d2)
  * Switch_cm_right()
  *
  * Description:
- *     Scroll right on the cache managers screen 
+ *     Scroll right on the cache managers screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_right(void *d1, void *d2)
@@ -2818,7 +2795,7 @@ Switch_cm_right(void *d1, void *d2)
  * Switch_cm_rightmost()
  *
  * Description:
- *     Scroll to last column on the cache managers screen 
+ *     Scroll to last column on the cache managers screen
  *----------------------------------------------------------------------*/
 int
 Switch_cm_rightmost(void *d1, void *d2)
@@ -2863,7 +2840,6 @@ create_CMframe_objects(void)
     struct onode **cmLabels_o_Ptr;
     int x_pos;
     int y_pos;
-    int code;
     int i;
     int j;
     int numBytes;
@@ -2884,14 +2860,14 @@ create_CMframe_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create cm command onode\n", rn);
        afsmon_Exit(420);
     }
-    code = gtxframe_AddToList(cmFrame, cm_cmd_o);
-    code = gator_light_set(cm_cmd_o, HIGHLIGHT);
+    gtxframe_AddToList(cmFrame, cm_cmd_o);
+    gator_light_set(cm_cmd_o, HIGHLIGHT);
 
 
     /* we already have the dimensions for the frame - same as the ovw frame */
     /* use the ovw program name object for the cm screen too */
 
-    code = gtxframe_AddToList(cmFrame, ovw_progName_o);
+    gtxframe_AddToList(cmFrame, ovw_progName_o);
 
 
     /* create the page number object */
@@ -2903,8 +2879,8 @@ create_CMframe_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create pageNumber onode\n", rn);
        afsmon_Exit(415);
     }
-    code = gtxframe_AddToList(cmFrame, cm_pageNum_o);
-    code = gator_light_set(cm_pageNum_o, HIGHLIGHT);
+    gtxframe_AddToList(cmFrame, cm_pageNum_o);
+    gator_light_set(cm_pageNum_o, HIGHLIGHT);
 
     /* create the probe number object */
     cm_probeNum_o =
@@ -2915,8 +2891,8 @@ create_CMframe_objects(void)
        sprintf(errMsg, "[ %s ] Failed to create cm probeNum onode\n", rn);
        afsmon_Exit(425);
     }
-    code = gtxframe_AddToList(cmFrame, cm_probeNum_o);
-    code = gator_light_set(cm_probeNum_o, HIGHLIGHT);
+    gtxframe_AddToList(cmFrame, cm_probeNum_o);
+    gator_light_set(cm_probeNum_o, HIGHLIGHT);
 
 
     /* create the numCM monitored object */
@@ -2929,7 +2905,7 @@ create_CMframe_objects(void)
                "[ %s ] Failed to create numCM onode for the cm frame\n", rn);
        afsmon_Exit(430);
     }
-    code = gtxframe_AddToList(cmFrame, cm_numCM_o);
+    gtxframe_AddToList(cmFrame, cm_numCM_o);
 
     /* create the "more columns to left" indicator */
     cm_leftArrows_o =
@@ -2940,7 +2916,7 @@ create_CMframe_objects(void)
                rn);
        afsmon_Exit(435);
     }
-    code = gtxframe_AddToList(cmFrame, cm_leftArrows_o);
+    gtxframe_AddToList(cmFrame, cm_leftArrows_o);
 
     /* create the "more columns to right" indicator */
     cm_rightArrows_o =
@@ -2952,7 +2928,7 @@ create_CMframe_objects(void)
                rn);
        afsmon_Exit(440);
     }
-    code = gtxframe_AddToList(cmFrame, cm_rightArrows_o);
+    gtxframe_AddToList(cmFrame, cm_rightArrows_o);
 
 
 
@@ -2976,7 +2952,7 @@ create_CMframe_objects(void)
      * the file server statistics */
 
     numBytes = cm_numHosts_perPage * sizeof(struct ServerInfo_line);
-    cm_lines = (struct ServerInfo_line *)malloc(numBytes);
+    cm_lines = malloc(numBytes);
     if (cm_lines == (struct ServerInfo_line *)0) {
        sprintf(errMsg,
                "[ %s ] Failed to allocate %d bytes for CM data lines\n", rn,
@@ -2984,14 +2960,14 @@ create_CMframe_objects(void)
        afsmon_Exit(445);
     }
 
-    /* for each line of server statistics allocate memory to store two arrays 
+    /* for each line of server statistics allocate memory to store two arrays
      * of data onodes */
 
     cm_lines_Ptr = cm_lines;
     for (i = 0; i < cm_numHosts_perPage; i++) {
        for (arrIdx = 0; arrIdx < 2; arrIdx++) {
            numBytes = cm_cols_perPage * sizeof(struct onode *);
-           cm_lines_Ptr->data_o[arrIdx] = (struct onode **)malloc(numBytes);
+           cm_lines_Ptr->data_o[arrIdx] = malloc(numBytes);
            if (cm_lines_Ptr->data_o[arrIdx] == NULL) {
                sprintf(errMsg,
                        "[ %s ] Failed to allocate %d bytes for CM data onodes\n",
@@ -3015,7 +2991,7 @@ create_CMframe_objects(void)
            sprintf(errMsg, "[ %s ] Failed to create an CM name onode\n", rn);
            afsmon_Exit(455);
        }
-       code = gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o);
+       gtxframe_AddToList(cmFrame, cm_lines_Ptr->host_o);
 
        /* if (afsmon_debug) {
         * fprintf(debugFD,"[ %s ] Addr of host_o = %d for line %d\n",
@@ -3046,7 +3022,7 @@ create_CMframe_objects(void)
                            "[ %s ] Failed to create an CM data onode\n", rn);
                    afsmon_Exit(460);
                }
-               code = gtxframe_AddToList(cmFrame, *cm_data_o_Ptr);
+               gtxframe_AddToList(cmFrame, *cm_data_o_Ptr);
 
                cm_data_o_Ptr++;
            }                   /* for each column */
@@ -3063,8 +3039,7 @@ create_CMframe_objects(void)
      * labels */
     for (arrIdx = 0; arrIdx < 3; arrIdx++) {
 
-       cmLabels_o[arrIdx] =
-           (struct onode **)malloc(sizeof(struct onode *) * cm_cols_perPage);
+       cmLabels_o[arrIdx] = malloc(sizeof(struct onode *) * cm_cols_perPage);
        if (cmLabels_o[arrIdx] == NULL) {
            sprintf(errMsg,
                    "[ %s ] Failed to allocate memory for CM label onodes\n",
@@ -3085,7 +3060,7 @@ create_CMframe_objects(void)
                        rn);
                afsmon_Exit(470);
            }
-           code = gtxframe_AddToList(cmFrame, *cmLabels_o_Ptr);
+           gtxframe_AddToList(cmFrame, *cmLabels_o_Ptr);
            cmLabels_o_Ptr++;
        }
 
@@ -3106,7 +3081,7 @@ create_CMframe_objects(void)
     keymap_BindToString(cmFrame->keymap, "Q", afsmonExit_gtx, NULL, NULL);
     keymap_BindToString(cmFrame->keymap, "\ 3", afsmonExit_gtx, NULL, NULL);
 
-    /* o = overview, c = cm, n = next, p = prev, l = left, r = right 
+    /* o = overview, c = cm, n = next, p = prev, l = left, r = right
      * N = last page, P = first page, L = leftmost col, R = rightmost col */
 
     keymap_BindToString(cmFrame->keymap, "o", Switch_cm_2_ovw, NULL, NULL);