Re: [PATCH 2/6] qemu_conf: Drop a pair of needless 'cleanup' labels

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 10, 2019 at 09:19:50AM +0200, Pavel Hrdina wrote:
> On Mon, Sep 09, 2019 at 06:00:23PM +0200, Michal Privoznik wrote:
> > There are two 'cleanup' labels - one in
> > virQEMUDriverConfigHugeTLBFSInit() and the other in
> > virQEMUDriverConfigSetDefaults() that do nothing more than
> > return and integer value. No memory freeing or anything important
> > is done there. Drop them in favour of returning immediately.
> > 
> > Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> > ---
> >  src/qemu/qemu_conf.c | 26 ++++++++------------------
> >  1 file changed, 8 insertions(+), 18 deletions(-)
> > 
> > diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> > index 32d411e536..f11df03cf8 100644
> > --- a/src/qemu/qemu_conf.c
> > +++ b/src/qemu/qemu_conf.c
> > @@ -402,18 +402,12 @@ virQEMUDriverConfigHugeTLBFSInit(virHugeTLBFSPtr hugetlbfs,
> >                                   const char *path,
> >                                   bool deflt)
> >  {
> > -    int ret = -1;
> > -
> > -    if (VIR_STRDUP(hugetlbfs->mnt_dir, path) < 0)
> > -        goto cleanup;
> > -
> > -    if (virFileGetHugepageSize(path, &hugetlbfs->size) < 0)
> > -        goto cleanup;
> > +    if (VIR_STRDUP(hugetlbfs->mnt_dir, path) < 0 ||
> > +        virFileGetHugepageSize(path, &hugetlbfs->size) < 0)
> > +        return -1;
> 
> I prefer the old code-style to have two separate if conditions but
> that's just my personal view.
> 
> We don't have a syntax-check rule for that but the body should be
> wrapped in curly braces [1].  I know that our code doesn't follow that
> rule but we should avoid introducing new occurrences.

Ups, missed the link to hacking guide.

[1] <https://libvirt.org/hacking.html#curly_braces>

Attachment: signature.asc
Description: PGP signature

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux