-
-
Notifications
You must be signed in to change notification settings - Fork 1.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
checksum: Further rework #6868
checksum: Further rework #6868
Conversation
GNU testsuite comparison:
|
fc60028
to
2035092
Compare
68cb1c1
to
17769e5
Compare
GNU testsuite comparison:
|
197409f
to
abd438f
Compare
@sylvestre @cakebaker ping for review ^^ |
/// from the expectation. | ||
pub failed_cksum: u32, | ||
pub failed_open_file: u32, | ||
/// number |
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 comment looks incomplete ;-)
)), | ||
} | ||
BASE64.decode(ck).map(hex::encode).ok() | ||
} else if ck.len() % 2 != 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.
A (pedantic) detail: I would use ==
for better readability and swap the if
and else
parts.
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.
There are two minor details, otherwise it looks good :)
abd438f
to
01bda53
Compare
- Rename the function to emphasize its goal - Do not pass the filename anymore, as it is only used to create an error, that may be done in the scope calling the function - Change the return type to Option, as the error is made in the outer scope - Don't try to decode the base64 string as UTF8 string. This most oftenly fails and is wrong. - Get rid of the `bytes_to_hex` function, as it provides the same functionality as `hex::encode`
- Add comments to explain what each field is counting
01bda53
to
cfc66f9
Compare
Thanks for noticing these |
Thanks! |
This PR further rework
checksum.rs
to get rid of entangled variable processing.It also partly fixes #6576, for the case where the digest has an odd length (it may still fail in case the length is even but still wrong)