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, bytes, (uint8_t *)buf, 0);
+ 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, bytes, (uint8_t *)buf, flags);
+ if (ret < 0) {
+ return ret;
}
+ *total = bytes;
return 1;
}
return -ERANGE;
}
- ret = blk_pwrite_compressed(blk, offset, buf, bytes);
+ ret = blk_pwrite_compressed(blk, offset, bytes, buf);
if (ret < 0) {
return ret;
}