]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUILD: memory: fix free_list pointer declaration again for atomic CAS
authorWilly Tarreau <w@1wt.eu>
Sat, 20 Oct 2018 15:37:38 +0000 (17:37 +0200)
committerWilly Tarreau <w@1wt.eu>
Sat, 20 Oct 2018 15:37:38 +0000 (17:37 +0200)
Commit ac6c880 ("BUILD: memory: fix pointer declaration for atomic CAS")
attemtped to fix a build warning affecting the lock-free version of the
pool allocator. But the fix tried to hide the cause instead of addressing
it, thus clang still complains about (void **) not matching (void ***).

The real solution is to declare free_list (void **) and not to use a cast.
Now this builds fine with gcc/clang with and without threads.

No backport is needed.

include/common/memory.h

index da96b829267cdfff037ff8fbbeff0bad60bdf8a5..5fde4bcddc7eee6236df03abe3867e8f33101ee0 100644 (file)
@@ -267,12 +267,12 @@ static inline void *pool_alloc(struct pool_head *pool)
  */
 static inline void __pool_free(struct pool_head *pool, void *ptr)
 {
-       void *free_list = pool->free_list;
+       void **free_list = pool->free_list;
 
        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, &free_list, ptr));
        HA_ATOMIC_SUB(&pool->used, 1);
 }