1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-02 03:52:49 -05:00

Formatting: standardise on "func(\n", not "func\n(".

If the function name (or expression) in a function call or declaration
is itself so long that even the first argument doesn't fit after it on
the same line, or if that would leave so little space that it would be
silly to try to wrap all the run-on lines into a tall thin column,
then I used to do this

    ludicrously_long_function_name
        (arg1, arg2, arg3);

and now prefer this

    ludicrously_long_function_name(
        arg1, arg2, arg3);

I picked up the habit from Python, where the latter idiom is required
by Python's syntactic significance of newlines (you can write the
former if you use a backslash-continuation, but pretty much everyone
seems to agree that that's much uglier). But I've found it works well
in C as well: it makes it more obvious that the previous line is
incomplete, it gives you a tiny bit more space to wrap the following
lines into (the old idiom indents the _third_ line one space beyond
the second), and I generally turn out to agree with the knock-on
indentation decisions made by at least Emacs if you do it in the
middle of a complex expression. Plus, of course, using the _same_
idiom between C and Python means less state-switching.

So, while I'm making annoying indentation changes in general, this
seems like a good time to dig out all the cases of the old idiom in
this code, and switch them over to the new.
This commit is contained in:
Simon Tatham
2022-08-03 20:48:46 +01:00
parent 04c1617f20
commit 14203bc54f
17 changed files with 268 additions and 271 deletions

View File

@ -283,8 +283,8 @@ bool fxp_init(void)
return false;
}
if (remotever > SFTP_PROTO_VERSION) {
fxp_internal_error
("remote protocol is more advanced than we support");
fxp_internal_error(
"remote protocol is more advanced than we support");
sftp_pkt_free(pktin);
return false;
}

View File

@ -530,8 +530,8 @@ void sharestate_free(ssh_sharing_state *sharestate)
sfree(sharestate);
}
static struct share_halfchannel *share_add_halfchannel
(struct ssh_sharing_connstate *cs, unsigned server_id)
static struct share_halfchannel *share_add_halfchannel(
struct ssh_sharing_connstate *cs, unsigned server_id)
{
struct share_halfchannel *hc = snew(struct share_halfchannel);
hc->server_id = server_id;
@ -544,8 +544,8 @@ static struct share_halfchannel *share_add_halfchannel
}
}
static struct share_halfchannel *share_find_halfchannel
(struct ssh_sharing_connstate *cs, unsigned server_id)
static struct share_halfchannel *share_find_halfchannel(
struct ssh_sharing_connstate *cs, unsigned server_id)
{
struct share_halfchannel dummyhc;
dummyhc.server_id = server_id;
@ -559,9 +559,9 @@ static void share_remove_halfchannel(struct ssh_sharing_connstate *cs,
sfree(hc);
}
static struct share_channel *share_add_channel
(struct ssh_sharing_connstate *cs, unsigned downstream_id,
unsigned upstream_id, unsigned server_id, int state, int maxpkt)
static struct share_channel *share_add_channel(
struct ssh_sharing_connstate *cs, unsigned downstream_id,
unsigned upstream_id, unsigned server_id, int state, int maxpkt)
{
struct share_channel *chan = snew(struct share_channel);
chan->downstream_id = downstream_id;
@ -598,16 +598,16 @@ static void share_channel_set_server_id(struct ssh_sharing_connstate *cs,
add234(cs->channels_by_server, chan);
}
static struct share_channel *share_find_channel_by_upstream
(struct ssh_sharing_connstate *cs, unsigned upstream_id)
static struct share_channel *share_find_channel_by_upstream(
struct ssh_sharing_connstate *cs, unsigned upstream_id)
{
struct share_channel dummychan;
dummychan.upstream_id = upstream_id;
return find234(cs->channels_by_us, &dummychan, NULL);
}
static struct share_channel *share_find_channel_by_server
(struct ssh_sharing_connstate *cs, unsigned server_id)
static struct share_channel *share_find_channel_by_server(
struct ssh_sharing_connstate *cs, unsigned server_id)
{
struct share_channel dummychan;
dummychan.server_id = server_id;
@ -626,9 +626,8 @@ static void share_remove_channel(struct ssh_sharing_connstate *cs,
sfree(chan);
}
static struct share_xchannel *share_add_xchannel
(struct ssh_sharing_connstate *cs,
unsigned upstream_id, unsigned server_id)
static struct share_xchannel *share_add_xchannel(
struct ssh_sharing_connstate *cs, unsigned upstream_id, unsigned server_id)
{
struct share_xchannel *xc = snew(struct share_xchannel);
xc->upstream_id = upstream_id;
@ -647,16 +646,16 @@ static struct share_xchannel *share_add_xchannel
return xc;
}
static struct share_xchannel *share_find_xchannel_by_upstream
(struct ssh_sharing_connstate *cs, unsigned upstream_id)
static struct share_xchannel *share_find_xchannel_by_upstream(
struct ssh_sharing_connstate *cs, unsigned upstream_id)
{
struct share_xchannel dummyxc;
dummyxc.upstream_id = upstream_id;
return find234(cs->xchannels_by_us, &dummyxc, NULL);
}
static struct share_xchannel *share_find_xchannel_by_server
(struct ssh_sharing_connstate *cs, unsigned server_id)
static struct share_xchannel *share_find_xchannel_by_server(
struct ssh_sharing_connstate *cs, unsigned server_id)
{
struct share_xchannel dummyxc;
dummyxc.server_id = server_id;
@ -671,9 +670,8 @@ static void share_remove_xchannel(struct ssh_sharing_connstate *cs,
share_xchannel_free(xc);
}
static struct share_forwarding *share_add_forwarding
(struct ssh_sharing_connstate *cs,
const char *host, int port)
static struct share_forwarding *share_add_forwarding(
struct ssh_sharing_connstate *cs, const char *host, int port)
{
struct share_forwarding *fwd = snew(struct share_forwarding);
fwd->host = dupstr(host);
@ -687,8 +685,8 @@ static struct share_forwarding *share_add_forwarding
return fwd;
}
static struct share_forwarding *share_find_forwarding
(struct ssh_sharing_connstate *cs, const char *host, int port)
static struct share_forwarding *share_find_forwarding(
struct ssh_sharing_connstate *cs, const char *host, int port)
{
struct share_forwarding dummyfwd, *ret;
dummyfwd.host = dupstr(host);
@ -1013,10 +1011,10 @@ void share_dead_xchannel_respond(struct ssh_sharing_connstate *cs,
if (get_bool(src)) {
strbuf *packet = strbuf_new();
put_uint32(packet, xc->server_id);
ssh_send_packet_from_downstream
(cs->parent->cl, cs->id, SSH2_MSG_CHANNEL_FAILURE,
packet->s, packet->len,
"downstream refused X channel open");
ssh_send_packet_from_downstream(
cs->parent->cl, cs->id, SSH2_MSG_CHANNEL_FAILURE,
packet->s, packet->len,
"downstream refused X channel open");
strbuf_free(packet);
}
} else if (msg->type == SSH2_MSG_CHANNEL_CLOSE) {
@ -1380,9 +1378,9 @@ static void share_got_pkt_from_downstream(struct ssh_sharing_connstate *cs,
* cleaned up if downstream goes away.
*/
pkt[wantreplypos] = 1;
ssh_send_packet_from_downstream
(cs->parent->cl, cs->id, type, pkt, pktlen,
orig_wantreply ? NULL : "upstream added want_reply flag");
ssh_send_packet_from_downstream(
cs->parent->cl, cs->id, type, pkt, pktlen,
orig_wantreply ? NULL : "upstream added want_reply flag");
fwd = share_add_forwarding(cs, host, port);
ssh_sharing_queue_global_request(cs->parent->cl, cs);
@ -1443,9 +1441,9 @@ static void share_got_pkt_from_downstream(struct ssh_sharing_connstate *cs,
* deleted even if downstream doesn't want to know.
*/
pkt[wantreplypos] = 1;
ssh_send_packet_from_downstream
(cs->parent->cl, cs->id, type, pkt, pktlen,
orig_wantreply ? NULL : "upstream added want_reply flag");
ssh_send_packet_from_downstream(
cs->parent->cl, cs->id, type, pkt, pktlen,
orig_wantreply ? NULL : "upstream added want_reply flag");
ssh_sharing_queue_global_request(cs->parent->cl, cs);
/*

View File

@ -1208,15 +1208,15 @@ static void ssh2_userauth_process_queue(PacketProtocolLayer *ppl)
* When acquire_cred yields no useful expiration, go with
* the service ticket expiration.
*/
s->gss_stat = s->shgss->lib->init_sec_context
(s->shgss->lib,
&s->shgss->ctx,
s->shgss->srv_name,
s->gssapi_fwd,
&s->gss_rcvtok,
&s->gss_sndtok,
NULL,
NULL);
s->gss_stat = s->shgss->lib->init_sec_context(
s->shgss->lib,
&s->shgss->ctx,
s->shgss->srv_name,
s->gssapi_fwd,
&s->gss_rcvtok,
&s->gss_sndtok,
NULL,
NULL);
if (s->gss_stat!=SSH_GSS_S_COMPLETE &&
s->gss_stat!=SSH_GSS_S_CONTINUE_NEEDED) {