Patchwork block: Fix build with tracing enabled

login
register
mail settings
Submitter Kevin Wolf
Date April 22, 2013, 3:48 p.m.
Message ID <1366645720-11384-1-git-send-email-kwolf@redhat.com>
Download mbox | patch
Permalink /patch/238593/
State New
Headers show

Comments

Kevin Wolf - April 22, 2013, 3:48 p.m.
filename was still uninitialised when it's used as a parameter to a
tracing function, so let's move the initialisation. Also, commit c2ad1b0c
forgot to add a NULL check, which this patch adds while we're at it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
Andreas Färber - April 22, 2013, 3:52 p.m.
Am 22.04.2013 17:48, schrieb Kevin Wolf:
> filename was still uninitialised when it's used as a parameter to a
> tracing function, so let's move the initialisation. Also, commit c2ad1b0c
> forgot to add a NULL check, which this patch adds while we're at it.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Tested-by: Andreas Färber <afaerber@suse.de>

and queued a copy on qom-cpu until it gets applied.

Thanks,
Andreas
Eric Blake - April 22, 2013, 3:57 p.m.
On 04/22/2013 09:48 AM, Kevin Wolf wrote:
> filename was still uninitialised when it's used as a parameter to a
> tracing function, so let's move the initialisation. Also, commit c2ad1b0c
> forgot to add a NULL check, which this patch adds while we're at it.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/block.c b/block.c
> index 819eb4e..aa9a533 100644
> --- a/block.c
> +++ b/block.c
> @@ -676,7 +676,13 @@ static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
>      assert(bs->file == NULL);
>      assert(options != NULL && bs->options != options);
>  
> -    trace_bdrv_open_common(bs, filename, flags, drv->format_name);
> +    if (file != NULL) {
> +        filename = file->filename;
> +    } else {
> +        filename = qdict_get_try_str(options, "filename");
> +    }
> +
> +    trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);

Yet another case of a non-C99 gcc extension; but as this is not the
first use, I'll overlook it, and give:

Reviewed-by: Eric Blake <eblake@redhat.com>
Stefan Hajnoczi - April 23, 2013, 7:05 a.m.
On Mon, Apr 22, 2013 at 05:48:40PM +0200, Kevin Wolf wrote:
> filename was still uninitialised when it's used as a parameter to a
> tracing function, so let's move the initialisation. Also, commit c2ad1b0c
> forgot to add a NULL check, which this patch adds while we're at it.
> 
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> ---
>  block.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan
Anthony Liguori - April 24, 2013, 6:25 p.m.
Applied.  Thanks.

Regards,

Anthony Liguori

Patch

diff --git a/block.c b/block.c
index 819eb4e..aa9a533 100644
--- a/block.c
+++ b/block.c
@@ -676,7 +676,13 @@  static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
     assert(bs->file == NULL);
     assert(options != NULL && bs->options != options);
 
-    trace_bdrv_open_common(bs, filename, flags, drv->format_name);
+    if (file != NULL) {
+        filename = file->filename;
+    } else {
+        filename = qdict_get_try_str(options, "filename");
+    }
+
+    trace_bdrv_open_common(bs, filename ?: "", flags, drv->format_name);
 
     if (use_bdrv_whitelist && !bdrv_is_whitelisted(drv)) {
         return -ENOTSUP;
@@ -698,12 +704,6 @@  static int bdrv_open_common(BlockDriverState *bs, BlockDriverState *file,
         bdrv_enable_copy_on_read(bs);
     }
 
-    if (file != NULL) {
-        filename = file->filename;
-    } else {
-        filename = qdict_get_try_str(options, "filename");
-    }
-
     if (filename != NULL) {
         pstrcpy(bs->filename, sizeof(bs->filename), filename);
     } else {