cesanta / mongoose-os

Mongoose OS - an IoT Firmware Development Framework. Supported microcontrollers: ESP32, ESP8266, CC3220, CC3200, STM32F4, STM32L4, STM32F7. Amazon AWS IoT, Microsoft Azure, Google IoT Core integrated. Code in C or JavaScript.
https://mongoose-os.com
Other
2.51k stars 429 forks source link

Cppcheck warnings #563

Open Harvie opened 3 years ago

Harvie commented 3 years ago

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) {
^
rojer commented 3 years ago

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