summaryrefslogtreecommitdiffstatshomepage
path: root/src/tools/imgtool/imgtool.cpp
diff options
context:
space:
mode:
author R. Belmont <rb6502@users.noreply.github.com>2016-11-11 16:00:55 -0500
committer GitHub <noreply@github.com>2016-11-11 16:00:55 -0500
commitc18affdad82ba68ceadae31963162be817e45de7 (patch)
tree594ee2644878869b2214ed5e05bab68786d09bf0 /src/tools/imgtool/imgtool.cpp
parentdbd07cef385248937dc509135088f81329216209 (diff)
parent696b24e24fe9f39d98c975d6f2f08bccdb8e1c58 (diff)
Merge pull request #1660 from npwoods/imgtool_fix_implicit_partition
[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.cpp16
1 files changed, 6 insertions, 10 deletions
diff --git a/src/tools/imgtool/imgtool.cpp b/src/tools/imgtool/imgtool.cpp
index 417c9304caa..8d749931bb4 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); }