-
Notifications
You must be signed in to change notification settings - Fork 816
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
Assert on NULL IO functions #1052
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
d2ace49
to
516e186
Compare
516e186
to
7c480fc
Compare
Tests passed ✓, Code: 17128 B, Stack: 1440 B, Structs: 812 B
|
Hi @wangdongustc, thanks for creating a PR. I think this would be more useful in Are you able to also include asserts on read/prog/erase being non-null? These should all probably follow the same rules. But only if LFS_READONLY is not defined: LFS_ASSERT(lfs->cfg->read != NULL);
#ifndef LFS_READONLY
LFS_ASSERT(lfs->cfg->prog != NULL);
LFS_ASSERT(lfs->cfg->erase != NULL);
LFS_ASSERT(lfs->cfg->sync != NULL);
#endif This gets quite a bit more nuanced than it first appears... And clever solution for the prettyasserts.py issue, thanks for that. I had a fix for pointer comparisons on an unrelated branch (b5e264b), but I like your solution more. (We will probably want to end up with both eventually to allow pointer comparisons without a literal NULL) |
7c480fc
to
dae656a
Compare
@geky Thanks for the feedback!
Done! (Actually I did this earlier yesterday. But then I thought, why bother asserting the "read" function? Nobody would expect that lfs will work without a "read" function. So I changed back to only assert the "sync" function later. 🤣 |
Tests passed ✓, Code: 17128 B, Stack: 1440 B, Structs: 812 B
|
Now I'm wondering what it would take to support write-only memory 😬 Thanks for this! Merging! |
WOM. 😆 |
Apparently someone wrote a kernel driver for it: https://github.com/spacerace/write-only-memory |
Assert that the IO functions (especially the
sync
function when using non-caching storage) are provided by the user.