mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-14 17:47:33 -05:00
Start using C99 variadic macros.
In the past, I've had a lot of macros which you call with double parentheses, along the lines of debug(("format string", params)), so that the inner parens protect the commas and permit the macro to treat the whole printf-style argument list as one macro argument. That's all very well, but it's a bit inconvenient (it doesn't leave you any way to implement such a macro by prepending another argument to the list), and now this code base's rules allow C99isms, I can switch all those macros to using a single pair of parens, using the C99 ability to say '...' in the parameter list of the #define and get at the corresponding suffix of the arguments as __VA_ARGS__. So I'm doing it. I've made the following printf-style macros variadic: bpp_logevent, ppl_logevent, ppl_printf and debug. While I'm here, I've also fixed up a collection of conditioned-out calls to debug() in the Windows front end which were clearly expecting a macro with a different calling syntax, because they had an integer parameter first. If I ever have a need to condition those back in, they should actually work now.
This commit is contained in:
56
ssh2bpp.c
56
ssh2bpp.c
@ -113,8 +113,8 @@ void ssh2_bpp_new_outgoing_crypto(
|
||||
(ssh2_cipher_alg(s->out.cipher)->flags & SSH_CIPHER_IS_CBC) &&
|
||||
!(s->bpp.remote_bugs & BUG_CHOKES_ON_SSH2_IGNORE));
|
||||
|
||||
bpp_logevent(("Initialised %.200s outbound encryption",
|
||||
ssh2_cipher_alg(s->out.cipher)->text_name));
|
||||
bpp_logevent("Initialised %.200s outbound encryption",
|
||||
ssh2_cipher_alg(s->out.cipher)->text_name);
|
||||
} else {
|
||||
s->out.cipher = NULL;
|
||||
s->cbc_ignore_workaround = false;
|
||||
@ -124,12 +124,12 @@ void ssh2_bpp_new_outgoing_crypto(
|
||||
s->out.mac = ssh2_mac_new(mac, s->out.cipher);
|
||||
mac->setkey(s->out.mac, mac_key);
|
||||
|
||||
bpp_logevent(("Initialised %.200s outbound MAC algorithm%s%s",
|
||||
ssh2_mac_alg(s->out.mac)->text_name,
|
||||
etm_mode ? " (in ETM mode)" : "",
|
||||
(s->out.cipher &&
|
||||
ssh2_cipher_alg(s->out.cipher)->required_mac ?
|
||||
" (required by cipher)" : "")));
|
||||
bpp_logevent("Initialised %.200s outbound MAC algorithm%s%s",
|
||||
ssh2_mac_alg(s->out.mac)->text_name,
|
||||
etm_mode ? " (in ETM mode)" : "",
|
||||
(s->out.cipher &&
|
||||
ssh2_cipher_alg(s->out.cipher)->required_mac ?
|
||||
" (required by cipher)" : ""));
|
||||
} else {
|
||||
s->out.mac = NULL;
|
||||
}
|
||||
@ -138,8 +138,8 @@ void ssh2_bpp_new_outgoing_crypto(
|
||||
s->out.pending_compression = compression;
|
||||
s->out_comp = NULL;
|
||||
|
||||
bpp_logevent(("Will enable %s compression after user authentication",
|
||||
s->out.pending_compression->text_name));
|
||||
bpp_logevent("Will enable %s compression after user authentication",
|
||||
s->out.pending_compression->text_name);
|
||||
} else {
|
||||
s->out.pending_compression = NULL;
|
||||
|
||||
@ -149,8 +149,8 @@ void ssh2_bpp_new_outgoing_crypto(
|
||||
s->out_comp = ssh_compressor_new(compression);
|
||||
|
||||
if (s->out_comp)
|
||||
bpp_logevent(("Initialised %s compression",
|
||||
ssh_compressor_alg(s->out_comp)->text_name));
|
||||
bpp_logevent("Initialised %s compression",
|
||||
ssh_compressor_alg(s->out_comp)->text_name);
|
||||
}
|
||||
}
|
||||
|
||||
@ -176,8 +176,8 @@ void ssh2_bpp_new_incoming_crypto(
|
||||
ssh2_cipher_setkey(s->in.cipher, ckey);
|
||||
ssh2_cipher_setiv(s->in.cipher, iv);
|
||||
|
||||
bpp_logevent(("Initialised %.200s inbound encryption",
|
||||
ssh2_cipher_alg(s->in.cipher)->text_name));
|
||||
bpp_logevent("Initialised %.200s inbound encryption",
|
||||
ssh2_cipher_alg(s->in.cipher)->text_name);
|
||||
} else {
|
||||
s->in.cipher = NULL;
|
||||
}
|
||||
@ -186,12 +186,12 @@ void ssh2_bpp_new_incoming_crypto(
|
||||
s->in.mac = ssh2_mac_new(mac, s->in.cipher);
|
||||
mac->setkey(s->in.mac, mac_key);
|
||||
|
||||
bpp_logevent(("Initialised %.200s inbound MAC algorithm%s%s",
|
||||
ssh2_mac_alg(s->in.mac)->text_name,
|
||||
etm_mode ? " (in ETM mode)" : "",
|
||||
(s->in.cipher &&
|
||||
ssh2_cipher_alg(s->in.cipher)->required_mac ?
|
||||
" (required by cipher)" : "")));
|
||||
bpp_logevent("Initialised %.200s inbound MAC algorithm%s%s",
|
||||
ssh2_mac_alg(s->in.mac)->text_name,
|
||||
etm_mode ? " (in ETM mode)" : "",
|
||||
(s->in.cipher &&
|
||||
ssh2_cipher_alg(s->in.cipher)->required_mac ?
|
||||
" (required by cipher)" : ""));
|
||||
} else {
|
||||
s->in.mac = NULL;
|
||||
}
|
||||
@ -200,8 +200,8 @@ void ssh2_bpp_new_incoming_crypto(
|
||||
s->in.pending_compression = compression;
|
||||
s->in_decomp = NULL;
|
||||
|
||||
bpp_logevent(("Will enable %s decompression after user authentication",
|
||||
s->in.pending_compression->text_name));
|
||||
bpp_logevent("Will enable %s decompression after user authentication",
|
||||
s->in.pending_compression->text_name);
|
||||
} else {
|
||||
s->in.pending_compression = NULL;
|
||||
|
||||
@ -211,8 +211,8 @@ void ssh2_bpp_new_incoming_crypto(
|
||||
s->in_decomp = ssh_decompressor_new(compression);
|
||||
|
||||
if (s->in_decomp)
|
||||
bpp_logevent(("Initialised %s decompression",
|
||||
ssh_decompressor_alg(s->in_decomp)->text_name));
|
||||
bpp_logevent("Initialised %s decompression",
|
||||
ssh_decompressor_alg(s->in_decomp)->text_name);
|
||||
}
|
||||
|
||||
/* Clear the pending_newkeys flag, so that handle_input below will
|
||||
@ -239,14 +239,14 @@ static void ssh2_bpp_enable_pending_compression(struct ssh2_bpp_state *s)
|
||||
|
||||
if (s->in.pending_compression) {
|
||||
s->in_decomp = ssh_decompressor_new(s->in.pending_compression);
|
||||
bpp_logevent(("Initialised delayed %s decompression",
|
||||
ssh_decompressor_alg(s->in_decomp)->text_name));
|
||||
bpp_logevent("Initialised delayed %s decompression",
|
||||
ssh_decompressor_alg(s->in_decomp)->text_name);
|
||||
s->in.pending_compression = NULL;
|
||||
}
|
||||
if (s->out.pending_compression) {
|
||||
s->out_comp = ssh_compressor_new(s->out.pending_compression);
|
||||
bpp_logevent(("Initialised delayed %s compression",
|
||||
ssh_compressor_alg(s->out_comp)->text_name));
|
||||
bpp_logevent("Initialised delayed %s compression",
|
||||
ssh_compressor_alg(s->out_comp)->text_name);
|
||||
s->out.pending_compression = NULL;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user