diff options
author | charnier <charnier@FreeBSD.org> | 1997-06-23 06:47:12 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-06-23 06:47:12 +0000 |
commit | 8b0eb34c58cd8ccb217c4150db4678986d99964e (patch) | |
tree | e67af4e96ceb25eb2a9952ef7921801b2fd9fe4f /usr.bin/brandelf | |
parent | 514c793c39343496d38d00916410302a19e4c3ff (diff) | |
download | FreeBSD-src-8b0eb34c58cd8ccb217c4150db4678986d99964e.zip FreeBSD-src-8b0eb34c58cd8ccb217c4150db4678986d99964e.tar.gz |
Use err(3). Typo fix in usage string.
Diffstat (limited to 'usr.bin/brandelf')
-rw-r--r-- | usr.bin/brandelf/brandelf.c | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/usr.bin/brandelf/brandelf.c b/usr.bin/brandelf/brandelf.c index e671794..86519aa 100644 --- a/usr.bin/brandelf/brandelf.c +++ b/usr.bin/brandelf/brandelf.c @@ -25,7 +25,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: brandelf.c,v 1.5 1997/03/29 04:28:17 imp Exp $ + * $Id: brandelf.c,v 1.6 1997/05/21 23:07:17 jdp Exp $ */ #include <elf.h> @@ -34,8 +34,9 @@ #include <stdlib.h> #include <string.h> #include <unistd.h> +#include <err.h> -int usage(void); +static void usage __P((void)); int main(int argc, char **argv) @@ -59,30 +60,27 @@ main(int argc, char **argv) } argc -= optind; argv += optind; - if (!argc) { - fprintf(stderr, "No file(s) specified.\n"); - exit(1); - } + if (!argc) + errx(1, "no file(s) specified"); while (argc) { int fd; char buffer[EI_NIDENT]; char string[(EI_NIDENT-EI_BRAND)+1]; if ((fd = open(argv[0], O_RDWR, 0)) < 0) { - fprintf(stderr, "No such file %s.\n", argv[0]); + warnx("no such file %s", argv[0]); retval = 1; goto fail; } if (read(fd, buffer, EI_NIDENT) < EI_NIDENT) { - fprintf(stderr, "File '%s' too short.\n", argv[0]); + warnx("file '%s' too short", argv[0]); retval = 1; goto fail; } if (buffer[0] != ELFMAG0 || buffer[1] != ELFMAG1 || buffer[2] != ELFMAG2 || buffer[3] != ELFMAG3) { - fprintf(stderr, "File '%s' is not ELF format.\n", - argv[0]); + warnx("file '%s' is not ELF format", argv[0]); retval = 1; goto fail; } @@ -101,8 +99,8 @@ main(int argc, char **argv) strncpy(&buffer[EI_BRAND], type, EI_NIDENT-EI_BRAND); lseek(fd, 0, SEEK_SET); if (write(fd, buffer, EI_NIDENT) != EI_NIDENT) { - fprintf(stderr, "Error writing %s\n", argv[0]); - retval = 1; + warnx("error writing %s", argv[0]); + retval = 1; goto fail; } } @@ -114,9 +112,9 @@ fail: return retval; } -int -usage(void) +static void +usage() { - fprintf(stderr, "Usage: brandelf [-t string] file ...\n"); + fprintf(stderr, "usage: brandelf [-t string] file ...\n"); exit(1); } |