On Thu, May 26, 2022 at 09:49:03AM +0100, Stefan Hajnoczi wrote:
> On Thu, May 19, 2022 at 03:48:33PM +0100, Alberto Faria wrote:
> > diff --git a/block/qcow2.c b/block/qcow2.c
> > index 5493e6b847..d5a1e8bc43 100644
> > --- a/block/qcow2.c
> > +++ b/block/qcow2.c
> > @@ -113,7 +113,7 @@ static ssize_t qcow2_crypto_hdr_read_func(QCryptoBlock 
> > *block, size_t offset,
> >          error_setg_errno(errp, -ret, "Could not read encryption header");
> >          return -1;
> >      }
> > -    return ret;
> > +    return buflen;
> >  }
> >  
> >  
> > @@ -174,7 +174,7 @@ static ssize_t qcow2_crypto_hdr_write_func(QCryptoBlock 
> > *block, size_t offset,
> >          error_setg_errno(errp, -ret, "Could not read encryption header");
> >          return -1;
> >      }
> > -    return ret;
> > +    return buflen;
> >  }
> 
> I think block/crypto.c's read_func and write_func could be converted to
> 0 (success) and -errno (failure) in the same way. Callers don't handle
> cases where the return value != buflen or failure.

Yes, the callers expect a full buffer to be written, or for error to be
reported.  the 'ssize_t' return type should be converted to merely
'int' with 0 success/-1 error.

With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|


Reply via email to