fix ioctl return value
PATCH 1/1 fix ioctl return value
we expect a number less than 0, not exactly -1.
And furthermore, we return errno itself, so no need to use it.
This might break guests when this ioctl fails for some reason.
--- kvm-all.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)
kvm-all.c +2 -3
@@ -319,9 +319,8 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, d.slot = mem->slot; -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) ==-1 ) { -dprintf ("ioctl failed %d\n" , errno); - ret =-1 ; +if ((ret =kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d)) <0 ) { +dprintf ("ioctl failed %d\n" , ret);break ; }
Signature · 1 line
1.6.2.2
Quoted 15 lines · Glauber Costa
we expect a number less than 0, not exactly -1.
And furthermore, we return errno itself, so no need to use it.This might break guests when this ioctl fails for some reason.
Signed-off-by Glauber Costa <[email protected]>--- kvm-all.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)kvm-all.c +0
-0
kvm-all.c int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, · line 324
Quoted 9 lines
kvm-all.c +2
-3@@ -319,9 +319,8 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, d.slot = mem->slot; -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) ==-1 ) { -dprintf ("ioctl failed %d\n" , errno); - ret =-1 ; +if ((ret =kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d)) <0 ) { +dprintf ("ioctl failed %d\n" , ret);
While this is fine, I usually prefer:
ret = kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d);
if (ret < 0) {
dprintf(ioctl failed %d\n", ret);
Signature · 3 lines
Regards, Anthony Liguori
Quoted 28 lines · Anthony Liguori
Quoted 15 lines · Glauber Costa
we expect a number less than 0, not exactly -1.
And furthermore, we return errno itself, so no need to use it.This might break guests when this ioctl fails for some reason.
Signed-off-by Glauber Costa <[email protected]>--- kvm-all.c | 5 ++--- 1 files changed, 2 insertions(+), 3 deletions(-)kvm-all.c +0
-0kvm-all.c int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, · line 324
Quoted 9 lines
kvm-all.c +2
-3@@ -319,9 +319,8 @@ int kvm_physical_sync_dirty_bitmap(target_phys_addr_t start_addr, d.slot = mem->slot; -if (kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d) ==-1 ) { -dprintf ("ioctl failed %d\n" , errno); - ret =-1 ; +if ((ret =kvm_vm_ioctl (s,KVM_GET_DIRTY_LOG , &d)) <0 ) { +dprintf ("ioctl failed %d\n" , ret);While this is fine, I usually prefer:
Quoted 3 lines
ret =
kvm_vm_ioctl(s, KVM_GET_DIRTY_LOG, &d);if (ret < 0) { dprintf(ioctl failed %d\n", ret);
want me to shoot a new one?
Quoted 2 lines · Glauber Costa
want me to shoot a new one?
It's up to you.
Signature · 3 lines
Regards, Anthony Liguori