Fix duplicate entries issue in GetPDR possibleStates.
Issue:
Change-Id: Ifadf3101a602274af5fa5443d2bf298b29e2ebcf
----
pldmtool platform GetPDR -d 18
{
"nextRecordHandle": 19,
"responseCount": 32,
"recordHandle": 18,
"PDRHeaderVersion": 1,
"PDRType": "State Effecter PDR",
"recordChangeNumber": 0,
"dataLength": 22,
"PLDMTerminusHandle": 1,
"effecterID": 1,
"entityType": "Virtual Machine Manager",
"entityInstanceNumber": 0,
"containerID": 0,
"effecterSemanticID": 0,
"effecterInit": "noInit",
"effecterDescriptionPDR": false,
"compositeEffecterCount": 1,
"stateSetID": "Boot Progress(196)",
"possibleStatesSize": 4,
"possibleStates": " 1 1 2 1 2 3 1 2 3 5 9 21 21 22 26"
}
After Fix:
---------
/pldmtool platform GetPDR -d 18
{
"nextRecordHandle": 19,
"responseCount": 32,
"recordHandle": 18,
"PDRHeaderVersion": 1,
"PDRType": "State Effecter PDR",
"recordChangeNumber": 0,
"dataLength": 22,
"PLDMTerminusHandle": 1,
"effecterID": 1,
"entityType": "Virtual Machine Manager",
"entityInstanceNumber": 0,
"containerID": 0,
"effecterSemanticID": 0,
"effecterInit": "noInit",
"effecterDescriptionPDR": false,
"compositeEffecterCount": 1,
"stateSetID": "Boot Progress(196)",
"possibleStatesSize": 4,
"possibleStates": " 1 2 3 5 9 21 22 26"
}
Issue:
----
pldmtool platform GetPDR -m 9 -d 7
{
"nextRecordHandle": 8,
"responseCount": 31,
"recordHandle": 7,
"PDRHeaderVersion": 1,
"PDRType": "State Sensor PDR",
"recordChangeNumber": 0,
"dataLength": 21,
"PLDMTerminusHandle": 1,
"sensorID": 9,
"entityType": "57347(OEM)",
"entityInstanceNumber": 0,
"containerID": 0,
"sensorInit": "noInit",
"sensorAuxiliaryNamesPDR": false,
"compositeSensorCount": 2,
"stateSetID": "Configuration State(15)",
"possibleStatesSize": "Configuration State(15)",
"possibleStates": " 1 1 2 1 2 3"
}
After Fix:
--------
./pldmtool platform GetPDR -m 9 -d 7
{
"nextRecordHandle": 8,
"responseCount": 31,
"recordHandle": 7,
"PDRHeaderVersion": 1,
"PDRType": "State Sensor PDR",
"recordChangeNumber": 0,
"dataLength": 21,
"PLDMTerminusHandle": 1,
"sensorID": 9,
"entityType": "57347(OEM)",
"entityInstanceNumber": 0,
"containerID": 0,
"sensorInit": "noInit",
"sensorAuxiliaryNamesPDR": false,
"compositeSensorCount": 2,
"stateSetID[1]": "Link State(33)",
"possibleStatesSize[1]": 1,
"possibleStates[1]": " 1 2",
"stateSetID[0]": "Configuration State(15)",
"possibleStatesSize[0]": 1,
"possibleStates[0]": " 1 2 3"
}
Change-Id: I3636c29bf382cf90007a76623f541bb7f95c10f2
Signed-off-by: Sridevi Ramesh <sridevra@in.ibm.com>
diff --git a/pldmtool/pldm_platform_cmd.cpp b/pldmtool/pldm_platform_cmd.cpp
index 9bd0ccb..da60d4d 100644
--- a/pldmtool/pldm_platform_cmd.cpp
+++ b/pldmtool/pldm_platform_cmd.cpp
@@ -210,6 +210,7 @@
{
pstates << " " << (possibleStatesPos * CHAR_BIT + i);
data.append(pstates.str());
+ pstates.str("");
}
}
possibleStatesPos++;
@@ -232,18 +233,23 @@
output["compositeSensorCount"] = unsigned(pdr->composite_sensor_count);
auto statesPtr = pdr->possible_states;
- auto compositeSensorCount = pdr->composite_sensor_count;
+ auto compCount = pdr->composite_sensor_count;
- while (compositeSensorCount--)
+ while (compCount--)
{
auto state = reinterpret_cast<const state_sensor_possible_states*>(
statesPtr);
- output["stateSetID"] = getStateSetName(state->state_set_id);
- output["possibleStatesSize"] = getStateSetName(state->state_set_id);
- output["possibleStates"] =
- printPossibleStates(state->possible_states_size, state->states);
+ output.emplace(("stateSetID[" + std::to_string(compCount) + "]"),
+ getStateSetName(state->state_set_id));
+ output.emplace(
+ ("possibleStatesSize[" + std::to_string(compCount) + "]"),
+ state->possible_states_size);
+ output.emplace(
+ ("possibleStates[" + std::to_string(compCount) + "]"),
+ printPossibleStates(state->possible_states_size,
+ state->states));
- if (compositeSensorCount)
+ if (compCount)
{
statesPtr += sizeof(state_sensor_possible_states) +
state->possible_states_size - 1;
@@ -451,20 +457,24 @@
unsigned(pdr->composite_effecter_count);
auto statesPtr = pdr->possible_states;
- auto compositeEffecterCount = pdr->composite_effecter_count;
+ auto compEffCount = pdr->composite_effecter_count;
- while (compositeEffecterCount--)
+ while (compEffCount--)
{
auto state =
reinterpret_cast<const state_effecter_possible_states*>(
statesPtr);
+ output.emplace(("stateSetID[" + std::to_string(compEffCount) + "]"),
+ getStateSetName(state->state_set_id));
+ output.emplace(
+ ("possibleStatesSize[" + std::to_string(compEffCount) + "]"),
+ state->possible_states_size);
+ output.emplace(
+ ("possibleStates[" + std::to_string(compEffCount) + "]"),
+ printPossibleStates(state->possible_states_size,
+ state->states));
- output["stateSetID"] = getStateSetName(state->state_set_id);
- output["possibleStatesSize"] = (state->possible_states_size);
- output["possibleStates"] =
- printPossibleStates(state->possible_states_size, state->states);
-
- if (compositeEffecterCount)
+ if (compEffCount)
{
statesPtr += sizeof(state_effecter_possible_states) +
state->possible_states_size - 1;