Skip to content

Commit f9aadc2

Browse files
committed
Fix spurious warning/error in Wire
1 parent d9808a6 commit f9aadc2

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

megaavr/libraries/Wire/src/Wire.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -732,9 +732,11 @@ twi_buf_index_t TwoWire::requestFrom(uint8_t address, twi_buf_index_t quantity
732732
badArg("requestFrom requests more bytes then there is Buffer space");
733733
}
734734
}
735-
if (__builtin_constant_p(address) > 0x7F) { // Compile-time check if address is actually 7 bit long
736-
badArg("Supplied address seems to be 8 bit. Only 7-bit-addresses are supported");
737-
return;
735+
if (__builtin_constant_p(address)) {
736+
if(address > 0x7F) { // Compile-time check if address is actually 7 bit long
737+
badArg("Supplied address seems to be 8 bit. Only 7-bit-addresses are supported");
738+
return 0; /* This return 0 is never actually returned, but it still generates a warning, and sometimes fails!*/
739+
}
738740
}
739741
if (quantity >= TWI_BUFFER_LENGTH) {
740742
quantity = TWI_BUFFER_LENGTH;

0 commit comments

Comments
 (0)