summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2014-05-21 06:23:03 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2014-05-21 06:23:03 +0000
commit58d6b0c0f6c4bb2a9fe1e5ec494c8124c7083c27 (patch)
tree425d1eb0976b16a317345afdfa1e11db7a9c71cb /bin
parent06c1f7e88086cc8bc06ccbe161ef507e32244f7a (diff)
Use errc/warnc to simplify code.
ok jca@ krw@
Diffstat (limited to 'bin')
-rw-r--r--bin/chmod/chmod.c6
-rw-r--r--bin/cp/cp.c10
-rw-r--r--bin/dd/args.c6
-rw-r--r--bin/mv/mv.c8
-rw-r--r--bin/rm/rm.c4
5 files changed, 16 insertions, 18 deletions
diff --git a/bin/chmod/chmod.c b/bin/chmod/chmod.c
index 64a9daf8baf..203d2a36449 100644
--- a/bin/chmod/chmod.c
+++ b/bin/chmod/chmod.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chmod.c,v 1.29 2014/03/16 18:38:30 guenther Exp $ */
+/* $OpenBSD: chmod.c,v 1.30 2014/05/21 06:23:01 guenther Exp $ */
/* $NetBSD: chmod.c,v 1.12 1995/03/21 09:02:09 cgd Exp $ */
/*
@@ -212,7 +212,7 @@ done:
else
continue;
case FTS_DNR: /* Warn, chmod, continue. */
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
+ warnc(p->fts_errno, "%s", p->fts_path);
rval = 1;
break;
case FTS_DP: /* Already changed at FTS_D. */
@@ -222,7 +222,7 @@ done:
break;
case FTS_ERR: /* Warn, continue. */
case FTS_NS:
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
+ warnc(p->fts_errno, "%s", p->fts_path);
rval = 1;
continue;
case FTS_SL: /* Ignore. */
diff --git a/bin/cp/cp.c b/bin/cp/cp.c
index 27ad524d435..436e4eb6712 100644
--- a/bin/cp/cp.c
+++ b/bin/cp/cp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cp.c,v 1.35 2012/08/28 06:02:58 otto Exp $ */
+/* $OpenBSD: cp.c,v 1.36 2014/05/21 06:23:02 guenther Exp $ */
/* $NetBSD: cp.c,v 1.14 1995/09/07 06:14:51 jtc Exp $ */
/*
@@ -409,10 +409,8 @@ copy(char *argv[], enum op type, int fts_options)
if (mkdir(to.p_path,
curr->fts_statp->st_mode | S_IRWXU) < 0)
err(1, "%s", to.p_path);
- } else if (!S_ISDIR(to_stat.st_mode)) {
- errno = ENOTDIR;
- err(1, "%s", to.p_path);
- }
+ } else if (!S_ISDIR(to_stat.st_mode))
+ errc(1, ENOTDIR, "%s", to.p_path);
break;
case S_IFBLK:
case S_IFCHR:
@@ -432,7 +430,7 @@ copy(char *argv[], enum op type, int fts_options)
rval = 1;
break;
case S_IFSOCK:
- warnx("%s: %s", curr->fts_path, strerror(EOPNOTSUPP));
+ warnc(EOPNOTSUPP, "%s", curr->fts_path);
break;
default:
if (copy_file(curr, fts_dne(curr)))
diff --git a/bin/dd/args.c b/bin/dd/args.c
index 827337a9e02..fb0f0178338 100644
--- a/bin/dd/args.c
+++ b/bin/dd/args.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: args.c,v 1.24 2014/03/27 15:32:13 tedu Exp $ */
+/* $OpenBSD: args.c,v 1.25 2014/05/21 06:23:02 guenther Exp $ */
/* $NetBSD: args.c,v 1.7 1996/03/01 01:18:58 jtc Exp $ */
/*-
@@ -383,7 +383,7 @@ get_bsz(char *val)
}
return (num);
erange:
- errx(1, "%s: %s", oper, strerror(ERANGE));
+ errc(1, ERANGE, "%s", oper);
}
/*
@@ -462,5 +462,5 @@ get_off(char *val)
}
return (num);
erange:
- errx(1, "%s: %s", oper, strerror(ERANGE));
+ errc(1, ERANGE, "%s", oper);
}
diff --git a/bin/mv/mv.c b/bin/mv/mv.c
index 979797ddff0..23c49fb5f90 100644
--- a/bin/mv/mv.c
+++ b/bin/mv/mv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mv.c,v 1.35 2009/10/27 23:59:22 deraadt Exp $ */
+/* $OpenBSD: mv.c,v 1.36 2014/05/21 06:23:02 guenther Exp $ */
/* $NetBSD: mv.c,v 1.9 1995/03/21 09:06:52 cgd Exp $ */
/*
@@ -300,13 +300,13 @@ err: if (unlink(to))
(void)close(from_fd);
if (badchown) {
- errno = serrno;
if ((sbp->st_mode & (S_ISUID|S_ISGID))) {
- warn("%s: set owner/group; not setting setuid/setgid",
+ warnc(serrno,
+ "%s: set owner/group; not setting setuid/setgid",
to);
sbp->st_mode &= ~(S_ISUID|S_ISGID);
} else if (!fflg)
- warn("%s: set owner/group", to);
+ warnc(serrno, "%s: set owner/group", to);
}
if (fchmod(to_fd, sbp->st_mode))
warn("%s: set mode", to);
diff --git a/bin/rm/rm.c b/bin/rm/rm.c
index bc08516c8f5..ed43f02e5b8 100644
--- a/bin/rm/rm.c
+++ b/bin/rm/rm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rm.c,v 1.28 2013/04/23 18:41:08 deraadt Exp $ */
+/* $OpenBSD: rm.c,v 1.29 2014/05/21 06:23:02 guenther Exp $ */
/* $NetBSD: rm.c,v 1.19 1995/09/07 06:48:50 jtc Exp $ */
/*-
@@ -152,7 +152,7 @@ rm_tree(char **argv)
}
continue;
case FTS_ERR:
- errx(1, "%s: %s", p->fts_path, strerror(p->fts_errno));
+ errc(1, p->fts_errno, "%s", p->fts_path);
case FTS_NS:
/*
* FTS_NS: assume that if can't stat the file, it