Properly detect CPU presence in ADCSensor
The ADCSensor daemon in dbus-sensors attempts to determine if an
inventory path is a CPU by just checking for 'cpu' anwhere in the
name.
But for all cpu paths should end with "cpuX" or "CPUx".
Tested:
For a non-CPU path: /xyz/openbmc_project/.../cpu0/xxx
With out this patch: it will mistake this for a CPU path.
With this patch: it will filter out this path.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I0702e306a532f12d8cf646a46eae988205e1d004
diff --git a/src/ADCSensorMain.cpp b/src/ADCSensorMain.cpp
index d62c9a6..3cbb5f6 100644
--- a/src/ADCSensorMain.cpp
+++ b/src/ADCSensorMain.cpp
@@ -346,7 +346,9 @@
std::string path = message.get_path();
boost::to_lower(path);
- if (path.rfind("cpu") == std::string::npos)
+ sdbusplus::message::object_path cpuPath(path);
+ std::string cpuName = cpuPath.filename();
+ if (!cpuName.starts_with("cpu"))
{
return; // not interested
}