diff options
| author | 2016-11-11 12:00:01 -0500 | |
|---|---|---|
| committer | 2016-11-11 12:00:01 -0500 | |
| commit | 696b24e24fe9f39d98c975d6f2f08bccdb8e1c58 (patch) | |
| tree | ceaec3d3a55bcde3f7743fc83b424ec0d5194e59 /src/tools/imgtool/imgtool.cpp | |
| parent | a9d260cf145b5f0912d6b489a8b1605d45b59d63 (diff) | |
[Imgtool] Fixed a recently introduced bug which caused image types that do not support partitions to function incorrectly
Diffstat (limited to 'src/tools/imgtool/imgtool.cpp')
| -rw-r--r-- | src/tools/imgtool/imgtool.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/src/tools/imgtool/imgtool.cpp b/src/tools/imgtool/imgtool.cpp index 57a702dd17b..12adfe533d3 100644 --- a/src/tools/imgtool/imgtool.cpp +++ b/src/tools/imgtool/imgtool.cpp @@ -518,7 +518,7 @@ imgtoolerr_t imgtool::image::list_partitions(std::vector<imgtool::partition_info else { // default implementation - partitions.emplace_back(unknown_partition_get_info, 0, ~0); + partitions.emplace_back(module().imgclass, 0, ~0); } return IMGTOOLERR_SUCCESS; } @@ -560,9 +560,8 @@ uint64_t imgtool::image::rand() // imgtool::partition ctor //------------------------------------------------- -imgtool::partition::partition(imgtool::image &image, imgtool_class &imgclass, int partition_index, uint64_t base_block, uint64_t block_count) +imgtool::partition::partition(imgtool::image &image, const imgtool_class &imgclass, int partition_index, uint64_t base_block, uint64_t block_count) : m_image(image) - //, m_partition_index(partition_index) , m_base_block(base_block) , m_block_count(block_count) , m_imgclass(imgclass) @@ -635,9 +634,7 @@ imgtoolerr_t imgtool::partition::open(imgtool::image &image, int partition_index { imgtoolerr_t err = (imgtoolerr_t)IMGTOOLERR_SUCCESS; imgtool::partition::ptr p; - imgtool_class imgclass; std::vector<imgtool::partition_info> partitions; - uint64_t base_block, block_count; imgtoolerr_t (*open_partition)(imgtool::partition &partition, uint64_t first_block, uint64_t block_count); // list the partitions @@ -646,14 +643,13 @@ imgtoolerr_t imgtool::partition::open(imgtool::image &image, int partition_index return err; // is this an invalid index? - if ((partition_index < 0) || (partition_index >= partitions.size()) || !partitions[partition_index].get_info()) + if ((partition_index < 0) || (partition_index >= partitions.size()) || (!partitions[partition_index].imgclass().get_info && !partitions[partition_index].imgclass().derived_get_info)) return IMGTOOLERR_INVALIDPARTITION; // use this partition - memset(&imgclass, 0, sizeof(imgclass)); - imgclass.get_info = partitions[partition_index].get_info(); - base_block = partitions[partition_index].base_block(); - block_count = partitions[partition_index].block_count(); + const imgtool_class &imgclass(partitions[partition_index].imgclass()); + uint64_t base_block = partitions[partition_index].base_block(); + uint64_t block_count = partitions[partition_index].block_count(); // allocate the new partition object try { p = std::make_unique<imgtool::partition>(image, imgclass, partition_index, base_block, block_count); } |
