1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-03 04:22:47 -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:
Simon Tatham
2018-12-08 20:32:31 +00:00
parent 383a16d5e5
commit e08641c912
26 changed files with 525 additions and 532 deletions

View File

@ -201,7 +201,7 @@ static void ssh_verstring_send(struct ssh_verstring_state *s)
bufchain_add(s->bpp.out_raw, "\015", 1);
bufchain_add(s->bpp.out_raw, "\012", 1);
bpp_logevent(("We claim version: %s", s->our_vstring));
bpp_logevent("We claim version: %s", s->our_vstring);
}
#define BPP_WAITFOR(minlen) do \
@ -312,7 +312,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
s->vslen--;
s->vstring[s->vslen] = '\0';
bpp_logevent(("Remote version: %s", s->vstring));
bpp_logevent("Remote version: %s", s->vstring);
/*
* Pick out the protocol version and software version. The former
@ -378,7 +378,7 @@ void ssh_verstring_handle_input(BinaryPacketProtocol *bpp)
crStopV;
}
bpp_logevent(("Using SSH protocol version %d", s->major_protoversion));
bpp_logevent("Using SSH protocol version %d", s->major_protoversion);
if (!s->send_early) {
/*
@ -450,7 +450,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* sniffing.
*/
s->remote_bugs |= BUG_CHOKES_ON_SSH1_IGNORE;
bpp_logevent(("We believe remote version has SSH-1 ignore bug"));
bpp_logevent("We believe remote version has SSH-1 ignore bug");
}
if (conf_get_int(s->conf, CONF_sshbug_plainpw1) == FORCE_ON ||
@ -462,8 +462,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* the password.
*/
s->remote_bugs |= BUG_NEEDS_SSH1_PLAIN_PASSWORD;
bpp_logevent(("We believe remote version needs a "
"plain SSH-1 password"));
bpp_logevent("We believe remote version needs a "
"plain SSH-1 password");
}
if (conf_get_int(s->conf, CONF_sshbug_rsa1) == FORCE_ON ||
@ -475,8 +475,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* an AUTH_RSA message.
*/
s->remote_bugs |= BUG_CHOKES_ON_RSA;
bpp_logevent(("We believe remote version can't handle SSH-1 "
"RSA authentication"));
bpp_logevent("We believe remote version can't handle SSH-1 "
"RSA authentication");
}
if (conf_get_int(s->conf, CONF_sshbug_hmac2) == FORCE_ON ||
@ -489,7 +489,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* These versions have the HMAC bug.
*/
s->remote_bugs |= BUG_SSH2_HMAC;
bpp_logevent(("We believe remote version has SSH-2 HMAC bug"));
bpp_logevent("We believe remote version has SSH-2 HMAC bug");
}
if (conf_get_int(s->conf, CONF_sshbug_derivekey2) == FORCE_ON ||
@ -502,8 +502,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* generate the keys).
*/
s->remote_bugs |= BUG_SSH2_DERIVEKEY;
bpp_logevent(("We believe remote version has SSH-2 "
"key-derivation bug"));
bpp_logevent("We believe remote version has SSH-2 "
"key-derivation bug");
}
if (conf_get_int(s->conf, CONF_sshbug_rsapad2) == FORCE_ON ||
@ -516,7 +516,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* These versions have the SSH-2 RSA padding bug.
*/
s->remote_bugs |= BUG_SSH2_RSA_PADDING;
bpp_logevent(("We believe remote version has SSH-2 RSA padding bug"));
bpp_logevent("We believe remote version has SSH-2 RSA padding bug");
}
if (conf_get_int(s->conf, CONF_sshbug_pksessid2) == FORCE_ON ||
@ -527,8 +527,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* public-key authentication.
*/
s->remote_bugs |= BUG_SSH2_PK_SESSIONID;
bpp_logevent(("We believe remote version has SSH-2 "
"public-key-session-ID bug"));
bpp_logevent("We believe remote version has SSH-2 "
"public-key-session-ID bug");
}
if (conf_get_int(s->conf, CONF_sshbug_rekey2) == FORCE_ON ||
@ -544,7 +544,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* These versions have the SSH-2 rekey bug.
*/
s->remote_bugs |= BUG_SSH2_REKEY;
bpp_logevent(("We believe remote version has SSH-2 rekey bug"));
bpp_logevent("We believe remote version has SSH-2 rekey bug");
}
if (conf_get_int(s->conf, CONF_sshbug_maxpkt2) == FORCE_ON ||
@ -555,8 +555,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* This version ignores our makpkt and needs to be throttled.
*/
s->remote_bugs |= BUG_SSH2_MAXPKT;
bpp_logevent(("We believe remote version ignores SSH-2 "
"maximum packet size"));
bpp_logevent("We believe remote version ignores SSH-2 "
"maximum packet size");
}
if (conf_get_int(s->conf, CONF_sshbug_ignore2) == FORCE_ON) {
@ -565,7 +565,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* none detected automatically.
*/
s->remote_bugs |= BUG_CHOKES_ON_SSH2_IGNORE;
bpp_logevent(("We believe remote version has SSH-2 ignore bug"));
bpp_logevent("We believe remote version has SSH-2 ignore bug");
}
if (conf_get_int(s->conf, CONF_sshbug_oldgex2) == FORCE_ON ||
@ -577,7 +577,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* we use the newer version.
*/
s->remote_bugs |= BUG_SSH2_OLDGEX;
bpp_logevent(("We believe remote version has outdated SSH-2 GEX"));
bpp_logevent("We believe remote version has outdated SSH-2 GEX");
}
if (conf_get_int(s->conf, CONF_sshbug_winadj) == FORCE_ON) {
@ -586,7 +586,7 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* reason or another. Currently, none detected automatically.
*/
s->remote_bugs |= BUG_CHOKES_ON_WINADJ;
bpp_logevent(("We believe remote version has winadj bug"));
bpp_logevent("We believe remote version has winadj bug");
}
if (conf_get_int(s->conf, CONF_sshbug_chanreq) == FORCE_ON ||
@ -603,8 +603,8 @@ static void ssh_detect_bugs(struct ssh_verstring_state *s)
* https://secure.ucc.asn.au/hg/dropbear/rev/cd02449b709c
*/
s->remote_bugs |= BUG_SENDS_LATE_REQUEST_REPLY;
bpp_logevent(("We believe remote version has SSH-2 "
"channel request bug"));
bpp_logevent("We believe remote version has SSH-2 "
"channel request bug");
}
}