fsx: fix compile warnings
authorAmir Goldstein <amir73il@gmail.com>
Wed, 30 Aug 2017 14:51:37 +0000 (17:51 +0300)
committerEryu Guan <eguan@redhat.com>
Sun, 3 Sep 2017 04:19:26 +0000 (12:19 +0800)
[eguan: fix conflicts with patch "fsx: Fix -Wformat-security
warnings"]

Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
ltp/fsx.c

index cc0a89787960a2653c54dd99ea3cc141a3a1f5ab..ea00ff7407ba893204f8e7925b3f76860bf7c176 100644 (file)
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -569,14 +569,20 @@ check_trunc_hack(void)
 {
        struct stat statbuf;
 
-       ftruncate(fd, (off_t)0);
-       ftruncate(fd, (off_t)100000);
+       if (ftruncate(fd, (off_t)0))
+               goto ftruncate_err;
+       if (ftruncate(fd, (off_t)100000))
+               goto ftruncate_err;
        fstat(fd, &statbuf);
        if (statbuf.st_size != (off_t)100000) {
                prt("no extend on truncate! not posix!\n");
                exit(130);
        }
-       ftruncate(fd, 0);
+       if (ftruncate(fd, 0)) {
+ftruncate_err:
+               prterr("check_trunc_hack: ftruncate");
+               exit(131);
+       }
 }
 
 void
@@ -1742,7 +1748,10 @@ __test_fallocate(int mode, const char *mode_str)
                                        mode_str);
                } else {
                        ret = 1;
-                       ftruncate(fd, 0);
+                       if (ftruncate(fd, 0)) {
+                               warn("main: ftruncate");
+                               exit(132);
+                       }
                }
        }
        return ret;