mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-15 18:17:32 -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:
10
ssh2bpp.c
10
ssh2bpp.c
@ -63,7 +63,7 @@ BinaryPacketProtocol *ssh2_bpp_new(struct DataTransferStats *stats)
|
||||
|
||||
static void ssh2_bpp_free(BinaryPacketProtocol *bpp)
|
||||
{
|
||||
struct ssh2_bpp_state *s = FROMFIELD(bpp, struct ssh2_bpp_state, bpp);
|
||||
struct ssh2_bpp_state *s = container_of(bpp, struct ssh2_bpp_state, bpp);
|
||||
sfree(s->buf);
|
||||
if (s->out.cipher)
|
||||
ssh2_cipher_free(s->out.cipher);
|
||||
@ -89,7 +89,7 @@ void ssh2_bpp_new_outgoing_crypto(
|
||||
{
|
||||
struct ssh2_bpp_state *s;
|
||||
assert(bpp->vt == &ssh2_bpp_vtable);
|
||||
s = FROMFIELD(bpp, struct ssh2_bpp_state, bpp);
|
||||
s = container_of(bpp, struct ssh2_bpp_state, bpp);
|
||||
|
||||
if (s->out.cipher)
|
||||
ssh2_cipher_free(s->out.cipher);
|
||||
@ -132,7 +132,7 @@ void ssh2_bpp_new_incoming_crypto(
|
||||
{
|
||||
struct ssh2_bpp_state *s;
|
||||
assert(bpp->vt == &ssh2_bpp_vtable);
|
||||
s = FROMFIELD(bpp, struct ssh2_bpp_state, bpp);
|
||||
s = container_of(bpp, struct ssh2_bpp_state, bpp);
|
||||
|
||||
if (s->in.cipher)
|
||||
ssh2_cipher_free(s->in.cipher);
|
||||
@ -177,7 +177,7 @@ void ssh2_bpp_new_incoming_crypto(
|
||||
|
||||
static void ssh2_bpp_handle_input(BinaryPacketProtocol *bpp)
|
||||
{
|
||||
struct ssh2_bpp_state *s = FROMFIELD(bpp, struct ssh2_bpp_state, bpp);
|
||||
struct ssh2_bpp_state *s = container_of(bpp, struct ssh2_bpp_state, bpp);
|
||||
|
||||
crBegin(s->crState);
|
||||
|
||||
@ -700,7 +700,7 @@ static void ssh2_bpp_format_packet(struct ssh2_bpp_state *s, PktOut *pkt)
|
||||
|
||||
static void ssh2_bpp_handle_output(BinaryPacketProtocol *bpp)
|
||||
{
|
||||
struct ssh2_bpp_state *s = FROMFIELD(bpp, struct ssh2_bpp_state, bpp);
|
||||
struct ssh2_bpp_state *s = container_of(bpp, struct ssh2_bpp_state, bpp);
|
||||
PktOut *pkt;
|
||||
|
||||
if (s->cbc_ignore_workaround) {
|
||||
|
Reference in New Issue
Block a user