@@ -52,7 +52,10 @@ int test_main(int ac, char **av)
kvm::vm vm(sys);
mem_map memmap(vm);
void* logged_slot_virt;
- posix_memalign(&logged_slot_virt, 4096, 4096);
+ int ret = posix_memalign(&logged_slot_virt, 4096, 4096);
+ if (ret) {
+ throw errno_exception(ret);
+ }
volatile int* shared_var = static_cast<volatile int*>(logged_slot_virt);
identity::hole hole(logged_slot_virt, 4096);
identity::vm ident_vm(vm, memmap, hole);
@@ -20,9 +20,9 @@ hole::hole(void* address, size_t size)
vm::vm(kvm::vm& vm, mem_map& mmap, hole h)
{
- posix_memalign(&tss, 4096, 4 * 4096);
- if (!tss) {
- throw errno_exception(errno);
+ int ret = posix_memalign(&tss, 4096, 4 * 4096);
+ if (ret) {
+ throw errno_exception(ret);
}
uint64_t hole_gpa = reinterpret_cast<uintptr_t>(h.address);
posix_memalign returns zero on success and an errno value otherwise. The value of the global variable "errno" is actually indeterminiate after a call to posix_memalign(), according to the man page. This patch also fixes the compilation errors: api/dirty-log.cc:55:50: error: ignoring return value of ‘int posix_memalign(void**, size_t, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result] posix_memalign(&logged_slot_virt, 4096, 4096); api/identity.cc:23:41: error: ignoring return value of ‘int posix_memalign(void**, size_t, size_t)’, declared with attribute warn_unused_result [-Werror=unused-result] posix_memalign(&tss, 4096, 4 * 4096); Signed-off-by: David Matlack <dmatlack@google.com> --- api/dirty-log.cc | 5 ++++- api/identity.cc | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-)