From 3e7626264d8ced44e0a0b379f5dacf9152348729 Mon Sep 17 00:00:00 2001 From: Philippe Charnier Date: Sun, 10 Dec 2000 20:54:13 +0000 Subject: [PATCH] Add rcsid. Remove unused #include. Remove error() definition and replace with warn(). --- usr.bin/ldd/ldd.c | 17 +++++++---------- usr.bin/ldd/sods.c | 44 +++++++++++++++++++------------------------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/usr.bin/ldd/ldd.c b/usr.bin/ldd/ldd.c index 5c25d05753d8..e272b6b3a257 100644 --- a/usr.bin/ldd/ldd.c +++ b/usr.bin/ldd/ldd.c @@ -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 -#include -#include -#include -#include +#ifndef lint +static const char rcsid[] = + "$FreeBSD$"; +#endif /* not lint */ + #include #include #include @@ -42,7 +40,6 @@ #include #include #include -#include #include 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); } } diff --git a/usr.bin/ldd/sods.c b/usr.bin/ldd/sods.c index a41afaa63c13..69176162c868 100644 --- a/usr.bin/ldd/sods.c +++ b/usr.bin/ldd/sods.c @@ -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 #include +#include #include -#include #include #include -#include #include -#include #include #include @@ -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) {