adafruit / Adafruit_nRF52_Arduino

Adafruit code for the Nordic nRF52 BLE SoC on Arduino
Other
598 stars 488 forks source link

BLEDiscovery.cpp for loop with uninitialized i in 1.5.0 release #776

Closed WillsThingsNC closed 1 year ago

WillsThingsNC commented 1 year ago

Operating System

Windows 10

IDE version

2.1.0

Board

Feather nRF52840 Express

BSP version

1.5.0

Sketch

Any sketch using Bluefruit52 lib

What happened ?

It appears the recent commit, Add LOG_LV2 for BLE Characteristic UUIDs on Discovery, forgot to initialize i in the for loop at line 243. Not sure if this breaks anything functionally (I'm not familiar with what LOG_LV2() does), but it does spit out a compiler warning.

How to reproduce ?

Compile any sketch using the Bluefruit52 library (#include <bluefruit.h>) with compiler warnings set to "More" or "All"

Debug Log

\Arduino15\packages\adafruit\hardware\nrf52\1.5.0\libraries\Bluefruit52Lib\src\BLEDiscovery.cpp: In member function 'void BLEDiscovery::_eventHandler(ble_evt_t*)':
\Arduino15\packages\adafruit\hardware\nrf52\1.5.0\libraries\Bluefruit52Lib\src\BLEDiscovery.cpp:243:23: warning: 'i' may be used uninitialized in this function [-Wmaybe-uninitialized]
  243 |       for (uint8_t i; i < chr_rsp->count; i++) {
      |                       ^

Screenshots

No response