-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
ports: change block dev read/write methods to return integer errno instead of bool #16223
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
base: master
Are you sure you want to change the base?
ports: change block dev read/write methods to return integer errno instead of bool #16223
Conversation
The readblocks/writeblocks functions, both native and Python versions, must return 0 on success and negative errno integer on error. These native typedefs help to document that. Signed-off-by: Damien George <damien@micropython.org>
These are only called by the vfs_blockdev implementation, so their return value doesn't need to be a FATFS specific type. Signed-off-by: Damien George <damien@micropython.org>
And make that 0 for success, negative errno integer for error. And as a consequence of this change the return value of the SDCard block device Python bindings so they return an integer instead of a bool. Signed-off-by: Damien George <damien@micropython.org>
Signed-off-by: Damien George <damien@micropython.org>
This is what `vfs_blockdev.c` now expects, 0 for success and a negative errno integer for failure. Signed-off-by: Damien George <damien@micropython.org>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #16223 +/- ##
=======================================
Coverage 98.57% 98.57%
=======================================
Files 164 164
Lines 21345 21345
=======================================
Hits 21041 21041
Misses 304 304 ☔ View full report in Codecov by Sentry. |
Code size report:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach looks good to me for the long term. Let me know if I can help test on ESP32.
Summary
This is an alternative to #16222, and a more comprehensive fix. It changes all Python-level block dev functions so they return an integer errno code instead of a bool.
Fixes issues #16171 and #16214.
Testing
Tested on PYBV11 using:
That would previously fail, but with this patch passes.
TODO: test on esp32.
Trade-offs and Alternatives
This changes the API (the return value) of the stm32 and esp32 SDCard
readblocks
andwriteblocks
methods. A non-API-changing fix is in #16222.I propose to merge #16222 to fix the issue for a patch release, then this PR to properly fix things (and eventually revert #16222).