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

@ -950,7 +950,7 @@ static void share_disconnect(struct ssh_sharing_connstate *cs,
static void share_closing(Plug *plug, const char *error_msg, int error_code,
int calling_back)
{
struct ssh_sharing_connstate *cs = FROMFIELD(
struct ssh_sharing_connstate *cs = container_of(
plug, struct ssh_sharing_connstate, plug);
if (error_msg) {
@ -1766,7 +1766,7 @@ static void share_got_pkt_from_downstream(struct ssh_sharing_connstate *cs,
static void share_receive(Plug *plug, int urgent, char *data, int len)
{
ssh_sharing_connstate *cs = FROMFIELD(
ssh_sharing_connstate *cs = container_of(
plug, ssh_sharing_connstate, plug);
static const char expected_verstring_prefix[] =
"SSHCONNECTION@putty.projects.tartarus.org-2.0-";
@ -1842,7 +1842,7 @@ static void share_receive(Plug *plug, int urgent, char *data, int len)
static void share_sent(Plug *plug, int bufsize)
{
/* ssh_sharing_connstate *cs = FROMFIELD(
/* ssh_sharing_connstate *cs = container_of(
plug, ssh_sharing_connstate, plug); */
/*
@ -1858,7 +1858,8 @@ static void share_sent(Plug *plug, int bufsize)
static void share_listen_closing(Plug *plug, const char *error_msg,
int error_code, int calling_back)
{
ssh_sharing_state *sharestate = FROMFIELD(plug, ssh_sharing_state, plug);
ssh_sharing_state *sharestate =
container_of(plug, ssh_sharing_state, plug);
if (error_msg)
log_general(sharestate, "listening socket: %s", error_msg);
sk_close(sharestate->listensock);
@ -1921,7 +1922,7 @@ static const PlugVtable ssh_sharing_conn_plugvt = {
static int share_listen_accepting(Plug *plug,
accept_fn_t constructor, accept_ctx_t ctx)
{
struct ssh_sharing_state *sharestate = FROMFIELD(
struct ssh_sharing_state *sharestate = container_of(
plug, struct ssh_sharing_state, plug);
struct ssh_sharing_connstate *cs;
const char *err;