The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
From: norman@oclsc.org (Norman Wilson)
Subject: [TUHS] Happy birthday, Dennis Ritchie! [ really sun vs dec/apollo --> X and NeWS ]
Date: Thu, 21 Sep 2017 13:46:10 -0400	[thread overview]
Message-ID: <1506015974.14196.for-standards-violators@oclsc.org> (raw)

On Tue, Sep 19, 2017, at 10:42, Larry McVoy wrote:
> slib.c:1653 (bk-7.3): open failed: permission denied
> 
> which is way way way more useful than just permission denied.

Random832 replied:

  Well. It's less useful in one way - it doesn't say what file it was
  trying to open. You could pass the filename *instead* of "open failed",
  but that still omits the issue I had pointed out: what were you trying
  to open the file for (at the very least, were you trying to read, write,
  or exec it). Ideally the function would have a format and arguments.

====

Exactly.

The string interpretation of errno is just another
item of data that goes in an error message.  There is
no fixed place it belongs, and it doesn't always
belong there, because all that is error does not
fail from a syscall (or library routine).

I do often insert a function of the form

	void errmsg(char *, ...)

in my C programs.  It takes printf-like arguments.
Normally they just get passed to vfprintf(stderr, ...),
though sometimes there is something more esoteric,
and often fprintf(stderr, "%s: ", progname) ends up
in front.

But errmsg never knows anything about errno.  Why
should it?  It's supposed to send complaints to
a standard place; it's not supposed to invent the
complaints for itself!  If an errno is involved,
I write something like
	errmsg("%s: cannot open: %s", filename, strerror(errno));
(Oh, yes, errmsg appends a newline too.  The idea
is to avoid cluttering code with minutiae of how
errors are reported.)

I don't print the source code filename or line number
except for `this shouldn't have happened' errors.
For routine events like the user gave the wrong
filename or it had the wrong permissions or his
data are malformed, pointers to the source code are
just unhelpful clutter, like the complicated
%JARGON-OBSCURE-ABBREVIATION prefixes that accompanied
every official error message in VMS.

Of course, if the user's data are malformed, he
should be told which file has the problem and
where in the file.  But that's different from
telling him that line 193 of some file he doesn't
have and will probably never see contains the system
call that reported that he typed the wrong filename.

Norman Wilson
Toronto ON


             reply	other threads:[~2017-09-21 17:46 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 17:46 Norman Wilson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-09-19 12:24 Norman Wilson
2017-09-19 18:09 ` Random832
2017-09-19 19:21   ` Chris Torek
2017-09-08 20:54 [TUHS] Happy birthday, Dennis Ritchie! Dave Horsfall
2017-09-08 21:14 ` William Pechter
2017-09-11 16:30   ` Paul Winalski
2017-09-11 16:49     ` [TUHS] Happy birthday, Dennis Ritchie! [ really sun vs dec/apollo ] Jon Steinhart
2017-09-11 23:09       ` Larry McVoy
2017-09-12  7:38         ` arnold
2017-09-12 15:35           ` [TUHS] Happy birthday, Dennis Ritchie! [ really sun vs dec/apollo --> X and NeWS ] Jon Steinhart
2017-09-12 16:57             ` Larry McVoy
2017-09-12 17:04             ` Arthur Krewat
2017-09-12 17:07               ` Larry McVoy
2017-09-12 23:33               ` Dave Horsfall
2017-09-12 20:15             ` Steve Johnson
2017-09-13  2:23               ` Larry McVoy
2017-09-14  0:53                 ` Nemo
2017-09-14  1:18                   ` Henry Bent
2017-09-14  3:15                   ` Larry McVoy
2017-09-14  9:35                   ` Rico Pajarola
2017-09-14 11:11                     ` arnold
2017-09-14 12:13                       ` Rico Pajarola
2017-09-14 12:50                         ` Chet Ramey
2017-09-14 13:27                           ` Rico Pajarola
2017-09-14 14:30                             ` Chet Ramey
2017-09-14 13:21                       ` Steffen Nurpmeso
2017-09-14 19:44                         ` arnold
2017-09-15 17:42                           ` Steffen Nurpmeso
2017-09-14 20:31                         ` Ian Zimmerman
2017-09-15  3:16                   ` Dave Horsfall
2017-09-15  3:33                     ` Warner Losh
2017-09-15  8:32                       ` Ron Natalie
2017-09-15 12:42                     ` Arthur Krewat
2017-09-15 18:20                     ` Steffen Nurpmeso
2017-09-15 18:37                       ` Paul Winalski
2017-09-13  7:30               ` arnold
2017-09-13 13:35                 ` Larry McVoy
2017-09-13 23:55                   ` Dave Horsfall
2017-09-14  0:18                     ` Henry Bent
2017-09-14  2:10                       ` Larry McVoy
2017-09-14 19:37                       ` Steve Johnson
2017-09-14 19:54                         ` Steve Nickolas
2017-09-14 20:50                           ` Ian Zimmerman
2017-09-14 21:00                             ` Ron Natalie
2017-09-14 20:11                         ` Ron Natalie
2017-09-14 20:26                           ` Jon Steinhart
2017-09-19  0:52                         ` Random832
2017-09-19  2:50                           ` Larry McVoy
2017-09-19  2:56                             ` Gregg Levine
2017-09-19  3:37                               ` Larry McVoy
2017-09-19  6:52                                 ` Lars Brinkhoff
2017-09-19  7:22                             ` Ian Zimmerman
2017-09-19 13:22                               ` Larry McVoy
2017-09-19 13:53                             ` Steffen Nurpmeso
2017-09-19 13:56                               ` Larry McVoy
2017-09-19 17:56                                 ` Random832
2017-09-19 18:31                                   ` Steffen Nurpmeso
2017-09-19 18:34                                     ` Larry McVoy
2017-09-19 19:31                                   ` Lawrence Stewart
2017-09-20  3:13                                   ` Larry McVoy
2017-09-23 22:24                                     ` Ralph Corderoy
2017-09-19 14:32                             ` Clem Cole
2017-09-19 14:42                               ` Larry McVoy
2017-09-19 15:12                                 ` Clem Cole
2017-09-19 18:03                                 ` Random832

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506015974.14196.for-standards-violators@oclsc.org \
    --to=norman@oclsc.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).