mynewt-core icon indicating copy to clipboard operation
mynewt-core copied to clipboard

sys/stats: Fix build with GCC 9.2.1

Open andrzej-kaczmarek opened this issue 6 years ago • 1 comments

This fixes following build error:

Compiling repos/apache-mynewt-core/sys/stats/full/src/stats.c Error: In function 'stats_init', inlined from 'stats_module_init_internal' at repos/apache-mynewt-core/sys/stats/full/src/stats.c:148:10: repos/apache-mynewt-core/sys/stats/full/src/stats.c:298:5: error: 'memset' offset [13, 16] from the object at 'g_stats_stats' is out of the bounds of referenced subobject 's_hdr' with type 'struct stats_hdr' at offset 0 [-Werror=array-bounds] 298 | memset((uint8_t *)shdr + offset, 0, size * cnt); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors

I do not really like that we have separate macros for retrieving const and non-const data pointer, but I do not see any easy way to workaround this except for removing consts explicitly which basically original private API did by casting to uint8_t*.

andrzej-kaczmarek avatar Dec 16 '19 14:12 andrzej-kaczmarek

Perhaps someone has some better idea how to fix this... :)

andrzej-kaczmarek avatar Dec 16 '19 14:12 andrzej-kaczmarek