Skip to content

Commit 1484480

Browse files
committed
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 <[email protected]>
1 parent 47ad28f commit 1484480

File tree

1 file changed

+15
-14
lines changed

1 file changed

+15
-14
lines changed

src/test/librbd/fsx.cc

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2890,21 +2890,22 @@ check_clone(int clonenum, bool replay_image)
28902890
}
28912891

28922892
good_buf = NULL;
2893-
ret = posix_memalign((void **)&good_buf,
2894-
std::max(writebdy, (int)sizeof(void *)),
2895-
file_info.st_size);
2896-
if (ret > 0) {
2897-
prterrcode("check_clone: posix_memalign(good_buf)", -ret);
2898-
exit(96);
2899-
}
2900-
29012893
temp_buf = NULL;
2902-
ret = posix_memalign((void **)&temp_buf,
2903-
std::max(readbdy, (int)sizeof(void *)),
2904-
file_info.st_size);
2905-
if (ret > 0) {
2906-
prterrcode("check_clone: posix_memalign(temp_buf)", -ret);
2907-
exit(97);
2894+
if (file_info.st_size > 0) {
2895+
ret = posix_memalign((void **)&good_buf,
2896+
std::max(writebdy, (int)sizeof(void *)),
2897+
file_info.st_size);
2898+
if (ret > 0) {
2899+
prterrcode("check_clone: posix_memalign(good_buf)", -ret);
2900+
exit(96);
2901+
}
2902+
ret = posix_memalign((void **)&temp_buf,
2903+
std::max(readbdy, (int)sizeof(void *)),
2904+
file_info.st_size);
2905+
if (ret > 0) {
2906+
prterrcode("check_clone: posix_memalign(temp_buf)", -ret);
2907+
exit(97);
2908+
}
29082909
}
29092910

29102911
if (pread(fd, good_buf, file_info.st_size, 0) < 0) {

0 commit comments

Comments
 (0)