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.95k stars 6.66k forks source link

infineon hal whd_chip.c warning #80240

Open brandon-exact opened 1 month ago

brandon-exact commented 1 month ago

Describe the bug

When compiling modules/hal/infineon/wifi-host-driver/WiFi_Host_Driver/src/whd_chip.c with CONFIG_SPEED_OPTIMIZATIONS=y the compiler creates warnings:

modules/hal/infineon/wifi-host-driver/WiFi_Host_Driver/src/whd_chip.c: In function 'whd_ioctl_print':
modules/hal/infineon/wifi-host-driver/WiFi_Host_Driver/src/whd_chip.c:688:17: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
  688 |                 strncpy(iovar, (char *)data, strlen( (char *)data ) );
      |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
modules/hal/infineon/wifi-host-driver/WiFi_Host_Driver/src/whd_chip.c:687:17: note: length computed here
  687 |             if (strlen( (char *)data ) <= WHD_IOVAR_STRING_SIZE)
      |                 ^~~~~~~~~~~~~~~~~~~~~~
[248/301] Building C object modules/hal_infineon/CMakeFiles/modules_hal_infineon.dir/home/brandon/fork/modules/hal/infineon/wifi-host-driver/WiFi_Host_Driver/src/whd_wifi_api.c.obj
In function 'whd_iovar_mkbuf',
    inlined from 'whd_wifi_get_iovar_buffer_with_param' at /home/brandon/fork/modules/hal/infineon/wifi-host-driver/WiFi_Host_Driver/src/whd_wifi_api.c:3739:14:
modules/hal/infineon/wifi-host-driver/WiFi_Host_Driver/src/whd_wifi_api.c:3715:5: warning: 'strncpy' output truncated before terminating nul copying as many bytes from a string as its length [-Wstringop-truncation]
 3715 |     strncpy(iovar_buf, name, (iovar_len - 1) );
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
modules/hal/infineon/wifi-host-driver/WiFi_Host_Driver/src/whd_wifi_api.c:3702:17: note: length computed here
 3702 |     iovar_len = strlen(name) + 1;

To Reproduce

cd samples/net/wifi
west build -p -b cy8cproto_062_4343w -- -DCONFIG_SPEED_OPTIMIZATIONS=y

Environment (please complete the following information):

ifyall commented 1 month ago

@brandon-exact, thank you for the bug submission. I have filed a ticket with our internal team that owns the WHD.

Ian