dalehumby / ESPHome-Apple-Watch-detection

ESPHome BLE Apple Watch presence detection
MIT License
332 stars 17 forks source link

Fix uninitialized memory compile warning #17

Open dalehumby opened 2 years ago

dalehumby commented 2 years ago

Fix the warning

Compiling .pioenvs/lounge/src/main.cpp.o
lounge.yaml: In static member function 'static void std::_Function_handler<void(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Functor = setup()::<lambda(const esphome::esp32_ble_tracker::ESPBTDevice&)>; _ArgTypes = {const esphome::esp32_ble_tracker::ESPBTDevice&}]':
lounge.yaml:69:40: warning: '*((void*)& best_rssi +2)' may be used uninitialized in this function [-Wmaybe-uninitialized]
lounge.yaml:49:25: note: '*((void*)& best_rssi +2)' was declared here

This doesn't appear to be a problem? But should still be fixed.

ZacTyAdams commented 1 year ago

This does appear to stop the build from completing as of 4.4.2023

/config/esphome/esp32-bluetooth-proxy-69cd88.yaml: In static member function 'static void std::_Function_handler<void(_ArgTypes ...), _Functor>::_M_invoke(const std::_Any_data&, _ArgTypes&& ...) [with _Functor = setup()::<lambda(const esphome::esp32_ble_tracker::ESPBTDevice&)>; _ArgTypes = {const esphome::esp32_ble_tracker::ESPBTDevice&}]':
/config/esphome/esp32-bluetooth-proxy-69cd88.yaml:51:40: error: '*((void*)& best_rssi +2)' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             id(apple_watch_rssi).publish_state(*best_rssi);
             ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
/config/esphome/esp32-bluetooth-proxy-69cd88.yaml:31:25: note: '*((void*)& best_rssi +2)' was declared here
           optional<int16_t> best_rssi = nullopt;
                         ^~~~~~~~~
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_ble_storage.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_config.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_dev.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_dm.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_main.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_profile_queue.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_sec.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_sm.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_storage.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/core/btc_util.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/profile/std/a2dp/bta_av_co.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_control.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_source.o
cc1plus: some warnings being treated as errors
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/profile/std/a2dp/btc_av.o
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/profile/std/avrc/btc_avrc.o
*** [/data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/src/main.o] Error 1
Compiling /data/esp32-bluetooth-proxy-69cd88/.pioenvs/esp32-bluetooth-proxy-69cd88/bt/host/bluedroid/btc/profile/std/avrc/bta_avrc_co.o
========================== [FAILED] Took 4.11 seconds ==========================