summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcharnier <charnier@FreeBSD.org>1997-06-16 06:35:23 +0000
committercharnier <charnier@FreeBSD.org>1997-06-16 06:35:23 +0000
commitad63a4c160a79c30e6d75d0701de90b50c00aef2 (patch)
tree7e753a3247b26d5963f94c98e67733ae46a948f6
parentf57e3df3324a4b0b829dd9ac41e59cb42b2279cd (diff)
downloadFreeBSD-src-ad63a4c160a79c30e6d75d0701de90b50c00aef2.zip
FreeBSD-src-ad63a4c160a79c30e6d75d0701de90b50c00aef2.tar.gz
Use err(3).
-rw-r--r--sbin/mknod/mknod.c38
1 files changed, 12 insertions, 26 deletions
diff --git a/sbin/mknod/mknod.c b/sbin/mknod/mknod.c
index 0d4b814..21f63db 100644
--- a/sbin/mknod/mknod.c
+++ b/sbin/mknod/mknod.c
@@ -45,7 +45,7 @@ static const char copyright[] =
static char sccsid[] = "@(#)mknod.c 8.1 (Berkeley) 6/5/93";
#else
static const char rcsid[] =
- "$Id: mknod.c,v 1.5 1997/02/22 14:32:38 peter Exp $";
+ "$Id: mknod.c,v 1.6 1997/03/12 19:03:40 bde Exp $";
#endif
#endif /* not lint */
@@ -57,6 +57,7 @@ static const char rcsid[] =
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <err.h>
int
main(argc, argv)
@@ -80,39 +81,24 @@ main(argc, argv)
mode |= S_IFCHR;
else if (argv[2][0] == 'b')
mode |= S_IFBLK;
- else {
- (void)fprintf(stderr,
- "mknod: node must be type 'b' or 'c'\n");
- exit(1);
- }
+ else
+ errx(1, "node must be type 'b' or 'c'");
errno = 0;
major = (long)strtoul(argv[3], &endp, 0);
- if (endp == argv[3] || *endp != '\0') {
- (void)fprintf(stderr,
- "mknod: %s: non-numeric major number\n", argv[3]);
- exit(1);
- }
+ if (endp == argv[3] || *endp != '\0')
+ errx(1, "%s: non-numeric major number", argv[3]);
range_error = errno;
errno = 0;
minor = (long)strtoul(argv[4], &endp, 0);
- if (endp == argv[4] || *endp != '\0') {
- (void)fprintf(stderr,
- "mknod: %s: non-numeric minor number\n", argv[4]);
- exit(1);
- }
+ if (endp == argv[4] || *endp != '\0')
+ errx(1, "%s: non-numeric minor number", argv[4]);
range_error |= errno;
dev = makedev(major, minor);
- if (range_error || major(dev) != major || minor(dev) != minor) {
- (void)fprintf(stderr,
- "mknod: major or minor number too large\n");
- exit(1);
- }
+ if (range_error || major(dev) != major || minor(dev) != minor)
+ errx(1, "major or minor number too large");
- if (mknod(argv[1], mode, dev) != 0) {
- (void)fprintf(stderr,
- "mknod: %s: %s\n", argv[1], strerror(errno));
- exit(1);
- }
+ if (mknod(argv[1], mode, dev) != 0)
+ err(1, "%s", argv[1]);
exit(0);
}
OpenPOWER on IntegriCloud