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

Rename FROMFIELD to 'container_of'.

Ian Jackson points out that the Linux kernel has a macro of this name
with the same purpose, and suggests that it's a good idea to use the
same name as they do, so that at least some people reading one code
base might recognise it from the other.

I never really thought very hard about what order FROMFIELD's
parameters should go in, and therefore I'm pleasantly surprised to
find that my order agrees with the kernel's, so I don't have to
permute every call site as part of making this change :-)
This commit is contained in:
Simon Tatham
2018-10-05 23:49:08 +01:00
parent ed652a70e8
commit 9396fcc9f7
47 changed files with 410 additions and 399 deletions

View File

@ -99,7 +99,8 @@ PacketProtocolLayer *ssh1_login_new(
static void ssh1_login_free(PacketProtocolLayer *ppl)
{
struct ssh1_login_state *s = FROMFIELD(ppl, struct ssh1_login_state, ppl);
struct ssh1_login_state *s =
container_of(ppl, struct ssh1_login_state, ppl);
if (s->successor_layer)
ssh_ppl_free(s->successor_layer);
@ -166,7 +167,8 @@ static PktIn *ssh1_login_pop(struct ssh1_login_state *s)
static void ssh1_login_process_queue(PacketProtocolLayer *ppl)
{
struct ssh1_login_state *s = FROMFIELD(ppl, struct ssh1_login_state, ppl);
struct ssh1_login_state *s =
container_of(ppl, struct ssh1_login_state, ppl);
PktIn *pktin;
PktOut *pkt;
int i;
@ -1172,7 +1174,7 @@ static void ssh1_login_special_cmd(PacketProtocolLayer *ppl,
SessionSpecialCode code, int arg)
{
struct ssh1_login_state *s =
FROMFIELD(ppl, struct ssh1_login_state, ppl);
container_of(ppl, struct ssh1_login_state, ppl);
PktOut *pktout;
if (code == SS_PING || code == SS_NOP) {
@ -1187,14 +1189,14 @@ static void ssh1_login_special_cmd(PacketProtocolLayer *ppl,
static int ssh1_login_want_user_input(PacketProtocolLayer *ppl)
{
struct ssh1_login_state *s =
FROMFIELD(ppl, struct ssh1_login_state, ppl);
container_of(ppl, struct ssh1_login_state, ppl);
return s->want_user_input;
}
static void ssh1_login_got_user_input(PacketProtocolLayer *ppl)
{
struct ssh1_login_state *s =
FROMFIELD(ppl, struct ssh1_login_state, ppl);
container_of(ppl, struct ssh1_login_state, ppl);
if (s->want_user_input)
queue_idempotent_callback(&s->ppl.ic_process_queue);
}
@ -1202,6 +1204,6 @@ static void ssh1_login_got_user_input(PacketProtocolLayer *ppl)
static void ssh1_login_reconfigure(PacketProtocolLayer *ppl, Conf *conf)
{
struct ssh1_login_state *s =
FROMFIELD(ppl, struct ssh1_login_state, ppl);
container_of(ppl, struct ssh1_login_state, ppl);
ssh_ppl_reconfigure(s->successor_layer, conf);
}