mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-26 20:03:54 -06:00
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:
parent
92529251d2
commit
bf5b16fa40
12 changed files with 49 additions and 51 deletions
|
@ -541,28 +541,34 @@ fail:
|
|||
static int do_pread(BlockBackend *blk, char *buf, int64_t offset,
|
||||
int64_t bytes, int64_t *total)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (bytes > INT_MAX) {
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
*total = blk_pread(blk, offset, (uint8_t *)buf, bytes);
|
||||
if (*total < 0) {
|
||||
return *total;
|
||||
ret = blk_pread(blk, offset, (uint8_t *)buf, bytes);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
*total = bytes;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int do_pwrite(BlockBackend *blk, char *buf, int64_t offset,
|
||||
int64_t bytes, int flags, int64_t *total)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if (bytes > INT_MAX) {
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
*total = blk_pwrite(blk, offset, (uint8_t *)buf, bytes, flags);
|
||||
if (*total < 0) {
|
||||
return *total;
|
||||
ret = blk_pwrite(blk, offset, (uint8_t *)buf, bytes, flags);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
*total = bytes;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue