[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [Qemu-devel] [PATCH] scsi-generic: Simplify error handling code |
Date: |
Thu, 18 Jan 2018 08:21:27 -0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 |
On 01/18/2018 05:20 AM, Paolo Bonzini wrote:
> On 18/01/2018 03:52, Fam Zheng wrote:
>> Coverity doesn't like the ignored return value introduced in
>> 9d3b155186c278 (hw/block: Fix the return type), and other callers are
>> converted already in ceff3e1f01.
>>
>> This one was added lately in d9bcd6f7f23a and missed the train. Do it
>> now.
>>
>> Signed-off-by: Fam Zheng <address@hidden>
>> ---
>> hw/scsi/scsi-generic.c | 9 +++------
>> 1 file changed, 3 insertions(+), 6 deletions(-)
>>
>> diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
>> index ba70c0dc19..7414fe2d67 100644
>> --- a/hw/scsi/scsi-generic.c
>> +++ b/hw/scsi/scsi-generic.c
>> @@ -482,7 +482,6 @@ static void scsi_generic_realize(SCSIDevice *s, Error
>> **errp)
>> int rc;
>> int sg_version;
>> struct sg_scsi_id scsiid;
>> - Error *local_err = NULL;
>>
>> if (!s->conf.blk) {
>> error_setg(errp, "drive property not set");
>> @@ -516,11 +515,9 @@ static void scsi_generic_realize(SCSIDevice *s, Error
>> **errp)
>> error_setg(errp, "SG_GET_SCSI_ID ioctl failed");
>> return;
>> }
>> - blkconf_apply_backend_options(&s->conf,
>> - blk_is_read_only(s->conf.blk),
>> - true, &local_err);
>> - if (local_err) {
>> - error_propagate(errp, local_err);
>> + if (!blkconf_apply_backend_options(&s->conf,
>> + blk_is_read_only(s->conf.blk),
>> + true, errp)) {
>> return;
>> }
>>
>>
>
> 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)" ?
I wondered once if a macro might improve this pattern but thought the
code would get more obscure.
- [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é <=
- 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, 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