[libvirt] [PATCHv2 10/13] snapshot: simplify indentation of nwfilter

Peter Krempa pkrempa at redhat.com
Fri Oct 21 19:22:05 UTC 2011


Dňa 29.9.2011 18:22, Eric Blake  wrote / napísal(a):
> Fixing this involved some refactoring of common code out of
> domain_conf and nwfilter_conf into nwfilter_params.
>
> * src/conf/nwfilter_params.h (virNWFilterFormatParamAttributes):
> Adjust signature.
> * src/conf/nwfilter_params.c (_formatParameterAttrs)
> (virNWFilterFormatParamAttributes): Adjust indentation handling,
> and handle filterref here.
> (formatterParam): Delete unused struct.
> * src/conf/domain_conf.c (virDomainNetDefFormat): Adjust caller.
> * src/conf/nwfilter_conf.c (virNWFilterIncludeDefFormat): Likewise.
> ---
>   src/conf/domain_conf.c     |   15 ++++---------
>   src/conf/nwfilter_conf.c   |   18 ++++++----------
>   src/conf/nwfilter_params.c |   45 +++++++++++++++++++------------------------
>   src/conf/nwfilter_params.h |    7 ++++-
>   4 files changed, 37 insertions(+), 48 deletions(-)
>
> diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
> index 70201af..efdf914 100644
> --- a/src/conf/domain_conf.c
> +++ b/src/conf/domain_conf.c

> @@ -9562,15 +9561,11 @@ virDomainNetDefFormat(virBufferPtr buf,
>           }
>       }
>       if (def->filter) {
> -        virBufferEscapeString(buf, "<filterref filter='%s'",
> -                              def->filter);
> -        attrs = virNWFilterFormatParamAttributes(def->filterparams,
> -                                                 "        ");

The offset of the <filterref element is 6 spaces and of NWFilter param 
attributes is 8 spaces here.

> -        if (!attrs || strlen(attrs)<= 1)
> -            virBufferAddLit(buf, "/>\n");
> -        else
> -            virBufferAsprintf(buf, ">\n%s</filterref>\n", attrs);
> -        VIR_FREE(attrs);
> +        virBufferAdjustIndent(buf, 4);

Here you add a offset of 4 (the param attributes are indented 6 spaces). 
This probably should be set to 6 as other elements in this function are 
indented 6 spaces. (Look into the original mail please, if you are 
checking this, whitespace in this reply is mangled by thunderbird ...)

> +        if (virNWFilterFormatParamAttributes(buf, def->filterparams,
> +                                             def->filter)<  0)
> +            return -1;
> +        virBufferAdjustIndent(buf, -4);
>       }
>       if (def->bootIndex)
>           virBufferAsprintf(buf, "<boot order='%d'/>\n", def->bootIndex);

ACK with that fixed.

Peter




More information about the libvir-list mailing list