Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ARCH/X86: check the return value of posix_memalign() - v1.18.x #10463

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 24 additions & 6 deletions test/gtest/ucs/arch/test_x86_64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class test_arch : public ucs::test {
#ifndef __AVX__
UCS_TEST_SKIP_R("Built without AVX support");
#else
int i, j, result;
int i, j, result, ret = 0;
char *test_window_src, *test_window_dst, *src, *dst, *dup;
size_t len, total_size, test_window_size, hole_size, align;

Expand All @@ -82,9 +82,20 @@ class test_arch : public ucs::test {
*/
total_size = test_window_size + (2 * hole_size);

posix_memalign((void **)&test_window_src, align, total_size);
posix_memalign((void **)&test_window_dst, align, total_size);
posix_memalign((void **)&dup, align, total_size);
ret = posix_memalign((void**)&test_window_src, align, total_size);
if (ret) {
goto src_fail;
}

ret = posix_memalign((void**)&test_window_dst, align, total_size);
if (ret) {
goto dst_fail;
}

ret = posix_memalign((void**)&dup, align, total_size);
if (ret) {
goto dup_fail;
}

src = test_window_src + hole_size;
dst = test_window_dst + hole_size;
Expand Down Expand Up @@ -122,9 +133,16 @@ class test_arch : public ucs::test {
}
}

free(test_window_src);
free(test_window_dst);
free(dup);

dup_fail:
free(test_window_dst);
dst_fail:
free(test_window_src);
src_fail:
if (ret) {
UCS_TEST_ABORT("Failed to allocate memory: " << strerror(ret));
}
#endif
}
};
Expand Down
Loading