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

Fabiano Fidêncio fidencio at redhat.com
Thu Dec 19 16:21:21 UTC 2019


On Thu, Dec 19, 2019 at 5:07 PM Pavel Hrdina <phrdina at redhat.com> 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 at redhat.com>
> > ---
> >  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.

Best Regards,
-- 
Fabiano Fidêncio





More information about the libvir-list mailing list