PERFORCE change 83115 for review
Victor Cruceru
soc-victor at FreeBSD.org
Sun Sep 4 13:26:42 PDT 2005
http://perforce.freebsd.org/chv.cgi?CH=83115
Change 83115 by soc-victor at soc-victor_82.76.158.176 on 2005/09/04 20:26:09
The rest of the basic cleanup for the HOST-RESOURCES-MIB
Affected files ...
.. //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c#7 edit
Differences ...
==== //depot/projects/soc2005/bsnmp/usr.sbin/bsnmpd/modules/snmp_hostres/hostres_swrun_tbl.c#7 (text+ko) ====
@@ -37,11 +37,9 @@
#include <string.h>
#include <assert.h>
#include <sys/proc.h>
-#include <sys/param.h>
#include <sys/sysctl.h>
#include <sys/user.h>
#include <sys/linker.h>
-#include <sys/types.h>
#include <signal.h>
@@ -157,7 +155,8 @@
entry->name[sizeof(entry->name) - 1] = '\0';
- (void)strncpy(&entry->name[0], &kp->ki_ocomm[0], sizeof(entry->name) - 1);
+ (void)strncpy((char*)&entry->name[0],
+ &kp->ki_ocomm[0], sizeof(entry->name) - 1);
entry->id = oid_zeroDotZero; /*unknown id - FIX ME*/
@@ -178,7 +177,8 @@
*/
if(*argv != NULL && (*argv)[0] == '/') {
memset(&entry->path[0], '\0', sizeof(entry->path));
- (void)strncpy(&entry->path[0], *argv, sizeof(entry->path) - 1);
+ (void)strncpy((char*)&entry->path[0],
+ *argv, sizeof(entry->path) - 1);
}
argv++; /*skip the first one which was used for path*/
@@ -186,20 +186,25 @@
while (argv != NULL && *argv != NULL ) {
if (entry->parameters[0] != 0) {
/*add a space between parameters, except before the first one*/
- strncat(&entry->parameters[0],
- " ",
- sizeof(entry->parameters) - strlen(entry->parameters) - 1);
+ strncat((char *)&entry->parameters[0],
+ " ",
+ sizeof(entry->parameters) -
+ strlen((const char*)&entry->parameters[0])
+ - 1);
}
- strncat(&entry->parameters[0], *argv,
- sizeof(entry->parameters) - strlen(entry->parameters) - 1);
+ strncat((char *)&entry->parameters[0], *argv,
+ sizeof(entry->parameters) -
+ strlen((const char*)&entry->parameters[0])
+ - 1);
argv++;
}/*end while */
}
- entry->type = ( IS_KERNPROC(kp) ? SRT_OPERATING_SYSTEM : SRT_APPLICATION );
+ entry->type = ( IS_KERNPROC(kp) ? (int32_t)SRT_OPERATING_SYSTEM :
+ (int32_t)SRT_APPLICATION );
- entry ->status = hrSWRun_OS_get_proc_status(kp);
+ entry ->status = (int32_t)hrSWRun_OS_get_proc_status(kp);
cpu_time = kp->ki_runtime / 100000; /*centi-seconds*/
/*may overflow the snmp type */
entry->perfCPU = (cpu_time > (uint64_t)INT_MAX ? INT_MAX : cpu_time);
@@ -216,7 +221,8 @@
assert(entry != NULL);
entry->name[sizeof(entry->name) - 1] = '\0';
- (void)strncpy(&entry->name[0], &kfs->name[0], sizeof(entry->name) - 1);
+ (void)strncpy((char *)&entry->name[0], &kfs->name[0],
+ sizeof(entry->name) - 1);
/*FIX ME: can we find the location where the module was loaded from? */
entry->path[0] = '\0';
@@ -227,12 +233,12 @@
entry->id = oid_zeroDotZero; /*unknown id - FIX ME*/
if (strncmp(kfs->name, "kernel", strlen("kernel") ) == 0) {
- entry->type = SRT_OPERATING_SYSTEM;
+ entry->type = (int32_t)SRT_OPERATING_SYSTEM;
hrState_g.hrSWOSIndex = entry->index;
}else{
- entry->type = SRT_DEVICE_DRIVER; /*not really*/
+ entry->type = (int32_t)SRT_DEVICE_DRIVER; /*well, not really*/
}
- entry->status = SRS_RUNNING;
+ entry->status = (int32_t)SRS_RUNNING;
entry->perfCPU = 0; /*Info not available*/
entry->perfMemory = kfs->size / 1024; /*in kilo-bytes*/
entry->r_tick = get_ticks();
@@ -373,8 +379,11 @@
/* not found, it's gone. Mark it as invalid for now, it
* will be removed from the list at next global refersh
*/
- HR_DPRINTF((stderr, "%s: missing item with kid = %d \n ", __func__, entry->index - NO_PID - 1));
- entry->status = SRS_INVALID;
+ HR_DPRINTF((stderr,
+ "%s: missing item with kid = %d \n ",
+ __func__,
+ entry->index - NO_PID - 1));
+ entry->status = (int32_t)SRS_INVALID;
}
@@ -384,8 +393,10 @@
assert(hrState_g.kd != NULL);
plist = kvm_getprocs(hrState_g.kd, KERN_PROC_PID, entry->index - 1, &nproc);
if (plist == NULL || nproc != 1) {
- HR_DPRINTF((stderr, "%s: missing item with PID = %d \n ", __func__, entry->index - 1));
- entry->status = SRS_INVALID;
+ HR_DPRINTF((stderr, "%s: missing item with PID = %d \n ",
+ __func__,
+ entry->index - 1));
+ entry->status = (int32_t)SRS_INVALID;
return;
}
kinfo_proc_to_hrSWRunTblEntry_v(plist,entry);
@@ -435,8 +446,10 @@
/* not found, it's gone. Mark it as invalid for now, it
* will be removed from the list at next global refersh
*/
- HR_DPRINTF((stderr, "%s: missing item with kid = %d \n ", __func__, entry->index - NO_PID - 1));
- entry->status = SRS_INVALID;
+ HR_DPRINTF((stderr, "%s: missing item with kid = %d \n ",
+ __func__,
+ entry->index - NO_PID - 1));
+ entry->status = (int32_t)SRS_INVALID;
return (SNMP_ERR_NOERROR);
}
@@ -447,8 +460,10 @@
assert(hrState_g.kd != NULL);
plist = kvm_getprocs(hrState_g.kd, KERN_PROC_PID, entry->index - 1, &nproc);
if (plist == NULL || nproc != 1) {
- HR_DPRINTF((stderr, "%s: missing item with PID = %d \n ", __func__, entry->index - 1));
- entry->status = SRS_INVALID;
+ HR_DPRINTF((stderr, "%s: missing item with PID = %d \n ",
+ __func__,
+ entry->index - 1));
+ entry->status = (int32_t)SRS_INVALID;
return (SNMP_ERR_NOERROR);
}
if(IS_KERNPROC(plist)) {
@@ -528,13 +543,13 @@
entry->index));
fetch_hrSWRun_entry_v(entry);
}
- if(entry->status == SRS_INVALID){
+ if(entry->status == (int32_t)SRS_INVALID){
return (SNMP_ERR_NOERROR);
}
switch (value->var.subs[sub - 1]) {
case LEAF_hrSWRunStatus: {
- if( value->v.integer != SRS_INVALID) {
+ if( value->v.integer != (int32_t)SRS_INVALID) {
return (SNMP_ERR_WRONG_VALUE);
}
return (invalidate_hrSWRun_entry(entry));
@@ -543,7 +558,7 @@
return (SNMP_ERR_NOT_WRITEABLE);
} /* end switch (value->var.subs[sub - 1]) */
- return (SNMP_ERR_NOERROR);
+ /*not reachable*/
case SNMP_OP_ROLLBACK:
case SNMP_OP_COMMIT:
More information about the p4-projects
mailing list