qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Hajnoczi <stefanha@gmail.com>
To: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
Cc: qemu-devel@nongnu.org, qemu-block@nongnu.org,
	Kevin Wolf <kwolf@redhat.com>, John Snow <jsnow@redhat.com>,
	Stefan Hajnoczi <stefanha@redhat.com>,
	Max Reitz <mreitz@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 4/6] hw/block: Fix the return type
Date: Tue, 1 Aug 2017 14:05:44 +0100	[thread overview]
Message-ID: <20170801130544.GA22017@stefanha-x1.localdomain> (raw)
In-Reply-To: <20170726120255.14292-5-maozy.fnst@cn.fujitsu.com>

[-- Attachment #1: Type: text/plain, Size: 1930 bytes --]

On Wed, Jul 26, 2017 at 08:02:53PM +0800, Mao Zhongyi wrote:
> When the function no success value to transmit, it usually make the
> function return void. It has turned out not to be a success, because
> it means that the extra local_err variable and error_propagate() will
> be needed. It leads to cumbersome code, therefore, transmit success/
> failure in the return value is worth.
> 
> So fix the return type of blkconf_apply_backend_options(),
> blkconf_geometry() and virtio_blk_data_plane_create() to avoid it.
> 
> Cc: John Snow <jsnow@redhat.com>
> Cc: Kevin Wolf <kwolf@redhat.com>
> Cc: Max Reitz <mreitz@redhat.com>
> Cc: Stefan Hajnoczi <stefanha@redhat.com>
> 
> Signed-off-by: Mao Zhongyi <maozy.fnst@cn.fujitsu.com>
> ---
>  hw/block/block.c                | 21 ++++++++++++---------
>  hw/block/dataplane/virtio-blk.c | 16 +++++++++-------
>  hw/block/dataplane/virtio-blk.h |  6 +++---
>  include/hw/block/block.h        | 10 +++++-----
>  4 files changed, 29 insertions(+), 24 deletions(-)
> 
> diff --git a/hw/block/block.c b/hw/block/block.c
> index 27878d0..717bd0e 100644
> --- a/hw/block/block.c
> +++ b/hw/block/block.c
> @@ -51,8 +51,8 @@ void blkconf_blocksizes(BlockConf *conf)
>      }
>  }
>  
> -void blkconf_apply_backend_options(BlockConf *conf, bool readonly,
> -                                   bool resizable, Error **errp)
> +int blkconf_apply_backend_options(BlockConf *conf, bool readonly,
> +                                  bool resizable, Error **errp)

I'm not a fan of these changes because it makes inconsistencies between
the return value and the errp argument possible (e.g. returning success
but setting errp, or returning failure without setting errp).

If you really want to do this please use bool as the return type instead
of int.  int can be abused to return error information that should
really be in the Error object.

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 455 bytes --]

  reply	other threads:[~2017-08-01 13:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-26 12:02 [Qemu-devel] [PATCH 0/6] Convert to realize and improve error handling Mao Zhongyi
2017-07-26 12:02 ` [Qemu-devel] [PATCH 1/6] hw/ide: Convert DeviceClass init to realize Mao Zhongyi
2017-07-26 12:02 ` [Qemu-devel] [PATCH 2/6] hw/block/fdc: Convert " Mao Zhongyi
2017-07-26 12:02 ` [Qemu-devel] [PATCH 3/6] hw/block/nvme: " Mao Zhongyi
2017-07-26 12:02 ` [Qemu-devel] [PATCH 4/6] hw/block: Fix the return type Mao Zhongyi
2017-08-01 13:05   ` Stefan Hajnoczi [this message]
2017-08-01 14:29     ` Markus Armbruster
2017-08-02  7:51       ` Mao Zhongyi
2017-07-26 12:02 ` [Qemu-devel] [PATCH 5/6] hw/block: Use errp directly rather than local_err Mao Zhongyi
2017-07-26 12:02 ` [Qemu-devel] [PATCH 6/6] dev-storage: Fix the unusual function name Mao Zhongyi

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=20170801130544.GA22017@stefanha-x1.localdomain \
    --to=stefanha@gmail.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=maozy.fnst@cn.fujitsu.com \
    --cc=mreitz@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).