block: Change blk_{pread,pwrite}() param order
Swap 'buf' and 'bytes' around for consistency with
blk_co_{pread,pwrite}(), and in preparation to implement these functions
using generated_co_wrapper.
Callers were updated using this Coccinelle script:
@@ expression blk, offset, buf, bytes, flags; @@
- blk_pread(blk, offset, buf, bytes, flags)
+ blk_pread(blk, offset, bytes, buf, flags)
@@ expression blk, offset, buf, bytes, flags; @@
- blk_pwrite(blk, offset, buf, bytes, flags)
+ blk_pwrite(blk, offset, bytes, buf, flags)
It had no effect on hw/block/nand.c, presumably due to the #if, so that
file was updated manually.
Overly-long lines were then fixed by hand.
Signed-off-by: Alberto Faria <afaria@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Hanna Reitz <hreitz@redhat.com>
Message-Id: <20220705161527.1054072-4-afaria@redhat.com>
Signed-off-by: Hanna Reitz <hreitz@redhat.com>
diff --git a/qemu-img.c b/qemu-img.c
index a0c0e89..df607a2 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -1309,7 +1309,7 @@
int ret = 0;
int64_t idx;
- ret = blk_pread(blk, offset, buffer, bytes, 0);
+ ret = blk_pread(blk, offset, bytes, buffer, 0);
if (ret < 0) {
error_report("Error while reading offset %" PRId64 " of %s: %s",
offset, filename, strerror(-ret));
@@ -1526,7 +1526,7 @@
int64_t pnum;
chunk = MIN(chunk, IO_BUF_SIZE);
- ret = blk_pread(blk1, offset, buf1, chunk, 0);
+ ret = blk_pread(blk1, offset, chunk, buf1, 0);
if (ret < 0) {
error_report("Error while reading offset %" PRId64
" of %s: %s",
@@ -1534,7 +1534,7 @@
ret = 4;
goto out;
}
- ret = blk_pread(blk2, offset, buf2, chunk, 0);
+ ret = blk_pread(blk2, offset, chunk, buf2, 0);
if (ret < 0) {
error_report("Error while reading offset %" PRId64
" of %s: %s",
@@ -3779,7 +3779,7 @@
n = old_backing_size - offset;
}
- ret = blk_pread(blk_old_backing, offset, buf_old, n, 0);
+ ret = blk_pread(blk_old_backing, offset, n, buf_old, 0);
if (ret < 0) {
error_report("error while reading from old backing file");
goto out;
@@ -3793,7 +3793,7 @@
n = new_backing_size - offset;
}
- ret = blk_pread(blk_new_backing, offset, buf_new, n, 0);
+ ret = blk_pread(blk_new_backing, offset, n, buf_new, 0);
if (ret < 0) {
error_report("error while reading from new backing file");
goto out;
@@ -3812,8 +3812,8 @@
if (buf_old_is_zero) {
ret = blk_pwrite_zeroes(blk, offset + written, pnum, 0);
} else {
- ret = blk_pwrite(blk, offset + written,
- buf_old + written, pnum, 0);
+ ret = blk_pwrite(blk, offset + written, pnum,
+ buf_old + written, 0);
}
if (ret < 0) {
error_report("Error while writing to COW image: %s",
@@ -5122,7 +5122,7 @@
for (out_pos = 0; in_pos < size; block_count++) {
int bytes = (in_pos + in.bsz > size) ? size - in_pos : in.bsz;
- ret = blk_pread(blk1, in_pos, in.buf, bytes, 0);
+ ret = blk_pread(blk1, in_pos, bytes, in.buf, 0);
if (ret < 0) {
error_report("error while reading from input image file: %s",
strerror(-ret));
@@ -5130,7 +5130,7 @@
}
in_pos += bytes;
- ret = blk_pwrite(blk2, out_pos, in.buf, bytes, 0);
+ ret = blk_pwrite(blk2, out_pos, bytes, in.buf, 0);
if (ret < 0) {
error_report("error while writing to output image file: %s",
strerror(-ret));