Skip to content

Fixes issue in SX1509::readWord(uint8_t, uint16_t *) #26

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025

Conversation

Willmac16
Copy link
Contributor

Existing implementation accessed memory it shouldn't, and didn't write both values to the target uint16_t.

Existing implementation accessed memory it shouldn't, and didn't write both values to the target uint16_t.
@Willmac16
Copy link
Contributor Author

For reference, when the original code is run, my compiler spits out:

.pio/libdeps/teensymm/SX1509 IO Expander/src/SparkFunSX1509.cpp: In member function 'bool SX1509::readPin(uint8_t, bool*)':
.pio/libdeps/teensymm/SX1509 IO Expander/src/SparkFunSX1509.cpp:789:26: warning: array subscript 1 is outside array bounds of 'uint16_t [1]' {aka 'short unsigned int [1]'} [-Warray-bounds]
  789 |                 value[1] = dest[0];
      |                 ~~~~~~~~~^~~~~~~~~
.pio/libdeps/teensymm/SX1509 IO Expander/src/SparkFunSX1509.cpp:212:18: note: while referencing 'tempRegDir'
  212 |         uint16_t tempRegDir;

@PaulZC
Copy link
Contributor

PaulZC commented Apr 28, 2025

Hi @Willmac16 ,

Thank you for this. Merging...

Best wishes,
Paul

@PaulZC PaulZC merged commit 523e4fe into sparkfun:master Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants