Make it possible to check whether the return value of ioctl() is negative.

Signed-off-by: Bart Van Assche <bvanass...@acm.org>
---
 tools/f2fs_io/f2fs_io.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/f2fs_io/f2fs_io.c b/tools/f2fs_io/f2fs_io.c
index e807177a4174..6bb094cc7f25 100644
--- a/tools/f2fs_io/f2fs_io.c
+++ b/tools/f2fs_io/f2fs_io.c
@@ -513,7 +513,7 @@ static void do_erase(int argc, char **argv, const struct 
cmd_desc *cmd)
 
 static void do_write(int argc, char **argv, const struct cmd_desc *cmd)
 {
-       u64 buf_size = 0, inc_num = 0, ret = 0, written = 0;
+       u64 buf_size = 0, inc_num = 0, written = 0;
        u64 offset;
        char *buf = NULL;
        unsigned bs, count, i;
@@ -561,6 +561,8 @@ static void do_write(int argc, char **argv, const struct 
cmd_desc *cmd)
        fd = xopen(argv[6], O_CREAT | O_WRONLY | flags, 0755);
 
        if (atomic_commit || atomic_abort) {
+               int ret;
+
                if (argc == 8)
                        useconds = atoi(argv[7]) * 1000;
 
@@ -573,6 +575,8 @@ static void do_write(int argc, char **argv, const struct 
cmd_desc *cmd)
 
        total_time = get_current_us();
        for (i = 0; i < count; i++) {
+               uint64_t ret;
+
                if (!strcmp(argv[4], "inc_num"))
                        *(int *)buf = inc_num++;
                else if (!strcmp(argv[4], "rand"))
@@ -593,12 +597,16 @@ static void do_write(int argc, char **argv, const struct 
cmd_desc *cmd)
                usleep(useconds);
 
        if (atomic_commit) {
+               int ret;
+
                ret = ioctl(fd, F2FS_IOC_COMMIT_ATOMIC_WRITE);
                if (ret < 0) {
                        fputs("committing atomic write failed\n", stderr);
                        exit(1);
                }
        } else if (atomic_abort) {
+               int ret;
+
                ret = ioctl(fd, F2FS_IOC_ABORT_VOLATILE_WRITE);
                if (ret < 0) {
                        fputs("aborting atomic write failed\n", stderr);


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to