len2 = strlen(s2);
if (len1 < len2)
- return ((char *)NULL);
+ return (NULL);
ptr = s1;
ptr++;
len1--;
}
- return ((char *)NULL);
+ return (NULL);
}
#endif
/* deallocate FS & CM Print buffers */
- if (curr_fsData != (struct fs_Display_Data *)0) {
+ if (curr_fsData != NULL) {
if (afsmon_debug)
fprintf(debugFD, "Deallocating FS Print Buffers .... curr");
free(curr_fsData);
}
- if (prev_fsData != (struct fs_Display_Data *)0) {
+ if (prev_fsData != NULL) {
if (afsmon_debug)
fprintf(debugFD, ", prev \n");
free(prev_fsData);
}
- if (prev_cmData != (struct cm_Display_Data *)0) {
+ if (curr_cmData != NULL) {
if (afsmon_debug)
fprintf(debugFD, "Deallocating CM Print Buffers .... curr");
free(curr_cmData);
}
- if (prev_cmData != (struct cm_Display_Data *)0) {
+ if (prev_cmData != NULL) {
if (afsmon_debug)
fprintf(debugFD, ", prev \n");
free(prev_cmData);
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);
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);
/* 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,
/* 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)
/* 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 */
/* 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,
/* 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)
/* 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 */
char *handlerPtr; /* ptr to pass theresh handler string */
int code = 0; /* error code */
int linenum = 0; /* config file line number */
- int threshCount; /* count of thresholds for each server */
int error_in_config; /* syntax errors in config file ?? */
int i;
int numBytes;
numFS = 0;
numCM = 0;
- threshCount = 0;
error_in_config = 0; /* flag to note if config file has syntax errors */
while ((fgets(line, CFG_STR_LEN, configFD)) != NULL) {
}
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);
}
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);
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
{
afs_int32 *srcbuf;
struct fs_stats_FullPerfStats *fullPerfP;
+ struct fs_stats_FullPerfStats buffer;
int idx;
int i, j;
afs_int32 *tmpbuf;
- afs_int32 numInt32s;
-
- fullPerfP = (struct fs_stats_FullPerfStats *)
- (a_fsResults->data.AFS_CollData_val);
+ int code;
/* there are two parts to the xstat FS statistics
* - fullPerfP->overall which give the overall performance statistics, and
* - fullPerfP->det which gives detailed info about file server operation
* execution times */
- /*
- * Unfortunately, the full perf stats contain timeval structures which
- * do not have the same size everywhere. Avoid displaying gargbage,
- * but at least try to show the overall stats.
- */
- numInt32s = a_fsResults->data.AFS_CollData_len;
- if (numInt32s !=
- (sizeof(struct fs_stats_FullPerfStats) / sizeof(afs_int32))) {
- srcbuf = a_fsResults->data.AFS_CollData_val;
+ code = xstat_fs_DecodeFullPerfStats(&fullPerfP,
+ a_fsResults->data.AFS_CollData_val,
+ a_fsResults->data.AFS_CollData_len,
+ &buffer);
+ if (code) {
+ /* Not able to decode the full perf stats. Avoid displaying garbage. */
for (i = 0; i < NUM_FS_STAT_ENTRIES; i++) {
- if (i < numInt32s && i < NUM_XSTAT_FS_AFS_PERFSTATS_LONGS) {
- sprintf(a_fsData->data[i], "%d", srcbuf[i]);
- } else {
- sprintf(a_fsData->data[i], "%s", "--");
- }
+ sprintf(a_fsData->data[i], "%s", "--");
}
return 0;
}
char fileName[256]; /* file name to execute */
int i;
char *ch;
- int code;
int argNum;
int anotherArg; /* boolean used to flag if another arg is available */
if (fork() == 0) {
exec_fsThreshHandler = 1;
- code = afsmon_Exit(60);
+ afsmon_Exit(60);
}
return (0);
/* >>> 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);
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);
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);
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);
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);
/* 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",
/* 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",
}
strncpy(curr_CM->hostName, he->h_name, HOST_NAME_LEN); /* complete name */
memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4);
-#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
- curr_skt->sin_family = AF_INET; /*Internet family */
-#else
- curr_skt->sin_family = htons(AF_INET); /*Internet family */
-#endif
- curr_skt->sin_port = htons(7001); /*Cache Manager port */
+ curr_skt->sin_family = AF_INET;
+ curr_skt->sin_port = htons(7001); /* Cache Manager port */
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
curr_skt->sin_len = sizeof(struct sockaddr_in);
#endif