[libvirt] [PATCH] mdev: Cleanup code after commits @daf5081b and @2739a983

Erik Skultety posted 1 patch 6 years, 11 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/2f6928a179a3089ce10440896f7832b32d0a1c0b.1493910174.git.eskultet@redhat.com
src/util/virmdev.c | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
[libvirt] [PATCH] mdev: Cleanup code after commits @daf5081b and @2739a983
Posted by Erik Skultety 6 years, 11 months ago
So, because mingw is somehow OK with dereferencing a pointer within a
VIR_DEBUG macro, compared to outside of it to which it complained with a
"potential NULL pointer dereference" error (still a false positive), we
can make the code a tiny bit cleaner.

Sighed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
---
 src/util/virmdev.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/src/util/virmdev.c b/src/util/virmdev.c
index 174f48cb3..bd8e3f8de 100644
--- a/src/util/virmdev.c
+++ b/src/util/virmdev.c
@@ -449,13 +449,8 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,

     virObjectLock(dst);
     for (i = 0; i < count; i++) {
-        const char *mdev_path = NULL;
         virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);

-        if (!mdev)
-            goto cleanup;
-
-        mdev_path = mdev->path;
         if (virMediatedDeviceIsUsed(mdev, dst) ||
             virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
             goto cleanup;
@@ -464,11 +459,11 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
          * - caller is responsible for NOT freeing devices in @src on success
          * - we're responsible for performing a rollback on failure
          */
+        VIR_DEBUG("Add '%s' to list of active mediated devices used by '%s'",
+                  mdev->path, domname);
         if (virMediatedDeviceListAdd(dst, &mdev) < 0)
             goto rollback;

-        VIR_DEBUG("'%s' added to list of active mediated devices used by '%s'",
-                  mdev_path, domname);
     }

     ret = 0;
--
2.12.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] mdev: Cleanup code after commits @daf5081b and @2739a983
Posted by Laine Stump 6 years, 11 months ago
On 05/04/2017 11:03 AM, Erik Skultety wrote:
> So, because mingw is somehow OK with dereferencing a pointer within a
> VIR_DEBUG macro, compared to outside of it to which it complained with a
> "potential NULL pointer dereference" error (still a false positive), we
> can make the code a tiny bit cleaner.
> 
> Sighed-by: Erik Skultety <eskultet@redhat.com>
> Signed-off-by: Erik Skultety <eskultet@redhat.com>
> ---
>  src/util/virmdev.c | 9 ++-------
>  1 file changed, 2 insertions(+), 7 deletions(-)
> 
> diff --git a/src/util/virmdev.c b/src/util/virmdev.c
> index 174f48cb3..bd8e3f8de 100644
> --- a/src/util/virmdev.c
> +++ b/src/util/virmdev.c
> @@ -449,13 +449,8 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
> 
>      virObjectLock(dst);
>      for (i = 0; i < count; i++) {
> -        const char *mdev_path = NULL;
>          virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);
> 
> -        if (!mdev)
> -            goto cleanup;
> -
> -        mdev_path = mdev->path;
>          if (virMediatedDeviceIsUsed(mdev, dst) ||
>              virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
>              goto cleanup;
> @@ -464,11 +459,11 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
>           * - caller is responsible for NOT freeing devices in @src on success
>           * - we're responsible for performing a rollback on failure
>           */
> +        VIR_DEBUG("Add '%s' to list of active mediated devices used by '%s'",
> +                  mdev->path, domname);
>          if (virMediatedDeviceListAdd(dst, &mdev) < 0)
>              goto rollback;
> 
> -        VIR_DEBUG("'%s' added to list of active mediated devices used by '%s'",
> -                  mdev_path, domname);
>      }

ACK.

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] mdev: Cleanup code after commits @daf5081b and @2739a983
Posted by Erik Skultety 6 years, 11 months ago
On Thu, May 04, 2017 at 01:28:27PM -0400, Laine Stump wrote:
> On 05/04/2017 11:03 AM, Erik Skultety wrote:
> > So, because mingw is somehow OK with dereferencing a pointer within a
> > VIR_DEBUG macro, compared to outside of it to which it complained with a
> > "potential NULL pointer dereference" error (still a false positive), we
> > can make the code a tiny bit cleaner.
> >
> > Sighed-by: Erik Skultety <eskultet@redhat.com>
> > Signed-off-by: Erik Skultety <eskultet@redhat.com>
> > ---
> >  src/util/virmdev.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> >
> > diff --git a/src/util/virmdev.c b/src/util/virmdev.c
> > index 174f48cb3..bd8e3f8de 100644
> > --- a/src/util/virmdev.c
> > +++ b/src/util/virmdev.c
> > @@ -449,13 +449,8 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
> >
> >      virObjectLock(dst);
> >      for (i = 0; i < count; i++) {
> > -        const char *mdev_path = NULL;
> >          virMediatedDevicePtr mdev = virMediatedDeviceListGet(src, i);
> >
> > -        if (!mdev)
> > -            goto cleanup;
> > -
> > -        mdev_path = mdev->path;
> >          if (virMediatedDeviceIsUsed(mdev, dst) ||
> >              virMediatedDeviceSetUsedBy(mdev, drvname, domname) < 0)
> >              goto cleanup;
> > @@ -464,11 +459,11 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
> >           * - caller is responsible for NOT freeing devices in @src on success
> >           * - we're responsible for performing a rollback on failure
> >           */
> > +        VIR_DEBUG("Add '%s' to list of active mediated devices used by '%s'",
> > +                  mdev->path, domname);
> >          if (virMediatedDeviceListAdd(dst, &mdev) < 0)
> >              goto rollback;
> >
> > -        VIR_DEBUG("'%s' added to list of active mediated devices used by '%s'",
> > -                  mdev_path, domname);
> >      }
>
> ACK.

Thanks for review, I'll push after the release, even though the patch is
trivial, just in case :).

Erik

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