Skip to content

Unused variable and generally suspicious code in bloaty.cc #490

@localspook

Description

@localspook

Compiling raises a "variable set but not used" warning for filtered in bloaty.cc here:

bloaty/src/bloaty.cc

Lines 828 to 854 in 073e01d

uint64_t file_filtered = 0;
uint64_t vm_filtered = 0;
uint64_t filtered = 0;
if (ShowFile(options)) {
filtered += toplevel_row_.filtered_size.file;
}
if (ShowVM(options)) {
filtered += toplevel_row_.filtered_size.vm;
}
if (vm_filtered == 0 && file_filtered == 0) {
return;
}
*out << "Filtering enabled (source_filter); omitted";
if (file_filtered > 0 && vm_filtered > 0) {
*out << " file =" << SiPrint(file_filtered, /*force_sign=*/false)
<< ", vm =" << SiPrint(vm_filtered, /*force_sign=*/false);
} else if (file_filtered > 0) {
*out << SiPrint(file_filtered, /*force_sign=*/false);
} else {
*out << SiPrint(vm_filtered, /*force_sign=*/false);
}
*out << " of entries\n";
}

But also, file_filtered and vm_filtered are initialized to 0, and then never updated... so the condition on line 838 is always true, and everything below is dead code? I'm not sure if I'm missing something. I'm not familiar with bloaty internals, so I'm not sure what the right fix is, but just wanted to let you know about this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions