summaryrefslogtreecommitdiffstats
path: root/usr.bin/gprof/aout.c
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>2002-10-16 13:50:09 +0000
committercharnier <charnier@FreeBSD.org>2002-10-16 13:50:09 +0000
commit064bebe6d3d4f05ecc20524571d6bc4519997bd5 (patch)
treed111768d17cfb105c6bbb279f69b9a271d1a9c41 /usr.bin/gprof/aout.c
parent6dec6a19baa7759402451fa076be28cc26359333 (diff)
downloadFreeBSD-src-064bebe6d3d4f05ecc20524571d6bc4519997bd5.zip
FreeBSD-src-064bebe6d3d4f05ecc20524571d6bc4519997bd5.tar.gz
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.
Diffstat (limited to 'usr.bin/gprof/aout.c')
-rw-r--r--usr.bin/gprof/aout.c42
1 files changed, 16 insertions, 26 deletions
diff --git a/usr.bin/gprof/aout.c b/usr.bin/gprof/aout.c
index 3521359..6daa803 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;
}
OpenPOWER on IntegriCloud