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/.

pespin gerrit-no-reply at lists.osmocom.org
Thu Jan 23 23:18:54 UTC 2020


pespin has uploaded this change for review. ( 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
M tests/rlcmac/RLCMACTest.ok
2 files changed, 9 insertions(+), 9 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/89/16989/1

diff --git a/tests/rlcmac/RLCMACTest.cpp b/tests/rlcmac/RLCMACTest.cpp
index 0721fd1..039cdf8 100644
--- a/tests/rlcmac/RLCMACTest.cpp
+++ b/tests/rlcmac/RLCMACTest.cpp
@@ -114,12 +114,13 @@
 		cout << "vector1 = " << testData[i] << endl;
 		bitvec *vector = bitvec_alloc(23, test_ctx);
 		bitvec_unhex(vector, testData[i].c_str());
-		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 = " << osmo_hexdump(vector->data, 23) << endl;
 		cout << "vector2 = " << osmo_hexdump(resultVector->data, 23) << endl;
@@ -129,7 +130,6 @@
 			cout << "vector1 == vector2 : FALSE" << endl;
 		bitvec_unhex(resultVector, DUMMY_VEC);
 		bitvec_free(vector);
-		free(data);
 	}
 
 	bitvec_free(resultVector);
@@ -159,12 +159,13 @@
 		cout << "vector1 = " << testData[i] << endl;
 		bitvec *vector = bitvec_alloc(23, test_ctx);
 		bitvec_unhex(vector, testData[i].c_str());
-		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 = " << osmo_hexdump(vector->data, 23) << endl;
 		cout << "vector2 = " << osmo_hexdump(resultVector->data, 23) << endl;
@@ -174,7 +175,6 @@
 			cout << "vector1 == vector2 : FALSE" << endl;
 		bitvec_unhex(resultVector, DUMMY_VEC);
 		bitvec_free(vector);
-		free(data);
 	}
 
 	bitvec_free(resultVector);
diff --git a/tests/rlcmac/RLCMACTest.ok b/tests/rlcmac/RLCMACTest.ok
index 64aafc3..2af4d90 100644
--- a/tests/rlcmac/RLCMACTest.ok
+++ b/tests/rlcmac/RLCMACTest.ok
@@ -62,7 +62,7 @@
 =========Start ENCODE=============
 +++++++++Finish ENCODE+++++++++++
 vector1 = 49 13 e0 08 50 88 40 13 a8 04 8b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 
-vector2 = 49 13 43 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 
+vector2 = 49 13 01 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 2b 
 vector1 == vector2 : FALSE
 vector1 = 412430007fffffffffffffffefd19c7ba12b2b2b2b2b2b
 =========Start DECODE===========

-- 
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: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200123/495952ce/attachment.htm>


More information about the gerrit-log mailing list