]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/librbd/fsx: don't call posix_memalign() if size is 0
authorIlya Dryomov <idryomov@gmail.com>
Sat, 11 May 2024 08:00:47 +0000 (10:00 +0200)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 12 May 2024 12:03:59 +0000 (14:03 +0200)
While legal, it's specified as implementation-defined behavior and
newer valgrind throws InvalidSize error on it.

Fixes: https://tracker.ceph.com/issues/65813
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/test/librbd/fsx.cc

index 3cf971a23ac37532c47d74577b1c3e9197b75c7c..4ba00ad15558d2726bbd483b687feed86f358227 100644 (file)
@@ -2890,21 +2890,22 @@ check_clone(int clonenum, bool replay_image)
        }
 
        good_buf = NULL;
-       ret = posix_memalign((void **)&good_buf,
-                            std::max(writebdy, (int)sizeof(void *)),
-                            file_info.st_size);
-       if (ret > 0) {
-               prterrcode("check_clone: posix_memalign(good_buf)", -ret);
-               exit(96);
-       }
-
        temp_buf = NULL;
-       ret = posix_memalign((void **)&temp_buf,
-                            std::max(readbdy, (int)sizeof(void *)),
-                            file_info.st_size);
-       if (ret > 0) {
-               prterrcode("check_clone: posix_memalign(temp_buf)", -ret);
-               exit(97);
+       if (file_info.st_size > 0) {
+               ret = posix_memalign((void **)&good_buf,
+                                    std::max(writebdy, (int)sizeof(void *)),
+                                    file_info.st_size);
+               if (ret > 0) {
+                       prterrcode("check_clone: posix_memalign(good_buf)", -ret);
+                       exit(96);
+               }
+               ret = posix_memalign((void **)&temp_buf,
+                                    std::max(readbdy, (int)sizeof(void *)),
+                                    file_info.st_size);
+               if (ret > 0) {
+                       prterrcode("check_clone: posix_memalign(temp_buf)", -ret);
+                       exit(97);
+               }
        }
 
        if (pread(fd, good_buf, file_info.st_size, 0) < 0) {