Use of ossl_unused in

Arran Cudbard-Bell a.cudbardb at
Sat Oct 2 16:19:04 UTC 2021

In current master HEAD and 3.0.0 calling ERR_GET_REASON  throws the following

src/lib/tls/session.c:1323:43: warning: 'ERR_GET_REASON' was marked unused but was used [-Wused-but-marked-unused]
                while ((ssl_err = ERR_peek_error()) && (ERR_GET_REASON(ssl_err) == BIO_R_UNSUPPORTED_METHOD)) {

This is because the static inline functions in include/openssl/ have
been marked up with ossl_unused i.e. (__attribute__((unused))).

I'm not sure what compiler the OP of
was using, but it should not be generating a -Wunused-function for a static inline
function in a header file.  These are by their nature public functions, and should not
generate unused function warnings.  The only correct place to generate this warnings
is when the functions's visibility is limited to the compilation unit, and those functions
are not called within the compilation unit.

Can 067a3057c3aab0cdd9a3cdb13c2e0000f69a4170 either be reverted, or a guard
added so that ossl_unused is only set in the absence of a macro being defined (happy
to send a PR for this).

As it is currently, calling ERR_GET_LIB, ERR_GET_FUNC, ERR_GET_RFLAGS,
ERR_GET_REASON, ERR_FATAL_ERROR will produce spurious
"used-but-marked-unused" warnings at build time.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP
URL: <>

More information about the openssl-users mailing list