Cast RestartCount to Size_t to Match Property Type
restartCount variable is a size_t and the property is registered as
a size_t. However since the DBusVariant returned from systemd to
find a process's restart count was uint32_t, it is crashing on some
machines.
With this cast to size_t, the crash does not happen anymore.
Tested:
Ran and left metric-collector on. It seems to collect restartCount
without the std::bad_any_cast crash.
Change-Id: Icfe180c9c9ed7b53c543215a5d895ff4f879219c
Signed-off-by: Edward Lee <edwarddl@google.com>
diff --git a/recipes-google/metric-collector/metric-collector/0002-Metric-Collection-Daemon.patch b/recipes-google/metric-collector/metric-collector/0002-Metric-Collection-Daemon.patch
index 6a46359..d4e871f 100644
--- a/recipes-google/metric-collector/metric-collector/0002-Metric-Collection-Daemon.patch
+++ b/recipes-google/metric-collector/metric-collector/0002-Metric-Collection-Daemon.patch
@@ -301,7 +301,7 @@
+ return;
+ }
+ metrics->set_property("RestartCount",
-+ std::get<uint32_t>(nRestarts));
++ static_cast<size_t>(std::get<uint32_t>(nRestarts)));
+ },
+ "org.freedesktop.systemd1", daemonObjectPath.c_str(),
+ "org.freedesktop.DBus.Properties", "Get",