]> 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>
Mon, 20 May 2024 13:14:44 +0000 (15:14 +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>
(cherry picked from commit 148448033d03bc9b3e8f614ac0ec2a1aae674d26)

src/test/librbd/fsx.cc

index 62c314ad8a2812cac3607176e1efe336c341cf8b..a59db783cadfcc99ad755588d81fb517fecea186 100644 (file)
@@ -2657,21 +2657,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) {