mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-05 21:42:47 -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:
@ -54,7 +54,7 @@ BinaryPacketProtocol *ssh1_bpp_new(void)
|
||||
|
||||
static void ssh1_bpp_free(BinaryPacketProtocol *bpp)
|
||||
{
|
||||
struct ssh1_bpp_state *s = FROMFIELD(bpp, struct ssh1_bpp_state, bpp);
|
||||
struct ssh1_bpp_state *s = container_of(bpp, struct ssh1_bpp_state, bpp);
|
||||
if (s->cipher)
|
||||
ssh1_cipher_free(s->cipher);
|
||||
if (s->compctx)
|
||||
@ -73,7 +73,7 @@ void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
|
||||
{
|
||||
struct ssh1_bpp_state *s;
|
||||
assert(bpp->vt == &ssh1_bpp_vtable);
|
||||
s = FROMFIELD(bpp, struct ssh1_bpp_state, bpp);
|
||||
s = container_of(bpp, struct ssh1_bpp_state, bpp);
|
||||
|
||||
assert(!s->cipher);
|
||||
|
||||
@ -97,7 +97,7 @@ void ssh1_bpp_new_cipher(BinaryPacketProtocol *bpp,
|
||||
|
||||
static void ssh1_bpp_handle_input(BinaryPacketProtocol *bpp)
|
||||
{
|
||||
struct ssh1_bpp_state *s = FROMFIELD(bpp, struct ssh1_bpp_state, bpp);
|
||||
struct ssh1_bpp_state *s = container_of(bpp, struct ssh1_bpp_state, bpp);
|
||||
|
||||
crBegin(s->crState);
|
||||
|
||||
@ -314,7 +314,7 @@ static void ssh1_bpp_format_packet(struct ssh1_bpp_state *s, PktOut *pkt)
|
||||
|
||||
static void ssh1_bpp_handle_output(BinaryPacketProtocol *bpp)
|
||||
{
|
||||
struct ssh1_bpp_state *s = FROMFIELD(bpp, struct ssh1_bpp_state, bpp);
|
||||
struct ssh1_bpp_state *s = container_of(bpp, struct ssh1_bpp_state, bpp);
|
||||
PktOut *pkt;
|
||||
|
||||
if (s->pending_compression_request) {
|
||||
|
Reference in New Issue
Block a user