Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 May 2025 19:23:04 +0300
From:      Andriy Gapon <avg@FreeBSD.org>
To:        freebsd-current@freebsd.org
Subject:   Re: Un-sucking EINVAL
Message-ID:  <bc073de5-1c4a-41e8-b163-fcbfc4fb9c8f@FreeBSD.org>
In-Reply-To: <aC2Ap5ogfrlC-kHn@ragweed.eden.le-fay.org>
References:  <aC0CgBBWrodf6pa8@ragweed.eden.le-fay.org> <202505210722.54L7MTqw025632@critter.freebsd.dk> <aC2Ap5ogfrlC-kHn@ragweed.eden.le-fay.org>

index | next in thread | previous in thread | raw e-mail

On 21/05/2025 10:28, Lexi Winter wrote:
> you are completely right.  since we (for some reason, that i don't
> really understand) can't add new error codes to errno, we should stop
> using errno to indicate errors except where POSIX requires this.

I once had this idea, probably not original, that if we usually use 32-bit 
variables to pass around error / status codes, then why not split up those bits 
for some special uses.

E.g., lowest 10 or 12 bits could be actual error codes.

But highest, say, 8 or 10 bits could encode a domain of interpretation (to use a 
term borrowed from IPsec).
Domain number zero would be a POSIX or legacy domain and error codes in it would 
be the standard errno codes.
Then we could have a different domain (or several) for FreeBSD-specific error codes.

Some middle bits could be used to further subdivide a domain into modules or 
subsystems with their own error codes.
There could be some private (application specific) domains.

But, of course, a larger repertoire of error codes is still not as flexible and 
powerful as an ability to pass a specific error string along with an error code.

-- 
Andriy Gapon


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bc073de5-1c4a-41e8-b163-fcbfc4fb9c8f>