apache / mynewt-mcumgr

Apache mynewt
https://mynewt.apache.org/
99 stars 76 forks source link

mynewt: Fix strncpy warning #105

Closed caspermeijn closed 3 years ago

caspermeijn commented 3 years ago

GCC complains about a strncpy call when build using build_profile speed. This warning indicates a possible string truncation. The only proper solution I could find was to decrease the buffer size and explicitly set a zero byte.

Error: repos/apache-mynewt-mcumgr/cmd/os_mgmt/port/mynewt/src/mynewt_os_mgmt.c: In function 'os_mgmt_impl_task_info': repos/apache-mynewt-mcumgr/cmd/os_mgmt/port/mynewt/src/mynewt_os_mgmt.c:92:5: error: 'strncpy' specified bound 32 equals destination size [-Werror=stringop-truncation] 92 | strncpy(out_info->oti_name, task->t_name, sizeof out_info->oti_name); | ^~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors