Removing function names from errors (PR 9058)

Richard Levitte levitte at openssl.org
Fri Jun 14 08:47:22 UTC 2019


On Fri, 14 Jun 2019 07:13:21 +0200,
Viktor Dukhovni wrote:
> > #define ERR_raise_error ERR_raise_error_internal(__FILE__, __LINE__, __FUNC__)
> 
> Well, __FUNC__ is entirely non-standard, and __func__ is C99.  Are
> we ready to abandon C89/C90?  If not, then __func__ (and variants)
> becomes compiler-specific.

We've had the argument about C language versions before, and it seems
we're currently staying with C90, 'cause we have some prominent users
that are stuck with that version.

> In test/testutil.h, we have some of the requisite gymnastics:
> 
>     # if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L
>     #  if defined(_MSC_VER)
>     #   define TEST_CASE_NAME __FUNCTION__
>     #  else
>     #   define testutil_stringify_helper(s) #s
>     #   define testutil_stringify(s) testutil_stringify_helper(s)
>     #   define TEST_CASE_NAME __FILE__ ":" testutil_stringify(__LINE__)
>     #  endif                        /* _MSC_VER */
>     # else
>     #  define TEST_CASE_NAME __func__
>     # endif                         /* __STDC_VERSION__ */
> 
> While the GCC manual: http://gcc.gnu.org/onlinedocs/gcc-4.8.1/gcc/Function-Names.html
> suggests:
> 
>      #if __STDC_VERSION__ < 199901L
>      # if __GNUC__ >= 2
>      #  define __func__ __FUNCTION__
>      # else
>      #  define __func__ "<unknown>"
>      # endif
>      #endif
> 
> we would also need similar for any other pre-C99 supported compilers.

Yes.  We already have our own aliases for __FILE__ and __LINE__ (see
include/openssl/opensslconf.h.in), we can simply add an OPENSSL_FUNC
that's appropriately defined depending on what the compiler supports.

Side note: opensslconf.h.in isn't the best place for this kind of
macro, not even for OPENSSL_FILE and OPENSSL_LINE.  I'd rather move
all that to e_os2.h.

Cheers,
Richard

-- 
Richard Levitte         levitte at openssl.org
OpenSSL Project         http://www.openssl.org/~levitte/


More information about the openssl-project mailing list