[libvirt] [perl] Fix check of return value from virStreamRecv*

Jim Fehlig posted 1 patch 6 years, 4 months ago
Failed in applying to current master (apply log)
Changes | 2 +-
Virt.xs | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[libvirt] [perl] Fix check of return value from virStreamRecv*
Posted by Jim Fehlig 6 years, 4 months ago
Commit 049baec5 introduced a small bug in the logic checking
return value of virStreamRecv*. Change the logic to only croak
when return value is < 0 and not equal to -2 or -3.
---
 Changes | 2 +-
 Virt.xs | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Changes b/Changes
index 3763b1d..96b42f8 100644
--- a/Changes
+++ b/Changes
@@ -2,7 +2,7 @@ Revision history for perl module Sys::Virt
 
 4.0.0 2018-00-00
 
- - XXX
+ - Fix check of return value from virStreamRecv*
 
 3.9.1 2017-12-05
 
diff --git a/Virt.xs b/Virt.xs
index 415eb8a..c47b915 100644
--- a/Virt.xs
+++ b/Virt.xs
@@ -8074,7 +8074,7 @@ recv(st, data, nbytes, flags=0)
       else
           RETVAL = virStreamRecv(st, rawdata, nbytes);
 
-      if (RETVAL != -2 && RETVAL != -3) {
+      if ((RETVAL < 0) && (RETVAL != -2 || RETVAL != -3)) {
           Safefree(rawdata);
           _croak_error();
       }
-- 
2.15.1

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [perl] Fix check of return value from virStreamRecv*
Posted by Daniel P. Berrange 6 years, 4 months ago
On Fri, Dec 15, 2017 at 03:24:03PM -0700, Jim Fehlig wrote:
> Commit 049baec5 introduced a small bug in the logic checking
> return value of virStreamRecv*. Change the logic to only croak
> when return value is < 0 and not equal to -2 or -3.
> ---
>  Changes | 2 +-
>  Virt.xs | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Daniel P. Berrange <berrange@redhat.com>


Regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|

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