[libvirt] [PATCH 1/3] libvirt-domain: Introduce macro to save duplicated codes

Jiri Denemark jdenemar at redhat.com
Thu Oct 15 09:40:38 UTC 2015


On Thu, Oct 15, 2015 at 11:31:48 +0200, Peter Krempa wrote:
> On Thu, Oct 15, 2015 at 17:12:18 +0800, Wei Jiangang wrote:
> > Signed-off-by: Wei Jiangang <weijg.fnst at cn.fujitsu.com>
> > ---
> >  src/libvirt-domain.c | 55 ++++++++++++++--------------------------------------
> >  1 file changed, 15 insertions(+), 40 deletions(-)
> > 
> > diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c
> > index 6e1aacd..ed07c9e 100644
> > --- a/src/libvirt-domain.c
> > +++ b/src/libvirt-domain.c
> > @@ -33,6 +33,13 @@ VIR_LOG_INIT("libvirt.domain");
> >  
> >  #define VIR_FROM_THIS VIR_FROM_DOMAIN
> >  
> > +#define VIR_ABSOLUTIZE_PATH(PATH, ABSPATH)                             \
> > +    if (virFileAbsPath(PATH, ABSPATH) < 0) {                           \
> > +        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",                   \
> > +                       _("could not build absolute input file path")); \
> 
> This says "input" file path ... 
> 
> > +        goto error;                                                    \
> > +    }
...
> While saving code, this would actually break the error messages in some
> cases.

Not to mention that the result is harder to read and easier to break
(hidden goto error). I don't think it's a good idea at all.

Jirka




More information about the libvir-list mailing list