mirror of
https://github.com/libssh2/libssh2.git
synced 2025-11-20 02:42:09 +03:00
src: C89-compliant _libssh2_debug() macro (#831)
Before this patch, with debug logging disabled, libssh2 code used a variadic macro to catch `_libssh2_debug()` calls, and convert them to no-ops. In certain conditions, it used an empty inline function instead. Variadic macro is a C99 feature. It means that depending on compiler, and build settings, it littered the build log with warnings about this. The new solution uses the trick of passing the variable arg list as a single argument and pass that down to the debug function with a regular macro. When disabled, another regular C89-compatible macro converts it to a no-op. This makes inlining, C99 variadic macros and maintaining the conditions for each unnecessary and also makes the codebase compile more consistently, e.g. with forced C standards and/or picky warnings. TL;DR: It makes this feature C89-compliant.
This commit is contained in:
@@ -478,10 +478,10 @@ agent_sign(LIBSSH2_SESSION *session, unsigned char **sig, size_t *sig_len,
|
||||
/* check to see if we match requested */
|
||||
if((size_t)method_len != session->userauth_pblc_method_len ||
|
||||
memcmp(method_name, session->userauth_pblc_method, method_len)) {
|
||||
_libssh2_debug(session,
|
||||
_libssh2_debug((session,
|
||||
LIBSSH2_TRACE_KEX,
|
||||
"Agent sign method %.*s",
|
||||
method_len, method_name);
|
||||
method_len, method_name));
|
||||
|
||||
rc = LIBSSH2_ERROR_ALGO_UNSUPPORTED;
|
||||
goto error;
|
||||
|
||||
Reference in New Issue
Block a user