* [Qemu-devel] Re: [PATCH] fix ioctl return value
2009-07-21 13:45 [Qemu-devel] [PATCH] fix ioctl return value Glauber Costa
@ 2009-07-21 13:40 ` Anthony Liguori
2009-07-21 13:51 ` Glauber Costa
0 siblings, 1 reply; 4+ messages in thread
From: Anthony Liguori @ 2009-07-21 13:40 UTC (permalink / raw)
To: Glauber Costa; +Cc: qemu-devel
Glauber Costa wrote:
> 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 <glommer@redhat.com>
> ---
> kvm-all.c | 5 ++---
> 1 files changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/kvm-all.c b/kvm-all.c
> index 8567ac9..9a79466 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -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);
--
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH] fix ioctl return value
2009-07-21 13:51 ` Glauber Costa
@ 2009-07-21 13:44 ` Anthony Liguori
0 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2009-07-21 13:44 UTC (permalink / raw)
To: Glauber Costa; +Cc: qemu-devel
Glauber Costa wrote:
> want me to shoot a new one?
>
It's up to you.
--
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH] fix ioctl return value
@ 2009-07-21 13:45 Glauber Costa
2009-07-21 13:40 ` [Qemu-devel] " Anthony Liguori
0 siblings, 1 reply; 4+ messages in thread
From: Glauber Costa @ 2009-07-21 13:45 UTC (permalink / raw)
To: qemu-devel; +Cc: aliguori
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 <glommer@redhat.com>
---
kvm-all.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/kvm-all.c b/kvm-all.c
index 8567ac9..9a79466 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -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;
}
--
1.6.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] Re: [PATCH] fix ioctl return value
2009-07-21 13:40 ` [Qemu-devel] " Anthony Liguori
@ 2009-07-21 13:51 ` Glauber Costa
2009-07-21 13:44 ` Anthony Liguori
0 siblings, 1 reply; 4+ messages in thread
From: Glauber Costa @ 2009-07-21 13:51 UTC (permalink / raw)
To: Anthony Liguori; +Cc: qemu-devel
On Tue, Jul 21, 2009 at 08:40:36AM -0500, Anthony Liguori wrote:
> Glauber Costa wrote:
>> 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 <glommer@redhat.com>
>> ---
>> kvm-all.c | 5 ++---
>> 1 files changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/kvm-all.c b/kvm-all.c
>> index 8567ac9..9a79466 100644
>> --- a/kvm-all.c
>> +++ b/kvm-all.c
>> @@ -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);
want me to shoot a new one?
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-07-21 13:45 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-21 13:45 [Qemu-devel] [PATCH] fix ioctl return value Glauber Costa
2009-07-21 13:40 ` [Qemu-devel] " Anthony Liguori
2009-07-21 13:51 ` Glauber Costa
2009-07-21 13:44 ` Anthony Liguori
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).