TheThingsNetwork / arduino-device-lib

Arduino Library for TTN Devices
MIT License
206 stars 96 forks source link

Fix build when using -Werror #272

Closed lrusak closed 1 year ago

lrusak commented 3 years ago

This fixes two issues when building with -Werror

lib\arduino-device-lib\src\TheThingsNetwork.cpp: In member function 'bool TheThingsNetwork::setSF(uint8_t)':
lib\arduino-device-lib\src\TheThingsNetwork.cpp:943:14: error: 'dr' may be used uninitialized in this function [-Werror=maybe-uninitialized]
  943 |   s[0] = '0' + dr;
      |          ~~~~^~~~
cc1plus.exe: all warnings being treated as errors
*** [.pio\build\genericSTM32F407VGT6\lib0bc\arduino-device-lib\TheThingsNetwork.cpp.o] Error 1
lib\arduino-device-lib\src\TheThingsNetwork.cpp: In function 'int pgmstrcmp(const char*, uint8_t)':
lib\arduino-device-lib\src\TheThingsNetwork.cpp:262:69: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
  262 |   strcpy_P(str2, (char *)(pgm_read_word(&(compare_table[str2Index]))));
      |                                                                     ^
C:\Users\lukas\.platformio\packages\framework-arduinoststm32\cores\arduino/avr/pgmspace.h:55:45: note: in definition of macro 'strcpy_P'
   55 | #define strcpy_P(dest, src) strcpy((dest), (src))
      |                                             ^~~
cc1plus.exe: all warnings being treated as errors
*** [.pio\build\genericSTM32F407VGT6\lib0bc\arduino-device-lib\TheThingsNetwork.cpp.o] Error 1
CLAassistant commented 3 years ago

CLA assistant check
All committers have signed the CLA.