On 11/05/2013 12:03 PM, Max Reitz wrote: > error_setg_errno() may overwrite errno; therefore, its value should be > read before calling that function and not afterwards. > > Signed-off-by: Max Reitz <mre...@redhat.com> > --- > block.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Eric Blake <ebl...@redhat.com> Still, wouldn't it be easier to patch error_setg_errno (and friends) to guarantee that errno is unchanged on exit compared to its value on entrance, rather than having to audit for other mistakes like this? > > diff --git a/block.c b/block.c > index 58efb5b..0e96a22 100644 > --- a/block.c > +++ b/block.c > @@ -1084,8 +1084,8 @@ int bdrv_open(BlockDriverState *bs, const char > *filename, QDict *options, > snprintf(backing_filename, sizeof(backing_filename), > "%s", filename); > } else if (!realpath(filename, backing_filename)) { > - error_setg_errno(errp, errno, "Could not resolve path '%s'", > filename); > ret = -errno; > + error_setg_errno(errp, errno, "Could not resolve path '%s'", > filename); > goto fail; > } > > -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature