Skip to content
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

Fix i2c bulk read #175

Merged
merged 2 commits into from
Jul 30, 2024
Merged

Fix i2c bulk read #175

merged 2 commits into from
Jul 30, 2024

Conversation

bessman
Copy link
Collaborator

@bessman bessman commented Jul 27, 2024

Summary by Sourcery

This pull request fixes an off-by-one error in the I2C bulk read function and adds a check to handle zero-byte read requests. Additionally, the firmware version patch number has been incremented.

  • Bug Fixes:
    • Fixed an off-by-one error in the I2C bulk read loop to correctly handle the number of bytes read.
  • Enhancements:
    • Added a check to return immediately if the count of bytes to read is zero in the I2C bulk read function.
  • Chores:
    • Updated the firmware version patch number from 1 to 2.

Copy link

sourcery-ai bot commented Jul 27, 2024

Reviewer's Guide by Sourcery

This pull request addresses a bug in the I2C bulk read function by adding a check for zero count and adjusting the loop to start from 1. Additionally, the firmware version patch number has been incremented to reflect this change.

File-Level Changes

Files Changes
src/bus/i2c/i2c.c Fixed the bulk read operation by adding a zero count check and adjusting the loop to correctly handle the read operation.
src/helpers/device.c Updated the firmware version to reflect the new patch.

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @bessman - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Critical issue: Loop starts from 1, potentially skipping the first byte of data. (link)

Overall Comments:

  • The loop in I2C_CommandReadBulk now starts from 1 instead of 0, which will cause it to read one less byte than intended. This needs to be corrected to avoid potential bugs.
  • Consider adding a changelog or documentation to explain what this patch fixes, especially since you're incrementing the firmware version.
Here's what I looked at during the review
  • 🔴 General issues: 1 blocking issue
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

src/bus/i2c/i2c.c Outdated Show resolved Hide resolved
@bessman bessman force-pushed the fix/i2c_bulk_read branch from 855a76b to d2038f9 Compare July 28, 2024 14:27
@bessman bessman force-pushed the fix/i2c_bulk_read branch from d2038f9 to de095a0 Compare July 30, 2024 09:28
@bessman bessman merged commit de095a0 into fossasia:main Jul 30, 2024
1 of 2 checks passed
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.

1 participant