gpg_err_code_from_errno usage

Marcus Brinkmann marcus.brinkmann at ruhr-uni-bochum.de
Mon Mar 13 14:19:09 CET 2006


At Mon, 13 Mar 2006 13:54:48 +0100,
Nikos Mavrogiannopoulos wrote:
> In any case I don't find any benefit into checking errno for memory
> allocation. The value is not interesting at all, and it adds
> complexity to the code.

Normally, you don't check.  You just return the value that's stored in
errno in case of allocation failure.

Your concern was that some systems may not set errno.  This can only
be addressed by either coding behaviour specifically for these
systems, or by a generic check.  The check is necessary so that if
errno is returned, it is not overwritten.

There is also the question to what errno should be set on bogus
systems.  Can we rely on ENOMEM?  By what justification?  It is not
mandated by ISO C99 either.

I would really like to see a list of systems where malloc and friends
don't set errno.

As for complexity: You call for the complexity by asking to support
systems that don't support the respective standards.

Thanks,
Marcus




More information about the Gcrypt-devel mailing list