Also, in 'ftp', always put the error message last, after the hostname/ipaddr.
ok jsing@ krw@ millert@
int r;
if ((r = pthread_rwlock_rdlock(&start)))
- errx(1, "could not obtain lock in thread: %s", strerror(r));
+ errc(1, r, "could not obtain lock in thread");
real_func(arg);
if ((r = pthread_rwlock_unlock(&start)))
- errx(1, "could not release lock in thread: %s", strerror(r));
+ errc(1, r, "could not release lock in thread");
return NULL;
}
self = pthread_self();
real_func = func;
if ((r = pthread_rwlock_init(&start, NULL)))
- errx(1, "could not initialize lock: %s", strerror(r));
+ errc(1, r, "could not initialize lock");
if ((r = pthread_rwlock_wrlock(&start))) /* block */
- errx(1, "could not lock lock: %s", strerror(r));
+ errc(1, r, "could not lock lock");
for (i = 0; i < THREAD_COUNT; i++)
if ((r = pthread_create(&pthread[i], NULL, thread, arg))) {
- warnx("could not create thread: %s", strerror(r));
+ warnc(r, "could not create thread");
pthread[i] = self;
}
if ((r = pthread_rwlock_unlock(&start))) /* unleash */
- errx(1, "could not release lock: %s", strerror(r));
+ errc(1, r, "could not release lock");
sleep(1);
for (i = 0; i < THREAD_COUNT; i++)
if (! pthread_equal(pthread[i], self) &&
(r = pthread_join(pthread[i], NULL)))
- warnx("could not join thread: %s", strerror(r));
+ warnc(r, "could not join thread");
}
-/* $OpenBSD: earlysig.c,v 1.1 2013/06/21 06:47:20 guenther Exp $ */
+/* $OpenBSD: earlysig.c,v 1.2 2014/05/20 01:25:24 guenther Exp $ */
/*
* Public domain. 2005, Otto Moerbeek; 2013, Philip Guenther
/* make sure the thread library is fully active */
if ((r = pthread_create(&tid, NULL, tmain, NULL)))
- errx(1, "pthread_create: %s", strerror(r));
+ errc(1, r, "pthread_create");
pthread_join(tid, NULL);
/* make sure kill() and all the symbols in fork() are bound */
-/* $OpenBSD: pthread_rwlock.c,v 1.2 2012/02/26 11:47:51 miod Exp $ */
+/* $OpenBSD: pthread_rwlock.c,v 1.3 2014/05/20 01:25:24 guenther Exp $ */
/* PUBLIC DOMAIN Feb 2012 <guenther@openbsd.org> */
#include <sys/types.h>
for (i = 0; i < NUM_READERS; i++) {
ids[i] = i;
if ((r = pthread_create(&tr[i], NULL, reader, &ids[i])))
- errx(1, "create %d: %s", i, strerror(r));
+ errc(1, r, "create %d", i);
}
if ((r = pthread_create(&tw, NULL, writer, NULL)))
- errx(1, "create writer: %s", strerror(r));
+ errc(1, r, "create writer");
pthread_mutex_lock(&m);
while (state != WRITE)
-/* $OpenBSD: main-thread-exited.c,v 1.1 2012/03/05 02:40:21 guenther Exp $ */
+/* $OpenBSD: main-thread-exited.c,v 1.2 2014/05/20 01:25:24 guenther Exp $ */
/* PUBLIC DOMAIN Mar 2012 <guenther@openbsd.org> */
/* in child */
if ((r = pthread_create(&t, NULL, tmain, NULL)))
- errx(1, "pthread_create: %s", strerror(r));
+ errc(1, r, "pthread_create");
pthread_exit(NULL);
abort();
}
-/* $OpenBSD: rlim-file.c,v 1.3 2003/07/31 21:48:10 deraadt Exp $ */
+/* $OpenBSD: rlim-file.c,v 1.4 2014/05/20 01:25:24 guenther Exp $ */
/*
* Written by Artur Grabowski <art@openbsd.org> (2002) Public Domain.
*/
errx(1, "try to do the test on a less loaded system");
if (errno != EMFILE)
- errx(1, "bad errno (%d): %s", errno, strerror(errno));
+ err(1, "bad errno (%d)", errno);
return 0;
}
-/* $OpenBSD: csplit.c,v 1.4 2012/03/04 04:05:15 fgsch Exp $ */
+/* $OpenBSD: csplit.c,v 1.5 2014/05/20 01:25:23 guenther Exp $ */
/* $FreeBSD: src/usr.bin/csplit/csplit.c,v 1.9 2004/03/22 11:15:03 tjr Exp $ */
/*-
if ((size_t)snprintf(currfile, sizeof(currfile), "%s%0*ld", prefix,
(int)sufflen, nfiles) >= sizeof(currfile))
- errx(1, "%s: %s", currfile, strerror(ENAMETOOLONG));
+ errc(1, ENAMETOOLONG, "%s", currfile);
if ((fp = fopen(currfile, "w+")) == NULL)
err(1, "%s", currfile);
nfiles++;
-/* $OpenBSD: dc.c,v 1.11 2009/10/27 23:59:37 deraadt Exp $ */
+/* $OpenBSD: dc.c,v 1.12 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 2003, Otto Moerbeek <otto@drijf.net>
err(1, "cannot open file %s", argv[0]);
if (fstat(fileno(file), &st) == -1)
err(1, "%s", argv[0]);
- if (S_ISDIR(st.st_mode)) {
- errno = EISDIR;
- err(1, "%s", argv[0]);
- }
+ if (S_ISDIR(st.st_mode))
+ errc(1, EISDIR, "%s", argv[0]);
src_setstream(&src, file);
reset_bmachine(&src);
eval();
-/* $OpenBSD: diffdir.c,v 1.41 2012/11/29 02:15:44 guenther Exp $ */
+/* $OpenBSD: diffdir.c,v 1.42 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 2003, 2010 Todd C. Miller <Todd.Miller@courtesan.com>
dirlen1 = strlcpy(path1, *p1 ? p1 : ".", sizeof(path1));
if (dirlen1 >= sizeof(path1) - 1) {
- warnx("%s: %s", p1, strerror(ENAMETOOLONG));
+ warnc(ENAMETOOLONG, "%s", p1);
status = 2;
return;
}
}
dirlen2 = strlcpy(path2, *p2 ? p2 : ".", sizeof(path2));
if (dirlen2 >= sizeof(path2) - 1) {
- warnx("%s: %s", p2, strerror(ENAMETOOLONG));
+ warnc(ENAMETOOLONG, "%s", p2);
status = 2;
return;
}
-/* $OpenBSD: du.c,v 1.24 2013/11/13 21:20:01 deraadt Exp $ */
+/* $OpenBSD: du.c,v 1.25 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: du.c,v 1.11 1996/10/18 07:20:35 thorpej Exp $ */
/*
case FTS_DNR: /* Warn, continue. */
case FTS_ERR:
case FTS_NS:
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
+ warnc(p->fts_errno, "%s", p->fts_path);
rval = 1;
break;
default:
-/* $OpenBSD: fetch.c,v 1.121 2014/05/19 20:09:22 jca Exp $ */
+/* $OpenBSD: fetch.c,v 1.122 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: fetch.c,v 1.14 1997/08/18 10:20:20 lukem Exp $ */
/*-
#endif /* !SMALL */
}
if (error) {
- warnx("%s: %s", gai_strerror(error), host);
+ warnx("%s: %s", host, gai_strerror(error));
goto cleanup_url_get;
}
hints.ai_flags |= AI_NUMERICHOST;
error = getaddrinfo(srcaddr, NULL, &hints, &ares);
if (error) {
- warnx("%s: %s", gai_strerror(error), srcaddr);
+ warnx("%s: %s", srcaddr, gai_strerror(error));
goto cleanup_url_get;
}
}
-/* $OpenBSD: ftp.c,v 1.85 2014/04/22 20:48:41 tedu Exp $ */
+/* $OpenBSD: ftp.c,v 1.86 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: ftp.c,v 1.27 1997/08/18 10:20:23 lukem Exp $ */
/*
error = getaddrinfo(srcaddr, NULL, &ahints, &ares);
if (error) {
- warnx("%s: %s", gai_strerror(error), srcaddr);
+ warnx("%s: %s", srcaddr, gai_strerror(error));
code = -1;
return (0);
}
(void)fflush(ttyout);
}
if (c < 0)
- warnx("local: %s: %s", local, strerror(serrno));
+ warnc(serrno, "local: %s", local);
if (d < 0) {
if (serrno != EPIPE)
- warnx("netout: %s", strerror(serrno));
+ warnc(serrno, "netout");
bytes = -1;
}
break;
(void)fflush(ttyout);
}
if (ferror(fin))
- warnx("local: %s: %s", local, strerror(serrno));
+ warnc(serrno, "local: %s", local);
if (ferror(dout)) {
if (errno != EPIPE)
- warnx("netout: %s", strerror(serrno));
+ warnc(serrno, "netout");
bytes = -1;
}
break;
}
if (c < 0) {
if (serrno != EPIPE)
- warnx("netin: %s", strerror(serrno));
+ warnc(serrno, "netin");
bytes = -1;
}
if (d < c) {
if (d < 0)
- warnx("local: %s: %s", local, strerror(serrno));
+ warnc(serrno, "local: %s", local);
else
warnx("%s: short write", local);
}
}
if (ferror(din)) {
if (serrno != EPIPE)
- warnx("netin: %s", strerror(serrno));
+ warnc(serrno, "netin");
bytes = -1;
}
if (ferror(fout))
- warnx("local: %s: %s", local, strerror(serrno));
+ warnc(serrno, "local: %s", local);
break;
}
progressmeter(1, NULL);
error = getaddrinfo(srcaddr, NULL, &ahints, &ares);
if (error) {
- warnx("%s: %s", gai_strerror(error), srcaddr);
+ warnx("%s: %s", srcaddr, gai_strerror(error));
code = -1;
return (0);
}
-/* $OpenBSD: ruserpass.c,v 1.28 2009/05/05 19:35:30 martynas Exp $ */
+/* $OpenBSD: ruserpass.c,v 1.29 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: ruserpass.c,v 1.14 1997/07/20 09:46:01 lukem Exp $ */
/*
return (0);
i = snprintf(buf, sizeof(buf), "%s/.netrc", hdir);
if (i < 0 || i >= sizeof(buf)) {
- warnx("%s/.netrc: %s", hdir, strerror(ENAMETOOLONG));
+ warnc(ENAMETOOLONG, "%s/.netrc", hdir);
return (0);
}
cfile = fopen(buf, "r");
-/* $OpenBSD: util.c,v 1.47 2013/11/26 13:21:16 deraadt Exp $ */
+/* $OpenBSD: util.c,v 1.48 2014/05/20 01:25:23 guenther Exp $ */
/*-
* Copyright (c) 1999 James Howard and Dag-Erling Coïdan Smørgrav
case FTS_ERR:
file_err = 1;
if(!sflag)
- warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
+ warnc(p->fts_errno, "%s", p->fts_path);
break;
case FTS_DP:
break;
-/* $OpenBSD: args.c,v 1.17 2013/11/26 13:21:17 deraadt Exp $ */
+/* $OpenBSD: args.c,v 1.18 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 1980, 1993
home = getenv("HOME");
if (home != NULL && *home != '\0') {
if (snprintf(fname, sizeof fname, "%s/%s", home, prof) >= sizeof fname) {
- warnx("%s/%s: %s", home, prof, strerror(ENAMETOOLONG));
+ warnc(ENAMETOOLONG, "%s/%s", home, prof);
return;
}
if ((f = fopen(option_source = fname, "r")) != NULL) {
-/* $OpenBSD: indent.c,v 1.23 2013/11/26 13:21:17 deraadt Exp $ */
+/* $OpenBSD: indent.c,v 1.24 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 1980, 1993
if (*p == '/')
p++;
if (snprintf(bakfile, MAXPATHLEN, "%s.BAK", p) >= MAXPATHLEN)
- errx(1, "%s.BAK: %s", p, strerror(ENAMETOOLONG));
+ errc(1, ENAMETOOLONG, "%s.BAK", p);
/* copy in_name to backup file */
bakchn = creat(bakfile, 0600);
-/* $OpenBSD: lndir.c,v 1.19 2010/08/22 21:25:37 tedu Exp $ */
+/* $OpenBSD: lndir.c,v 1.20 2014/05/20 01:25:23 guenther Exp $ */
/* $XConsortium: lndir.c /main/15 1995/08/30 10:56:18 gildea $ */
/*
if (stat(tn, &ts) < 0)
err(1, "%s", tn);
if (!(S_ISDIR(ts.st_mode)))
- errx(2, "%s: %s", tn, strerror(ENOTDIR));
+ errc(2, ENOTDIR, "%s", tn);
if (chdir(tn) < 0)
err(1, "%s", tn);
if (stat(fn, &fs) < 0)
err(1, "%s", fn);
if (!(S_ISDIR(fs.st_mode)))
- errx(2, "%s: %s", fn, strerror(ENOTDIR));
+ errc(2, ENOTDIR, "%s", fn);
exit(dodir(fn, &fs, &ts, 0));
}
-/* $OpenBSD: login.c,v 1.61 2009/10/27 23:59:40 deraadt Exp $ */
+/* $OpenBSD: login.c,v 1.62 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: login.c,v 1.13 1996/05/15 23:50:16 jtc Exp $ */
/*-
break;
case 'h':
if (uid) {
- warnx("-h option: %s", strerror(EPERM));
+ warnc(EPERM, "-h option");
quickexit(1);
}
free(fqdn);
break;
case 'L':
if (uid) {
- warnx("-L option: %s", strerror(EPERM));
+ warnc(EPERM, "-L option");
quickexit(1);
}
if (lipaddr) {
break;
case 'R':
if (uid) {
- warnx("-R option: %s", strerror(EPERM));
+ warnc(EPERM, "-R option");
quickexit(1);
}
if (ripaddr) {
break;
case 'u':
if (uid) {
- warnx("-u option: %s", strerror(EPERM));
+ warnc(EPERM, "-u option");
quickexit(1);
}
rusername = optarg;
-/* $OpenBSD: look.c,v 1.14 2013/11/26 13:19:07 deraadt Exp $ */
+/* $OpenBSD: look.c,v 1.15 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: look.c,v 1.7 1995/08/31 22:41:02 jtc Exp $ */
/*-
if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
err(2, "%s", file);
if (sb.st_size > SIZE_T_MAX)
- errx(2, "%s: %s", file, strerror(EFBIG));
+ errc(2, EFBIG, "%s", file);
if ((front = mmap(NULL,
(size_t)sb.st_size, PROT_READ, MAP_PRIVATE, fd, (off_t)0)) == MAP_FAILED)
err(2, "%s", file);
-/* $OpenBSD: lex.c,v 1.36 2014/01/17 18:42:30 okan Exp $ */
+/* $OpenBSD: lex.c,v 1.37 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: lex.c,v 1.10 1997/05/17 19:55:13 pk Exp $ */
/*
switch (stb.st_mode & S_IFMT) {
case S_IFDIR:
(void)Fclose(ibuf);
- errno = EISDIR;
- warn("%s", name);
+ warnc(EISDIR, "%s", name);
return(-1);
case S_IFREG:
default:
(void)Fclose(ibuf);
- errno = EINVAL;
- warn("%s", name);
+ warnc(EINVAL, "%s", name);
return(-1);
}
-/* $OpenBSD: netcat.c,v 1.118 2014/03/12 10:19:40 jca Exp $ */
+/* $OpenBSD: netcat.c,v 1.119 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 2001 Eric Jackson <ericj@monkey.org>
*
if (bind(s, (struct sockaddr *)ares->ai_addr,
ares->ai_addrlen) < 0)
- errx(1, "bind failed: %s", strerror(errno));
+ err(1, "bind failed");
freeaddrinfo(ares);
}
-/* $OpenBSD: nl.c,v 1.2 2013/11/15 22:20:04 millert Exp $ */
+/* $OpenBSD: nl.c,v 1.3 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: nl.c,v 1.11 2011/08/16 12:00:46 christos Exp $ */
/*-
break;
case 'd':
clen = mbrlen(optarg, MB_CUR_MAX, NULL);
- if (clen == (size_t)-1 || clen == (size_t)-2) {
- errno = EILSEQ;
- err(EXIT_FAILURE, NULL);
- }
+ if (clen == (size_t)-1 || clen == (size_t)-2)
+ errc(EXIT_FAILURE, EILSEQ, NULL);
if (clen != 0) {
memcpy(delim1, optarg, delim1len = clen);
clen = mbrlen(optarg + delim1len,
MB_CUR_MAX, NULL);
- if (clen == (size_t)-1 || clen == (size_t)-2) {
- errno = EILSEQ;
- err(EXIT_FAILURE, NULL);
- }
+ if (clen == (size_t)-1 || clen == (size_t)-2)
+ errc(EXIT_FAILURE, EILSEQ, NULL);
if (clen != 0) {
memcpy(delim2, optarg + delim1len,
delim2len = clen);
-/* $OpenBSD: mkpath.c,v 1.3 2013/11/12 13:51:42 deraadt Exp $ */
+/* $OpenBSD: mkpath.c,v 1.4 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 1983, 1992, 1993
* The Regents of the University of California. All rights reserved.
return (-1);
}
} else if (!S_ISDIR(sb.st_mode)) {
- warnx("%s: %s", path, strerror(ENOTDIR));
+ warnc(ENOTDIR, "%s", path);
return (-1);
}
-/* $OpenBSD: printf.c,v 1.20 2014/04/18 11:35:51 guenther Exp $ */
+/* $OpenBSD: printf.c,v 1.21 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
warnx ("%s: not completely converted", s);
rval = 1;
} else if (errno == ERANGE) {
- warnx ("%s: %s", s, strerror(ERANGE));
+ warnc(ERANGE, "%s", s);
rval = 1;
}
}
-/* $OpenBSD: skeyinit.c,v 1.54 2014/04/23 18:24:23 ajacoutot Exp $ */
+/* $OpenBSD: skeyinit.c,v 1.55 2014/05/20 01:25:23 guenther Exp $ */
/* OpenBSD S/Key (skeyinit.c)
*
if (rmkey) {
if (snprintf(filename, sizeof(filename),
"%s/%s", _PATH_SKEYDIR, pp->pw_name)
- >= sizeof(filename)) {
- errno = ENAMETOOLONG;
- err(1, "Cannot remove S/Key entry");
- }
+ >= sizeof(filename))
+ errc(1, ENAMETOOLONG,
+ "Cannot remove S/Key entry");
if (unlink(filename) != 0)
err(1, "Cannot remove S/Key entry");
printf("S/Key entry for %s removed.\n",
(void)printf("[Adding %s with %s]\n", pp->pw_name,
ht ? ht : skey_get_algorithm());
if (snprintf(filename, sizeof(filename), "%s/%s",
- _PATH_SKEYDIR, pp->pw_name) >= sizeof(filename)) {
- errno = ENAMETOOLONG;
- err(1, "Cannot create S/Key entry");
- }
+ _PATH_SKEYDIR, pp->pw_name) >= sizeof(filename))
+ errc(1, ENAMETOOLONG,
+ "Cannot create S/Key entry");
if ((l = open(filename,
O_RDWR | O_NONBLOCK | O_CREAT | O_TRUNC |O_NOFOLLOW,
S_IRUSR | S_IWUSR)) == -1 ||
/* Now write the new-style record. */
if (snprintf(filename, sizeof(filename), "%s/%s", _PATH_SKEYDIR,
logname) >= sizeof(filename)) {
- errno = ENAMETOOLONG;
- warn("%s", logname);
+ warnc(ENAMETOOLONG, "%s", logname);
continue;
}
fd = open(filename, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
-/* $OpenBSD: spellprog.c,v 1.7 2013/11/28 18:24:55 deraadt Exp $ */
+/* $OpenBSD: spellprog.c,v 1.8 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 1991, 1993
if (wlists[i].fd == -1 || fstat(wlists[i].fd, &sb) != 0)
err(1, "%s", argv[i]);
if (sb.st_size > SIZE_T_MAX)
- errx(1, "%s: %s", argv[i], strerror(EFBIG));
+ errc(1, EFBIG, "%s", argv[i]);
wlists[i].front = mmap(NULL, (size_t)sb.st_size, PROT_READ,
MAP_PRIVATE, wlists[i].fd, (off_t)0);
if (wlists[i].front == MAP_FAILED)
-/* $OpenBSD: uudecode.c,v 1.18 2012/03/04 04:05:15 fgsch Exp $ */
+/* $OpenBSD: uudecode.c,v 1.19 2014/05/20 01:25:23 guenther Exp $ */
/* $FreeBSD: uudecode.c,v 1.49 2003/05/03 19:44:46 obrien Exp $ */
/*-
flags = O_WRONLY|O_CREAT|O_EXCL|O_NOFOLLOW;
if (lstat(outfile, &st) == 0) {
if (iflag) {
- errno = EEXIST;
- warn("%s: %s", infile, outfile);
+ warnc(EEXIST, "%s: %s", infile, outfile);
return (0);
}
switch (st.st_mode & S_IFMT) {
warn("%s: unlink %s", infile, outfile);
return (1);
case S_IFDIR:
- errno = EISDIR;
- warn("%s: %s", infile, outfile);
+ warnc(EISDIR, "%s: %s", infile, outfile);
return (1);
default:
if (oflag) {
flags &= ~(O_EXCL|O_NOFOLLOW);
break;
}
- errno = EEXIST;
- warn("%s: %s", infile, outfile);
+ warnc(EEXIST, "%s: %s", infile, outfile);
return (1);
}
} else if (errno != ENOENT) {
-/* $OpenBSD: which.c,v 1.18 2013/04/10 02:57:20 guenther Exp $ */
+/* $OpenBSD: which.c,v 1.19 2014/05/20 01:25:23 guenther Exp $ */
/*
* Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
p[--plen] = '\0'; /* strip trailing '/' */
if (plen + 1 + proglen >= sizeof(filename)) {
- warnx("%s/%s: %s", p, prog, strerror(ENAMETOOLONG));
+ warnc(ENAMETOOLONG, "%s/%s", p, prog);
free(path);
return (0);
}
-/* $OpenBSD: xinstall.c,v 1.56 2013/11/27 13:32:02 okan Exp $ */
+/* $OpenBSD: xinstall.c,v 1.57 2014/05/20 01:25:23 guenther Exp $ */
/* $NetBSD: xinstall.c,v 1.9 1995/12/20 10:25:17 jonathan Exp $ */
/*
if (stat(*argv, &from_sb))
err(EX_OSERR, "%s", *argv);
if (!S_ISREG(to_sb.st_mode))
- errx(EX_OSERR, "%s: %s", to_name, strerror(EFTYPE));
+ errc(EX_OSERR, EFTYPE, "%s", to_name);
if (to_sb.st_dev == from_sb.st_dev &&
to_sb.st_ino == from_sb.st_ino)
errx(EX_USAGE, "%s and %s are the same file", *argv, to_name);
if (stat(from_name, &from_sb))
err(EX_OSERR, "%s", from_name);
if (!S_ISREG(from_sb.st_mode))
- errx(EX_OSERR, "%s: %s", from_name, strerror(EFTYPE));
+ errc(EX_OSERR, EFTYPE, "%s", from_name);
/* Build the target path. */
if (flags & DIRECTORY) {
(void)snprintf(pathbuf, sizeof(pathbuf), "%s/%s",
/* Only compare against regular files. */
if (docompare && !S_ISREG(to_sb.st_mode)) {
docompare = 0;
- warnx("%s: %s", to_name, strerror(EFTYPE));
+ warnc(EFTYPE, "%s", to_name);
}
} else if (docompare) {
/* File does not exist so silently ignore compare flag. */
if (fstat(temp_fd, &temp_sb)) {
serrno = errno;
(void)unlink(tempfile);
- errx(EX_OSERR, "%s: %s", tempfile, strerror(serrno));
+ errc(EX_OSERR, serrno, "%s", tempfile);
}
if (compare(temp_fd, tempfile, (size_t)temp_sb.st_size, to_fd,
from_fd, (off_t)0)) == MAP_FAILED) {
serrno = errno;
(void)unlink(to_name);
- errx(EX_OSERR, "%s: %s", from_name, strerror(serrno));
+ errc(EX_OSERR, serrno, "%s", from_name);
}
madvise(p, size, MADV_SEQUENTIAL);
siz = (size_t)size;
if (nr != 0) {
serrno = errno;
(void)unlink(to_name);
- errx(EX_OSERR, "%s: %s", from_name, strerror(serrno));
+ errc(EX_OSERR, serrno, "%s", from_name);
}
}
}
case -1:
serrno = errno;
(void)unlink(to_name);
- errx(EX_TEMPFAIL, "forks: %s", strerror(serrno));
+ errc(EX_TEMPFAIL, serrno, "forks");
case 0:
execl(path_strip, "strip", "--", to_name, (char *)NULL);
warn("%s", path_strip);
int mkdir_errno = errno;
if (stat(path, &sb)) {
/* Not there; use mkdir()s errno */
- errno = mkdir_errno;
- err(EX_OSERR, "%s", path);
+ errc(EX_OSERR, mkdir_errno, "%s",
+ path);
/* NOTREACHED */
}
if (!S_ISDIR(sb.st_mode)) {
/* Is there, but isn't a directory */
- errno = ENOTDIR;
- err(EX_OSERR, "%s", path);
+ errc(EX_OSERR, ENOTDIR, "%s", path);
/* NOTREACHED */
}
}
-/* $OpenBSD: elf_hide.c,v 1.7 2013/11/12 19:48:40 deraadt Exp $ */
+/* $OpenBSD: elf_hide.c,v 1.8 2014/05/20 01:25:24 guenther Exp $ */
/*
* Copyright (c) 1997 Dale Rahn.
tmpsymtab = (Elf_Sym *) calloc(1, symtabsize);
symmap = (Symmap *) calloc(nsyms, sizeof(Symmap));
if (!tmpsymtab || !symmap)
- errx(5, "calloc: %s", strerror(ENOMEM));
+ errc(5, ENOMEM, "calloc");
bcopy(symtab, tmpsymtab, symtabsize);
-/* $OpenBSD: nlist.c,v 1.44 2013/11/12 13:11:10 deraadt Exp $ */
+/* $OpenBSD: nlist.c,v 1.45 2014/05/20 01:25:24 guenther Exp $ */
/*-
* Copyright (c) 1990, 1993
error = __elf_knlist(fd, db, ksyms);
if (fmterr != NULL)
- warnx("%s: %s: %s", kfile, fmterr, strerror(EFTYPE));
+ warnc(EFTYPE, "%s: %s", kfile, fmterr);
return(error);
}
-/* $OpenBSD: lpr.c,v 1.45 2013/11/24 21:32:32 deraadt Exp $ */
+/* $OpenBSD: lpr.c,v 1.46 2014/05/20 01:25:24 guenther Exp $ */
/* $NetBSD: lpr.c,v 1.19 2000/10/11 20:23:52 is Exp $ */
/*
struct stat stb;
if (snprintf(buf, sizeof(buf), "%s/.seq", SD) >= sizeof(buf))
- errx(1, "%s/.seq: %s", SD, strerror(ENAMETOOLONG));
+ errc(1, ENAMETOOLONG, "%s/.seq", SD);
PRIV_START;
if ((fd = safe_open(buf, O_RDWR|O_CREAT|O_NOFOLLOW, 0661)) < 0)
err(1, "cannot open %s", buf);
-/* $OpenBSD: pcidump.c,v 1.35 2013/11/12 19:48:53 deraadt Exp $ */
+/* $OpenBSD: pcidump.c,v 1.36 2014/05/20 01:25:24 guenther Exp $ */
/*
* Copyright (c) 2006, 2007 David Gwynne <loki@animata.net>
error = probe(bus, dev, func);
if (error != 0)
- errx(1, "\"%s\": %s", argv[0], strerror(error));
+ errc(1, error, "\"%s\"", argv[0]);
} else {
printf("Domain %s:\n", pcidev);
scanpcidomain();
-/* $OpenBSD: procmap.c,v 1.52 2014/02/13 21:17:13 tedu Exp $ */
+/* $OpenBSD: procmap.c,v 1.53 2014/05/20 01:25:24 guenther Exp $ */
/* $NetBSD: pmap.c,v 1.1 2002/09/01 20:32:44 atatat Exp $ */
/*
kproc = kvm_getprocs(kd, KERN_PROC_PID, pid,
sizeof(struct kinfo_proc), &rc);
if (kproc == NULL || rc == 0) {
- errno = ESRCH;
- warn("%d", pid);
+ warnc(ESRCH, "%d", pid);
pid = -1;
continue;
}
-/* $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
void cleanup(void);
void error(char *);
+void errorc(int, char *);
void errorx(char *);
void cp(char *, char *, mode_t);
void mv(char *, char *);
*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);
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);
int sverrno = errno;
(void)snprintf(buf, sizeof(buf), "%s to %s", from, to);
- errno = sverrno;
- error(buf);
+ errorc(sverrno, buf);
}
}
exit(1);
}
+void
+errorc(int code, char *name)
+{
+
+ warnc(code, "%s", name);
+ cleanup();
+ exit(1);
+}
+
void
errorx(char *name)
{