Hi David,

On Fri, Jun 01, 2018 at 12:27:15PM +0000, David CARLIER wrote:
> Hi,
> 
> Here a little proposal to fix a compilation warning.
> 
> Hope it s useful.
> 
> Kind regards.

Oops, I should always test with multiple compilers, for some reason gcc
didn't warn about that, but clang certainly does.
Instead of using a static variable, I think merely adding a cast is better,
as attached. What do you think ?

Regards,

Olivier
>From 08bdd8e3b27afdd5101843f23edd337166c87159 Mon Sep 17 00:00:00 2001
From: Olivier Houchard <cog...@ci0.org>
Date: Fri, 1 Jun 2018 14:32:39 +0200
Subject: [PATCH] MINOR: task: Fix a compiler warning by adding a cast.

When calling HA_ATOMIC_CAS with a pointer as the target, the compiler
expects a pointer as the new value, so give it one by casting 0x1 to
(void *).
---
 include/proto/task.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/proto/task.h b/include/proto/task.h
index 760b368b5..0c2c5f28c 100644
--- a/include/proto/task.h
+++ b/include/proto/task.h
@@ -218,7 +218,7 @@ static inline void task_insert_into_tasklet_list(struct 
task *t)
         * another runqueue. We set leaf_p to 0x1 to indicate that the node is
         * not in a tree but that it's in the tasklet list. See task_in_rq().
         */
-       if (unlikely(!HA_ATOMIC_CAS(&t->rq.node.leaf_p, &expected, 0x1)))
+       if (unlikely(!HA_ATOMIC_CAS(&t->rq.node.leaf_p, &expected, (void 
*)0x1)))
                return;
        HA_ATOMIC_ADD(&tasks_run_queue, 1);
        task_list_size[tid]++;
-- 
2.16.3

Reply via email to