ref: 4c155036f9ce3a74bc3eb3bb79725616d3b6c125
parent: 1a96ef0a24a443094ad3c0293387a70e607227ee
author: gkostka <kostka.grzegorz@gmail.com>
date: Thu Dec 1 11:37:23 EST 2016
ext4_blockdev: don't make zero length block read/write operations Patch submitted by g.tywanczuk@posnet.com.
--- a/src/ext4_blockdev.c
+++ b/src/ext4_blockdev.c
@@ -350,14 +350,16 @@
/*Aligned data*/
blen = len / bdev->bdif->ph_bsize;
- r = ext4_bdif_bwrite(bdev, p, block_idx, blen);
- if (r != EOK)
- return r;
+ if (blen != 0) {
+ r = ext4_bdif_bwrite(bdev, p, block_idx, blen);
+ if (r != EOK)
+ return r;
- p += bdev->bdif->ph_bsize * blen;
- len -= bdev->bdif->ph_bsize * blen;
+ p += bdev->bdif->ph_bsize * blen;
+ len -= bdev->bdif->ph_bsize * blen;
- block_idx += blen;
+ block_idx += blen;
+ }
/*Rest of the data*/
if (len) {
@@ -416,14 +418,16 @@
/*Aligned data*/
blen = len / bdev->bdif->ph_bsize;
- r = ext4_bdif_bread(bdev, p, block_idx, blen);
- if (r != EOK)
- return r;
+ if (blen != 0) {
+ r = ext4_bdif_bread(bdev, p, block_idx, blen);
+ if (r != EOK)
+ return r;
- p += bdev->bdif->ph_bsize * blen;
- len -= bdev->bdif->ph_bsize * blen;
+ p += bdev->bdif->ph_bsize * blen;
+ len -= bdev->bdif->ph_bsize * blen;
- block_idx += blen;
+ block_idx += blen;
+ }
/*Rest of the data*/
if (len) {