prettiness police
authorKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 29 Apr 1995 01:16:04 +0000 (17:16 -0800)
committerKeith Bostic <bostic@ucbvax.Berkeley.EDU>
Sat, 29 Apr 1995 01:16:04 +0000 (17:16 -0800)
From: Charles Hannum <mycroft@NetBSD.ORG>

SCCS-vsn: sbin/clri/clri.c 8.3
SCCS-vsn: sbin/dump/dumprmt.c 8.2

usr/src/sbin/clri/clri.c
usr/src/sbin/dump/dumprmt.c

index 89e7381..0053547 100644 (file)
@@ -15,7 +15,7 @@ static char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)clri.c     8.2 (Berkeley) %G%";
+static char sccsid[] = "@(#)clri.c     8.3 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -58,29 +58,20 @@ main(argc, argv)
                err(1, "%s", fs);
        if (lseek(fd, (off_t)(SBLOCK * DEV_BSIZE), SEEK_SET) < 0)
                err(1, "%s", fs);
                err(1, "%s", fs);
        if (lseek(fd, (off_t)(SBLOCK * DEV_BSIZE), SEEK_SET) < 0)
                err(1, "%s", fs);
-       if (read(fd, sblock, sizeof(sblock)) != sizeof(sblock)) {
-               (void)fprintf(stderr,
-                   "clri: %s: can't read the superblock.\n", fs);
-               exit(1);
-       }
+       if (read(fd, sblock, sizeof(sblock)) != sizeof(sblock))
+               errx(1, "%s: can't read superblock", fs);
 
        sbp = (struct fs *)sblock;
 
        sbp = (struct fs *)sblock;
-       if (sbp->fs_magic != FS_MAGIC) {
-               (void)fprintf(stderr,
-                   "clri: %s: superblock magic number 0x%x, not 0x%x.\n",
+       if (sbp->fs_magic != FS_MAGIC)
+               errx(1, "%s: superblock magic number 0x%x, not 0x%x",
                    fs, sbp->fs_magic, FS_MAGIC);
                    fs, sbp->fs_magic, FS_MAGIC);
-               exit(1);
-       }
        bsize = sbp->fs_bsize;
 
        /* remaining arguments are inode numbers. */
        while (*++argv) {
                /* get the inode number. */
        bsize = sbp->fs_bsize;
 
        /* remaining arguments are inode numbers. */
        while (*++argv) {
                /* get the inode number. */
-               if ((inonum = atoi(*argv)) <= 0) {
-                       (void)fprintf(stderr,
-                           "clri: %s is not a valid inode number.\n", *argv);
-                       exit(1);
-               }
+               if ((inonum = atoi(*argv)) <= 0)
+                       errx(1, "%s is not a valid inode number", *argv);
                (void)printf("clearing %d\n", inonum);
 
                /* read in the appropriate block. */
                (void)printf("clearing %d\n", inonum);
 
                /* read in the appropriate block. */
index eac5feb..0b2993c 100644 (file)
@@ -6,7 +6,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)dumprmt.c  8.1 (Berkeley) %G%";
+static char sccsid[] = "@(#)dumprmt.c  8.2 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -28,6 +28,7 @@ static char sccsid[] = "@(#)dumprmt.c 8.1 (Berkeley) %G%";
 #include <protocols/dumprestore.h>
 
 #include <ctype.h>
 #include <protocols/dumprestore.h>
 
 #include <ctype.h>
+#include <err.h>
 #include <netdb.h>
 #include <pwd.h>
 #include <signal.h>
 #include <netdb.h>
 #include <pwd.h>
 #include <signal.h>
@@ -79,8 +80,7 @@ static void
 rmtconnaborted()
 {
 
 rmtconnaborted()
 {
 
-       (void) fprintf(stderr, "rdump: Lost connection to remote host.\n");
-       exit(1);
+       errx(1, "Lost connection to remote host.");
 }
 
 void
 }
 
 void
@@ -98,16 +98,11 @@ rmtgetconn()
 
        if (sp == NULL) {
                sp = getservbyname("shell", "tcp");
 
        if (sp == NULL) {
                sp = getservbyname("shell", "tcp");
-               if (sp == NULL) {
-                       (void) fprintf(stderr,
-                           "rdump: shell/tcp: unknown service\n");
-                       exit(1);
-               }
+               if (sp == NULL)
+                       errx(1, "shell/tcp: unknown service");
                pwd = getpwuid(getuid());
                pwd = getpwuid(getuid());
-               if (pwd == NULL) {
-                       (void) fprintf(stderr, "rdump: who are you?\n");
-                       exit(1);
-               }
+               if (pwd == NULL)
+                       errx(1, "who are you?");
        }
        if ((cp = index(rmtpeer, '@')) != NULL) {
                tuser = rmtpeer;
        }
        if ((cp = index(rmtpeer, '@')) != NULL) {
                tuser = rmtpeer;
@@ -149,8 +144,7 @@ okname(cp0)
        for (cp = cp0; *cp; cp++) {
                c = *cp;
                if (!isascii(c) || !(isalnum(c) || c == '_' || c == '-')) {
        for (cp = cp0; *cp; cp++) {
                c = *cp;
                if (!isascii(c) || !(isalnum(c) || c == '_' || c == '-')) {
-                       (void) fprintf(stderr, "rdump: invalid user name %s\n",
-                           cp0);
+                       warnx("invalid user name: %s", cp0);
                        return (0);
                }
        }
                        return (0);
                }
        }