PLDM : fix the invalid effecter and sensor PDRs
The LED effecter and sensor PDRs where created even when
the FRU or the entity path was not present which puts the
entity ID in the PDR as 0. This commit fixes that issue.
Change-Id: I70f1838cfe613a4f11432105b793e465e8fa8adb
Signed-off-by: Pavithra Barithaya <pavithra.b@ibm.com>
diff --git a/libpldmresponder/pdr_numeric_effecter.hpp b/libpldmresponder/pdr_numeric_effecter.hpp
index 91f82ea..df5faf9 100644
--- a/libpldmresponder/pdr_numeric_effecter.hpp
+++ b/libpldmresponder/pdr_numeric_effecter.hpp
@@ -6,13 +6,10 @@
namespace pldm
{
-
namespace responder
{
-
namespace pdr_numeric_effecter
{
-
using Json = nlohmann::json;
static const Json empty{};
@@ -72,6 +69,15 @@
pdr->entity_type = e.value("type", 0);
pdr->entity_instance = e.value("instance", 0);
pdr->container_id = e.value("container", 0);
+
+ // do not create the PDR when the FRU or the entity path is not
+ // present
+ if (!pdr->entity_type)
+ {
+ std::cerr << "The entity path for the FRU is not present."
+ << std::endl;
+ continue;
+ }
}
}
catch (const std::exception& ex)
diff --git a/libpldmresponder/pdr_state_effecter.hpp b/libpldmresponder/pdr_state_effecter.hpp
index be7a5fc..37a8f06 100644
--- a/libpldmresponder/pdr_state_effecter.hpp
+++ b/libpldmresponder/pdr_state_effecter.hpp
@@ -8,13 +8,10 @@
namespace pldm
{
-
namespace responder
{
-
namespace pdr_state_effecter
{
-
using Json = nlohmann::json;
static const Json empty{};
@@ -91,6 +88,15 @@
pdr->entity_type = e.value("type", 0);
pdr->entity_instance = e.value("instance", 0);
pdr->container_id = e.value("container", 0);
+
+ // do not create the PDR when the FRU or the entity path is not
+ // present
+ if (!pdr->entity_type)
+ {
+ std::cerr << "The entity path for the FRU is not present."
+ << std::endl;
+ continue;
+ }
}
}
catch (const std::exception& ex)
diff --git a/libpldmresponder/pdr_state_sensor.hpp b/libpldmresponder/pdr_state_sensor.hpp
index 6e950bd..6effc53 100644
--- a/libpldmresponder/pdr_state_sensor.hpp
+++ b/libpldmresponder/pdr_state_sensor.hpp
@@ -6,13 +6,10 @@
namespace pldm
{
-
namespace responder
{
-
namespace pdr_state_sensor
{
-
using Json = nlohmann::json;
static const Json empty{};
@@ -93,6 +90,15 @@
pdr->entity_type = e.value("type", 0);
pdr->entity_instance = e.value("instance", 0);
pdr->container_id = e.value("container", 0);
+
+ // do not create the PDR when the FRU or the entity path is not
+ // present
+ if (!pdr->entity_type)
+ {
+ std::cerr << "The entity path for the FRU is not present."
+ << std::endl;
+ continue;
+ }
}
}
catch (const std::exception& ex)