Fix issue: Find composite sensors/effecters PDRs error

Fix the issue that when looking for composite sensors/effecters PDRs
return faild: The resource is not found.

Fix the test function in pldm_utils_test.cpp.

Signed-off-by: Chicago Duan <duanzhijia01@inspur.com>
Change-Id: I3e5df59de1a1d71e8eec043fdbb7868bbff6343b
diff --git a/test/pldm_utils_test.cpp b/test/pldm_utils_test.cpp
index 4684f9a..65b16c1 100644
--- a/test/pldm_utils_test.cpp
+++ b/test/pldm_utils_test.cpp
@@ -412,12 +412,12 @@
 
     std::vector<uint8_t> pdr(sizeof(struct pldm_state_effecter_pdr) -
                              sizeof(uint8_t) +
-                             sizeof(struct state_effecter_possible_states));
+                             sizeof(struct state_effecter_possible_states) * 3);
 
     auto rec = reinterpret_cast<pldm_state_effecter_pdr*>(pdr.data());
+    auto state_start = rec->possible_states;
 
-    auto state =
-        reinterpret_cast<state_effecter_possible_states*>(rec->possible_states);
+    auto state = reinterpret_cast<state_effecter_possible_states*>(state_start);
 
     rec->hdr.type = 11;
     rec->hdr.record_handle = 1;
@@ -427,9 +427,15 @@
     state->state_set_id = 198;
     state->possible_states_size = 1;
 
+    state_start += state->possible_states_size + sizeof(state->state_set_id) +
+                   sizeof(state->possible_states_size);
+    state = reinterpret_cast<state_effecter_possible_states*>(state_start);
     state->state_set_id = 193;
     state->possible_states_size = 1;
 
+    state_start += state->possible_states_size + sizeof(state->state_set_id) +
+                   sizeof(state->possible_states_size);
+    state = reinterpret_cast<state_effecter_possible_states*>(state_start);
     state->state_set_id = 192;
     state->possible_states_size = 1;
 
@@ -451,12 +457,12 @@
 
     std::vector<uint8_t> pdr(sizeof(struct pldm_state_effecter_pdr) -
                              sizeof(uint8_t) +
-                             sizeof(struct state_effecter_possible_states));
+                             sizeof(struct state_effecter_possible_states) * 3);
 
     auto rec = reinterpret_cast<pldm_state_effecter_pdr*>(pdr.data());
+    auto state_start = rec->possible_states;
 
-    auto state =
-        reinterpret_cast<state_effecter_possible_states*>(rec->possible_states);
+    auto state = reinterpret_cast<state_effecter_possible_states*>(state_start);
 
     rec->hdr.type = 11;
     rec->hdr.record_handle = 1;
@@ -466,9 +472,15 @@
     state->state_set_id = 198;
     state->possible_states_size = 1;
 
+    state_start += state->possible_states_size + sizeof(state->state_set_id) +
+                   sizeof(state->possible_states_size);
+    state = reinterpret_cast<state_effecter_possible_states*>(state_start);
     state->state_set_id = 193;
     state->possible_states_size = 1;
 
+    state_start += state->possible_states_size + sizeof(state->state_set_id) +
+                   sizeof(state->possible_states_size);
+    state = reinterpret_cast<state_effecter_possible_states*>(state_start);
     state->state_set_id = 123;
     state->possible_states_size = 1;
 
@@ -812,12 +824,12 @@
 
     std::vector<uint8_t> pdr(sizeof(struct pldm_state_sensor_pdr) -
                              sizeof(uint8_t) +
-                             sizeof(struct state_sensor_possible_states));
+                             sizeof(struct state_sensor_possible_states) * 3);
 
     auto rec = reinterpret_cast<pldm_state_sensor_pdr*>(pdr.data());
+    auto state_start = rec->possible_states;
 
-    auto state =
-        reinterpret_cast<state_sensor_possible_states*>(rec->possible_states);
+    auto state = reinterpret_cast<state_sensor_possible_states*>(state_start);
 
     rec->hdr.type = 4;
     rec->hdr.record_handle = 1;
@@ -827,9 +839,17 @@
     state->state_set_id = 2;
     state->possible_states_size = 1;
 
+    state_start += state->possible_states_size + sizeof(state->state_set_id) +
+                   sizeof(state->possible_states_size);
+    state = reinterpret_cast<state_sensor_possible_states*>(state_start);
+
     state->state_set_id = 7;
     state->possible_states_size = 1;
 
+    state_start += state->possible_states_size + sizeof(state->state_set_id) +
+                   sizeof(state->possible_states_size);
+    state = reinterpret_cast<state_sensor_possible_states*>(state_start);
+
     state->state_set_id = 1;
     state->possible_states_size = 1;
 
@@ -851,12 +871,12 @@
 
     std::vector<uint8_t> pdr(sizeof(struct pldm_state_sensor_pdr) -
                              sizeof(uint8_t) +
-                             sizeof(struct state_sensor_possible_states));
+                             sizeof(struct state_sensor_possible_states) * 3);
 
     auto rec = reinterpret_cast<pldm_state_sensor_pdr*>(pdr.data());
+    auto state_start = rec->possible_states;
 
-    auto state =
-        reinterpret_cast<state_sensor_possible_states*>(rec->possible_states);
+    auto state = reinterpret_cast<state_sensor_possible_states*>(state_start);
 
     rec->hdr.type = 4;
     rec->hdr.record_handle = 1;
@@ -866,9 +886,15 @@
     state->state_set_id = 15;
     state->possible_states_size = 1;
 
+    state_start += state->possible_states_size + sizeof(state->state_set_id) +
+                   sizeof(state->possible_states_size);
+    state = reinterpret_cast<state_sensor_possible_states*>(state_start);
     state->state_set_id = 19;
     state->possible_states_size = 1;
 
+    state_start += state->possible_states_size + sizeof(state->state_set_id) +
+                   sizeof(state->possible_states_size);
+    state = reinterpret_cast<state_sensor_possible_states*>(state_start);
     state->state_set_id = 39;
     state->possible_states_size = 1;
 
@@ -879,4 +905,4 @@
     EXPECT_EQ(record.empty(), true);
 
     pldm_pdr_destroy(repo);
-}
\ No newline at end of file
+}
diff --git a/utils.cpp b/utils.cpp
index 7402df5..1212f62 100644
--- a/utils.cpp
+++ b/utils.cpp
@@ -42,13 +42,14 @@
             {
                 auto pdr = reinterpret_cast<pldm_state_effecter_pdr*>(outData);
                 auto compositeEffecterCount = pdr->composite_effecter_count;
+                auto possible_states_start = pdr->possible_states;
 
                 for (auto effecters = 0x00; effecters < compositeEffecterCount;
                      effecters++)
                 {
                     auto possibleStates =
                         reinterpret_cast<state_effecter_possible_states*>(
-                            pdr->possible_states);
+                            possible_states_start);
                     auto setId = possibleStates->state_set_id;
                     auto possibleStateSize =
                         possibleStates->possible_states_size;
@@ -60,8 +61,8 @@
                         pdrs.emplace_back(std::move(effecter_pdr));
                         break;
                     }
-                    possibleStates += possibleStateSize + sizeof(setId) +
-                                      sizeof(possibleStateSize);
+                    possible_states_start += possibleStateSize + sizeof(setId) +
+                                             sizeof(possibleStateSize);
                 }
             }
 
@@ -95,13 +96,14 @@
             {
                 auto pdr = reinterpret_cast<pldm_state_sensor_pdr*>(outData);
                 auto compositeSensorCount = pdr->composite_sensor_count;
+                auto possible_states_start = pdr->possible_states;
 
                 for (auto sensors = 0x00; sensors < compositeSensorCount;
                      sensors++)
                 {
                     auto possibleStates =
                         reinterpret_cast<state_sensor_possible_states*>(
-                            pdr->possible_states);
+                            possible_states_start);
                     auto setId = possibleStates->state_set_id;
                     auto possibleStateSize =
                         possibleStates->possible_states_size;
@@ -113,8 +115,8 @@
                         pdrs.emplace_back(std::move(sensor_pdr));
                         break;
                     }
-                    possibleStates += possibleStateSize + sizeof(setId) +
-                                      sizeof(possibleStateSize);
+                    possible_states_start += possibleStateSize + sizeof(setId) +
+                                             sizeof(possibleStateSize);
                 }
             }