Adding const to task constructors

Adding const decorator to class constructor to ensure Flashing Plan
isn't modified during task construction

Bug: 194686221
Test: tested Flashall on raven
Change-Id: I99b71b2b756beaf871a31a1a035545d754d128e8
This commit is contained in:
Daniel Zheng 2023-04-10 09:53:08 -07:00
parent 1e6456b011
commit e6dbd4f194
2 changed files with 12 additions and 12 deletions

View file

@ -42,8 +42,8 @@ void FlashTask::Run() {
do_for_partitions(pname_, slot_, flash, true);
}
RebootTask::RebootTask(FlashingPlan* fp) : fp_(fp){};
RebootTask::RebootTask(FlashingPlan* fp, const std::string& reboot_target)
RebootTask::RebootTask(const FlashingPlan* fp) : fp_(fp){};
RebootTask::RebootTask(const FlashingPlan* fp, const std::string& reboot_target)
: reboot_target_(reboot_target), fp_(fp){};
void RebootTask::Run() {
@ -153,7 +153,7 @@ std::unique_ptr<FlashSuperLayoutTask> FlashSuperLayoutTask::Initialize(
partition_size);
}
UpdateSuperTask::UpdateSuperTask(FlashingPlan* fp) : fp_(fp) {}
UpdateSuperTask::UpdateSuperTask(const FlashingPlan* fp) : fp_(fp) {}
void UpdateSuperTask::Run() {
unique_fd fd = fp_->source->OpenFile("super_empty.img");
@ -177,7 +177,7 @@ void UpdateSuperTask::Run() {
fp_->fb->RawCommand(command, "Updating super partition");
}
ResizeTask::ResizeTask(FlashingPlan* fp, const std::string& pname, const std::string& size,
ResizeTask::ResizeTask(const FlashingPlan* fp, const std::string& pname, const std::string& size,
const std::string& slot)
: fp_(fp), pname_(pname), size_(size), slot_(slot) {}
@ -190,13 +190,13 @@ void ResizeTask::Run() {
do_for_partitions(pname_, slot_, resize_partition, false);
}
DeleteTask::DeleteTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){};
DeleteTask::DeleteTask(const FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){};
void DeleteTask::Run() {
fp_->fb->DeletePartition(pname_);
}
WipeTask::WipeTask(FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){};
WipeTask::WipeTask(const FlashingPlan* fp, const std::string& pname) : fp_(fp), pname_(pname){};
void WipeTask::Run() {
std::string partition_type;

View file

@ -46,8 +46,8 @@ class FlashTask : public Task {
class RebootTask : public Task {
public:
RebootTask(FlashingPlan* fp);
RebootTask(FlashingPlan* fp, const std::string& reboot_target);
RebootTask(const FlashingPlan* fp);
RebootTask(const FlashingPlan* fp, const std::string& reboot_target);
void Run() override;
private:
@ -73,7 +73,7 @@ class FlashSuperLayoutTask : public Task {
class UpdateSuperTask : public Task {
public:
UpdateSuperTask(FlashingPlan* fp);
UpdateSuperTask(const FlashingPlan* fp);
void Run() override;
private:
@ -82,7 +82,7 @@ class UpdateSuperTask : public Task {
class ResizeTask : public Task {
public:
ResizeTask(FlashingPlan* fp, const std::string& pname, const std::string& size,
ResizeTask(const FlashingPlan* fp, const std::string& pname, const std::string& size,
const std::string& slot);
void Run() override;
@ -95,7 +95,7 @@ class ResizeTask : public Task {
class DeleteTask : public Task {
public:
DeleteTask(FlashingPlan* _fp, const std::string& _pname);
DeleteTask(const FlashingPlan* _fp, const std::string& _pname);
void Run() override;
private:
@ -105,7 +105,7 @@ class DeleteTask : public Task {
class WipeTask : public Task {
public:
WipeTask(FlashingPlan* fp, const std::string& pname);
WipeTask(const FlashingPlan* fp, const std::string& pname);
void Run() override;
private: