Change in osmo-pcu[master]: tests/rlcmac: Memzero decoded struct

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Sat Jan 25 19:33:00 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-pcu/+/16989 )

Change subject: tests/rlcmac: Memzero decoded struct
......................................................................

tests/rlcmac: Memzero decoded struct

Otherwise final output is undefined.

Change-Id: I9b501b8a99473b4d79279f8a3a9854e0b2eb3284
---
M tests/rlcmac/RLCMACTest.cpp
1 file changed, 9 insertions(+), 8 deletions(-)

Approvals:
  Jenkins Builder: Verified
  fixeria: Looks good to me, approved
  laforge: Looks good to me, approved



diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp
index acfe56a..5ed8c0f 100644
--- a/tests/rlcmac/RLCMACTest.cpp
+++ b/tests/rlcmac/RLCMACTest.cpp
@@ -119,12 +119,13 @@
 			cout << hex << (unsigned)*(vector->data + i);
 		}
 		cout << endl;
-		RlcMacDownlink_t * data = (RlcMacDownlink_t *)malloc(sizeof(RlcMacDownlink_t));
+		RlcMacDownlink_t data;
+		memset(&data, 0, sizeof(data));
 		cout << "=========Start DECODE===========" << endl;
-		decode_gsm_rlcmac_downlink(vector, data);
+		decode_gsm_rlcmac_downlink(vector, &data);
 		cout << "+++++++++Finish DECODE++++++++++" << endl;
 		cout << "=========Start ENCODE=============" << endl;
-		encode_gsm_rlcmac_downlink(resultVector, data);
+		encode_gsm_rlcmac_downlink(resultVector, &data);
 		cout << "+++++++++Finish ENCODE+++++++++++" << endl;
 		cout << "vector1 = ";
 		for (int i = 0; i < 23; i++)
@@ -148,7 +149,6 @@
 		}
 		bitvec_unhex(resultVector, DUMMY_VEC);
 		bitvec_free(vector);
-		free(data);
 	}
 
 	bitvec_free(resultVector);
@@ -183,12 +183,13 @@
 			cout << hex << (unsigned)*(vector->data + i);
 		}
 		cout << endl;
-		RlcMacUplink_t * data = (RlcMacUplink_t *)malloc(sizeof(RlcMacUplink_t));
+		RlcMacUplink_t data;
+		memset(&data, 0, sizeof(data));
 		cout << "=========Start DECODE===========" << endl;
-		decode_gsm_rlcmac_uplink(vector, data);
+		decode_gsm_rlcmac_uplink(vector, &data);
 		cout << "+++++++++Finish DECODE++++++++++" << endl;
 		cout << "=========Start ENCODE=============" << endl;
-		encode_gsm_rlcmac_uplink(resultVector, data);
+		encode_gsm_rlcmac_uplink(resultVector, &data);
 		cout << "+++++++++Finish ENCODE+++++++++++" << endl;
 		cout << "vector1 = ";
 		for (int i = 0; i < 23; i++)
@@ -212,7 +213,6 @@
 		}
 		bitvec_unhex(resultVector, DUMMY_VEC);
 		bitvec_free(vector);
-		free(data);
 	}
 
 	bitvec_free(resultVector);
@@ -227,6 +227,7 @@
 
 	bitvec_unhex(vector, "40200bffd161003e0e519ffffffb800000000000000000");
 	RlcMacUplink_t data;
+	memset(&data, 0, sizeof(data));
 
 	EGPRS_AckNack_Desc_t *urbb =
 		&data.u.Egprs_Packet_Downlink_Ack_Nack.EGPRS_AckNack.Desc;

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/16989
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I9b501b8a99473b4d79279f8a3a9854e0b2eb3284
Gerrit-Change-Number: 16989
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <axilirator at gmail.com>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200125/6e061a81/attachment.htm>


More information about the gerrit-log mailing list