fsstress: fix compiler warnings
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 7 Dec 2018 06:23:18 +0000 (22:23 -0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 9 Dec 2018 14:55:18 +0000 (22:55 +0800)
Fix all the gcc warnings in fsstress, and resize buffers to avoid
overflows.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-By: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
ltp/fsstress.c

index edbb3f2f8fb938227f0e9f9e477900c68406e781..8d0734fc0d1c02a42267082def689c6996b0df2d 100644 (file)
@@ -499,7 +499,7 @@ int main(int argc, char **argv)
                exit(1);
        }
        if (logname) {
-               char path[PATH_MAX];
+               char path[PATH_MAX + NAME_MAX + 1];
                snprintf(path, sizeof(path), "%s/%s", rpath, logname);
                if (freopen(path, "a", stdout) == NULL) {
                        perror("freopen logfile failed");
@@ -583,7 +583,7 @@ int main(int argc, char **argv)
                                return 0;
 #endif
                        if (logname) {
-                               char path[PATH_MAX];
+                               char path[PATH_MAX + NAME_MAX + 2 + 11];
                                snprintf(path, sizeof(path), "%s/%s.%d",
                                         rpath, logname, i);
                                if (freopen(path, "a", stdout) == NULL) {