set-verity-state: Simplify code path around overlayfs_setup()
Original code: Calls |overlayfs_setup()| if |any_changed| is false |any_changed| is true implies |set_avb_verity_enabled_state()| is true which implies |overlayfs_setup()| is called by it. All this means |overlayfs_setup()| is called exactly once regardless of the value of |any_changed|, so simplify the logic to the above observation. Bug: 241688845 Test: Presubmit Change-Id: Ifcbae8db7fdda2f7576769cb4a213c305c670709
This commit is contained in:
parent
0b179f2049
commit
4ef9fcce84
1 changed files with 3 additions and 7 deletions
|
@ -86,7 +86,6 @@ static bool set_avb_verity_enabled_state(AvbOps* ops, bool enable_verity) {
|
|||
return false;
|
||||
}
|
||||
|
||||
overlayfs_setup(enable_verity);
|
||||
printf("Successfully %s verity\n", enable_verity ? "enabled" : "disabled");
|
||||
return true;
|
||||
}
|
||||
|
@ -122,8 +121,6 @@ int main(int argc, char* argv[]) {
|
|||
|
||||
bool enable = enable_opt.value();
|
||||
|
||||
bool any_changed = false;
|
||||
|
||||
// Figure out if we're using VB1.0 or VB2.0 (aka AVB) - by
|
||||
// contract, androidboot.vbmeta.digest is set by the bootloader
|
||||
// when using AVB).
|
||||
|
@ -151,6 +148,7 @@ int main(int argc, char* argv[]) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool any_changed = false;
|
||||
if (using_avb) {
|
||||
// Yep, the system is using AVB.
|
||||
AvbOps* ops = avb_ops_user_new();
|
||||
|
@ -158,12 +156,10 @@ int main(int argc, char* argv[]) {
|
|||
printf("Error getting AVB ops\n");
|
||||
return 1;
|
||||
}
|
||||
if (set_avb_verity_enabled_state(ops, enable)) {
|
||||
any_changed = true;
|
||||
}
|
||||
any_changed |= set_avb_verity_enabled_state(ops, enable);
|
||||
avb_ops_user_free(ops);
|
||||
}
|
||||
if (!any_changed) any_changed = overlayfs_setup(enable);
|
||||
any_changed |= overlayfs_setup(enable);
|
||||
|
||||
if (any_changed) {
|
||||
printf("Now reboot your device for settings to take effect\n");
|
||||
|
|
Loading…
Reference in a new issue