mongoose-os icon indicating copy to clipboard operation
mongoose-os copied to clipboard

Cppcheck warnings

Open Harvie opened this issue 5 years ago • 1 comments

There is huge ammount of cppcheck warnings in this repo, i only hand-picked few of them, which seemed most relevant:

$ cppcheck --force deps/modules/mongoose-os >/dev/null

deps/modules/mongoose-os/platforms/stm32/src/stm32_entry.c:33:46: error: Subtracting pointers that point to different objects [comparePointers]
  memset(&_bss_start, 0, ((char *) &_bss_end - (char *) &_bss_start));
                                             ^
deps/modules/mongoose-os/platforms/stm32/src/stm32_entry.c:35:31: error: Subtracting pointers that point to different objects [comparePointers]
         ((char *) &_data_end - (char *) &_data_start));

deps/modules/mongoose-os/platforms/stm32/src/stm32_entry.c:36:48: error: Subtracting pointers that point to different objects [comparePointers]
  memset(&_heap_start, 0, ((char *) &_heap_end - (char *) &_heap_start));
                                               ^
deps/modules/mongoose-os/src/common/cs_file.c:44:9: error: Resource leak: fp [resourceLeak]
        return NULL;
        ^
deps/modules/mongoose-os/src/common/cs_frbuf.c:90:26: error: Memory leak: b [memleak]
      if (b->fp == NULL) return false;
                         ^
deps/modules/mongoose-os/src/mgos_core_dump.c:94:31: error: There is an unknown macro here somewhere. Configuration is required. If CS_STRINGIFY_MACRO is a macro then please configure it. [unknownMacro]
  mgos_cd_puts("\"arch\": \"" CS_STRINGIFY_MACRO(FW_ARCHITECTURE) "\", ");
                              ^
deps/modules/mongoose-os/src/mgos_sys_config.c:387:3: error: Common realloc mistake: 's_validators' nulled but not freed upon failure [memleakOnRealloc]
  s_validators = (mgos_config_validator_fn *) realloc(
  ^
deps/modules/mongoose-os/src/status_test.cpp:21:1: error: syntax error [syntaxError]
TEST(StatusTest, DefaultConstructedOK) {
^
deps/modules/mongoose-os/src/statusor_test.cpp:38:1: error: syntax error [syntaxError]
TEST(StatsOrTest, DefaulConstructedUnknown) {
^

Harvie avatar Dec 05 '20 22:12 Harvie

only some of these are useful. please send PRs for those that make sense.

rojer avatar Dec 05 '20 23:12 rojer