zephyrproject-rtos / zephyr

Primary Git Repository for the Zephyr Project. Zephyr is a new generation, scalable, optimized, secure RTOS for multiple hardware architectures.
https://docs.zephyrproject.org
Apache License 2.0
10.62k stars 6.5k forks source link

flash_stm32_qspi.c fails to compile with CONFIG_MISRA_SANE=y #65795

Closed benner closed 4 months ago

benner commented 10 months ago

Application using QSPI and CONFIG_MISRA_SANE=y fails to compile

If I enable CONFIG_MISRA_SANE=y in prj.conf application fails to compile.

Target platform: STM32G4

To Reproduce On STM32, configure QSPI device (st,stm32-qspi), enable CONFIG_MISRA_SANE=y in prj.conf.

Expected behavior I'm able to compile the project

Impact Cannot enforce CONFIG_MISRA_SANE for whole project.

Logs and console output

/tmp/zephyrworkspace/zephyr/drivers/flash/flash_stm32_qspi.c: In function 'flash_stm32_qspi_init':
/tmp/zephyrworkspace/zephyr/drivers/flash/flash_stm32_qspi.c:1278:95: error: ISO C90 forbids array 'raw' whose size cannot be evaluated [-Werror=vla]
 1278 |                 uint8_t raw[JESD216_SFDP_SIZE(decl_nph)];
      |                                                                                               ^                   
cc1: some warnings being treated as errors

Environment (please complete the following information):

Additional context DT:

        quadspi1: quadspi@a0001000 {
            compatible = "st,stm32-qspi";
            #address-cells = <0x1>;
            #size-cells = <0x0>;
            reg = <0xa0001000 0x400>;

            interrupts = <95 0>;

            clocks = <&rcc STM32_CLOCK_BUS_AHB3 0x00000100>;
            status = "disabled";
        };
github-actions[bot] commented 10 months ago

Hi @benner! We appreciate you submitting your first issue for our open-source project. 🌟

Even though I'm a bot, I can assure you that the whole community is genuinely grateful for your time and effort. 🤖💙

FRASTM commented 10 months ago

Note that when CONFIG_MISRA_SANE=y build error occur when compiling samples/drivers/jesd216/

~/samples/drivers/jesd216/src/main.c: In function 'main':
~/zephyr/samples/drivers/jesd216/src/main.c:325:17: error: ISO C90 forbids variable length array 'dw' [-Werror=vla]
  325 |                 uint32_t dw[php->len_dw];
      |                 ^~~~~~~~
cc1: some warnings being treated as errors

Considering that php-> len_dw is held by uint8_t ; / Length of table in 32-bit DWORDs / then in case of CONFIG_MISRA_SANE=y, the dw should be declared as uint32_t dw[255]

github-actions[bot] commented 7 months ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.

github-actions[bot] commented 5 months ago

This issue has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this issue will automatically be closed in 14 days. Note, that you can always re-open a closed issue at any time.