During builds GCC 13.2 issues the following warning:
src/gallium/frontends/clover/api/memory.cpp:612:21: warning: ignoring return value of ‘int posix_memalign(void**, size_t, size_t)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
612 | posix_memalign(&ptr, alignment, size);
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
Fix this by checking the returned value is actually 0 and if not we now
report a nullptr.
Signed-off-by: Kai Wasserbäch <kai@dev.carbon-project.org>
Reviewed-by: Karol Herbst <kherbst@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25724>
void *ptr = nullptr;
if (alignment < sizeof(void*))
alignment = sizeof(void*);
- posix_memalign(&ptr, alignment, size);
+ int ret = posix_memalign(&ptr, alignment, size);
+ if (ret)
+ return nullptr;
if (ptr)
ctx.add_svm_allocation(ptr, size);