Add rcsid. Remove unused #include. Remove error() definition and replace

with warn().
This commit is contained in:
charnier 2000-12-10 20:54:13 +00:00
parent f1787cda63
commit a2eeec5823
2 changed files with 26 additions and 35 deletions

View File

@ -26,15 +26,13 @@
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $FreeBSD$
*/
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/file.h>
#include <sys/time.h>
#include <sys/resource.h>
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <sys/wait.h>
#include <a.out.h>
#include <elf.h>
@ -42,7 +40,6 @@
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
extern void dump_file __P((const char *));
@ -73,7 +70,7 @@ char *argv[];
case 'f':
if (fmt1) {
if (fmt2)
errx(1, "Too many formats");
errx(1, "too many formats");
fmt2 = optarg;
} else
fmt1 = optarg;
@ -205,7 +202,7 @@ char *argv[];
break;
case 0:
rval |= execl(*argv, *argv, NULL) != 0;
perror(*argv);
warn("%s", *argv);
_exit(1);
}
}

View File

@ -21,20 +21,21 @@
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $FreeBSD$
*/
#ifndef lint
static const char rcsid[] =
"$FreeBSD$";
#endif /* not lint */
#include <assert.h>
#include <ctype.h>
#include <err.h>
#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
#include <sys/stat.h>
@ -81,7 +82,6 @@ static void dump_syms();
static void dump_rtsyms();
static void error(const char *, ...);
static const char *rtsym_name(unsigned long);
static const char *sym_name(unsigned long);
@ -129,6 +129,7 @@ static unsigned char *rtsym_used;
static unsigned long origin; /* What values are relocated relative to */
#ifdef STANDALONE
int
main(int argc, char *argv[])
{
int i;
@ -151,23 +152,27 @@ dump_file(const char *fname)
caddr_t objbase;
if (stat(fname, &sb) == -1) {
error("Cannot stat \"%s\"", fname);
warnx("cannot stat \"%s\"", fname);
++error_count;
return;
}
if ((sb.st_mode & S_IFMT) != S_IFREG) {
error("\"%s\" is not a regular file", fname);
warnx("\"%s\" is not a regular file", fname);
++error_count;
return;
}
if ((fd = open(fname, O_RDONLY, 0)) == -1) {
error("Cannot open \"%s\"", fname);
warnx("cannot open \"%s\"", fname);
++error_count;
return;
}
objbase = mmap(0, sb.st_size, PROT_READ, MAP_SHARED, fd, 0);
if (objbase == (caddr_t) -1) {
error("Cannot mmap \"%s\"", fname);
warnx("cannot mmap \"%s\"", fname);
++error_count;
close(fd);
return;
}
@ -177,7 +182,8 @@ dump_file(const char *fname)
file_base = (const char *) objbase; /* Makes address arithmetic easier */
if (IS_ELF(*(Elf32_Ehdr*) file_base)) {
error("%s: this is an ELF program; use objdump to examine.", fname);
warnx("%s: this is an ELF program; use objdump to examine", fname);
++error_count;
munmap(objbase, sb.st_size);
close(fd);
return;
@ -191,7 +197,8 @@ dump_file(const char *fname)
N_GETMAGIC_NET(*ex), N_GETMAGIC_NET(*ex));
if (N_BADMAG(*ex)) {
error("%s: Bad magic number", fname);
warnx("%s: bad magic number", fname);
++error_count;
munmap(objbase, sb.st_size);
return;
}
@ -524,19 +531,6 @@ dump_syms()
}
}
static void
error(const char *format, ...)
{
va_list ap;
va_start(ap, format);
vfprintf(stderr, format, ap);
va_end(ap);
putc('\n', stderr);
++error_count;
}
static const char *
rtsym_name(unsigned long n)
{