adafruit / Adafruit_Seesaw

Arduino library driver for seesaw multi-use chip
93 stars 64 forks source link

Fix warnings identified by -Wall -Wextra #41

Closed earlephilhower closed 3 years ago

earlephilhower commented 3 years ago

Minor narrowing conversions, and an immediately overridden #define.

The conversions are very straightforward, but the two #define NEOKEY_1X4_KEY right after each other I don't understand. This PR removes the first one (which is overridden anyway right now) and has the same behavior as master, but I have no hardware with which to actually test if, instead, the first definition should have been used (and second remoced instead).

Found while adding Adafruit_TinyUSB_Arduino to CI on the community Raspberry Pi Pico Arduino core CI.

earlephilhower commented 3 years ago

https://pipelines.actions.githubusercontent.com/x0U4nmbNYclEyqCnzEahaBmte1H9I0az43CdnC4SKQAiShopyK/_apis/pipelines/1/runs/38/signedlogcontent/16?urlExpires=2021-05-23T16%3A00%3A47.8818347Z&urlSigningMethod=HMACV1&urlSignature=oeDrh5T5D1ZmRNg8rWoQkR%2FIfAq2Tf7YsUk04f4F6jw%3D

In file included from /home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.cpp:1:
/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.h:24: error: "NEOKEY_1X4_KEY" redefined [-Werror]
   24 | #define NEOKEY_1X4_KEY(x) (((x) / 8) * 4 + ((x) % 8))
      | 
/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.h:23: note: this is the location of the previous definition
   23 | #define NEOKEY_1X4_KEY(x) (((x) / 4) * 8 + ((x) % 4))
      | 
/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.cpp: In member function 'uint8_t Adafruit_NeoKey_1x4::read()':
/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.cpp:91:54: error: narrowing conversion of 'b' from 'int' to 'uint16_t' {aka 'short unsigned int'} [-Werror=narrowing]
   91 |           keyEvent evt = {SEESAW_KEYPAD_EDGE_RISING, b};
      |                                                      ^
/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.cpp:98:55: error: narrowing conversion of 'b' from 'int' to 'uint16_t' {aka 'short unsigned int'} [-Werror=narrowing]
   98 |           keyEvent evt = {SEESAW_KEYPAD_EDGE_FALLING, b};
      |                                                       ^
/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.cpp: In member function 'void Adafruit_MultiNeoKey1x4::read()':
/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.cpp:320:58: error: narrowing conversion of 'event_key' from 'int' to 'uint16_t' {aka 'short unsigned int'} [-Werror=narrowing]
  320 |               keyEvent evt = {SEESAW_KEYPAD_EDGE_RISING, event_key};
      |                                                          ^~~~~~~~~
/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoKey_1x4.cpp:326:59: error: narrowing conversion of 'event_key' from 'int' to 'uint16_t' {aka 'short unsigned int'} [-Werror=narrowing]
  326 |               keyEvent evt = {SEESAW_KEYPAD_EDGE_FALLING, event_key};
      |                                                           ^~~~~~~~~
/home/runner/arduino_ide/hardware/pico/rp2040/system/arm-none-eabi/bin/arm-none-eabi-g++ -c -DUSE_TINYUSB -I/home/runner/arduino_ide/hardware/pico/rp2040/cores/rp2040/TinyUSB -I/home/runner/arduino_ide/hardware/pico/rp2040/libraries/Adafruit_TinyUSB_Arduino/src/arduino -DCFG_TUSB_MCU=OPT_MCU_RP2040 -DUSB_VID=0x2e8a -DUSB_PID=0x000a "-DUSB_MANUFACTURER=\"Raspberry Pi\"" "-DUSB_PRODUCT=\"Pico\"" -Os -march=armv6-m -mcpu=cortex-m0plus -mthumb -ffunction-sections -fdata-sections -fno-exceptions -iprefix/home/runner/arduino_ide/hardware/pico/rp2040/ @/home/runner/arduino_ide/hardware/pico/rp2040/lib/platform_inc.txt -fno-rtti -std=gnu++17 -g -DSERIALUSB_PID=0x000a -DF_CPU=133000000L -DARDUINO=10607 -DARDUINO_RASPBERRY_PI_PICO "-DBOARD_NAME=\"RASPBERRY_PI_PICO\"" -DARDUINO_ARCH_RP2040 -Wall -Wextra -Werror -Wno-ignored-qualifiers -I/home/runner/arduino_ide/hardware/pico/rp2040/cores/rp2040 -I/home/runner/arduino_ide/hardware/pico/rp2040/variants/rpipico -I/home/runner/arduino_ide/hardware/pico/rp2040/libraries/Adafruit_TinyUSB_Arduino/src -I/home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3 -I/home/runner/Arduino/libraries/Adafruit_BusIO-1.7.3 -I/home/runner/arduino_ide/hardware/pico/rp2040/libraries/Wire -I/home/runner/arduino_ide/hardware/pico/rp2040/libraries/SPI /home/runner/Arduino/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoTrellis.cpp -o /home/runner/work/arduino-pico/arduino-pico/build.tmp/libraries/Adafruit_Seesaw-1.4.3/Adafruit_NeoTrellis.cpp.o
cc1plus: all warnings being treated as errors
ladyada commented 3 years ago

@hathach this is a good first library to add the CI warnings to

earlephilhower commented 3 years ago

@hathach will you be doing a new minor release with this change? Thx!

ladyada commented 3 years ago

yep! we do weekly arduino library sweeps, do you need it sooner?

earlephilhower commented 3 years ago

No rush, thank you! I'll watch this repo and when a new ZIP comes out I'll re-add this to the Pico CI.