Replace unneeded memcpy for sr_payload

Set appropriate length for csi payload calloc and memcpy, according to bit_len
parent d27d1933
...@@ -473,19 +473,22 @@ int aerial_phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind) ...@@ -473,19 +473,22 @@ int aerial_phy_nr_uci_indication(nfapi_nr_uci_indication_t *ind)
uci_ind_pdu->sr.sr_payload = CALLOC(1, sizeof(*uci_ind_pdu->sr.sr_payload)); uci_ind_pdu->sr.sr_payload = CALLOC(1, sizeof(*uci_ind_pdu->sr.sr_payload));
AssertFatal(uci_ind_pdu->sr.sr_payload != NULL, AssertFatal(uci_ind_pdu->sr.sr_payload != NULL,
"Memory not allocated for uci_ind_pdu->sr.sr_payload in phy_nr_uci_indication."); "Memory not allocated for uci_ind_pdu->sr.sr_payload in phy_nr_uci_indication.");
memcpy(uci_ind_pdu->sr.sr_payload,ind_pdu->sr.sr_payload,sizeof(*uci_ind_pdu->sr.sr_payload)); //SCF222.10.02 sr_bit_len values from 1 to 8, payload always just one byte
uci_ind_pdu->sr.sr_payload[0] = ind_pdu->sr.sr_payload[0];
} }
if (ind_pdu->csi_part1.csi_part1_payload) { if (ind_pdu->csi_part1.csi_part1_payload) {
uci_ind_pdu->csi_part1.csi_part1_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part1.csi_part1_payload)); uint8_t byte_len = (ind_pdu->csi_part1.csi_part1_bit_len / 8) + 1;
uci_ind_pdu->csi_part1.csi_part1_payload = calloc(byte_len, sizeof(uint8_t));
AssertFatal(uci_ind_pdu->csi_part1.csi_part1_payload != NULL, AssertFatal(uci_ind_pdu->csi_part1.csi_part1_payload != NULL,
"Memory not allocated for uci_ind_pdu->csi_part1.csi_part1_payload in phy_nr_uci_indication."); "Memory not allocated for uci_ind_pdu->csi_part1.csi_part1_payload in phy_nr_uci_indication.");
memcpy(uci_ind_pdu->csi_part1.csi_part1_payload,ind_pdu->csi_part1.csi_part1_payload,sizeof(*uci_ind_pdu->csi_part1.csi_part1_payload)); memcpy(uci_ind_pdu->csi_part1.csi_part1_payload,ind_pdu->csi_part1.csi_part1_payload,byte_len);
} }
if (ind_pdu->csi_part2.csi_part2_payload) { if (ind_pdu->csi_part2.csi_part2_payload) {
uci_ind_pdu->csi_part2.csi_part2_payload = CALLOC(1, sizeof(*uci_ind_pdu->csi_part2.csi_part2_payload)); uint8_t byte_len = (ind_pdu->csi_part2.csi_part2_bit_len / 8) + 1;
uci_ind_pdu->csi_part2.csi_part2_payload = calloc(byte_len, sizeof(uint8_t));
AssertFatal(uci_ind_pdu->csi_part2.csi_part2_payload != NULL, AssertFatal(uci_ind_pdu->csi_part2.csi_part2_payload != NULL,
"Memory not allocated for uci_ind_pdu->csi_part2.csi_part2_payload in phy_nr_uci_indication."); "Memory not allocated for uci_ind_pdu->csi_part2.csi_part2_payload in phy_nr_uci_indication.");
memcpy(uci_ind_pdu->csi_part2.csi_part2_payload,ind_pdu->csi_part2.csi_part2_payload,sizeof(*uci_ind_pdu->csi_part2.csi_part2_payload)); memcpy(uci_ind_pdu->csi_part2.csi_part2_payload,ind_pdu->csi_part2.csi_part2_payload,byte_len);
} }
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment