Macro expansion bug in HAL SPI driver Topic is solved

Report here problems in any of ChibiOS components. This forum is NOT for support.
greb
Posts: 10
Joined: Tue Apr 05, 2016 12:50 pm
Has thanked: 2 times
Been thanked: 3 times

Macro expansion bug in HAL SPI driver  Topic is solved

Postby greb » Thu Apr 12, 2018 4:18 pm

Hi,

I've found a macro expansion bug in the SPI driver while porting my application to ChibiOS 18.2.x. While using spiSelectI I got the following compiler error:

Code: Select all

/disk/greb/src/ChibiOS/os/hal/include/hal_spi.h:160:20: error: invalid type argument of '->' (have 'SPIDriver {aka struct SPIDriver}')
   palClearLine(spip->config->ssline);                                       \
                    ^
/disk/greb/src/ChibiOS/os/hal/ports/STM32/LLD/GPIOv2/hal_pal_lld.h:381:74: note: in definition of macro 'pal_lld_clearport'
 #define pal_lld_clearport(port, bits) ((port)->BSRR.H.clear = (uint16_t)(bits))
                                                                          ^
/disk/grep/src/ChibiOS/os/hal/include/hal_pal.h:626:32: note: in expansion of macro 'palClearPort'
 #define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad))
                                ^
/disk/grep/src/ChibiOS/os/hal/include/hal_pal.h:626:51: note: in expansion of macro 'PAL_PORT_BIT'
 #define palClearPad(port, pad) palClearPort(port, PAL_PORT_BIT(pad))
                                                   ^
/disk/grep/src/ChibiOS/os/hal/include/hal_pal.h:741:28: note: in expansion of macro 'palClearPad'
 #define palClearLine(line) palClearPad(PAL_PORT(line), PAL_PAD(line))
                            ^
/disk/grep/src/ChibiOS/os/hal/include/hal_pal.h:741:56: note: in expansion of macro 'PAL_PAD'
 #define palClearLine(line) palClearPad(PAL_PORT(line), PAL_PAD(line))
                                                        ^
/disk/greb/src/ChibiOS/os/hal/include/hal_spi.h:160:3: note: in expansion of macro 'palClearLine'
   palClearLine(spip->config->ssline);                                       \
   ^
cl.c:115:5: note: in expansion of macro 'spiSelectI'
     spiSelectI(&SPID1);



I recommend putting the macro parameter spip in parantheses to avoid expansion problems.

Best regards,
greb

User avatar
Giovanni
Site Admin
Posts: 14444
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 1074 times
Been thanked: 921 times
Contact:

Re: Macro expansion bug in HAL SPI driver

Postby Giovanni » Fri Apr 13, 2018 10:03 am

Hi,

Fixed as bug #937.

I fixed several instances, please let me know if you find more.

Giovanni


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 23 guests