From 57d7366524ed02e7e3eab62af05cd38171efaea8 Mon Sep 17 00:00:00 2001 From: Sang-Hoon Park Date: Thu, 4 Mar 2021 11:06:48 +0000 Subject: Add log on memory allocation failure in CpuContext In CpuContext, a logging is added on memory allocation failure. Practically, it also fixes the unused result build error. Change-Id: I8a3fd4fd5839ce7ce072b75eec7e7e22fc9bc531 Signed-off-by: Sang-Hoon Park Reviewed-on: https://review.mlplatform.org/c/ml/ComputeLibrary/+/5216 Reviewed-by: Gian Marco Iodice Tested-by: Arm Jenkins Comments-Addressed: Arm Jenkins --- src/cpu/CpuContext.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/cpu/CpuContext.cpp b/src/cpu/CpuContext.cpp index 5980a5ab0d..5d71d9a6d8 100644 --- a/src/cpu/CpuContext.cpp +++ b/src/cpu/CpuContext.cpp @@ -53,7 +53,13 @@ void *default_aligned_allocate(void *user_data, size_t size, size_t alignment) size_t real_size = (rem) ? (size + alignment - rem) : size; ptr = aligned_alloc(alignment, real_size); #else /* defined(BARE_METAL) || defined(__APPLE__) */ - posix_memalign(&ptr, alignment, size); + if(posix_memalign(&ptr, alignment, size) != 0) + { + // posix_memalign returns non-zero on failures, the return values will be + // - EINVAL: wrong alignment + // - ENOMEM: insufficient memory + ARM_COMPUTE_LOG_ERROR_ACL("posix_memalign failed, the returned pointer will be invalid"); + } #endif /* defined(BARE_METAL) || defined(__APPLE__) */ return ptr; } -- cgit v1.2.1