espressif / esp-rainmaker

ESP RainMaker Agent for firmware development
Apache License 2.0
431 stars 145 forks source link

Use memcpy instead of strncpy to silence compiler warning (MEGH-5483) #313

Open thomasschaub opened 2 months ago

thomasschaub commented 2 months ago

The old version triggers a stringop-truncation compiler warning. According to the GCC manual, memcpy is the suggested fix in this exact scenario.

Curious: the warning seems to be only triggered in esp-idf's CONFIG_COMPILER_OPTIMIZATION_PERF mode (which corresponds to GCC's -O2 flag). It seems that GCC triggers the warning for -O2, but not for -O1 (demo).

CLAassistant commented 2 months ago

CLA assistant check
All committers have signed the CLA.

thomasschaub commented 2 months ago

I just saw that #297 is basically the same thing, so if that get's merged, I'd be happy to drop this one.