block: Make blk_{pread,pwrite}() return 0 on success

They currently return the value of their 'bytes' parameter on success.

Make them return 0 instead, for consistency with other I/O functions and
in preparation to implement them using generated_co_wrapper. This also
makes it clear that short reads/writes are not possible.

Signed-off-by: Alberto Faria <afaria@redhat.com>
Message-Id: <20220705161527.1054072-2-afaria@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
This commit is contained in:
Alberto Faria 2022-07-05 17:15:09 +01:00 committed by Hanna Reitz
parent 92529251d2
commit bf5b16fa40
12 changed files with 49 additions and 51 deletions

View file

@ -1029,8 +1029,8 @@ static void mos6522_q800_via1_realize(DeviceState *dev, Error **errp)
return;
}
len = blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM));
if (len != sizeof(v1s->PRAM)) {
ret = blk_pread(v1s->blk, 0, v1s->PRAM, sizeof(v1s->PRAM));
if (ret < 0) {
error_setg(errp, "can't read PRAM contents");
return;
}

View file

@ -240,7 +240,7 @@ static void sifive_u_otp_realize(DeviceState *dev, Error **errp)
return;
}
if (blk_pread(s->blk, 0, s->fuse, filesize) != filesize) {
if (blk_pread(s->blk, 0, s->fuse, filesize) < 0) {
error_setg(errp, "failed to read the initial flash content");
return;
}