]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: memory: fix pointer declaration for atomic CAS
authorWilly Tarreau <w@1wt.eu>
Thu, 18 Oct 2018 14:12:28 +0000 (16:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 18 Oct 2018 14:12:28 +0000 (16:12 +0200)
The calls to HA_ATOMIC_CAS() on the lockfree version of the pool allocator
were mistakenly done on (void*) for the old value instead of (void **).
While this has no impact on "recent" gcc, it does have one for gcc < 4.7
since the CAS was open coded and it's not possible to assign a temporary
variable of type "void".

No backport is needed, this only affects 1.9.

include/common/memory.h
src/memory.c

index a0b6d620310c3d84306b37b58e3f9a72997c532d..da96b829267cdfff037ff8fbbeff0bad60bdf8a5 100644 (file)
@@ -272,7 +272,7 @@ static inline void __pool_free(struct pool_head *pool, void *ptr)
        do {
                *POOL_LINK(pool, ptr) = (void *)free_list;
                __ha_barrier_store();
-       } while (!HA_ATOMIC_CAS(&pool->free_list, (void *)&free_list, ptr));
+       } while (!HA_ATOMIC_CAS(&pool->free_list, (void **)&free_list, ptr));
        HA_ATOMIC_SUB(&pool->used, 1);
 }
 
index 51c623a85199a7a792ef7a6202e137190613a36b..d75dc7e6e0de3655c3f7ccc02bc7d37b36552ae3 100644 (file)
@@ -168,7 +168,7 @@ void *__pool_refill_alloc(struct pool_head *pool, unsigned int avail)
                do {
                        *POOL_LINK(pool, ptr) = free_list;
                        __ha_barrier_store();
-               } while (HA_ATOMIC_CAS(&pool->free_list, (void *)&free_list, ptr) == 0);
+               } while (HA_ATOMIC_CAS(&pool->free_list, (void **)&free_list, ptr) == 0);
        }
 
        HA_ATOMIC_ADD(&pool->allocated, allocated - allocated_orig);
@@ -199,7 +199,7 @@ void pool_flush(struct pool_head *pool)
                return;
        do {
                next = pool->free_list;
-       } while (!HA_ATOMIC_CAS(&pool->free_list, (void *)&next, NULL));
+       } while (!HA_ATOMIC_CAS(&pool->free_list, (void **)&next, NULL));
        while (next) {
                temp = next;
                next = *POOL_LINK(pool, temp);