Subject: Re: `sys_errlist' in `stdio.h'
To: None <current-users@NetBSD.ORG>
From: Alan Peakall <alan@parsys.co.uk>
List: current-users
Date: 01/16/1996 10:32:06
>>Moving the declaration to <errno.h> would address the original problem,
>>as ``old'' code should no more know about that header than about `const'.

bad@flatlin.ka.sub.org:
>Pardon?  What old code doesn't know about errno.h?  I believe that
>file has been in use since V7 latest.

You are quite correct, I regret that I was suffering the mental aberration
of confusing the absence of a declaration for `errno' in `errno.h' with the
absence of `errno.h' itself !

juengst@de.uni-bonn.physik.saph1:
> The interface (the header file and its declarations) is the only tool
> which is available for the compiler to check the correct usage of a
> specific implementation by the programmer of an application.
                                                  ^^^^^^^^^^^

So far the only (non-obsolete) application cited for `sys_errlist' has been
the implementation of `strerror()' - I see this as an aspect of the
implementation internals of the library.

> It might be possible to use a private declaration, but this is not a
> real solution. You should never use a private declaration of a system
> (OS) identifier, because its implementation could be different for
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> each system (look at lseek, offset is sometimes int or long).

Can anyone cite an implementation of `sys_errlist' that is not
functionally `const char *const []'.  The constancy of the
character strings and pointers has always been implicit even when
the compiler could not understand a declarative statement of the fact.
Further, since `sys_errlist' has now been obsoleted by `strerror()',
no one should be reimplementing it.

On SunOS4.1.3 and (presumably) all its BSD ancestors `sys_errlist' is
not declared in any header file and so, undesirable as it may be, it
must always have been declared in `*.c' source files where it was
referenced.  Such declarations would have been unlikely to have used
`const', as there was then no compiler support and as `perror(3)' does
not specify it.  By exporting a stricter declaration from a commonly
used header file (`stdio.h' or `errno.h') NetBSD is demanding a porting
exception.

I know no good reason for new _application_ code to use `sys_errlist',
so it seems to me that the question is a pragmatic one of whether having
a more strictly typed declaration of `sys_errlist' really finds bugs
in old application code being ported to NetBSD to compensate for
the nuisance of the near certainty of requiring a porting exception
for code whose historic insecure usage (``a private declaration of
a system (OS) identifier'') was correct.  NetBSD seems to have
gone almost all the way towards becoming independent of `sys_errlist'
for its own utilities, which seems an argument for giving way to
the requirements of external source.

Rhetorically:

  Is `sys_errlist' is publicly declared for any reason but backward
  compatibility ?

  If the answer to the previous question is `NO', then should it not
  BE compatible ?