-
Notifications
You must be signed in to change notification settings - Fork 3k
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 is_valid_erase function to use get_erase_size with address #7953
Conversation
addr % get_erase_size() == 0 && | ||
size % get_erase_size() == 0 && | ||
addr % get_erase_size(addr) == 0 && | ||
size % get_erase_size(addr) == 0 && |
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.
You check that 'size' is aligned with current 'addr' but a large 'size' might take you to a 'dest' address in a different sector with a different 'erase-size' than 'addr'.
Basically I think you need to verify that:
( (addr+size) % get_erase_size(addr+size-1) == 0 )
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.
You are right about my code, but your solution is also problematic, as it only checks one sector. The right solution would be to iterate on the remaining sectors. Will fix that.
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.
You are right about the problem in my code, but your solution probably won't work either (as both only cover one sector). Right solution is probably an iteration over the remaining of the sectors. I'll fix it.
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.
@davidsaada - My thinking is that if the 'start' delete address is aligned to its sector, and the 'end' delete address is aligned to its own sector - then every sector in between them will be fully erased - so there's no need to iterate. What do you think?
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.
You're right - better than iteration. Will fix.
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.
Fixed. Please review.
49f14a4
to
e1c0b85
Compare
e1c0b85
to
ff7858a
Compare
/morph build |
Build : SUCCESSBuild number : 3166 Triggering tests/morph test |
Exporter Build : SUCCESSBuild number : 2767 |
Test : SUCCESSBuild number : 2974 |
Description
The base BlockDevice class includes the
is_valid_erase
function checking whether the address and size given to theerase
API are valid. This function used to call theget_erase_size
function without the address argument, but this was a bug, as it would have failed valid calls toerase
. It now callsget_erase_size
with the address argument.Just to clarify - this will work also for classes that don't implement
get_erase_size
with the address parameter, as it defaults to the one that doesn't have the address in the base class.Pull request type