From: Ilya Dryomov Date: Sat, 11 May 2024 08:00:47 +0000 (+0200) Subject: test/librbd/fsx: don't call posix_memalign() if size is 0 X-Git-Tag: v20.0.0~1907^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=148448033d03bc9b3e8f614ac0ec2a1aae674d26;p=ceph.git test/librbd/fsx: don't call posix_memalign() if size is 0 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 --- diff --git a/src/test/librbd/fsx.cc b/src/test/librbd/fsx.cc index 3cf971a23ac37..4ba00ad15558d 100644 --- a/src/test/librbd/fsx.cc +++ b/src/test/librbd/fsx.cc @@ -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) {