8000 capsules: tickv: hashed keys big endian by bradjc · Pull Request #3474 · tock/tock · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

capsules: tickv: hashed keys big endian #3474

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

Merged
merged 1 commit into from
Jun 16, 2023
Merged

Conversation

bradjc
Copy link
Contributor
@bradjc bradjc commented Jun 7, 2023

Pull Request Overview

This pull request changes how we pass hashed keys to the tickv library. Since the library stores hashed keys as big endian:

*region_data
.get_mut(offset + HASH_OFFSET)
.ok_or(ErrorCode::RegionFull)? = (header.hashed_key >> 56) as u8;
*region_data
.get_mut(offset + HASH_OFFSET + 1)
.ok_or(ErrorCode::RegionFull)? = (header.hashed_key >> 48) as u8;
*region_data
.get_mut(offset + HASH_OFFSET + 2)
.ok_or(ErrorCode::RegionFull)? = (header.hashed_key >> 40) as u8;
*region_data
.get_mut(offset + HASH_OFFSET + 3)
.ok_or(ErrorCode::RegionFull)? = (header.hashed_key >> 32) as u8;
*region_data
.get_mut(offset + HASH_OFFSET + 4)
.ok_or(ErrorCode::RegionFull)? = (header.hashed_key >> 24) as u8;
*region_data
.get_mut(offset + HASH_OFFSET + 5)
.ok_or(ErrorCode::RegionFull)? = (header.hashed_key >> 16) as u8;
*region_data
.get_mut(offset + HASH_OFFSET + 6)
.ok_or(ErrorCode::RegionFull)? = (header.hashed_key >> 8) as u8;
*region_data
.get_mut(offset + HASH_OFFSET + 7)
.ok_or(ErrorCode::RegionFull)? = (header.hashed_key) as u8;

we should pass the keys in as big endian.

Testing Strategy

I found this when trying to write a tockloader library to parse tickv databases.

After this change the stored hash and my computed hash are in the same byte order.

TODO or Help Wanted

n/a

Documentation Updated

  • Updated the relevant files in /docs, or no updates are required.

Formatting

  • Ran make prepush.

The tickv library stores hashed keys as big endian, so we should pass
our hashed key to the library in big endian.
@alevy alevy added this pull request to the merge queue Jun 16, 2023
Merged via the queue into master with commit eca35a6 Jun 16, 2023
@bors bors bot deleted the tickv-hashed-key-endianess branch June 16, 2023 21:58
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.

4 participants
0