[Libguestfs] [PATCH] generator: simplify generated code for always-available features

Richard W.M. Jones rjones at redhat.com
Wed Feb 3 13:29:49 UTC 2016


On Wed, Feb 03, 2016 at 01:25:30PM +0100, Pino Toscano wrote:
> Just refer to the dummy function directly, instead of using #define's.
> ---
>  generator/daemon.ml | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 
> diff --git a/generator/daemon.ml b/generator/daemon.ml
> index 7ffea7b..d1689e1 100644
> --- a/generator/daemon.ml
> +++ b/generator/daemon.ml
> @@ -732,19 +732,15 @@ and generate_daemon_optgroups_c () =
>      pr "  return 1;\n";
>      pr "}\n";
>      pr "\n";
> -
> -    List.iter (
> -      fun group ->
> -        pr "#define optgroup_%s_available dummy_available\n" group;
> -    ) optgroups_retired;
> -
> -    pr "\n";
>    );
>  
>    pr "struct optgroup optgroups[] = {\n";
>    List.iter (
>      fun group ->
> -      pr "  { \"%s\", optgroup_%s_available },\n" group group
> +      if List.mem group optgroups_retired then
> +        pr "  { \"%s\", dummy_available },\n" group
> +      else
> +        pr "  { \"%s\", optgroup_%s_available },\n" group group
>    ) optgroups_names_all;
>    pr "  { NULL, NULL }\n";
>    pr "};\n"

ACK.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
Read my programming and virtualization blog: http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine.  Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/




More information about the Libguestfs mailing list