Re: [PATCH 05/42] rpc: Don't check the output of virGetUserDirectory()

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

 



On Thu, Dec 19, 2019 at 05:25:59PM +0100, Pavel Hrdina wrote:
On Thu, Dec 19, 2019 at 05:21:21PM +0100, Fabiano Fidêncio wrote:
On Thu, Dec 19, 2019 at 5:07 PM Pavel Hrdina <phrdina@xxxxxxxxxx> wrote:
>
> On Thu, Dec 19, 2019 at 11:04:10AM +0100, Fabiano Fidêncio wrote:
> > virGetUserDirectory() *never* *ever* returns NULL, making the checks for
> > it completely unnecessary.
> >
> > Signed-off-by: Fabiano Fidêncio <fidencio@xxxxxxxxxx>
> > ---
> >  src/rpc/virnetclient.c     | 12 ++++--------
> >  src/rpc/virnettlscontext.c | 12 ------------
> >  2 files changed, 4 insertions(+), 20 deletions(-)
>
> [...]
>
> > diff --git a/src/rpc/virnettlscontext.c b/src/rpc/virnettlscontext.c
> > index ec9dd35c46..08944f6771 100644
> > --- a/src/rpc/virnettlscontext.c
> > +++ b/src/rpc/virnettlscontext.c
> > @@ -805,9 +805,6 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
> >           */
> >          userdir = virGetUserDirectory();
> >
> > -        if (!userdir)
> > -            goto error;
> > -
> >          user_pki_path = g_strdup_printf("%s/.pki/libvirt", userdir);
> >
> >          VIR_DEBUG("Trying to find TLS user credentials in %s", user_pki_path);
> > @@ -864,15 +861,6 @@ static int virNetTLSContextLocateCredentials(const char *pkipath,
> >      VIR_FREE(userdir);
> >
> >      return 0;
> > -
> > - error:
> > -    VIR_FREE(*cacert);
> > -    VIR_FREE(*cacrl);
> > -    VIR_FREE(*key);
> > -    VIR_FREE(*cert);
> > -    VIR_FREE(user_pki_path);
> > -    VIR_FREE(userdir);
> > -    return -1;
>
> This doesn't look right.  Looks like some leftover from rebase where
> you wanted to use g_autofree.

No, actually not. The only usage of `goto error` was when checking the
result of virGetUserDirectory().
By removing the check, we have also to remove the label.

Label yes, the VIR_FREE no as it would leak the memory.


There's "return 0;" right before that label.

Jano

Pavel



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

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