Skip to content

Prevent printing metadata block twice #271

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
Aug 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3697,15 +3697,15 @@ void info_guts(memory_access &raw_access, void *con) {
bin = raw_access.read_vector<uint8_t>(raw_access.get_binary_start(), read_size, true);
std::unique_ptr<block> first_block = find_first_block(bin, raw_access.get_binary_start());
if (first_block) {
// verify stuff
auto all_blocks = get_all_blocks(bin, raw_access.get_binary_start(), first_block, more_cb);

int block_i = 0;
select_group(metadata_info[block_i++], true);
info_metadata(first_block.get(), true);
for (auto &block : all_blocks) {
select_group(metadata_info[block_i++], true);
info_metadata(block.get(), true);
if (first_block->next_block_rel != 0) { // if there is more than one block
auto all_blocks = get_all_blocks(bin, raw_access.get_binary_start(), first_block, more_cb);
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmmm, does this change imply that if there are two or more blocks, then get_all_blocks doesn't return the first block; but if there's only one block, then get_all_blocks does return the first block??
Or am I just mis-reading the diff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, get_all_blocks returns all other blocks when there are multiple blocks, but it returns the first block again if there is only one block

Copy link
Contributor

Choose a reason for hiding this comment

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

This might be a stupid question (I'm good a those 😆 ), but I wonder if that suggests that get_all_blocks should instead return zero blocks if there is only one block? Seems like it might be more consistent behaviour? 🤷‍♂️

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's probably for another PR, as I'd need to fix some places it's used so that behaviour works

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough; not being familiar with the code, I didn't realise that you were relying on the existing behaviour in other places.

for (auto &block : all_blocks) {
select_group(metadata_info[block_i++], true);
info_metadata(block.get(), true);
}
}
} else {
// This displays that there are no metadata blocks
Expand Down
Loading