zephyr icon indicating copy to clipboard operation
zephyr copied to clipboard

flash_stm32_qspi.c fails to compile with CONFIG_MISRA_SANE=y

Open benner opened this issue 1 year ago • 3 comments

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):

  • OS: Linux
  • Toolchain Zephyr SDK 0.16.3
  • Using older but tested currently newest commit 5da13ea30a6a1b1beef19466a4f2211f34b4d61c too.

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";
		};

benner avatar Nov 27 '23 08:11 benner

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. 🤖💙

github-actions[bot] avatar Nov 27 '23 08:11 github-actions[bot]

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]

FRASTM avatar Dec 08 '23 14:12 FRASTM

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] avatar Feb 18 '24 00:02 github-actions[bot]

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] avatar Apr 28 '24 00:04 github-actions[bot]