Pointer cast to suppress warnings Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
Post Reply
wild-boar
Posts: 17
Joined: Thu May 08, 2014 11:58 pm
Been thanked: 9 times

Pointer cast to suppress warnings

Post by wild-boar »

Hi,

I recently upgraded a project from ChibiOS 18 to 20. I am getting an incompatible pointer type warning in my project. Here is a patch that fixes this warning. Thanks!

Code: Select all

diff --git a/os/rt/src/chsem.c b/os/rt/src/chsem.c
index c786830df..e0150fd58 100644
--- a/os/rt/src/chsem.c
+++ b/os/rt/src/chsem.c
@@ -76,9 +76,9 @@
 /*===========================================================================*/
 
 #if CH_CFG_USE_SEMAPHORES_PRIORITY == TRUE
-#define sem_insert(tp, qp) ch_sch_prio_insert(&tp->hdr.pqueue, qp)
+#define sem_insert(tp, qp) ch_sch_prio_insert((ch_queue_t *)&tp->hdr.pqueue, qp)
 #else
-#define sem_insert(tp, qp) ch_queue_insert(&tp->hdr.queue, qp)
+#define sem_insert(tp, qp) ch_queue_insert((ch_queue_t *)&tp->hdr.queue, qp)
 #endif
 
 /*===========================================================================*/
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Pointer cast to suppress warnings

Post by Giovanni »

Hi,

I see the problem with the first one, it should be:

Code: Select all

#define sem_insert(tp, qp) ch_sch_prio_insert(&tp->hdr.queue, qp)


But why the second?

Code: Select all

&tp->hdr.queue
should already be of type

Code: Select all

(ch_queue_t *)


Giovanni
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Pointer cast to suppress warnings

Post by Giovanni »

Moving to bug reports.

Giovanni
wild-boar
Posts: 17
Joined: Thu May 08, 2014 11:58 pm
Been thanked: 9 times

Re: Pointer cast to suppress warnings

Post by wild-boar »

Thanks. I think I got confused on the second item.
User avatar
Giovanni
Site Admin
Posts: 14891
Joined: Wed May 27, 2009 8:48 am
Has thanked: 1202 times
Been thanked: 996 times

Re: Pointer cast to suppress warnings

Post by Giovanni »

Fixed in repository, thanks.

Giovanni
Post Reply