afsmonitor: Allow CBSTATS collection to work
[openafs.git] / src / afsmonitor / afsmonitor.c
index f7992d6..eee5936 100644 (file)
@@ -299,7 +299,7 @@ strcasestr(s1, s2)
     len2 = strlen(s2);
 
     if (len1 < len2)
-       return ((char *)NULL);
+       return (NULL);
 
     ptr = s1;
 
@@ -309,7 +309,7 @@ strcasestr(s1, s2)
        ptr++;
        len1--;
     }
-    return ((char *)NULL);
+    return (NULL);
 }
 #endif
 
@@ -569,8 +569,7 @@ insert_FS(char *a_hostName)         /* name of cache manager to be inserted in list */
 
     if (*a_hostName == '\0')
        return (-1);
-    curr_item = (struct afsmon_hostEntry *)
-       malloc(sizeof(struct afsmon_hostEntry));
+    curr_item = malloc(sizeof(struct afsmon_hostEntry));
     if (curr_item == (struct afsmon_hostEntry *)0) {
        fprintf(stderr, "Failed to allocate space for FS nameList\n");
        return (-1);
@@ -656,8 +655,7 @@ insert_CM(char *a_hostName)         /* name of cache manager to be inserted in list */
 
     if (*a_hostName == '\0')
        return (-1);
-    curr_item = (struct afsmon_hostEntry *)
-       malloc(sizeof(struct afsmon_hostEntry));
+    curr_item = malloc(sizeof(struct afsmon_hostEntry));
     if (curr_item == (struct afsmon_hostEntry *)0) {
        fprintf(stderr, "Failed to allocate space for CM nameList\n");
        return (-1);
@@ -1160,8 +1158,8 @@ parse_showEntry(char *a_line)
        /* if it is a section/group name, find it in the fs_categories[] array */
 
        found = 0;
-       if (strcasestr(arg2, "_section") != (char *)NULL
-           || strcasestr(arg2, "_group") != (char *)NULL) {
+       if (strcasestr(arg2, "_section") != NULL
+           || strcasestr(arg2, "_group") != NULL) {
            idx = 0;
            while (idx < FS_NUM_DATA_CATEGORIES) {
                sscanf(fs_categories[idx], "%s %d %d", catName, &fromIdx,
@@ -1184,7 +1182,7 @@ parse_showEntry(char *a_line)
        /* if it is a group name, read its start/end indices and fill in the
         * fs_Display_map[]. */
 
-       if (strcasestr(arg2, "_group") != (char *)NULL) {
+       if (strcasestr(arg2, "_group") != NULL) {
 
            if (fromIdx < 0 || toIdx < 0 || fromIdx > NUM_FS_STAT_ENTRIES
                || toIdx > NUM_FS_STAT_ENTRIES)
@@ -1204,7 +1202,7 @@ parse_showEntry(char *a_line)
            /* if it is a section name, get the count of number of groups in it and
             * for each group fill in the start/end indices in the fs_Display_map[] */
 
-       if (strcasestr(arg2, "_section") != (char *)NULL) {
+       if (strcasestr(arg2, "_section") != NULL) {
            /* fromIdx is actually the number of groups in thi section */
            numGroups = fromIdx;
            /* for each group in section */
@@ -1275,8 +1273,8 @@ parse_showEntry(char *a_line)
        /* if it is a section/group name, find it in the cm_categories[] array */
 
        found = 0;
-       if (strcasestr(arg2, "_section") != (char *)NULL
-           || strcasestr(arg2, "_group") != (char *)NULL) {
+       if (strcasestr(arg2, "_section") != NULL
+           || strcasestr(arg2, "_group") != NULL) {
            idx = 0;
            while (idx < CM_NUM_DATA_CATEGORIES) {
                sscanf(cm_categories[idx], "%s %d %d", catName, &fromIdx,
@@ -1299,7 +1297,7 @@ parse_showEntry(char *a_line)
        /* if it is a group name, read its start/end indices and fill in the
         * cm_Display_map[]. */
 
-       if (strcasestr(arg2, "_group") != (char *)NULL) {
+       if (strcasestr(arg2, "_group") != NULL) {
 
            if (fromIdx < 0 || toIdx < 0 || fromIdx > NUM_CM_STAT_ENTRIES
                || toIdx > NUM_CM_STAT_ENTRIES)
@@ -1319,7 +1317,7 @@ parse_showEntry(char *a_line)
            /* if it is a section name, get the count of number of groups in it and
             * for each group fill in the start/end indices in the cm_Display_map[] */
 
-       if (strcasestr(arg2, "_section") != (char *)NULL) {
+       if (strcasestr(arg2, "_section") != NULL) {
            /* fromIdx is actually the number of groups in thi section */
            numGroups = fromIdx;
            /* for each group in section */
@@ -1539,7 +1537,7 @@ process_config_file(char *a_config_filename)
        }
        if (curr_host->numThresh) {
            numBytes = curr_host->numThresh * sizeof(struct Threshold);
-           curr_host->thresh = (struct Threshold *)malloc(numBytes);
+           curr_host->thresh = malloc(numBytes);
            if (curr_host->thresh == NULL) {
                fprintf(stderr, "[ %s ] Memory Allocation error 1", rn);
                afsmon_Exit(25);
@@ -1557,7 +1555,7 @@ process_config_file(char *a_config_filename)
        }
        if (curr_host->numThresh) {
            numBytes = curr_host->numThresh * sizeof(struct Threshold);
-           curr_host->thresh = (struct Threshold *)malloc(numBytes);
+           curr_host->thresh = malloc(numBytes);
            if (curr_host->thresh == NULL) {
                fprintf(stderr, "[ %s ] Memory Allocation error 2", rn);
                afsmon_Exit(35);
@@ -1735,12 +1733,11 @@ save_FS_results_inCB(int a_newProbeCycle)       /* start of a new probe cycle ? */
        break;
     case AFS_XSTATSCOLL_CBSTATS:
        index = 1;
+       break;
     default:
-       if (index < 0) {
-           fprintf(stderr, "[ %s ] collection number %d is out of range.\n",
-                   rn, xstat_fs_Results.collectionNumber);
-           afsmon_Exit(51);
-       }
+       fprintf(stderr, "[ %s ] collection number %d is out of range.\n",
+               rn, xstat_fs_Results.collectionNumber);
+       afsmon_Exit(51);
     }
 
     /* If a new probe cycle started, mark the list in the current buffer
@@ -3496,8 +3493,8 @@ init_cm_buffers(void)
                    /* >>>  need to allocate rx connection info structure here <<< */
 
                    new_cmPR->data.AFSCB_CollData_val =
-                       (afs_int32 *) malloc(XSTAT_CM_FULLPERF_RESULTS_LEN
-                                            * sizeof(afs_int32));
+                       malloc(XSTAT_CM_FULLPERF_RESULTS_LEN
+                              *sizeof(afs_int32));
                    if (new_cmPR->data.AFSCB_CollData_val == NULL) {
                        free(new_cmlist_item);
                        free(new_cmPR->connP);
@@ -3588,7 +3585,7 @@ init_print_buffers(void)
 
     if (numFS) {
        numBytes = numFS * sizeof(struct fs_Display_Data);
-       curr_fsData = (struct fs_Display_Data *)malloc(numBytes);
+       curr_fsData = malloc(numBytes);
        if (curr_fsData == (struct fs_Display_Data *)0) {
            fprintf(stderr, "[ %s ] Memory allocation failure\n", rn);
            return (-1);
@@ -3596,7 +3593,7 @@ init_print_buffers(void)
        memset(curr_fsData, 0, numBytes);
 
        numBytes = numFS * sizeof(struct fs_Display_Data);
-       prev_fsData = (struct fs_Display_Data *)malloc(numBytes);
+       prev_fsData = malloc(numBytes);
        if (prev_fsData == (struct fs_Display_Data *)0) {
            fprintf(stderr, "[ %s ] Memory allocation failure\n", rn);
            return (-5);
@@ -3625,7 +3622,7 @@ init_print_buffers(void)
     if (numCM) {
        numBytes = numCM * sizeof(struct cm_Display_Data);
 
-       curr_cmData = (struct cm_Display_Data *)malloc(numBytes);
+       curr_cmData = malloc(numBytes);
        if (curr_cmData == (struct cm_Display_Data *)0) {
            fprintf(stderr, "[ %s ] Memory allocation failure\n", rn);
            return (-10);
@@ -3633,7 +3630,7 @@ init_print_buffers(void)
        memset(curr_cmData, 0, numBytes);
 
        numBytes = numCM * sizeof(struct cm_Display_Data);
-       prev_cmData = (struct cm_Display_Data *)malloc(numBytes);
+       prev_cmData = malloc(numBytes);
        if (prev_cmData == (struct cm_Display_Data *)0) {
            fprintf(stderr, "[ %s ] Memory allocation failure\n", rn);
            return (-15);
@@ -3726,7 +3723,7 @@ afsmon_execute(void)
        /* Allocate an array of sockets for each fileserver we monitor */
 
        FSsktbytes = numFS * sizeof(struct sockaddr_in);
-       FSSktArray = (struct sockaddr_in *)malloc(FSsktbytes);
+       FSSktArray = malloc(FSsktbytes);
        if (FSSktArray == (struct sockaddr_in *)0) {
            fprintf(stderr,
                    "[ %s ] cannot malloc %d sockaddr_ins for fileservers\n",
@@ -3811,7 +3808,7 @@ afsmon_execute(void)
        /* Allocate an array of sockets for each cache manager we monitor */
 
        CMsktbytes = numCM * sizeof(struct sockaddr_in);
-       CMSktArray = (struct sockaddr_in *)malloc(CMsktbytes);
+       CMSktArray = malloc(CMsktbytes);
        if (CMSktArray == (struct sockaddr_in *)0) {
            fprintf(stderr,
                    "[ %s ] cannot malloc %d sockaddr_ins for CM entries\n",