(small fix) Use memcpy instead of copying bytes manually#549
(small fix) Use memcpy instead of copying bytes manually#549cadouthat wants to merge 1 commit intobluekitchen:masterfrom
Conversation
This is cleaner and more efficient, but more importantly it fixes this annoying GCC warning:
```
hfp_hf.c:1561:26: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=]
1561 | hfp_hf_codecs[i] = codecs[i];
| ~~~~~~~~~~~~~~~~~^~~~~~~~~~~
```
|
Thanks for the fix/workaround. I'd like to understand this better first. Which gcc gives you this warning? Also, looking hard at the code, I don't see the problem. There's an global array of HFP_MAX_NUM_CODECS. Do you have btstack_assert enabled? Could you try |
|
I'm using GCC 10.3.1 arm-none-eabi (Pico SDK). Agreed that there doesn't appear to be anything wrong with the code, my guess is that GCC somehow mis-interprets hfp_hf_codecs as a null-terminated string, and believes that we may not be leaving room for the terminator. btstack_assert does appear to be enabled, and still no luck with |
|
Well I'm afraid this is a bug but not on our side, checkout |
|
Thanks for the info! Unfortunately I think my version is the most recent via Homebrew, so I'd have to install manually But regardless of the GCC warning, I still think the proposed change is good in itself |
|
@cadouthat Interestingly, my manually installed arm-none-eabi toolchain is 10.3-2021.10, while brew provides an up-to-date 13.2.0. I guess I'll switch to the one provided by brew - which is even compile for ARM64 instead of emulating x64 on my M2. |
This is cleaner and more efficient, but more importantly it fixes this annoying GCC warning: