qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Max Reitz <mreitz@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fam Zheng <fam@euphon.net>,
	"open list:Sheepdog" <sheepdog@lists.wpkg.org>,
	qemu-block@nongnu.org, Jeff Cody <codyprime@gmail.com>,
	Stefan Weil <sw@weilnetz.de>,
	Markus Armbruster <armbru@redhat.com>,
	stefanha@redhat.com, Liu Yuan <namei.unix@gmail.com>,
	"Denis V. Lunev" <den@openvz.org>, John Snow <jsnow@redhat.com>
Subject: Re: [PATCH v3 1/3] block: Add blk_new_with_bs() helper
Date: Tue, 28 Apr 2020 07:47:05 -0500	[thread overview]
Message-ID: <dbfc6e21-834f-01a7-b62c-dc445a0eed82@redhat.com> (raw)
In-Reply-To: <59352c54-2d9c-5bde-9f5b-541f2ae5cccc@redhat.com>

On 4/28/20 1:34 AM, Max Reitz wrote:

>>>> block_crypto_co_create_generic(BlockDriverState *bs,
>>>>                                              PreallocMode prealloc,
>>>>                                              Error **errp)
>>>>    {
>>>> -    int ret;
>>>> +    int ret = -EPERM;
>>>
>>> I’m not sure I’m a fan of this, because I feel like it makes the code
>>> harder to read, due to having to look in three places (here, around the
>>> blk_new_with_bs() call, and under the cleanup label) instead of in two
>>> (not here) to verify that the error handling code is correct.
>>>
>>> There’s also the fact that this is not really a default return value,
>>> but one very specific error code for if one very specific function call
>>> fails.
>>>
>>> I suppose it comes down to whether one considers LoC a complexity
>>> problem.  (I don’t, necessarily.)
>>>
>>> (Also I realize it seems rather common in the kernel to set error return
>>> variables before the function call, but I think the more common pattern
>>> in qemu is to set it in the error path.)
>>
>> I'm fine with either style.  Setting it up front is handy if that
>> particular error makes a good default, but in many of the functions I
>> touched, we were returning a variety of errors (-EIO, -EINVAL, -EPERM,
>> etc) such that there was no good default, and thus no reason to set a
>> default up front.  Is this something that would go through your tree,
>> and if so, are you okay making that tweak, or do I need to send v4?
> 
> I suppose I can do that, this is what I’d squash in, OK?

Yes, that change looks correct to me.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



  reply	other threads:[~2020-04-28 12:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 19:09 [PATCH v3 0/3] qcow2: Allow resize of images with internal snapshots Eric Blake
2020-04-24 19:09 ` [PATCH v3 1/3] block: Add blk_new_with_bs() helper Eric Blake
2020-04-27 10:00   ` Max Reitz
2020-04-27 14:03     ` Eric Blake
2020-04-28  6:34       ` Max Reitz
2020-04-28 12:47         ` Eric Blake [this message]
2020-04-24 19:09 ` [PATCH v3 2/3] qcow2: Allow resize of images with internal snapshots Eric Blake
2020-04-24 19:09 ` [PATCH v3 3/3] qcow2: Tweak comment about bitmaps vs. resize Eric Blake
2020-04-28 12:59 ` [PATCH v3 0/3] qcow2: Allow resize of images with internal snapshots Max Reitz
2020-04-28 18:24   ` Eric Blake

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=dbfc6e21-834f-01a7-b62c-dc445a0eed82@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=codyprime@gmail.com \
    --cc=den@openvz.org \
    --cc=fam@euphon.net \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=namei.unix@gmail.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sheepdog@lists.wpkg.org \
    --cc=stefanha@redhat.com \
    --cc=sw@weilnetz.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).