[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#227386: libc6-dev: ENOTSUP==EOPNOTSUPP, which violates SUSv3

On Sun, Feb 19, 2006 at 08:25:34AM +0000, Brian M. Carlson wrote:

> Anyway, my problem is that the fact that these two errors are
> the same is causing my code to break very badly.  I have a
> library that contains its own error codes that will be negative
> if casted to an int.  Additionally, I want to support the use
> of the standard errno.h error codes.  To make my life easier,
> I am using a script to generate a list of valid error codes:
> the POSIX ones, as well as mine.  The code generated by the
> script uses a switch statement to check whether a code is
> valid.  But because two case statements cannot have the same
> value, I get compiler errors.  I have logic to check for
> EAGAIN and EWOULDBLOCK, and only use one if both are the same;
> I'd prefer not to have to do this for other pairs.

That seems overly complex. You should most certainly know the range of
your own error codes, so something like the below looks much simpler (no
script needed, no dependance on the value of standard error codes):

	if (error_code >= MY_ERROR_MIN && error_code <= MY_ERROR_MAX)
		/* handle your own error codes here */
		errno = 0;
		(void *)strerror(error_code);
		if (!errno)
			/* error_code was known to libc */
			/* unknown, probably invalid error_code */

After a quick check at least Darwin 6.8 and FreeBSD 5.1 also uses the
same value for ENOTSUP and EOPNOTSUPP, so if you want to be portable,
you can not assume that these values are distinct.


     MTA SZTAKI Computer and Automation Research Institute
                Hungarian Academy of Sciences

Reply to: