summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pwd_mkdb
diff options
context:
space:
mode:
authorguenther <guenther@openbsd.org>2014-05-20 01:25:23 +0000
committerguenther <guenther@openbsd.org>2014-05-20 01:25:23 +0000
commit5ad04d351680822078003e2b066cfc9680d6157d (patch)
treebc78d1cc74e659478aa86d8884efcb9a0d678e50 /usr.sbin/pwd_mkdb
parentBring UTF8_{getc,putc} up-to-date: it's been a decade since 5- and 6-byte (diff)
downloadwireguard-openbsd-5ad04d351680822078003e2b066cfc9680d6157d.tar.xz
wireguard-openbsd-5ad04d351680822078003e2b066cfc9680d6157d.zip
Use errc/warnc to simplify code.
Also, in 'ftp', always put the error message last, after the hostname/ipaddr. ok jsing@ krw@ millert@
Diffstat (limited to 'usr.sbin/pwd_mkdb')
-rw-r--r--usr.sbin/pwd_mkdb/pwd_mkdb.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/usr.sbin/pwd_mkdb/pwd_mkdb.c b/usr.sbin/pwd_mkdb/pwd_mkdb.c
index fdc1312d48b..ba75c34a06f 100644
--- a/usr.sbin/pwd_mkdb/pwd_mkdb.c
+++ b/usr.sbin/pwd_mkdb/pwd_mkdb.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pwd_mkdb.c,v 1.43 2010/01/08 13:29:08 oga Exp $ */
+/* $OpenBSD: pwd_mkdb.c,v 1.44 2014/05/20 01:25:24 guenther Exp $ */
/*-
* Copyright (c) 1991, 1993, 1994
@@ -75,6 +75,7 @@ static int hasyp; /* are we running YP? */
void cleanup(void);
void error(char *);
+void errorc(int, char *);
void errorx(char *);
void cp(char *, char *, mode_t);
void mv(char *, char *);
@@ -360,8 +361,7 @@ scan(FILE *fp, struct passwd *pw, int *flags)
*flags = 0;
if (!pw_scan(line, pw, flags)) {
warnx("at line #%d", lcnt);
-fmt: errno = EFTYPE; /* XXX */
- error(pname);
+fmt: errorc(EFTYPE, pname);
}
return (1);
@@ -383,16 +383,14 @@ cp(char *from, char *to, mode_t mode)
int sverrno = errno;
(void)snprintf(buf, sizeof(buf), "%s to %s", from, to);
- errno = sverrno;
- error(buf);
+ errorc(sverrno, buf);
}
}
if (rcount < 0) {
int sverrno = errno;
(void)snprintf(buf, sizeof(buf), "%s to %s", from, to);
- errno = sverrno;
- error(buf);
+ errorc(sverrno, buf);
}
close(to_fd);
close(from_fd);
@@ -407,8 +405,7 @@ mv(char *from, char *to)
int sverrno = errno;
(void)snprintf(buf, sizeof(buf), "%s to %s", from, to);
- errno = sverrno;
- error(buf);
+ errorc(sverrno, buf);
}
}
@@ -422,6 +419,15 @@ error(char *name)
}
void
+errorc(int code, char *name)
+{
+
+ warnc(code, "%s", name);
+ cleanup();
+ exit(1);
+}
+
+void
errorx(char *name)
{