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

Get_first_emtpy_address - ALDB entries that lack an address should be ignored #44

Merged
merged 1 commit into from
Jan 31, 2013

Conversation

krkeegan
Copy link
Collaborator

When a link is added by MH, the record is first put into the aldb hash without an address as a sort of placeholder. Get_first_empty_address is then called to find an empty location in which to put the record.

Get_first_empty_address then loops through the aldb hash looking for the lowest used address. In looping, it will come across the record that was just described, which lacks an address. The subroutine then hexes the address, or lack there of, which for the placeholder results in an address of 0. The subroutine then improperly interprets this, the 0 result, as the lowest address.

This results in bizarre situations. In the most benign situation, the subroutine reports that it cannot find an unused address which results in an error requesting a re-scan of the device (this was happening to me a lot). In the more dangerous situation, the subroutine may report a used address as being empty which results in that address being over written.

This patch prevents an address of 0 from being used as a low address, effectively ignoring the placeholder added above and preventing the issues described. This is a further patch to the empty_aldb patch that I previously submitted.

… ignored

When a link is added by MH, the record is first put into the aldb hash without an address as a sort of placeholder.  Get_first_empty_address is then called to find an empty location in which to put the record.

Get_first_empty_address then loops through the aldb hash looking for the lowest used address.  In looping, it will come across the record that was just described, which lacks an address.  The subroutine then hexes the address, or lack there of, which for the placeholder results in an address of 0.  The subroutine then improperly interprets this, the 0 result, as the lowest address.

This results in bizarre situations.  In the most benign situation, the subroutine reports that it cannot find an unused address which results in an error requesting a re-scan of the device (this was happening to me a lot).  In the more dangerous situation, the subroutine may report a used address as being empty which results in that address being over written.

This patch prevents an address of 0 from being used as a low address, effectively ignoring the placeholder added above and preventing the issues described.
@krkeegan
Copy link
Collaborator Author

This simple fix really should be merged in. Without it, sync_links does a whole bunch of odd stuff.

hollie added a commit that referenced this pull request Jan 31, 2013
Get_first_emtpy_address - ALDB entries that lack an address should be ignored
@hollie hollie merged commit 21b8d18 into hollie:master Jan 31, 2013
@mstovenour
Copy link
Collaborator

Kevin, there is an additional condition that is not handled by the existing code or your enhancement. If the hash contains an empty entry (because of another bug somewhere else) the code will still return zero. I had such a bug in the i2 code that I subsequently fixed but prior to that I rewrote get_first_empty_address(). The routine was just overly complex in my mind. Take a look at the changes that I made in the i2 version and see if you think those changes are good for the i1 version as well. Eventually I would like to merge as much i1 and i2 code as possible. This is a routine that we should be able to share.

@krkeegan
Copy link
Collaborator Author

krkeegan commented Feb 2, 2013

I may have caught it already. There was a one line merge done about 2
nights ago that fixed an issue. But I will check out the code you did, if
it works I agree with replacing the old version. I agree, there should be
no unnecessary duplication of code between i1 and i2.

On Fri, Feb 1, 2013 at 6:30 PM, Michael Stovenour
[email protected]:

Kevin, there is an additional condition that is not handled by the
existing code or your enhancement. If the hash contains an empty entry
(because of another bug somewhere else) the code will still return zero. I
had such a bug in the i2 code that I subsequently fixed but prior to that I
rewrote get_first_empty_address(). The routine was just overly complex in
my mind. Take a look at the changes that I made in the i2 version and see
if you think those changes are good for the i1 version as well. Eventually
I would like to merge as much i1 and i2 code as possible. This is a routine
that we should be able to share.


Reply to this email directly or view it on GitHubhttps://github.com//pull/44#issuecomment-13023342.

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.

3 participants