summaryrefslogtreecommitdiff
path: root/lib/device/dev-swap.c
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2017-12-19 01:12:18 +0000
committerAlasdair G Kergon <agk@redhat.com>2017-12-19 01:31:50 +0000
commit17649d4ac8d4c7d10bf58feefa5f1faae89713ca (patch)
tree4b61c337e2b99478ed9ee72c2518d6e3d3084629 /lib/device/dev-swap.c
parent3f9ae846b89a2963a4ca72cfa0281aab0bedcc02 (diff)
downloadlvm2-17649d4ac8d4c7d10bf58feefa5f1faae89713ca.tar.gz
device: Move dev_read memory allocation into device layer.
Rename dev_read() to dev_read_buf() - the function that reads data into a supplied buffer. Introduce a new dev_read() that allocates the buffer it returns and switch the important users over to this. No caller may change the returned data. (For now, callers are responsible for freeing it after use, but later the device layer will take full ownership.) dev_read_buf() should only be used for tiny buffers or unimportant code (such as the old disk formats).
Diffstat (limited to 'lib/device/dev-swap.c')
-rw-r--r--lib/device/dev-swap.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/device/dev-swap.c b/lib/device/dev-swap.c
index a7ff10bb1..094eb05e4 100644
--- a/lib/device/dev-swap.c
+++ b/lib/device/dev-swap.c
@@ -60,8 +60,7 @@ int dev_is_swap(struct device *dev, uint64_t *offset_found)
continue;
if (size < (page >> SECTOR_SHIFT))
break;
- if (!dev_read(dev, page - SIGNATURE_SIZE,
- SIGNATURE_SIZE, DEV_IO_SIGNATURES, buf)) {
+ if (!dev_read_buf(dev, page - SIGNATURE_SIZE, SIGNATURE_SIZE, DEV_IO_SIGNATURES, buf)) {
ret = -1;
break;
}