Adding polar_ok() was a good plan for improving error reporting, but also added two function calls (one to polar_log_func_line() and one to polar_log_err()) for each function call wrapped with polar_ok(). Especially in the critical path, this is a waste of time.
To avoid this overhead, add a simple check to the polar_ok() macro that reduces it to a single branch. Signed-off-by: Steffan Karger <stef...@karger.me> --- src/openvpn/crypto_polarssl.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openvpn/crypto_polarssl.h b/src/openvpn/crypto_polarssl.h index 92c2c30..e6db445 100644 --- a/src/openvpn/crypto_polarssl.h +++ b/src/openvpn/crypto_polarssl.h @@ -130,8 +130,8 @@ bool polar_log_func_line(unsigned int flags, int errval, const char *func, * * @returns true if no errors are detected, false otherwise. */ -#define polar_ok(errval) \ - polar_log_func_line(D_CRYPT_ERRORS, errval, __func__, __LINE__) +#define polar_ok(errval) ((0 == errval) || \ + polar_log_func_line(D_CRYPT_ERRORS, errval, __func__, __LINE__)) #endif /* CRYPTO_POLARSSL_H_ */ -- 2.5.0