Page 1 of 1

Pointer cast to suppress warnings

Posted: Sat Dec 26, 2020 3:36 pm
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
 
 /*===========================================================================*/

Re: Pointer cast to suppress warnings

Posted: Sat Dec 26, 2020 7:29 pm
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

Re: Pointer cast to suppress warnings

Posted: Sat Dec 26, 2020 7:30 pm
by Giovanni
Moving to bug reports.

Giovanni

Re: Pointer cast to suppress warnings

Posted: Sat Dec 26, 2020 7:59 pm
by wild-boar
Thanks. I think I got confused on the second item.

Re: Pointer cast to suppress warnings

Posted: Sun Dec 27, 2020 11:09 am
by Giovanni
Fixed in repository, thanks.

Giovanni