[uClibc] sys_errlist

Manuel Novoa III mjn3 at codepoet.org
Wed Jul 16 17:41:18 UTC 2003


On Wed, Jul 16, 2003 at 06:26:03PM +0200, Bernardo Innocenti wrote:
> On Wednesday 16 July 2003 08:49, Manuel Novoa III wrote:
> > If you wanted to store the system error message text in a file and
> > load it dynamically, all you would have to do is replace the function
> >   int _susv3_strerror_r(int errnum, char *strerrbuf, size_t buflen)
> > in the current version of uClibc.  Well... that _and_ get rid of all
> > the outdated sys_errlist[] cruft in any relevant apps.
> 
> So I'd better fix that instead. Does glibc provide sys_errlist[] to
> applications?

Yes, but current versions issue the following link warning --

: `sys_errlist' is deprecated; use `strerror' or `strerror_r' instead

>  Is it required by any relevant standard?

I thought it appeared as deprecated in SUSv2, but apparently not.
I just searched and didn't find a reference.

> The fact that
> there are no underscores in the name makes me think that it's not
> something internal.

It still uses an internal version in its strerror_r implementation.

> Actually, the application where I've noticed this problem - telnetd -
> does not use sys_errlist[] at all, but all the messages get linked into
> the binary because of perror(). I'd like to drop this overhead.

Everything in uClibc goes through _susv3_strerror_r() now, except
for the sys_errlist[] table.  As I said, I'll add an option to omit
the message text and simply print the errno.

> > If you _still_ wanted to support sys_errlist[] with a scheme like you
> > suggest above, you would need to do a bit more.  A failure in opening
> > or reading the file, or in memory allocation, would result in one or
> > more of the table entries being NULL. Last time I looked, at least 
> > some of the uClinux userland apps using sys_errlist[] were not prepared
> > for a NULL ptr corresponding to a valid errno.
> 
> Hmmm... if they're just passing to uClinux version of printf(),
> they should be safe.

I don't recall the usage.

> Otherwise, we could always set all slots to point
> at an empty string instead of storing NULL into them.

A couple of other issues...

Some of the errnos for the same error are different on some archs.
That is why the internal strerror stuff has to check an index table.
So you'd either have to include an index table in the code and share
a file with all supported archs, or you'd have to supply a seperate
file for each supported arch.  One other fun note is that mips has
a max errno of 1133.  What were they thinking?

Also, since many applications that use sys_errlist[] are older, they
often declare it themselves.  If you were to define sys_errlist as
a function returning a pointer to a dynamicly constructed table, you
will likely still have to go in and patch a number of userland apps.

Manuel




More information about the uClibc mailing list