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

Rudimentary validator for binary files #94

Merged
merged 4 commits into from
Apr 12, 2021
Merged

Rudimentary validator for binary files #94

merged 4 commits into from
Apr 12, 2021

Conversation

XapaJIaMnu
Copy link
Collaborator

Validate that the binary file you are trying to load is not truncated.

@XapaJIaMnu XapaJIaMnu requested a review from kpu April 8, 2021 19:35
// it basically loads up the header and checks

// This struct and the getter are copied from the marian source, because it's located
// inside src/common/binary.cpp:15 and we can't include it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/// to be picked up by doxygen, consistent with what exists in source.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want this to be picked up by doxygen? It's an internal function, not exposed by the headers and only really meant to be read by the developers.

Copy link
Member

@kpu kpu Apr 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not exposed by headers, it usually belongs in an anonymous namespace. Particularly for generic names like Header and get.

The standard for documentation is higher in this repo than it is elsewhere, sorry @XapaJIaMnu.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I genuinely do not understand how I should document this better. I'm went through the repo and looked at various files: (this one comes to mind) https://github.com/browsermt/bergamot-translator/blob/main/src/translator/request.h

Do I need to add the defines bit on top?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what @kpu means is to either leave it in an anonymous namespace if it's local and don't bother documenting, or fit it with doxygen compatible documentation.

This is the request which is documented. The target is a sphinx doc build, a demo of which looks like this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok that should be fixed now.


bool validateBinaryModel(AlignedMemory& model, uint64_t fileSize) {
const void * current = &model[0];
uint64_t memoryNeeded = sizeof(uint64_t)*2; // We keep track of how much memory we would need if we have a complete file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap lines with comments to 80 characters is standard? My config overwrites this autoformat and I always end up bearing the brunt.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dude, we're not 1998, we have 4k monitors. Just. No. All modern projects (including marian) have abandoned that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with longer lines.

}
}

} // Annonymous namespace
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

} // namespace

@abhi-agg abhi-agg self-requested a review April 12, 2021 09:57
Copy link
Contributor

@abhi-agg abhi-agg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approving this change (as Kenneth already approved + CI is passing + All the unresolved conversations seem to be resolved) so that we can merge it 👍

@abhi-agg abhi-agg merged commit b345b0e into main Apr 12, 2021
@abhi-agg abhi-agg mentioned this pull request Apr 12, 2021
@abhi-agg abhi-agg deleted the validate_binary branch April 26, 2021 16:40
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