[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code
From: |
Paolo Bonzini |
Subject: |
Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code |
Date: |
Thu, 18 Jan 2018 13:03:43 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 |
On 18/01/2018 12:21, Philippe Mathieu-Daudé wrote:
>> I'm not a fan of bool return types, in general (because "!" is often
>> success while "< 0" is failure) and especially when there is an Error**;
>> I disagree with commit 9d3b155186. But the function is not in an area I
>> maintain so I'm queuing this, thanks.
> Do you prefer "if (local_err)" and "if (errp && *errp)" ?
The latter is wrong. I do prefer
if (local_err) {
error_propagate(errp, local_err);
return;
}
or maybe (but only if there is a meaning to a zero vs. positive return
value, or if errno is an important part of the returned Error *)
ret = f(..., errp);
if (ret < 0) {
return;
}
> I wondered once if a macro might improve this pattern but thought the
> code would get more obscure.
Eduardo had a series to avoid error_propagate, where NULL was replaced
by a (non-NULL) IGNORED_ERRORS macro. Then you could do:
f(..., errp);
if (error_is_set(errp)) {
return;
}
See here:
https://lists.gnu.org/archive/html/qemu-devel/2017-06/msg03139.html
Paolo
- [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Fam Zheng, 2018/01/17
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Philippe Mathieu-Daudé, 2018/01/17
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Paolo Bonzini, 2018/01/18
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Philippe Mathieu-Daudé, 2018/01/18
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code,
Paolo Bonzini <=
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Philippe Mathieu-Daudé, 2018/01/18
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Paolo Bonzini, 2018/01/18
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Eric Blake, 2018/01/18
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Eduardo Habkost, 2018/01/18
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Paolo Bonzini, 2018/01/18
- Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code, Eduardo Habkost, 2018/01/18