Static layout: Do not crash on empty PNOR

When PNOR is empty, or corrupted and it fails to retrieve the version,
the service throws an exception.
This is not good because it should run on a corrupted or empty PNOR,
which then could be used to re-program the PNOR.

This commit fixes the issue, by not throwing on the above case.

Tested: Verify the service does not crash on a corrupted VERSION
        partition, and could be used to do code update to fix the
        corruption.

Change-Id: Ic6a413a81ad13894a9c7f039df71fff9b9d4b2ad
Signed-off-by: Lei YU <mine260309@gmail.com>
diff --git a/static/item_updater_static.cpp b/static/item_updater_static.cpp
index 140d5cc..e4708dd 100644
--- a/static/item_updater_static.cpp
+++ b/static/item_updater_static.cpp
@@ -218,6 +218,12 @@
     const auto& [version, extendedVersion] = Version::getVersions(fullVersion);
     auto id = Version::getId(version);
 
+    if (id.empty())
+    {
+        // Possibly a corrupted PNOR
+        return;
+    }
+
     auto activationState = server::Activation::Activations::Active;
     if (version.empty())
     {
@@ -347,7 +353,8 @@
             return erase(iter.second->versionId);
         }
     }
-    return false;
+    // No active PNOR means PNOR is empty or corrupted
+    return true;
 }
 
 void ItemUpdaterStatic::updateFunctionalAssociation(
diff --git a/version.cpp b/version.cpp
index d9ad395..c6e43fc 100644
--- a/version.cpp
+++ b/version.cpp
@@ -30,8 +30,7 @@
     if (version.empty())
     {
         log<level::ERR>("Error version is empty");
-        elog<InvalidArgument>(Argument::ARGUMENT_NAME("Version"),
-                              Argument::ARGUMENT_VALUE(version.c_str()));
+        return {};
     }
 
     unsigned char digest[SHA512_DIGEST_LENGTH];