From 39d124b92c058eeb041a404839c3a017b138a0fe Mon Sep 17 00:00:00 2001 From: Chris Morin Date: Thu, 21 Jun 2018 18:42:22 -0700 Subject: [PATCH] init: Don't set ro.serialno when androidboot.serialno is not set This functionality is useful for improving boottimes on the ARC++ project. Without this change, ro.serialno would be set to the empty string when androidboot.serialno was unset in the kernel commandline. Bug: 62039211 Test: boot with androidboot.serialno unset and ensure ro.serialno is unset Change-Id: Iaee339dfa3f0c871e5e9c1fc0534347f2b3e8a07 --- init/init.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/init/init.cpp b/init/init.cpp index b494bcc09..77c4fc49e 100644 --- a/init/init.cpp +++ b/init/init.cpp @@ -352,21 +352,23 @@ static void export_oem_lock_status() { } static void export_kernel_boot_props() { + constexpr const char* UNSET = ""; struct { const char *src_prop; const char *dst_prop; const char *default_value; } prop_map[] = { - { "ro.boot.serialno", "ro.serialno", "", }, + { "ro.boot.serialno", "ro.serialno", UNSET, }, { "ro.boot.mode", "ro.bootmode", "unknown", }, { "ro.boot.baseband", "ro.baseband", "unknown", }, { "ro.boot.bootloader", "ro.bootloader", "unknown", }, { "ro.boot.hardware", "ro.hardware", "unknown", }, { "ro.boot.revision", "ro.revision", "0", }, }; - for (size_t i = 0; i < arraysize(prop_map); i++) { - std::string value = GetProperty(prop_map[i].src_prop, ""); - property_set(prop_map[i].dst_prop, (!value.empty()) ? value : prop_map[i].default_value); + for (const auto& prop : prop_map) { + std::string value = GetProperty(prop.src_prop, prop.default_value); + if (value != UNSET) + property_set(prop.dst_prop, value); } }