Re: [Libguestfs] [PATCH nbdkit 1/3] server: Rename global backend pointer to "top".

Eric Blake
Wed, 12 Feb 2020 13:42:31 -0000

> It's confusing to use the same terminology for a single backend as for
> the linked list of backends.  In particular it's often not clear if
> we're calling the next backend or the whole chain of backends.

Yes, that has caught me, too.  I like the rename.

ACK


> +++ b/server/internal.h
> @@ -118,8 +118,18 @@ extern char *unixsocket;
>   extern const char *user, *group;
>   extern bool verbose;
>
> -extern struct backend *backend;
> -#define for_each_backend(b) for (b = backend; b != NULL; b = b->next)
> +/* Linked list of backends.  Each backend struct is followed by either
> + * a filter or plugin struct.  "top" points to the first one.
They
> + * are linked through the backend->next field.
> + *
> + *         ┌──────────┐    ┌──────────┐    ┌──────────┐
> + * top ───▶│ backend  │───▶│ backend  │───▶│ backend  │
> + *         │ b->i = 2 │    │ b->i = 1 │    │ b->i = 0 │
> + *         │ filter   │    │ filter   │    │ plugin   │
> + *         └──────────┘    └──────────┘    └──────────┘
> + */

And the graphic helps, too.