aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/brandelf
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1997-06-23 06:47:12 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1997-06-23 06:47:12 +0000
commit4f971ac41096be54a7922f246c78770f2cd38edb (patch)
treed24ad226055eae6719944a77bffc5da34780491f /usr.bin/brandelf
parent0676cb8945ffb4eb7ff46ca65c85168990461d5b (diff)
downloadsrc-4f971ac41096be54a7922f246c78770f2cd38edb.tar.gz
src-4f971ac41096be54a7922f246c78770f2cd38edb.zip
Use err(3). Typo fix in usage string.
Notes
Notes: svn path=/head/; revision=26837
Diffstat (limited to 'usr.bin/brandelf')
-rw-r--r--usr.bin/brandelf/brandelf.c28
1 files changed, 13 insertions, 15 deletions
diff --git a/usr.bin/brandelf/brandelf.c b/usr.bin/brandelf/brandelf.c
index e6717946d071..86519aacb381 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);
}