Skip to content

Commit 8d22fdd

Browse files
committed
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%).
1 parent 2a21844 commit 8d22fdd

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/internal.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11281,6 +11281,7 @@ int wolfSSH_RsaVerify(const byte *sig, word32 sigSz,
1128111281
compare = ConstantCompare(encDigest, checkDigest, encDigestSz);
1128211282

1128311283
if (checkDigestSz < 0 || sizeCompare || compare) {
11284+
(void)loc; // unused if log disabled
1128411285
WLOG(WS_LOG_DEBUG, "%s: %s", loc, "Bad RSA Verify");
1128511286
ret = WS_RSA_E;
1128611287
}

wolfssh/log.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,17 @@ WOLFSSH_API int wolfSSH_LogEnabled(void);
7272
WOLFSSH_API void wolfSSH_Log(enum wolfSSH_LogLevel,
7373
const char *const, ...) FMTCHECK;
7474

75+
#if defined(DEBUG_WOLFSSH) || defined(WOLFSSH_SSHD)
7576
#define WLOG(...) do { \
7677
if (wolfSSH_LogEnabled()) \
7778
wolfSSH_Log(__VA_ARGS__); \
7879
} while (0)
79-
80+
#else
81+
#define WLOG(...)
82+
#endif
8083

8184
#ifdef __cplusplus
8285
}
8386
#endif
8487

8588
#endif /* _WOLFSSH_LOG_H_ */
86-

0 commit comments

Comments
 (0)