[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PULL 20/39] cow.c: replace QEMUOptionParameter with Qe
From: |
Peter Maydell |
Subject: |
Re: [Qemu-devel] [PULL 20/39] cow.c: replace QEMUOptionParameter with QemuOpts |
Date: |
Mon, 30 Jun 2014 18:52:29 +0100 |
On 16 June 2014 12:23, Stefan Hajnoczi <address@hidden> wrote:
> From: Chunyan Liu <address@hidden>
>
> Reviewed-by: Eric Blake <address@hidden>
> Reviewed-by: Stefan Hajnoczi <address@hidden>
> Signed-off-by: Dong Xu Wang <address@hidden>
> Signed-off-by: Chunyan Liu <address@hidden>
> Signed-off-by: Stefan Hajnoczi <address@hidden>
> ---
> block/cow.c | 54 ++++++++++++++++++++++++++----------------------------
> 1 file changed, 26 insertions(+), 28 deletions(-)
>
> diff --git a/block/cow.c b/block/cow.c
> index 7e61024..af85753 100644
> --- a/block/cow.c
> +++ b/block/cow.c
> @@ -324,31 +324,24 @@ static void cow_close(BlockDriverState *bs)
> {
> }
>
> -static int cow_create(const char *filename, QEMUOptionParameter *options,
> - Error **errp)
> +static int cow_create(const char *filename, QemuOpts *opts, Error **errp)
> {
> struct cow_header_v2 cow_header;
> struct stat st;
> int64_t image_sectors = 0;
> - const char *image_filename = NULL;
> + char *image_filename = NULL;
> Error *local_err = NULL;
> int ret;
> BlockDriverState *cow_bs;
>
> /* Read out options */
> - while (options && options->name) {
> - if (!strcmp(options->name, BLOCK_OPT_SIZE)) {
> - image_sectors = options->value.n / 512;
> - } else if (!strcmp(options->name, BLOCK_OPT_BACKING_FILE)) {
> - image_filename = options->value.s;
> - }
> - options++;
> - }
> + image_sectors = qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0) / 512;
> + image_filename = qemu_opt_get_del(opts, BLOCK_OPT_BACKING_FILE);
>
> - ret = bdrv_create_file(filename, options, NULL, &local_err);
> + ret = bdrv_create_file(filename, NULL, opts, &local_err);
> if (ret < 0) {
> error_propagate(errp, local_err);
> - return ret;
> + goto exit;
> }
>
> cow_bs = NULL;
This change means we now have a 'goto exit' before cow_bs
is initialized, and the exit: code path uses cow_bs:
>
> exit:
> + g_free(image_filename);
> bdrv_unref(cow_bs);
> return ret;
> }
clang 3.4 correctly warns:
/home/petmay01/linaro/qemu-from-laptop/qemu/block/cow.c:342:9:
warning: variable 'cow_bs' is used uninitialized whenever 'if'
condition is true [-Wsometimes-uninitialized]
if (ret < 0) {
^~~~~~~
/home/petmay01/linaro/qemu-from-laptop/qemu/block/cow.c:386:16: note:
uninitialized use occurs here
bdrv_unref(cow_bs);
^~~~~~
/home/petmay01/linaro/qemu-from-laptop/qemu/block/cow.c:342:5: note:
remove the 'if' if its condition is always false
if (ret < 0) {
^~~~~~~~~~~~~~
/home/petmay01/linaro/qemu-from-laptop/qemu/block/cow.c:335:29: note:
initialize the variable 'cow_bs' to silence this warning
BlockDriverState *cow_bs;
^
= NULL
1 warning generated.
Patch to follow.
thanks
-- PMM
- [Qemu-devel] [PULL 11/39] QemuOpts: change opt->name|str from (const char *) to (char *), (continued)
- [Qemu-devel] [PULL 11/39] QemuOpts: change opt->name|str from (const char *) to (char *), Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 12/39] QemuOpts: move qemu_opt_del ahead for later calling, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 13/39] QemuOpts: add qemu_opt_get_*_del functions for replace work, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 14/39] QemuOpts: add qemu_opts_print_help to replace print_option_help, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 15/39] QemuOpts: add conversion between QEMUOptionParameter to QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 16/39] QemuOpts: add qemu_opts_append to replace append_option_parameters, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 17/39] QemuOpts: check NULL input for qemu_opts_del, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 18/39] change block layer to support both QemuOpts and QEMUOptionParamter, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 19/39] vvfat.c: handle cross_driver's create_options and create_opts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 20/39] cow.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- Re: [Qemu-devel] [PULL 20/39] cow.c: replace QEMUOptionParameter with QemuOpts,
Peter Maydell <=
- [Qemu-devel] [PULL 21/39] gluster.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 22/39] iscsi.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 23/39] nfs.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 24/39] qcow.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 25/39] QemuOpts: export qemu_opt_find, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 26/39] qcow2.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 27/39] qed.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 28/39] raw-posix.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 29/39] raw-win32.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16
- [Qemu-devel] [PULL 30/39] raw_bsd.c: replace QEMUOptionParameter with QemuOpts, Stefan Hajnoczi, 2014/06/16