Blob Blame History Raw
commit 5b7506198a6872764a51e32363e219916e1e592e
Author: Minwoo Im <minwoo.im@samsung.com>
Date:   Wed Apr 24 01:48:58 2019 +0100

    ioctl: Fix wrong return case of get_property
    
    If get_property_helper() succeeds in the first time, and then fails in
    the next time, then the ret value will not be updated to an error value.
    This patch removes 'ret' variable to make 'err' to return being updated
    everytime get_property_helper() invoked.
    
    Signed-off-by: Minwoo Im <minwoo.im@samsung.com>

diff --git a/nvme-ioctl.c b/nvme-ioctl.c
index 16fdc66..75bf9fa 100644
--- a/nvme-ioctl.c
+++ b/nvme-ioctl.c
@@ -612,7 +612,7 @@ int nvme_get_property(int fd, int offset, uint64_t *value)
 int nvme_get_properties(int fd, void **pbar)
 {
 	int offset, advance;
-	int err, ret = -EINVAL;
+	int err;
 	int size = getpagesize();
 
 	*pbar = malloc(size);
@@ -624,15 +624,13 @@ int nvme_get_properties(int fd, void **pbar)
 	memset(*pbar, 0xff, size);
 	for (offset = NVME_REG_CAP; offset <= NVME_REG_CMBSZ; offset += advance) {
 		err = get_property_helper(fd, offset, *pbar + offset, &advance);
-		if (!err)
-			ret = 0;
-		else {
+		if (err) {
 			free(*pbar);
 			break;
 		}
 	}
 
-	return ret;
+	return err;
 }
 
 int nvme_set_property(int fd, int offset, int value)