On Tue, 14 Jan 2014, Theo de Raadt wrote:
> > I think it is worth adding this interface, given how frequently
> > this family is used:
> > 
> >   $ git grep -E '(err|warn)\(' origin/master|wc -l
> >     19583
> > 
> > all in all, including perl(1) stuff.  A family that is used so
> > often can well tolerate a few more options, i think.
> > Just my one cent.
> 
> The origian ones are used lot.  That is very seperate from your
> argument that we need even more variants, which are not used now?
> It's horse shit.  You just failed to justify it entirely.

A quick scan of base turns up 100 obvious places for it to be used, as 
found by
        egrep -RwA1 'v?(err|warn)x' /usr/src | egrep -w strerror

with a few false positives removed; see list below.  That illustrates the 
other replacement for the *c variants: instead of setting errno again the 
caller just switches to the *x variant and calls strerror() themselves.  
For example, the first example from chmod:
                warnx("%s: %s", p->fts_path, strerror(p->fts_errno));
would be
                warnc(p->fts_errno, "%s", p->fts_path);

Searching for errno assignments right before v(err|warn) turns up around 
90 additional places in base.

I like them.


Philip


bin/chmod/chmod.c:                      warnx("%s: %s", p->fts_path, 
strerror(p->fts_errno));
bin/chmod/chmod.c:                      warnx("%s: %s", p->fts_path, 
strerror(p->fts_errno));
bin/cp/cp.c-                        curr->fts_path, strerror(curr->fts_errno));
bin/cp/cp.c:                    warnx("%s: %s", curr->fts_path, 
strerror(EOPNOTSUPP));
bin/dd/args.c:erange:                           errx(1, "%s: %s", oper, 
strerror(ERANGE));
bin/dd/args.c:erange:                           errx(1, "%s: %s", oper, 
strerror(ERANGE));
bin/ls/ls.c-                        p->fts_name, strerror(p->fts_errno));
bin/ls/ls.c-                        cur->fts_name, strerror(cur->fts_errno));
bin/rm/rm.c-                                p->fts_path, 
strerror(p->fts_errno));
bin/rm/rm.c:                    errx(1, "%s: %s", p->fts_path, 
strerror(p->fts_errno));
bin/rm/rm.c-                                p->fts_path, 
strerror(p->fts_errno));
games/boggle/boggle/bog.c:                                              errx(1, 
"%s", strerror(ENOMEM));
games/boggle/boggle/bog.c:                                              errx(1, 
"%s", strerror(ENOMEM));
games/boggle/boggle/bog.c:                              errx(1, "%s", 
strerror(ENOMEM));
games/boggle/boggle/bog.c:                              errx(1, "%s", 
strerror(ENOMEM));
games/robots/main.c-                    strerror(score_err));
kerberosV/src/appl/kx/kx.c:     errx(1, "failed creating cookie file: %s", 
strerror(error));
regress/lib/libc/stdio_threading/include/local.h:               errx(1, "could 
not obtain lock in thread: %s", strerror(r));
regress/lib/libc/stdio_threading/include/local.h:               errx(1, "could 
not release lock in thread: %s", strerror(r));
regress/lib/libc/stdio_threading/include/local.h:               errx(1, "could 
not initialize lock: %s", strerror(r));
regress/lib/libc/stdio_threading/include/local.h:               errx(1, "could 
not lock lock: %s", strerror(r));
regress/lib/libc/stdio_threading/include/local.h:                       
warnx("could not create thread: %s", strerror(r));
regress/lib/libc/stdio_threading/include/local.h:               errx(1, "could 
not release lock: %s", strerror(r));
regress/lib/libc/stdio_threading/include/local.h-                   
strerror(r));
regress/lib/libc/stdio_threading/include/local.h:                       
warnx("could not join thread: %s", strerror(r));
regress/lib/libpthread/pthread_rwlock/pthread_rwlock.c:                 errx(1, 
"create %d: %s", i, strerror(r));
regress/lib/libpthread/pthread_rwlock/pthread_rwlock.c:         errx(1, "create 
writer: %s", strerror(r));
regress/lib/libpthread/mutex_sigs/mutex_sigs.c:         errx(1, "tmain: 
pthread_mutex_lock: %s", strerror(r));
regress/lib/libpthread/mutex_sigs/mutex_sigs.c:         errx(1, "tmain: 
pthread_mutex_unlock: %s", strerror(r));
regress/lib/libpthread/mutex_sigs/mutex_sigs.c:         errx(1, "tmain: 
pthread_create: %s", strerror(r));
regress/lib/libpthread/earlysig/earlysig.c:             errx(1, 
"pthread_create: %s", strerror(r));
regress/lib/libpthread/blocked_poll/blocked_poll.c:             errx(1, 
"pthread_create: %s", strerror(r));
regress/sys/kern/rlimit-file/rlim-file.c:               errx(1, "bad errno 
(%d): %s", errno, strerror(errno));
regress/sys/kern/main-thread-exited/main-thread-exited.c:               errx(1, 
"pthread_create: %s", strerror(r));
regress/sys/ptrace/ptrace-threads.c:            errx(1, "pthread_create: %s", 
strerror(r));
sbin/fsirand/fsirand.c-                     (n < SBSIZE) ? "short read" : 
strerror(errno));
sbin/fsirand/fsirand.c-                     (n < ibufsize) ? "short read" : 
strerror(errno));
sbin/mount_nfs/mount_nfs.c:             warnx("can't access %s: %s", spec, 
strerror(nfhret.stat));
sbin/newfs/newfs.c-                                          
strerror(WEXITSTATUS(status)));
sbin/ping/ping.c:                               errx(1, "%s", strerror(EPERM));
sbin/ping/ping.c-                                           strerror(EPERM));
sbin/ping/ping.c:                               errx(1, "%s", strerror(EPERM));
sbin/ping6/ping6.c-                                 strerror(EPERM));
sbin/reboot/reboot.c:           errx(1, "%s", strerror(EPERM));
sbin/newfs_ext2fs/newfs_ext2fs.c:               errx(EXIT_FAILURE, "%s: %s", 
special, strerror(errno));
usr.bin/csplit/csplit.c:                errx(1, "%s: %s", currfile, 
strerror(ENAMETOOLONG));
usr.bin/calendar/calendar.c:                            errx(1, "%s", 
strerror(EPERM));
usr.bin/chpass/chpass.c:        errx(1, "%s", strerror(EACCES));
usr.bin/compress/main.c-                                    
strerror(entry->fts_errno));
usr.bin/compress/main.c-                            errno == EINVAL ? "crc 
error" : strerror(errno));
usr.bin/diff/diffdir.c:         warnx("%s: %s", p1, strerror(ENAMETOOLONG));
usr.bin/diff/diffdir.c:         warnx("%s: %s", p2, strerror(ENAMETOOLONG));
usr.bin/du/du.c:                        warnx("%s: %s", p->fts_path, 
strerror(p->fts_errno));
usr.bin/encrypt/encrypt.c:                      errx(1, "%s", strerror(EFTYPE));
usr.bin/ftp/util.c-                         strerror(ENAMETOOLONG));
usr.bin/ftp/ruserpass.c:                warnx("%s/.netrc: %s", hdir, 
strerror(ENAMETOOLONG));
usr.bin/ftp/ftp.c:                      warnx("local: %s: %s", local, 
strerror(serrno));
usr.bin/ftp/ftp.c:                              warnx("netout: %s", 
strerror(serrno));
usr.bin/ftp/ftp.c:                      warnx("local: %s: %s", local, 
strerror(serrno));
usr.bin/ftp/ftp.c:                              warnx("netout: %s", 
strerror(serrno));
usr.bin/ftp/ftp.c:                              warnx("netin: %s", 
strerror(serrno));
usr.bin/ftp/ftp.c:                              warnx("local: %s: %s", local, 
strerror(serrno));
usr.bin/ftp/ftp.c:                              warnx("netin: %s", 
strerror(serrno));
usr.bin/ftp/ftp.c:                      warnx("local: %s: %s", local, 
strerror(serrno));
usr.bin/grep/util.c:                            warnx("%s: %s", p->fts_path, 
strerror(p->fts_errno));
usr.bin/indent/args.c:      warnx("%s/%s: %s", home, prof, 
strerror(ENAMETOOLONG));
usr.bin/indent/indent.c:            errx(1, "%s.BAK: %s", p, 
strerror(ENAMETOOLONG));
usr.bin/lndir/lndir.c:          errx(2, "%s: %s", tn, strerror(ENOTDIR));
usr.bin/lndir/lndir.c:          errx(2, "%s: %s", fn, strerror(ENOTDIR));
usr.bin/login/login.c:                          warnx("-h option: %s", 
strerror(EPERM));
usr.bin/login/login.c:                          warnx("-L option: %s", 
strerror(EPERM));
usr.bin/login/login.c:                          warnx("-R option: %s", 
strerror(EPERM));
usr.bin/login/login.c:                          warnx("-u option: %s", 
strerror(EPERM));
usr.bin/look/look.c:            errx(2, "%s: %s", file, strerror(EFBIG));
usr.bin/nc/netcat.c:                            errx(1, "bind failed: %s", 
strerror(errno));
usr.bin/passwd/yp_passwd.c-                 strerror(EACCES));
usr.bin/patch/mkpath.c:                 warnx("%s: %s", path, 
strerror(ENOTDIR));
usr.bin/printf/printf.c:                warnx ("%s: %s", s, strerror(ERANGE));
usr.bin/spell/spellprog.c:                      errx(1, "%s: %s", argv[i], 
strerror(EFBIG));
usr.bin/which/which.c:                  warnx("%s/%s: %s", p, prog, 
strerror(ENAMETOOLONG));
usr.bin/xinstall/xinstall.c:                    errx(EX_OSERR, "%s: %s", 
to_name, strerror(EFTYPE));
usr.bin/xinstall/xinstall.c:                    errx(EX_OSERR, "%s: %s", 
from_name, strerror(EFTYPE));
usr.bin/xinstall/xinstall.c:                    warnx("%s: %s", to_name, 
strerror(EFTYPE));
usr.bin/xinstall/xinstall.c:                    errx(EX_OSERR, "%s: %s", 
tempfile, strerror(serrno));
usr.bin/xinstall/xinstall.c-                safecopy ? tempfile : to_name, 
strerror(serrno));
usr.bin/xinstall/xinstall.c-                strerror(serrno));
usr.bin/xinstall/xinstall.c-                        safecopy ? tempfile 
:to_name, strerror(errno));
usr.bin/xinstall/xinstall.c-                                 backup, 
strerror(serrno));
usr.bin/xinstall/xinstall.c-                         to_name, strerror(serrno));
usr.bin/xinstall/xinstall.c:                    errx(EX_OSERR, "%s: %s", 
from_name, strerror(serrno));
usr.bin/xinstall/xinstall.c-                        to_name, strerror(nw > 0 ? 
EIO : serrno));
usr.bin/xinstall/xinstall.c-                                to_name, 
strerror(nw > 0 ? EIO : serrno));
usr.bin/xinstall/xinstall.c:                    errx(EX_OSERR, "%s: %s", 
from_name, strerror(serrno));
usr.bin/xinstall/xinstall.c:            errx(EX_TEMPFAIL, "forks: %s", 
strerror(serrno));
usr.sbin/edquota/edquota.c:             errx(1, "%s", strerror(EPERM));
usr.sbin/kgmon/kgmon.c-             kflag ? kvm_geterr(kvp->kd) : 
strerror(errno));
usr.sbin/kvm_mkdb/nlist.c:              warnx("%s: %s: %s", kfile, fmterr, 
strerror(EFTYPE));
usr.sbin/lpr/lpr/lpr.c:         errx(1, "%s/.seq: %s", SD, 
strerror(ENAMETOOLONG));
usr.sbin/pcidump/pcidump.c:                     errx(1, "\"%s\": %s", argv[0], 
strerror(error));
usr.sbin/crunchgen/elf_hide.c:          errx(5, "calloc: %s", strerror(ENOMEM));

Reply via email to