-
Notifications
You must be signed in to change notification settings - Fork 71
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
core-clp: Refactor LibarchiveFileReader
to properly handle empty data blocks (fixes #389).
#455
base: main
Are you sure you want to change the base?
Conversation
A high level comment: That said, I don't see a nit way of doing it unless we let One option I might consider is to keep the private method |
void LibarchiveFileReader::peek_buffered_data(char const*& buf, size_t& buf_size) const { | ||
auto LibarchiveFileReader::peek_buffered_data() const -> std::span<char const> { | ||
char const* buf{nullptr}; | ||
size_t buf_size{}; |
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.
why empty init instead of 0. does it mean we don't care about its value?
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.
buf_size
is set in the nested if-else below according to different cases. This is just a forward declaration- Empty init for
size_t
is 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.
Rewrote in a more clear way
The whole reason why we need this fix is because we don't have any high level code handling empty blocks. And I don't think the high level code should handle empty blocks in this case since the empty blocks should be hidden from the caller. This class is to provide abstraction to read data using libarchive, so the upper level caller shouldn't really care how data blocks are maintained (like there could be an empty data block) in different archives |
Perhaps I didn't make it clear, the caller here I was suggesting was the caller of That said, what I was really suggesting was to hide the "non_empty" details from the caller of |
LibarchiveFileReader
to properly handle empty data blocks (fixes #389).
Remind me, Zhihao, did we reach a conclusion on this? Also, can you resolve the conflicts? |
No, we didn't reach a conclusion. |
Description
The current
LibarchiveFileReader
implementation has the following problems:This PR makes the following changes accordingly:
std::span
for peeking buffer contentValidation performed