From 8d22fdd0045f7fcb8ecf72354b3c14fa333271c4 Mon Sep 17 00:00:00 2001 From: Axel Lindeberg Date: Thu, 25 Sep 2025 07:28:26 +0200 Subject: [PATCH] log: make WLOG macro a noop if logging disabled even if logging is disabled, the strings are still included in the binary. This is because the compiler does not see that wolfSSH_Log() is compiled as a noop. By making WLOG a noop if wolfSSH_Log is we reduce the compiled so-file by ~50k (about 25%). --- src/internal.c | 1 + wolfssh/log.h | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/internal.c b/src/internal.c index 05005b64a..641536268 100644 --- a/src/internal.c +++ b/src/internal.c @@ -11281,6 +11281,7 @@ int wolfSSH_RsaVerify(const byte *sig, word32 sigSz, compare = ConstantCompare(encDigest, checkDigest, encDigestSz); if (checkDigestSz < 0 || sizeCompare || compare) { + (void)loc; // unused if log disabled WLOG(WS_LOG_DEBUG, "%s: %s", loc, "Bad RSA Verify"); ret = WS_RSA_E; } diff --git a/wolfssh/log.h b/wolfssh/log.h index 26f202124..7756f89a8 100644 --- a/wolfssh/log.h +++ b/wolfssh/log.h @@ -72,15 +72,17 @@ WOLFSSH_API int wolfSSH_LogEnabled(void); WOLFSSH_API void wolfSSH_Log(enum wolfSSH_LogLevel, const char *const, ...) FMTCHECK; +#if defined(DEBUG_WOLFSSH) || defined(WOLFSSH_SSHD) #define WLOG(...) do { \ if (wolfSSH_LogEnabled()) \ wolfSSH_Log(__VA_ARGS__); \ } while (0) - +#else +#define WLOG(...) +#endif #ifdef __cplusplus } #endif #endif /* _WOLFSSH_LOG_H_ */ -