[uClibc] SPAM[RBL] Re: SPAM[RBL] Re: SPAM[RBL] sys_errlist

Manuel Novoa III mjn3 at codepoet.org
Wed Jul 16 06:49:42 UTC 2003


On Tue, Jul 15, 2003 at 10:07:09PM +0200, Bernardo Innocenti wrote:
> On Tuesday 15 July 2003 20:41, Erik Andersen wrote:
> 
> > Using sys_errlist[] requires that I actually populate the entire
> > array with strings.  Once all apps stop using sys_errlist[] there
> > will be a number of additional options available for efficiently
> > handling the storage for the various error stings.
> >
> > Last time I checked, a whole bunch of apps in uClinx-dist were
> > still using the sys_errlist[] array...
> 
> I would suggest taking an approach similar to glibc's handling
> of multithreaded errno. Something like this:
> 
> 	#define sys_errlist (__get_sys_errlist())
> 
> 	const char * const * __get_sys_errlist(void) __THROW
> 	{
> 		static __sys_errlist;
> 
> 		if (unlikely(__sys_errlist == NULL))
> 			__sys_errlist = __load_sys_errlist();
> 		return __sys_errlist;
> 	}
> 
> 	void __load_sys_errlist(void)
> 	{
> 		FILE *f;
> 		int i;
> 		char buf[128];
> 
> 		if (!(__sys_errlist = calloc(sys_nerr, sizeof(char *))))
> 			abort();
> 
> 		if ((f = fopen("/lib/libc_errors.txt", "r")))
> 			for(i = 0; i < sys_nerr; ++i)
> 				if (fgets(f, buf, sizeof(buf)))
> 					__sys_errlist[i] = strdup(buf);	
> 	}

I checked the archives for the previous messages in this thread and
found that you referenced strerror.c, which I removed from uClibc
over a year ago.  It last appeared in version 0.9.12.  If you're not
interested in upgrading to the latest version, you should at least
look at the diffs to see what bugs got fixed.

Regarding your concerns about the size increase in staticly linked apps
due to the system error messages, I'd be happy to add a an option to
the current version of uClibc to force strerror (and strsignal for
that matter) to omit the actual text messages.  Of course, that won't
help applications still using sys_errlist[].  But any application still
using sys_errlist[] really needs to be updated.

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.

Currently no uClibc routines use sys_errlist[].  About a year ago,
I removed it completely and then reinstated it because of complaints
that it was still used in some of the uClinux userland apps.  So I put
a link warning in place that it was deprecated (in SUSv2) and it would
eventually be removed (as it has from SUSv3).  In fact, I will probably
make it a build-time config option in the next release.

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.

Manuel




More information about the uClibc mailing list