goblin
goblin copied to clipboard
Fix corrupted file_alignment
Fix for #331
@koutheir does this look ok to you?
Thank you for your efforts, @anfedotoff
Some notes:
- We won't be adding anyhow/thiserror/error library to goblin, probably ever. So if the assumption of these result returning changes is they'll be more usable in a follow up PR that uses more context via anyhow/whatever, want to be clear this is not a good assumption to make :) I want to keep the dependencies as thin as possible.
- i think the signature of
find_offset
returning Option was fine, and more flexible (allowing users to convert that into a more specific error if need be), for a utils library function (that maybe/probably shouldn't be exposed, but it is useful). I'm 50/50 on the result signature, because that forces our error type onto user (and technically a string allocation) that uses this function directly. I also don't have any data on if anyone is even using this function so also maybe doesn't matter that much. I'm not convinced though that semantically it's an error returning function (just like HashMap::get doesn't return an error, or variousfind
methods in stdlib generally don't return error).
So I'm wondering why couldn't all the places find_offset was used with the new Result signature not have used the function find_offset_or or left it with ok_or
semantics? This is probably annoying question since all the work was done to make it use the result form now, but just curious :) I'm just wondering if this is not the best breaking change, specifically:
- It is an avoidable break as far as I can see
- It doesn't really address some necessary change like a field going from T -> Option<T>
- It doesn't add much in the way of future proofing (this is also similar to 1., in that the user can just convert the option to error if they want)
Anyway, I think it's probably fine if this ends up being better maintainable code, but it is a breaking change, so it'll get merged in a little later (along with the other breaking change that's been pending).
On that note, may be a good time to think of any other breaking changes for PE stuff that would be good to get in (and it's fine if there are none!)
@anfedotoff i'd be ok with merging this but i think we have to roll back the breaking change to the find_offset
function; it seems unnecessary to me. If you want a result in the callsites, I'd suggest using find_offset_or
and restore the error messages. Then we can merge and it won't be breaking, otherwise I think this PR will just languish.
Thanks for your patience!
@anfedotoff i'd be ok with merging this but i think we have to roll back the breaking change to the
find_offset
function; it seems unnecessary to me. If you want a result in the callsites, I'd suggest usingfind_offset_or
and restore the error messages. Then we can merge and it won't be breaking, otherwise I think this PR will just languish.Thanks for your patience!
Sorry, for late reply. It's ok if you don't want breaking changes. If we don't want to use anyhow
crate, then, from my point of view, all changes have no sense in this pull request.
I think, better is to roll back to one line fix, before calling function with bad arguments. Or we could find some better place to insert this one if
. What do you think?
@anfedotoff Ok that works for me!
@anfedotoff Ok that works for me!
I've done something strange, playing with git history and doing rebase master. I'll better reopen new PR from fresh master. Fix will be very short, sorry)