rework old-style functions prototypes

reduce WARNS=6 output
This commit is contained in:
Philippe Charnier 2013-02-14 08:16:03 +00:00
parent 535875c734
commit af2637db52
10 changed files with 115 additions and 165 deletions

View File

@ -68,7 +68,6 @@ int
aout_getnfile(const char *filename, char ***defaultEs)
{
FILE *nfile;
int valcmp();
nfile = fopen( filename ,"r");
if (nfile == NULL)

View File

@ -46,14 +46,13 @@ int newcycle;
int oldcycle;
#endif /* DEBUG */
int topcmp(const void *, const void *);
/*
* add (or just increment) an arc
*/
void
addarc( parentp , childp , count )
nltype *parentp;
nltype *childp;
long count;
addarc(nltype *parentp, nltype *childp, long count)
{
arctype *arcp;
@ -106,15 +105,16 @@ addarc( parentp , childp , count )
nltype **topsortnlp;
int
topcmp( npp1 , npp2 )
nltype **npp1;
nltype **npp2;
topcmp(const void *v1, const void *v2)
{
const nltype **npp1 = (const nltype **)v1;
const nltype **npp2 = (const nltype **)v2;
return (*npp1) -> toporder - (*npp2) -> toporder;
}
nltype **
doarcs()
doarcs(void)
{
nltype *parentp, **timesortnlp;
arctype *arcp;
@ -252,7 +252,7 @@ doarcs()
}
void
dotime()
dotime(void)
{
int index;
@ -263,8 +263,7 @@ dotime()
}
void
timepropagate( parentp )
nltype *parentp;
timepropagate(nltype *parentp)
{
arctype *arcp;
nltype *childp;
@ -352,7 +351,7 @@ timepropagate( parentp )
}
void
cyclelink()
cyclelink(void)
{
register nltype *nlp;
register nltype *cyclenlp;
@ -445,7 +444,7 @@ cyclelink()
* analyze cycles to determine breakup
*/
bool
cycleanalyze()
cycleanalyze(void)
{
arctype **cyclestack;
arctype **stkp;
@ -521,10 +520,7 @@ cycleanalyze()
}
bool
descend( node , stkstart , stkp )
nltype *node;
arctype **stkstart;
arctype **stkp;
descend(nltype *node, arctype **stkstart, arctype **stkp)
{
arctype *arcp;
bool ret;
@ -556,9 +552,7 @@ descend( node , stkstart , stkp )
}
bool
addcycle( stkstart , stkend )
arctype **stkstart;
arctype **stkend;
addcycle(arctype **stkstart, arctype **stkend)
{
arctype **arcpp;
arctype **stkloc;
@ -632,7 +626,7 @@ addcycle( stkstart , stkend )
}
void
compresslist()
compresslist(void)
{
cltype *clp;
cltype **prev;
@ -748,8 +742,7 @@ compresslist()
#ifdef DEBUG
void
printsubcycle( clp )
cltype *clp;
printsubcycle(cltype *clp)
{
arctype **arcpp;
arctype **endlist;
@ -764,7 +757,7 @@ printsubcycle( clp )
#endif /* DEBUG */
void
cycletime()
cycletime(void)
{
int cycle;
nltype *cyclenlp;
@ -794,7 +787,7 @@ cycletime()
* and while we're here, sum time for functions.
*/
void
doflags()
doflags(void)
{
int index;
nltype *childp;
@ -889,8 +882,7 @@ doflags()
* similarly, deal with propagation fractions from parents.
*/
void
inheritflags( childp )
nltype *childp;
inheritflags(nltype *childp)
{
nltype *headp;
arctype *arcp;

View File

@ -52,7 +52,7 @@ int dfn_depth;
int dfn_counter;
void
dfn_init()
dfn_init(void)
{
dfn_depth = 0;
@ -63,8 +63,7 @@ dfn_init()
* given this parent, depth first number its children.
*/
void
dfn( parentp )
nltype *parentp;
dfn(nltype *parentp)
{
arctype *arcp;
@ -110,8 +109,7 @@ dfn( parentp )
* push a parent onto the stack and mark it busy
*/
void
dfn_pre_visit( parentp )
nltype *parentp;
dfn_pre_visit(nltype *parentp)
{
dfn_depth += 1;
@ -133,8 +131,7 @@ dfn_pre_visit( parentp )
* are we already numbered?
*/
bool
dfn_numbered( childp )
nltype *childp;
dfn_numbered(nltype *childp)
{
return ( childp -> toporder != DFN_NAN && childp -> toporder != DFN_BUSY );
@ -144,8 +141,7 @@ dfn_numbered( childp )
* are we already busy?
*/
bool
dfn_busy( childp )
nltype *childp;
dfn_busy(nltype *childp)
{
if ( childp -> toporder == DFN_NAN ) {
@ -158,8 +154,7 @@ dfn_busy( childp )
* MISSING: an explanation
*/
void
dfn_findcycle( childp )
nltype *childp;
dfn_findcycle(nltype *childp)
{
int cycletop;
nltype *cycleheadp;
@ -267,8 +262,7 @@ dfn_findcycle( childp )
* for lint: ARGSUSED
*/
void
dfn_self_cycle( parentp )
nltype *parentp;
dfn_self_cycle(nltype *parentp)
{
/*
* since we are taking out self-cycles elsewhere
@ -289,8 +283,7 @@ dfn_self_cycle( parentp )
* and pop it off the stack
*/
void
dfn_post_visit( parentp )
nltype *parentp;
dfn_post_visit(nltype *parentp)
{
nltype *memberp;

View File

@ -51,15 +51,12 @@ __FBSDID("$FreeBSD$");
static int valcmp(const void *, const void *);
static struct gmonhdr gmonhdr;
static int lflag;
static int Lflag;
int
main(argc, argv)
int argc;
char **argv;
main(int argc, char **argv)
{
char **sp;
nltype **timesortnlp;
@ -233,11 +230,9 @@ main(argc, argv)
* and the arcs.
*/
void
getpfile(filename)
char *filename;
getpfile(char *filename)
{
FILE *pfile;
FILE *openpfile();
struct rawarc arc;
pfile = openpfile(filename);
@ -262,8 +257,7 @@ getpfile(filename)
}
FILE *
openpfile(filename)
char *filename;
openpfile(char *filename)
{
struct gmonhdr tmp;
FILE *pfile;
@ -322,8 +316,7 @@ openpfile(filename)
}
void
tally( rawp )
struct rawarc *rawp;
tally(struct rawarc *rawp)
{
nltype *parentp;
nltype *childp;
@ -351,8 +344,7 @@ tally( rawp )
* dump out the gmon.sum file
*/
void
dumpsum( sumfile )
char *sumfile;
dumpsum(const char *sumfile)
{
register nltype *nlp;
register arctype *arcp;
@ -393,9 +385,7 @@ dumpsum( sumfile )
}
static int
valcmp(v1, v2)
const void *v1;
const void *v2;
valcmp(const void *v1, const void *v2)
{
const nltype *p1 = (const nltype *)v1;
const nltype *p2 = (const nltype *)v2;
@ -410,8 +400,7 @@ valcmp(v1, v2)
}
void
readsamples(pfile)
FILE *pfile;
readsamples(FILE *pfile)
{
int i;
intmax_t sample;
@ -491,11 +480,11 @@ readsamples(pfile)
* have any overlap (the two end cases, above).
*/
void
asgnsamples()
asgnsamples(void)
{
register int j;
double ccnt;
double time;
double thetime;
unsigned long pcl, pch;
register int i;
unsigned long overlap;
@ -511,14 +500,14 @@ asgnsamples()
continue;
pcl = lowpc + (unsigned long)(scale * i);
pch = lowpc + (unsigned long)(scale * (i + 1));
time = ccnt;
thetime = ccnt;
# ifdef DEBUG
if ( debug & SAMPLEDEBUG ) {
printf( "[asgnsamples] pcl 0x%lx pch 0x%lx ccnt %.0f\n" ,
pcl , pch , ccnt );
}
# endif /* DEBUG */
totime += time;
totime += thetime;
for (j = j - 1; j < nname; j++) {
svalue0 = nl[j].svalue;
svalue1 = nl[j+1].svalue;
@ -541,10 +530,10 @@ asgnsamples()
printf("[asgnsamples] (0x%lx->0x%lx-0x%lx) %s gets %f ticks %lu overlap\n",
nl[j].value / HISTORICAL_SCALE_2,
svalue0, svalue1, nl[j].name,
overlap * time / scale, overlap);
overlap * thetime / scale, overlap);
}
# endif /* DEBUG */
nl[j].time += overlap * time / scale;
nl[j].time += overlap * thetime / scale;
}
}
}
@ -557,8 +546,7 @@ asgnsamples()
unsigned long
min(a, b)
unsigned long a,b;
min(unsigned long a, unsigned long b)
{
if (a<b)
return(a);
@ -566,8 +554,7 @@ min(a, b)
}
unsigned long
max(a, b)
unsigned long a,b;
max(unsigned long a, unsigned long b)
{
if (a>b)
return(a);
@ -581,7 +568,7 @@ max(a, b)
* for a routine is in the next bucket.
*/
void
alignentries()
alignentries(void)
{
register struct nl *nlp;
unsigned long bucket_of_entry;

View File

@ -258,8 +258,8 @@ bool addcycle(arctype **, arctype **);
void addlist(struct stringlist *, char *);
void alignentries(void);
int aout_getnfile(const char *, char ***);
int arccmp();
arctype *arclookup();
int arccmp(arctype *, arctype *);
arctype *arclookup(nltype *, nltype *);
void asgnsamples(void);
void compresslist(void);
bool cycleanalyze(void);
@ -267,41 +267,36 @@ void cyclelink(void);
void cycletime(void);
bool descend(nltype *, arctype **, arctype **);
void dfn(nltype *);
bool dfn_busy();
bool dfn_busy(nltype *);
void dfn_findcycle(nltype *);
void dfn_init(void);
bool dfn_numbered();
bool dfn_numbered(nltype *);
void dfn_post_visit(nltype *);
void dfn_pre_visit(nltype *);
void dfn_self_cycle(nltype *);
nltype **doarcs();
nltype **doarcs(void);
void doflags(void);
void dotime(void);
void dumpsum(char *);
void dumpsum(const char *);
int elf_getnfile(const char *, char ***);
void flatprofheader(void);
void flatprofline(nltype *);
void getpfile(char *);
/*
gprofheader();
gprofline();
*/
void gprofheader(void);
void gprofline(register nltype *);
int hertz(void);
void inheritflags(nltype *);
int kernel_getnfile(const char *, char ***);
/*
main();
*/
unsigned long max();
int membercmp();
unsigned long min();
nltype *nllookup();
unsigned long max(unsigned long, unsigned long);
int membercmp(nltype *, nltype *);
unsigned long min(unsigned long, unsigned long);
nltype *nllookup(unsigned long);
bool onlist(struct stringlist *, const char *);
FILE *openpfile();
long operandlength();
operandenum operandmode();
char *operandname();
void printblurb(char *);
FILE *openpfile(char *);
void printblurb(const char *);
void printchildren(nltype *);
void printcycle(nltype *);
void printgprof(nltype **);
@ -312,13 +307,12 @@ void printparents(nltype *);
void printprof(void);
void printsubcycle(cltype *);
void readsamples(FILE *);
unsigned long reladdr();
void sortchildren(nltype *);
void sortmembers(nltype *);
void sortparents(nltype *);
void tally(struct rawarc *);
void timepropagate(nltype *);
int totalcmp();
int totalcmp(const void *, const void *);
#define LESSTHAN -1
#define EQUALTO 0

View File

@ -44,6 +44,8 @@ __FBSDID("$FreeBSD$");
*/
#define HZ_WRONG 0
int hertz(void);
int
hertz(void)
{

View File

@ -16,7 +16,7 @@ __FBSDID("$FreeBSD$");
static char *excludes[] = { ".mcount", "_mcleanup", NULL };
int
kernel_getnfile(const char *unused, char ***defaultEs)
kernel_getnfile(const char *unused __unused, char ***defaultEs)
{
char *namelist;
size_t len;

View File

@ -44,8 +44,7 @@ __FBSDID("$FreeBSD$");
* entry point.
*/
nltype *
nllookup( address )
unsigned long address;
nllookup(unsigned long address)
{
register long low;
register long middle;
@ -90,9 +89,7 @@ nllookup( address )
}
arctype *
arclookup( parentp , childp )
nltype *parentp;
nltype *childp;
arclookup(nltype *parentp, nltype *childp)
{
arctype *arcp;

View File

@ -42,12 +42,15 @@ __FBSDID("$FreeBSD$");
#include "gprof.h"
#include "pathnames.h"
int namecmp(const void *, const void *);
int timecmp(const void *, const void *);
void
printprof()
printprof(void)
{
register nltype *np;
nltype **sortednlp;
int index, timecmp();
int idx;
actime = 0.0;
printf( "\f\n" );
@ -58,12 +61,12 @@ printprof()
sortednlp = (nltype **) calloc( nname , sizeof(nltype *) );
if ( sortednlp == (nltype **) 0 )
errx( 1 , "[printprof] ran out of memory for time sorting" );
for ( index = 0 ; index < nname ; index += 1 ) {
sortednlp[ index ] = &nl[ index ];
for ( idx = 0 ; idx < nname ; idx += 1 ) {
sortednlp[ idx ] = &nl[ idx ];
}
qsort( sortednlp , nname , sizeof(nltype *) , timecmp );
for ( index = 0 ; index < nname ; index += 1 ) {
np = sortednlp[ index ];
for ( idx = 0 ; idx < nname ; idx += 1 ) {
np = sortednlp[ idx ];
flatprofline( np );
}
actime = 0.0;
@ -71,9 +74,10 @@ printprof()
}
int
timecmp( npp1 , npp2 )
nltype **npp1, **npp2;
timecmp(const void *v1, const void *v2)
{
const nltype **npp1 = (const nltype **)v1;
const nltype **npp2 = (const nltype **)v2;
double timediff;
long calldiff;
@ -94,7 +98,7 @@ timecmp( npp1 , npp2 )
* header for flatprofline
*/
void
flatprofheader()
flatprofheader(void)
{
if ( bflag ) {
@ -122,8 +126,7 @@ flatprofheader()
}
void
flatprofline( np )
register nltype *np;
flatprofline(register nltype *np)
{
if ( zflag == 0 && np -> ncall == 0 && np -> time == 0 &&
@ -161,7 +164,7 @@ flatprofline( np )
}
void
gprofheader()
gprofheader(void)
{
if ( bflag ) {
@ -190,8 +193,7 @@ gprofheader()
}
void
gprofline( np )
register nltype *np;
gprofline(register nltype *np)
{
char kirkbuffer[ BUFSIZ ];
@ -216,18 +218,17 @@ gprofline( np )
}
void
printgprof(timesortnlp)
nltype **timesortnlp;
printgprof(nltype **timesortnlp)
{
int index;
int idx;
nltype *parentp;
/*
* Print out the structured profiling list
*/
gprofheader();
for ( index = 0 ; index < nname + ncycle ; index ++ ) {
parentp = timesortnlp[ index ];
for ( idx = 0 ; idx < nname + ncycle ; idx ++ ) {
parentp = timesortnlp[ idx ];
if ( zflag == 0 &&
parentp -> ncall == 0 &&
parentp -> selfcalls == 0 &&
@ -265,12 +266,12 @@ printgprof(timesortnlp)
* all else being equal, sort by names.
*/
int
totalcmp( npp1 , npp2 )
nltype **npp1;
nltype **npp2;
totalcmp(const void *v1, const void *v2)
{
register nltype *np1 = *npp1;
register nltype *np2 = *npp2;
const nltype **npp1 = (const nltype **)v1;
const nltype **npp2 = (const nltype **)v2;
register const nltype *np1 = *npp1;
register const nltype *np2 = *npp2;
double diff;
diff = ( np1 -> propself + np1 -> propchild )
@ -299,8 +300,7 @@ totalcmp( npp1 , npp2 )
}
void
printparents( childp )
nltype *childp;
printparents(nltype *childp)
{
nltype *parentp;
arctype *arcp;
@ -344,8 +344,7 @@ printparents( childp )
}
void
printchildren( parentp )
nltype *parentp;
printchildren(nltype *parentp)
{
nltype *childp;
arctype *arcp;
@ -378,8 +377,7 @@ printchildren( parentp )
}
void
printname( selfp )
nltype *selfp;
printname(nltype *selfp)
{
if ( selfp -> name != 0 ) {
@ -406,8 +404,7 @@ printname( selfp )
}
void
sortchildren( parentp )
nltype *parentp;
sortchildren(nltype *parentp)
{
arctype *arcp;
arctype *detachedp;
@ -447,8 +444,7 @@ sortchildren( parentp )
}
void
sortparents( childp )
nltype *childp;
sortparents(nltype *childp)
{
arctype *arcp;
arctype *detachedp;
@ -491,8 +487,7 @@ sortparents( childp )
* print a cycle header
*/
void
printcycle( cyclep )
nltype *cyclep;
printcycle(nltype *cyclep)
{
char kirkbuffer[ BUFSIZ ];
@ -516,8 +511,7 @@ printcycle( cyclep )
* print the members of a cycle
*/
void
printmembers( cyclep )
nltype *cyclep;
printmembers(nltype *cyclep)
{
nltype *memberp;
@ -541,8 +535,7 @@ printmembers( cyclep )
* sort members of a cycle
*/
void
sortmembers( cyclep )
nltype *cyclep;
sortmembers(nltype *cyclep)
{
nltype *todo;
nltype *doing;
@ -572,9 +565,7 @@ sortmembers( cyclep )
* next is sort on ncalls + selfcalls.
*/
int
membercmp( this , that )
nltype *this;
nltype *that;
membercmp(nltype *this, nltype *that)
{
double thistime = this -> propself + this -> propchild;
double thattime = that -> propself + that -> propchild;
@ -605,9 +596,7 @@ membercmp( this , that )
* arc count as minor key
*/
int
arccmp( thisp , thatp )
arctype *thisp;
arctype *thatp;
arccmp(arctype *thisp, arctype *thatp)
{
nltype *thisparentp = thisp -> arc_parentp;
nltype *thischildp = thisp -> arc_childp;
@ -684,8 +673,7 @@ arccmp( thisp , thatp )
}
void
printblurb( blurbname )
char *blurbname;
printblurb(const char *blurbname)
{
FILE *blurbfile;
int input;
@ -702,18 +690,20 @@ printblurb( blurbname )
}
int
namecmp( npp1 , npp2 )
nltype **npp1, **npp2;
namecmp(const void *v1, const void *v2)
{
const nltype **npp1 = (const nltype **)v1;
const nltype **npp2 = (const nltype **)v2;
return( strcmp( (*npp1) -> name , (*npp2) -> name ) );
}
void
printindex()
printindex(void)
{
nltype **namesortnlp;
register nltype *nlp;
int index, nnames, todo, i, j;
int idx, nnames, todo, i, j;
char peterbuffer[ BUFSIZ ];
/*
@ -723,19 +713,19 @@ printindex()
namesortnlp = (nltype **) calloc( nname + ncycle , sizeof(nltype *) );
if ( namesortnlp == (nltype **) 0 )
errx( 1 , "ran out of memory for sorting");
for ( index = 0 , nnames = 0 ; index < nname ; index++ ) {
if ( zflag == 0 && nl[index].ncall == 0 && nl[index].time == 0 )
for ( idx = 0 , nnames = 0 ; idx < nname ; idx++ ) {
if ( zflag == 0 && nl[idx].ncall == 0 && nl[idx].time == 0 )
continue;
namesortnlp[nnames++] = &nl[index];
namesortnlp[nnames++] = &nl[idx];
}
qsort( namesortnlp , nnames , sizeof(nltype *) , namecmp );
for ( index = 1 , todo = nnames ; index <= ncycle ; index++ ) {
namesortnlp[todo++] = &cyclenl[index];
for ( idx = 1 , todo = nnames ; idx <= ncycle ; idx++ ) {
namesortnlp[todo++] = &cyclenl[idx];
}
printf( "\f\nIndex by function name\n\n" );
index = ( todo + 2 ) / 3;
for ( i = 0; i < index ; i++ ) {
for ( j = i; j < todo ; j += index ) {
idx = ( todo + 2 ) / 3;
for ( i = 0; i < idx ; i++ ) {
for ( j = i; j < todo ; j += idx ) {
nlp = namesortnlp[ j ];
if ( nlp -> printflag ) {
sprintf( peterbuffer , "[%d]" , nlp -> index );

View File

@ -61,9 +61,7 @@ struct stringlist Ehead = { 0 , 0 };
struct stringlist *Elist = &Ehead;
void
addlist( listp , funcname )
struct stringlist *listp;
char *funcname;
addlist(struct stringlist *listp, char *funcname)
{
struct stringlist *slp;
@ -76,9 +74,7 @@ addlist( listp , funcname )
}
bool
onlist( listp , funcname )
struct stringlist *listp;
const char *funcname;
onlist(struct stringlist *listp, const char *funcname)
{
struct stringlist *slp;