From 7c472cd9a685fe13a96038dfe57c62c5da5a669c Mon Sep 17 00:00:00 2001 From: Simon Wilkinson Date: Fri, 10 Jul 2009 13:19:03 +0100 Subject: [PATCH] Prototype the xstat directory Prototype, ansify, and remove errors in the xstat directory Reviewed-on: http://gerrit.openafs.org/20 Reviewed-by: Russ Allbery Verified-by: Russ Allbery --- src/xstat/xstat_cm.c | 11 ++---- src/xstat/xstat_cm.h | 8 +++-- src/xstat/xstat_cm_test.c | 64 ++++++++++------------------------- src/xstat/xstat_fs.c | 31 +++++------------ src/xstat/xstat_fs.h | 9 ++--- src/xstat/xstat_fs_callback.c | 25 ++++---------- src/xstat/xstat_fs_test.c | 22 ++++-------- 7 files changed, 53 insertions(+), 117 deletions(-) diff --git a/src/xstat/xstat_cm.c b/src/xstat/xstat_cm.c index 8816a877f..88c9e1180 100644 --- a/src/xstat/xstat_cm.c +++ b/src/xstat/xstat_cm.c @@ -26,11 +26,6 @@ #define LWP_STACK_SIZE (16 * 1024) -/* - * Routines we need that don't have explicit include file definitions. - */ -extern char *hostutil_GetNameByINet(); /*Host parsing utility */ - /* * Exported variables. */ @@ -50,7 +45,7 @@ static int xstat_cm_ProbeFreqInSecs; /*Probe freq. in seconds */ static int xstat_cm_initflag = 0; /*Was init routine called? */ static int xstat_cm_debug = 0; /*Debugging output enabled? */ static int xstat_cm_oneShot = 0; /*One-shot operation? */ -static int (*xstat_cm_Handler) (); /*Probe handler routine */ +static int (*xstat_cm_Handler) (void); /*Probe handler routine */ static PROCESS probeLWP_ID; /*Probe LWP process ID */ static int xstat_cm_numCollections; /*Number of desired collections */ static afs_int32 *xstat_cm_collIDP; /*Ptr to collection IDs desired */ @@ -78,7 +73,7 @@ static afs_int32 *xstat_cm_collIDP; /*Ptr to collection IDs desired */ *------------------------------------------------------------------------*/ static int -xstat_cm_CleanupInit() +xstat_cm_CleanupInit(void) { xstat_cm_ConnInfo = (struct xstat_cm_ConnectionInfo *)0; xstat_cm_Results.probeNum = 0; @@ -625,7 +620,7 @@ xstat_cm_Init(int a_numServers, struct sockaddr_in *a_socketArray, *------------------------------------------------------------------------*/ int -xstat_cm_ForceProbeNow() +xstat_cm_ForceProbeNow(void) { static char rn[] = "xstat_cm_ForceProbeNow"; /*Routine name */ diff --git a/src/xstat/xstat_cm.h b/src/xstat/xstat_cm.h index 5566f7f2e..661e269f7 100644 --- a/src/xstat/xstat_cm.h +++ b/src/xstat/xstat_cm.h @@ -94,7 +94,9 @@ extern char terminationEvent; /*One-shot termination event */ /* * ------------------------ Exported functions ------------------------ */ -extern int xstat_cm_Init(); +extern int xstat_cm_Init(int, struct sockaddr_in *, int, + int (*a_ProbeHandler)(void), + int, int, afs_int32 *); /* * Summary: * Initialize the xstat_cm module: set up Rx connections to the @@ -116,7 +118,7 @@ extern int xstat_cm_Init(); * Error value otherwise. */ -extern int xstat_cm_ForceProbeNow(); +extern int xstat_cm_ForceProbeNow(void); /* * Summary: * Force an immediate probe to the connected Cache Managers. @@ -129,7 +131,7 @@ extern int xstat_cm_ForceProbeNow(); * Error value otherwise. */ -extern int xstat_cm_Cleanup(); +extern int xstat_cm_Cleanup(int); /* * Summary: * Clean up our memory and connection state. diff --git a/src/xstat/xstat_cm_test.c b/src/xstat/xstat_cm_test.c index 8a8c4bea7..3c2f34606 100644 --- a/src/xstat/xstat_cm_test.c +++ b/src/xstat/xstat_cm_test.c @@ -21,11 +21,7 @@ #include /*Command line interpreter */ #include #include - -/* - * External routines that don't have explicit include file definitions. - */ -extern struct hostent *hostutil_GetHostByName(); +#include /* * Command line parameter indices. @@ -116,10 +112,9 @@ static char *xferOpNames[] = { *------------------------------------------------------------------------*/ void -PrintCallInfo() +PrintCallInfo(void) { /*PrintCallInfo */ - static char rn[] = "PrintCallInfo"; /*Routine name */ register int i; /*Loop variable */ int numInt32s; /*# int32words returned */ afs_int32 *currInt32; /*Ptr to current afs_int32 value */ @@ -151,9 +146,8 @@ PrintCallInfo() /* Print detailed functional call statistics */ void -print_cmCallStats() +print_cmCallStats(void) { - static char rn[] = "print_cmCallStats"; /*Routine name */ char *printableTime; /*Ptr to printable time string */ struct afs_CMStats *cmp; time_t probeTime = xstat_cm_Results.probeTime; @@ -634,9 +628,7 @@ print_cmCallStats() *------------------------------------------------------------------------*/ void -PrintUpDownStats(a_upDownP) - struct afs_stats_SrvUpDownInfo *a_upDownP; /*Ptr to server up/down info */ - +PrintUpDownStats(struct afs_stats_SrvUpDownInfo *a_upDownP) { /*PrintUpDownStats */ /* @@ -700,9 +692,7 @@ PrintUpDownStats(a_upDownP) *------------------------------------------------------------------------*/ void -PrintOverallPerfInfo(a_ovP) - struct afs_stats_CMPerf *a_ovP; - +PrintOverallPerfInfo(struct afs_stats_CMPerf *a_ovP) { /*PrintOverallPerfInfo */ printf("\t%10d numPerfCalls\n", a_ovP->numPerfCalls); @@ -791,10 +781,9 @@ PrintOverallPerfInfo(a_ovP) *------------------------------------------------------------------------*/ void -PrintPerfInfo() +PrintPerfInfo(void) { /*PrintPerfInfo */ - static char rn[] = "PrintPerfInfo"; /*Routine name */ static afs_int32 perfInt32s = (sizeof(struct afs_stats_CMPerf) >> 2); /*Correct # int32s to rcv */ afs_int32 numInt32s; /*# int32words received */ struct afs_stats_CMPerf *perfP; /*Ptr to performance stats */ @@ -846,11 +835,8 @@ PrintPerfInfo() *------------------------------------------------------------------------*/ void -PrintOpTiming(a_opIdx, a_opNames, a_opTimeP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_opTimingData *a_opTimeP; - +PrintOpTiming(int a_opIdx, char *a_opNames[], + struct afs_stats_opTimingData *a_opTimeP) { /*PrintOpTiming */ printf @@ -886,11 +872,8 @@ PrintOpTiming(a_opIdx, a_opNames, a_opTimeP) *------------------------------------------------------------------------*/ void -PrintXferTiming(a_opIdx, a_opNames, a_xferP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_xferData *a_xferP; - +PrintXferTiming(int a_opIdx, char *a_opNames[], + struct afs_stats_xferData *a_xferP) { /*PrintXferTiming */ printf @@ -934,11 +917,8 @@ PrintXferTiming(a_opIdx, a_opNames, a_xferP) *------------------------------------------------------------------------*/ void -PrintErrInfo(a_opIdx, a_opNames, a_opErrP) - int a_opIdx; - char *a_opNames[]; - struct afs_stats_RPCErrors *a_opErrP; - +PrintErrInfo(int a_opIdx, char *a_opNames[], + struct afs_stats_RPCErrors *a_opErrP) { /*PrintErrInfo */ printf @@ -970,9 +950,7 @@ PrintErrInfo(a_opIdx, a_opNames, a_opErrP) *------------------------------------------------------------------------*/ void -PrintRPCPerfInfo(a_rpcP) - struct afs_stats_RPCOpInfo *a_rpcP; - +PrintRPCPerfInfo(struct afs_stats_RPCOpInfo *a_rpcP) { /*PrintRPCPerfInfo */ int currIdx; /*Loop variable */ @@ -1020,12 +998,11 @@ PrintRPCPerfInfo(a_rpcP) *------------------------------------------------------------------------*/ void -PrintFullPerfInfo() +PrintFullPerfInfo(void) { /*PrintFullPerfInfo */ struct afs_stats_AuthentInfo *authentP; /*Ptr to authentication stats */ struct afs_stats_AccessInfo *accessinfP; /*Ptr to access stats */ - struct afs_stats_AuthorInfo *authorP; /*Ptr to authorship stats */ static afs_int32 fullPerfInt32s = (sizeof(struct afs_stats_CMFullPerf) >> 2); /*Correct #int32s */ afs_int32 numInt32s; /*# int32s actually received */ struct afs_stats_CMFullPerf *fullP; /*Ptr to full perf info */ @@ -1112,7 +1089,7 @@ PrintFullPerfInfo() *------------------------------------------------------------------------*/ int -CM_Handler() +CM_Handler(void) { /*CM_Handler */ static char rn[] = "CM_Handler"; /*Routine name */ @@ -1180,9 +1157,7 @@ CM_Handler() *------------------------------------------------------------------------*/ static int -CountListItems(a_firstItem) - struct cmd_item *a_firstItem; - +CountListItems(struct cmd_item *a_firstItem) { /*CountListItems */ int list_len; /*List length */ @@ -1425,11 +1400,8 @@ RunTheTest(struct cmd_syndesc *a_s, void *arock) #include "AFS_component_version_number.c" - -main(argc, argv) - int argc; - char **argv; - +int +main(int argc, char **argv) { /*Main routine */ static char rn[] = "xstat_cm_test"; /*Routine name */ diff --git a/src/xstat/xstat_fs.c b/src/xstat/xstat_fs.c index e0247b29f..c149562af 100644 --- a/src/xstat/xstat_fs.c +++ b/src/xstat/xstat_fs.c @@ -22,26 +22,13 @@ #include /*Lightweight process package */ #include +#include #include #define LWP_STACK_SIZE (16 * 1024) -/* - * Routines we need that don't have explicit include file definitions. - */ -extern int RXAFSCB_ExecuteRequest(); /*AFS callback dispatcher */ -extern char *hostutil_GetNameByINet(); /*Host parsing utility */ - -/* - * Help out the linker by explicitly importing the callback routines - * File Servers may be lobbing at us. - */ -extern afs_int32 SRXAFSCB_CallBack(); -extern afs_int32 SRXAFSCB_InitCallBackState3(); -extern afs_int32 SRXAFSCB_Probe(); -extern afs_int32 SRXAFSCB_ProbeUUID(); -extern afs_int32 SRXAFSCB_GetCE(); -extern afs_int32 SRXAFSCB_GetLock(); +/* This should really be in a header file */ +extern int RXAFSCB_ExecuteRequest(struct rx_call *z_call); /* * Exported variables. @@ -62,7 +49,7 @@ static int xstat_fs_ProbeFreqInSecs; /*Probe freq. in seconds */ static int xstat_fs_initflag = 0; /*Was init routine called? */ static int xstat_fs_debug = 0; /*Debugging output enabled? */ static int xstat_fs_oneShot = 0; /*One-shot operation? */ -static int (*xstat_fs_Handler) (); /*Probe handler routine */ +static int (*xstat_fs_Handler) (void); /*Probe handler routine */ static PROCESS probeLWP_ID; /*Probe LWP process ID */ static int xstat_fs_numCollections; /*Number of desired collections */ static afs_int32 *xstat_fs_collIDP; /*Ptr to collection IDs desired */ @@ -97,7 +84,7 @@ static afs_int32 *xstat_fs_collIDP; /*Ptr to collection IDs desired */ *------------------------------------------------------------------------*/ static int -xstat_fs_CleanupInit() +xstat_fs_CleanupInit(void) { afs_int32 code; /*Return code from callback stubs */ struct rx_call *rxcall; /*Bogus param */ @@ -250,8 +237,6 @@ xstat_fs_LWP(void *unused) afs_int32 numColls; /*Number of collections to get */ afs_int32 *currCollIDP; /*Curr collection ID desired */ - static afs_int32 xstat_VersionNumber; /*Version # of server */ - /* * Set up some numbers we'll need. */ @@ -424,7 +409,7 @@ xstat_fs_LWP(void *unused) int xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray, - int a_ProbeFreqInSecs, int (*a_ProbeHandler) (), int a_flags, + int a_ProbeFreqInSecs, int (*a_ProbeHandler) (void), int a_flags, int a_numCollections, afs_int32 * a_collIDP) { static char rn[] = "xstat_fs_Init"; /*Routine name */ @@ -521,7 +506,7 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray, malloc(a_numServers * sizeof(struct xstat_fs_ConnectionInfo)); if (xstat_fs_ConnInfo == (struct xstat_fs_ConnectionInfo *)0) { fprintf(stderr, - "[%s] Can't allocate %d connection info structs (%d bytes)\n", + "[%s] Can't allocate %d connection info structs (%lu bytes)\n", rn, a_numServers, (a_numServers * sizeof(struct xstat_fs_ConnectionInfo))); return (-1); /*No cleanup needs to be done yet */ @@ -722,7 +707,7 @@ xstat_fs_Init(int a_numServers, struct sockaddr_in *a_socketArray, *------------------------------------------------------------------------*/ int -xstat_fs_ForceProbeNow() +xstat_fs_ForceProbeNow(void) { static char rn[] = "xstat_fs_ForceProbeNow"; /*Routine name */ diff --git a/src/xstat/xstat_fs.h b/src/xstat/xstat_fs.h index 17631f31b..8fdb059d2 100644 --- a/src/xstat/xstat_fs.h +++ b/src/xstat/xstat_fs.h @@ -95,7 +95,8 @@ extern char terminationEvent; /*One-shot termination event */ /* * ------------------------ Exported functions ------------------------ */ -extern int xstat_fs_Init(); +extern int xstat_fs_Init(int, struct sockaddr_in *, int, int (*)(void), + int, int, afs_int32 *); /* * Summary: * Initialize the xstat_fs module: set up Rx connections to the @@ -107,7 +108,7 @@ extern int xstat_fs_Init(); * int a_numServers : Num. servers to connect. * struct sockaddr_in *a_socketArray : Array of server sockets. * int a_ProbeFreqInSecs : Probe frequency in seconds. - * int (*a_ProbeHandler)() : Ptr to probe handler fcn. + * int (*a_ProbeHandler)(void) : Ptr to probe handler fcn. * int a_flags : Various flags. * int a_numCollections : Number of collections desired. * afs_int32 *a_collIDP : Ptr to collection IDs. @@ -117,7 +118,7 @@ extern int xstat_fs_Init(); * Error value otherwise. */ -extern int xstat_fs_ForceProbeNow(); +extern int xstat_fs_ForceProbeNow(void); /* * Summary: * Force an immediate probe to the connected File Servers. @@ -130,7 +131,7 @@ extern int xstat_fs_ForceProbeNow(); * Error value otherwise. */ -extern int xstat_fs_Cleanup(); +extern int xstat_fs_Cleanup(int); /* * Summary: * Clean up our memory and connection state. diff --git a/src/xstat/xstat_fs_callback.c b/src/xstat/xstat_fs_callback.c index dc5c90f5d..ee4bab0cf 100644 --- a/src/xstat/xstat_fs_callback.c +++ b/src/xstat/xstat_fs_callback.c @@ -35,6 +35,7 @@ #include #include /*Callback interface defs */ +#include int afs_cb_inited = 0; struct interfaceAddr afs_cb_interface; @@ -45,7 +46,7 @@ struct interfaceAddr afs_cb_interface; * Initialize the callback interface structure */ static int -init_afs_cb() +init_afs_cb(void) { int count; @@ -63,12 +64,9 @@ init_afs_cb() return 0; } -/* - * Routines we need that don't have explicit include file definitions. - */ -extern char *hostutil_GetNameByINet(); /*Host parsing utility */ - +#if XSTAT_FS_CALLBACK_VERBOSE static char mn[] = "xstat_fs_callback"; /*Module name */ +#endif /*------------------------------------------------------------------------ * SRXAFSCB_CallBack @@ -488,8 +486,6 @@ SRXAFSCB_InitCallBackState2(struct rx_call * rxcall, afs_int32 SRXAFSCB_WhoAreYou(struct rx_call * rxcall, struct interfaceAddr * addr) { - int code = 0; - #if XSTAT_FS_CALLBACK_VERBOSE static char rn[] = "SRXAFSCB_WhoAreYou"; /*Routine name */ char hostName[256]; /*Host name buffer */ @@ -749,8 +745,6 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall, struct interfaceAddr * addr, Capabilities * capabilites) { - int code = 0; - #if XSTAT_FS_CALLBACK_VERBOSE static char rn[] = "SRXAFSCB_TellMeAboutYourself"; /*Routine name */ char hostName[256]; /*Host name buffer */ @@ -777,14 +771,9 @@ SRXAFSCB_TellMeAboutYourself(struct rx_call * rxcall, return (0); } -int SRXAFSCB_GetDE(a_call, a_index, addr, inode, flags, time, fileName) - struct rx_call *a_call; - afs_int32 a_index; - afs_int32 addr; - afs_int32 inode; - afs_int32 flags; - afs_int32 time; - char ** fileName; +int SRXAFSCB_GetDE(struct rx_call *a_call, afs_int32 a_index, afs_int32 addr, + afs_int32 inode, afs_int32 flags, afs_int32 time, + char **fileName) { return RXGEN_OPCODE; } diff --git a/src/xstat/xstat_fs_test.c b/src/xstat/xstat_fs_test.c index e8230bf85..75af1a487 100644 --- a/src/xstat/xstat_fs_test.c +++ b/src/xstat/xstat_fs_test.c @@ -21,11 +21,7 @@ #include /*Command line interpreter */ #include #include - -/* - * External routines that don't have explicit include file definitions. - */ -extern struct hostent *hostutil_GetHostByName(); +#include /* * Command line parameter indices. @@ -105,10 +101,8 @@ static char *xferOpNames[] = { *------------------------------------------------------------------------*/ void -PrintCallInfo() +PrintCallInfo(void) { /*PrintCallInfo */ - - static char rn[] = "PrintCallInfo"; /*Routine name */ register int i; /*Loop variable */ int numInt32s; /*# int32words returned */ afs_int32 *currInt32; /*Ptr to current afs_int32 value */ @@ -406,10 +400,9 @@ PrintDetailedPerfInfo(struct fs_stats_DetailedStats *a_detP) *------------------------------------------------------------------------*/ void -PrintFullPerfInfo() +PrintFullPerfInfo(void) { - static char rn[] = "PrintFullPerfInfo"; /*Routine name */ static afs_int32 fullPerfInt32s = (sizeof(struct fs_stats_FullPerfStats) >> 2); /*Correct # int32s to rcv */ afs_int32 numInt32s; /*# int32words received */ struct fs_stats_FullPerfStats *fullPerfP; /*Ptr to full perf stats */ @@ -460,9 +453,8 @@ PrintFullPerfInfo() *------------------------------------------------------------------------*/ void -PrintPerfInfo() +PrintPerfInfo(void) { - static char rn[] = "PrintPerfInfo"; /*Routine name */ static afs_int32 perfInt32s = (sizeof(struct afs_PerfStats) >> 2); /*Correct # int32s to rcv */ afs_int32 numInt32s; /*# int32words received */ struct afs_PerfStats *perfP; /*Ptr to performance stats */ @@ -504,7 +496,7 @@ static char *CbCounterStrings[] = { void -PrintCbCounters() { +PrintCbCounters(void) { int numInt32s = sizeof(CbCounterStrings)/sizeof(char *); int i; afs_uint32 *val=xstat_fs_Results.data.AFS_CollData_val; @@ -543,7 +535,7 @@ PrintCbCounters() { *------------------------------------------------------------------------*/ int -FS_Handler() +FS_Handler(void) { static char rn[] = "FS_Handler"; /*Routine name */ @@ -658,7 +650,7 @@ CountListItems(struct cmd_item *a_firstItem) *------------------------------------------------------------------------*/ int -RunTheTest(struct cmd_syndesc *a_s) +RunTheTest(struct cmd_syndesc *a_s, void *dummy) { static char rn[] = "RunTheTest"; /*Routine name */ int code; /*Return code */ -- 2.39.5