diff options
author | Philippe Charnier <charnier@FreeBSD.org> | 2002-10-16 13:50:09 +0000 |
---|---|---|
committer | Philippe Charnier <charnier@FreeBSD.org> | 2002-10-16 13:50:09 +0000 |
commit | 97fa9b77399b799457a0e59000391966367c07d4 (patch) | |
tree | d111768d17cfb105c6bbb279f69b9a271d1a9c41 /usr.bin/gprof/aout.c | |
parent | b0a07322f5a6ce5759f5ed1d4550d8a31c4a227d (diff) | |
download | src-97fa9b77399b799457a0e59000391966367c07d4.tar.gz src-97fa9b77399b799457a0e59000391966367c07d4.zip |
Remove done() which was just exit() so use of warn()/err() can be made. Abort
on allocation failure instead of displaying a warning and deferencing NULL
pointer after. Spelling. Add prototypes. Add list of option in synopsis section
of man page, -d is not referenced because available as a compile option. It
should be made a runtime option btw.
Notes
Notes:
svn path=/head/; revision=105243
Diffstat (limited to 'usr.bin/gprof/aout.c')
-rw-r--r-- | usr.bin/gprof/aout.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/usr.bin/gprof/aout.c b/usr.bin/gprof/aout.c index 3521359a4189..6daa80336c2c 100644 --- a/usr.bin/gprof/aout.c +++ b/usr.bin/gprof/aout.c @@ -42,6 +42,7 @@ static char sccsid[] = "@(#)gprof.c 8.1 (Berkeley) 6/6/93"; __FBSDID("$FreeBSD$"); #include <a.out.h> +#include <err.h> #include "gprof.h" @@ -71,10 +72,8 @@ aout_getnfile(const char *filename, char ***defaultEs) int valcmp(); nfile = fopen( filename ,"r"); - if (nfile == NULL) { - perror( filename ); - done(); - } + if (nfile == NULL) + err( 1 , "%s", filename ); fread(&xbuf, 1, sizeof(xbuf), nfile); if (N_BADMAG(xbuf)) { fclose(nfile); @@ -102,19 +101,13 @@ getstrtab(FILE *nfile, const char *filename) { fseek(nfile, (long)(N_SYMOFF(xbuf) + xbuf.a_syms), 0); - if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) { - warnx("%s: no string table (old format?)" , filename ); - done(); - } + if (fread(&ssiz, sizeof (ssiz), 1, nfile) == 0) + errx( 1 , "%s: no string table (old format?)" , filename ); strtab = calloc(ssiz, 1); - if (strtab == NULL) { - warnx("%s: no room for %d bytes of string table", filename , ssiz); - done(); - } - if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1) { - warnx("%s: error reading string table", filename ); - done(); - } + if (strtab == NULL) + errx( 1 , "%s: no room for %ld bytes of string table", filename , ssiz); + if (fread(strtab+sizeof(ssiz), ssiz-sizeof(ssiz), 1, nfile) != 1) + errx( 1 , "%s: error reading string table" , filename ); } /* @@ -137,16 +130,13 @@ getsymtab(FILE *nfile, const char *filename) } nname++; } - if (nname == 0) { - warnx("%s: no symbols", filename ); - done(); - } + if (nname == 0) + errx( 1 , "%s: no symbols" , filename ); askfor = nname + 1; nl = (nltype *) calloc( askfor , sizeof(nltype) ); - if (nl == 0) { - warnx("no room for %d bytes of symbol table", askfor * sizeof(nltype) ); - done(); - } + if (nl == 0) + errx( 1 , "no room for %d bytes of symbol table" , + askfor * sizeof(nltype) ); /* pass2 - read symbols */ fseek(nfile, (long)N_SYMOFF(xbuf), 0); @@ -189,7 +179,7 @@ gettextspace(FILE *nfile) } textspace = (u_char *) malloc( xbuf.a_text ); if ( textspace == 0 ) { - warnx("ran out room for %d bytes of text space: can't do -c" , + warnx("no room for %lu bytes of text space: can't do -c" , xbuf.a_text ); return; } @@ -235,7 +225,7 @@ funcsymbol(struct nlist *nlistp) return TRUE; } #endif - while ( c = *name++ ) { + while ( (c = *name++) ) { if ( c == '.' ) { return FALSE; } |