diff mbox

[RFC,3/3] block/nfs: switch to error_init_local

Message ID 1434458200-23440-4-git-send-email-mst@redhat.com
State New
Headers show

Commit Message

Michael S. Tsirkin June 16, 2015, 12:53 p.m. UTC
We probably should just switch everyone, this is
just to demonstrate the API usage.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
 block/nfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Eric Blake June 16, 2015, 3:08 p.m. UTC | #1
On 06/16/2015 06:53 AM, Michael S. Tsirkin wrote:
> We probably should just switch everyone, this is
> just to demonstrate the API usage.
> 
> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> ---
>  block/nfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

And indeed this is the reason things are still at RFC level.  I like the
idea.  It doesn't change anything for a bug-free program, but where we
DO have a bug, we now get a stacktrace that aborts as soon as possible
rather than delaying to the propagation point and losing some information.

> 
> diff --git a/block/nfs.c b/block/nfs.c
> index ca9e24e..de4b8c3 100644
> --- a/block/nfs.c
> +++ b/block/nfs.c
> @@ -385,7 +385,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
>      NFSClient *client = bs->opaque;
>      int64_t ret;
>      QemuOpts *opts;
> -    Error *local_err = NULL;
> +    Error *local_err = error_init_local(errp);

Should be a fairly mechanical patch to catch all the spots; although
there are multiple spellings (not all callers name it local_err).
Michael S. Tsirkin June 16, 2015, 9:17 p.m. UTC | #2
On Tue, Jun 16, 2015 at 09:08:16AM -0600, Eric Blake wrote:
> On 06/16/2015 06:53 AM, Michael S. Tsirkin wrote:
> > We probably should just switch everyone, this is
> > just to demonstrate the API usage.
> > 
> > Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
> > ---
> >  block/nfs.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> And indeed this is the reason things are still at RFC level.  I like the
> idea.  It doesn't change anything for a bug-free program, but where we
> DO have a bug, we now get a stacktrace that aborts as soon as possible
> rather than delaying to the propagation point and losing some information.
> 
> > 
> > diff --git a/block/nfs.c b/block/nfs.c
> > index ca9e24e..de4b8c3 100644
> > --- a/block/nfs.c
> > +++ b/block/nfs.c
> > @@ -385,7 +385,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
> >      NFSClient *client = bs->opaque;
> >      int64_t ret;
> >      QemuOpts *opts;
> > -    Error *local_err = NULL;
> > +    Error *local_err = error_init_local(errp);
> 
> Should be a fairly mechanical patch to catch all the spots; although
> there are multiple spellings (not all callers name it local_err).

I'll try to write an spatch to do this.

> -- 
> Eric Blake   eblake redhat com    +1-919-301-3266
> Libvirt virtualization library http://libvirt.org
>
diff mbox

Patch

diff --git a/block/nfs.c b/block/nfs.c
index ca9e24e..de4b8c3 100644
--- a/block/nfs.c
+++ b/block/nfs.c
@@ -385,7 +385,7 @@  static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
     NFSClient *client = bs->opaque;
     int64_t ret;
     QemuOpts *opts;
-    Error *local_err = NULL;
+    Error *local_err = error_init_local(errp);
 
     client->aio_context = bdrv_get_aio_context(bs);