1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-07-03 04:22: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:
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

@ -350,7 +350,7 @@ static void serial_close(Serial *serial)
static void serial_free(Backend *be)
{
Serial *serial = FROMFIELD(be, Serial, backend);
Serial *serial = container_of(be, Serial, backend);
serial_close(serial);
@ -361,7 +361,7 @@ static void serial_free(Backend *be)
static void serial_reconfig(Backend *be, Conf *conf)
{
Serial *serial = FROMFIELD(be, Serial, backend);
Serial *serial = container_of(be, Serial, backend);
/*
* FIXME: what should we do if this returns an error?
@ -465,7 +465,7 @@ static void serial_try_write(Serial *serial)
*/
static int serial_send(Backend *be, const char *buf, int len)
{
Serial *serial = FROMFIELD(be, Serial, backend);
Serial *serial = container_of(be, Serial, backend);
if (serial->fd < 0)
return 0;
@ -481,7 +481,7 @@ static int serial_send(Backend *be, const char *buf, int len)
*/
static int serial_sendbuffer(Backend *be)
{
Serial *serial = FROMFIELD(be, Serial, backend);
Serial *serial = container_of(be, Serial, backend);
return bufchain_size(&serial->output_data);
}
@ -499,7 +499,7 @@ static void serial_size(Backend *be, int width, int height)
*/
static void serial_special(Backend *be, SessionSpecialCode code, int arg)
{
Serial *serial = FROMFIELD(be, Serial, backend);
Serial *serial = container_of(be, Serial, backend);
if (serial->fd >= 0 && code == SS_BRK) {
tcsendbreak(serial->fd, 0);
@ -534,7 +534,7 @@ static int serial_sendok(Backend *be)
static void serial_unthrottle(Backend *be, int backlog)
{
Serial *serial = FROMFIELD(be, Serial, backend);
Serial *serial = container_of(be, Serial, backend);
serial->inbufsize = backlog;
serial_uxsel_setup(serial);
}
@ -559,7 +559,7 @@ static void serial_provide_logctx(Backend *be, LogContext *logctx)
static int serial_exitcode(Backend *be)
{
Serial *serial = FROMFIELD(be, Serial, backend);
Serial *serial = container_of(be, Serial, backend);
if (serial->fd >= 0)
return -1; /* still connected */
else