mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-03 20:42:48 -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:
22
raw.c
22
raw.c
@ -35,7 +35,7 @@ static void c_write(Raw *raw, const void *buf, int len)
|
||||
static void raw_log(Plug *plug, int type, SockAddr *addr, int port,
|
||||
const char *error_msg, int error_code)
|
||||
{
|
||||
Raw *raw = FROMFIELD(plug, Raw, plug);
|
||||
Raw *raw = container_of(plug, Raw, plug);
|
||||
backend_socket_log(raw->frontend, type, addr, port,
|
||||
error_msg, error_code, raw->conf, raw->session_started);
|
||||
}
|
||||
@ -58,7 +58,7 @@ static void raw_check_close(Raw *raw)
|
||||
static void raw_closing(Plug *plug, const char *error_msg, int error_code,
|
||||
int calling_back)
|
||||
{
|
||||
Raw *raw = FROMFIELD(plug, Raw, plug);
|
||||
Raw *raw = container_of(plug, Raw, plug);
|
||||
|
||||
if (error_msg) {
|
||||
/* A socket error has occurred. */
|
||||
@ -90,7 +90,7 @@ static void raw_closing(Plug *plug, const char *error_msg, int error_code,
|
||||
|
||||
static void raw_receive(Plug *plug, int urgent, char *data, int len)
|
||||
{
|
||||
Raw *raw = FROMFIELD(plug, Raw, plug);
|
||||
Raw *raw = container_of(plug, Raw, plug);
|
||||
c_write(raw, data, len);
|
||||
/* We count 'session start', for proxy logging purposes, as being
|
||||
* when data is received from the network and printed. */
|
||||
@ -99,7 +99,7 @@ static void raw_receive(Plug *plug, int urgent, char *data, int len)
|
||||
|
||||
static void raw_sent(Plug *plug, int bufsize)
|
||||
{
|
||||
Raw *raw = FROMFIELD(plug, Raw, plug);
|
||||
Raw *raw = container_of(plug, Raw, plug);
|
||||
raw->bufsize = bufsize;
|
||||
}
|
||||
|
||||
@ -181,7 +181,7 @@ static const char *raw_init(Frontend *frontend, Backend **backend_handle,
|
||||
|
||||
static void raw_free(Backend *be)
|
||||
{
|
||||
Raw *raw = FROMFIELD(be, Raw, backend);
|
||||
Raw *raw = container_of(be, Raw, backend);
|
||||
|
||||
if (raw->s)
|
||||
sk_close(raw->s);
|
||||
@ -201,7 +201,7 @@ static void raw_reconfig(Backend *be, Conf *conf)
|
||||
*/
|
||||
static int raw_send(Backend *be, const char *buf, int len)
|
||||
{
|
||||
Raw *raw = FROMFIELD(be, Raw, backend);
|
||||
Raw *raw = container_of(be, Raw, backend);
|
||||
|
||||
if (raw->s == NULL)
|
||||
return 0;
|
||||
@ -216,7 +216,7 @@ static int raw_send(Backend *be, const char *buf, int len)
|
||||
*/
|
||||
static int raw_sendbuffer(Backend *be)
|
||||
{
|
||||
Raw *raw = FROMFIELD(be, Raw, backend);
|
||||
Raw *raw = container_of(be, Raw, backend);
|
||||
return raw->bufsize;
|
||||
}
|
||||
|
||||
@ -234,7 +234,7 @@ static void raw_size(Backend *be, int width, int height)
|
||||
*/
|
||||
static void raw_special(Backend *be, SessionSpecialCode code, int arg)
|
||||
{
|
||||
Raw *raw = FROMFIELD(be, Raw, backend);
|
||||
Raw *raw = container_of(be, Raw, backend);
|
||||
if (code == SS_EOF && raw->s) {
|
||||
sk_write_eof(raw->s);
|
||||
raw->sent_socket_eof= TRUE;
|
||||
@ -255,7 +255,7 @@ static const SessionSpecial *raw_get_specials(Backend *be)
|
||||
|
||||
static int raw_connected(Backend *be)
|
||||
{
|
||||
Raw *raw = FROMFIELD(be, Raw, backend);
|
||||
Raw *raw = container_of(be, Raw, backend);
|
||||
return raw->s != NULL;
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ static int raw_sendok(Backend *be)
|
||||
|
||||
static void raw_unthrottle(Backend *be, int backlog)
|
||||
{
|
||||
Raw *raw = FROMFIELD(be, Raw, backend);
|
||||
Raw *raw = container_of(be, Raw, backend);
|
||||
sk_set_frozen(raw->s, backlog > RAW_MAX_BACKLOG);
|
||||
}
|
||||
|
||||
@ -289,7 +289,7 @@ static void raw_provide_logctx(Backend *be, LogContext *logctx)
|
||||
|
||||
static int raw_exitcode(Backend *be)
|
||||
{
|
||||
Raw *raw = FROMFIELD(be, Raw, backend);
|
||||
Raw *raw = container_of(be, Raw, backend);
|
||||
if (raw->s != NULL)
|
||||
return -1; /* still connected */
|
||||
else if (raw->closed_on_socket_error)
|
||||
|
Reference in New Issue
Block a user