Re: [Libguestfs] [PATCH 7/9] Implement filters.

Eric Blake
Wed, 17 Jan 2018 22:31:31 -0000

On 01/17/2018 02:53 PM, Richard W.M. Jones wrote:
> Also implements the --filters parameter.
> ---
>  docs/nbdkit.pod |  21 +-
>  nbdkit.in       |  17 +-
>  src/Makefile.am |   1 +
>  src/filters.c   | 606
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  src/internal.h  |  23 ++-
>  src/main.c      | 114 +++++++++--
>  src/plugins.c   |  11 +-
>  7 files changed, 772 insertions(+), 21 deletions(-)
>

> +/* The next_functions structure contains pointers to backend
> + * functions.  However because these functions are all expecting a
> + * backend and a connection, we cannot call them directly, but must
> + * write some next_* functions that unpack the two parameters from a
> + * single ‘void *nxdata’ struct pointer (‘b_conn’).
> + */
> +
> +/* Literally a backend + a connection pointer.  This is the
> + * implementation if ‘void *nxdata’ in the filter API.

s/if/of/

> +++ b/src/main.c
> @@ -120,6 +121,7 @@ static const struct option long_options[] = {
>    { "export",     1, NULL, 'e' },
>    { "export-name",1, NULL, 'e' },
>    { "exportname", 1, NULL, 'e' },
> +  { "filter",     1, NULL, 0 },

If you assign a value > 256 to options that only have a long
spelling...
> @@ -245,6 +252,18 @@ main (int argc, char *argv[])
>          exit (EXIT_FAILURE);
>  #endif
>        }
> +      else if (strcmp (long_options[option_index].name,
"filter") == 0) {

...then you can simply add additional case labels in your switch
statement that handle each option, rather than having to make an
ever-increasing if chain.  That's a separate cleanup, so I'll go ahead
and propose it on top of your series (I'm also planning on rebasing my
FUA flags on top of your series, since so far it is looking pretty good).

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org