pldm: improve PDR config JSON files
Add the PDR type to the JOSN files so that the PDR type in the code is
unassociated with the JSON file name.
Rename 11.json become state_effecter_pdr.json.
Signed-off-by: George Liu <liuxiwei@inspur.com>
Change-Id: I3194989ecd80ea0d8befa91971bd58ff851dd375
diff --git a/libpldmresponder/pdr.hpp b/libpldmresponder/pdr.hpp
index b32f878..9432f3e 100644
--- a/libpldmresponder/pdr.hpp
+++ b/libpldmresponder/pdr.hpp
@@ -276,7 +276,6 @@
}
}}};
- auto eraseLen = strlen(".json");
Type pdrType{};
for (const auto& dirEntry : fs::directory_iterator(dir))
{
@@ -285,9 +284,7 @@
auto json = readJson(dirEntry.path().string());
if (!json.empty())
{
- auto fileName = dirEntry.path().filename().string();
- fileName.erase(fileName.end() - eraseLen);
- pdrType = stoi(fileName);
+ pdrType = json.value("pdrType", 0);
generators.at(pdrType)(json, repo);
}
}