Fixing parse-dynparts bugs/issues discoverd by coverity.
Change-Id: I4966c170e3db34c238f0f37c5271038bf650237d
std::string table;
// Code structure taken from Android's system/core/fs_mgr/fs_mgr_dm_linear.cpp
- for (auto partition : metadata.partitions) {
+ for (const auto& partition : metadata.partitions) {
if (!partition.num_extents) {
messages << "Skipping zero-length logical partition: "
<< GetPartitionName(partition) << endl;
LpMetadataGeometry geometry;
if (!ReadLogicalPartitionGeometry(fd, &geometry)) {
+ close(fd);
return nullptr;
}
if (slot_number >= geometry.metadata_slot_count) {
LERROR << __PRETTY_FUNCTION__ << " invalid metadata slot number";
+ close(fd);
return nullptr;
}
}
}
if (!metadata || !AdjustMetadataForSlot(metadata.get(), slot_number)) {
+ close(fd);
return nullptr;
}
+
+ close(fd);
return metadata;
}
using std::endl;
int main(int argc, char* argv[]) {
- if (argc < 2 || argc > 4 || (argc == 3 && std::string_view(argv[2]).compare("--list-tables"))) {
+ if (argc < 2 || argc > 3 || (argc == 3 && std::string_view(argv[2]).compare("--list-tables"))) {
cerr << "Usage: dmsetup create --concise \"$(" << argv[0] << " device)\"" << endl
<< "Alternatively, you can use --list-tables option to get partitions tables line"
<< " by line which you can provide to dmsetup create."