From 48caf2303d4b953d74b3caba0f8fc4ad94c9cdd8 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 18 Dec 2024 08:53:29 +0100 Subject: [PATCH 1/2] Fix build warning about discarding volatile qualifier in memory.c The warning was: ``` [4339/5327] Building C object driver/others/CMakeFiles/driver_others.dir/memory.c.o /home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c: In function 'blas_shutdown': /home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c:3257:10: warning: passing argument 1 of 'free' discards 'volatile' qualifier from pointer target type [-Wdiscarded-qualifiers] 3257 | free(newmemory); | ^~~~~~~~~ In file included from /home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/common.h:83, from /home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c:74: /home/rgommers/code/pixi-dev-scipystack/openblas/.pixi/envs/default/x86_64-conda-linux-gnu/sysroot/usr/include/stdlib.h:482:25: note: expected 'void *' but argument is of type 'volatile struct newmemstruct *' 482 | extern void free (void *__ptr) __THROW; | ~~~~~~^~~~~ ``` The use of `volatile` for `newmemstruct` seems on purpose, and there are more such constructs in this file. The warning appeared after gh-4451 and is correct. The `free` prototype doesn't expect a volatile pointer, hence this change adds a cast to silence the warning. --- driver/others/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index 6343a3785e..276e39ece0 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -3254,7 +3254,7 @@ void blas_shutdown(void){ #endif newmemory[pos].lock = 0; } - free(newmemory); + free((void*)newmemory); newmemory = NULL; memory_overflowed = 0; } From 765ad8bcd2bee89d8393a2200a6777989a8d4db0 Mon Sep 17 00:00:00 2001 From: Ralf Gommers Date: Wed, 18 Dec 2024 09:39:07 +0100 Subject: [PATCH 2/2] Fix guard around `alloc_hugetlb`, fixes compile warning The warning was: ``` /home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c: At top level: /home/rgommers/code/pixi-dev-scipystack/openblas/OpenBLAS/driver/others/memory.c:2565:14: warning: 'alloc_hugetlb' defined but not used [-Wunused-function] 2565 | static void *alloc_hugetlb(void *address){ | ^~~~~~~~~~~~~ ``` The added define is the same as is already present in the TLS part of `memory.c`. This follows up on gh-4681. --- driver/others/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/others/memory.c b/driver/others/memory.c index 276e39ece0..c53e798bc1 100644 --- a/driver/others/memory.c +++ b/driver/others/memory.c @@ -2538,7 +2538,7 @@ static void *alloc_shm(void *address){ } #endif -#if defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS +#if ((defined ALLOC_HUGETLB) && (defined OS_LINUX || defined OS_AIX || defined __sun__ || defined OS_WINDOWS)) static void alloc_hugetlb_free(struct release_t *release){