Skip to content

Commit 2680dd6

Browse files
Juha Heiskanenjuhhei01
authored andcommitted
Fixed unstable unit test verified by valgrind.
Change-Id: I1e4c9832e029e565c7a717ad82e516456adb57b5
1 parent 18eda56 commit 2680dd6

File tree

16 files changed

+90
-1
lines changed

16 files changed

+90
-1
lines changed

test/nanostack/unittest/6LoWPAN/adaptation_interface/test_adaptation_interface.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,7 @@ bool test_lowpan_adaptation_interface_data_ind()
937937
entry.mac_parameters = &params;
938938
entry.mac_security_key_usage_update_cb = mac_security_key_update_cb;
939939
mcps_data_ind_t data_ind;
940+
memset(&data_ind, 0, sizeof(mcps_data_ind_t));
940941
buffer_dyn_stub.buffer_ptr = NULL;
941942
lowpan_adaptation_interface_data_ind( NULL, &data_ind );
942943

test/nanostack/unittest/6LoWPAN/ws_llc_data_service/test_ws_llc_data_service.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ bool test_ws_llc_reset()
174174
mpx_api->mpx_data_request(mpx_api, &data_req, 0xA0ED);
175175
nsdynmemlib_stub.returnCounter = 1;
176176
asynch_request_t asynch_request;
177+
memset(&asynch_request, 0, sizeof(asynch_request_t));
177178
asynch_request.message_type = WS_FT_PAN_ADVERT;
178179

179180
ws_llc_asynch_request(&interface, &asynch_request);
@@ -192,6 +193,7 @@ bool test_asynch_msg_send()
192193
mpx_api_t *mpx_api = ws_llc_mpx_api_get(&interface);
193194
register_mpx_user(mpx_api);
194195
asynch_request_t asynch_request;
196+
memset(&asynch_request, 0, sizeof(asynch_request_t));
195197
asynch_request.message_type = WS_FT_PAN_ADVERT_SOL;
196198
message_id = WS_FT_PAN_ADVERT_SOL;
197199
valid_conf = false;
@@ -375,6 +377,7 @@ bool test_mpx_msg_rx()
375377
register_mpx_user(mpx_api);
376378

377379
mcps_data_ind_t data_ind;
380+
memset(&data_ind, 0, sizeof(mcps_data_ind_t));
378381
uint8_t utt_type = 0;
379382
uint8_t payload_buf[100];
380383
uint8_t header_buf[100];

test/nanostack/unittest/6lp_mac/beacon_handler/test_beacon_handler.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ bool test_beacon_received()
5959

6060
protocol_core_stub.entry_ptr = NULL;
6161
mlme_beacon_ind_t ind;
62+
memset(&ind, 0, sizeof(mlme_beacon_ind_t));
6263
beacon_received(0, &ind);
6364

6465
protocol_interface_info_entry_t entry;
@@ -112,6 +113,7 @@ bool test_beacon_received()
112113
params.beacon_compare_rx_cb_ptr = &compare_cb;
113114
ind.beacon_data_length = PLAIN_BEACON_PAYLOAD_SIZE+6;
114115
uint8_t dat[PLAIN_BEACON_PAYLOAD_SIZE+6];
116+
memset(dat, 0, PLAIN_BEACON_PAYLOAD_SIZE+6);
115117
dat[PLAIN_BEACON_PAYLOAD_SIZE] = 0x00;
116118

117119
ind.beacon_data = &dat;
@@ -151,6 +153,7 @@ bool test_beacon_received()
151153
nwk_pan_descriptor_t info;
152154
memset(&info, 0, sizeof(nwk_pan_descriptor_t));
153155
mlme_pan_descriptor_t pan;
156+
memset(&pan, 0, sizeof(mlme_pan_descriptor_t));
154157
info.pan_descriptor = &pan;
155158
pan.LogicalChannel = 1;
156159
ind.PANDescriptor.LogicalChannel = 2;
@@ -169,7 +172,9 @@ bool test_beacon_received()
169172
ns_dyn_mem_free(info.next);
170173

171174
mlme_pan_descriptor_t pan2;
175+
memset(&pan2, 0, sizeof(mlme_pan_descriptor_t));
172176
nwk_pan_descriptor_t info2;
177+
memset(&info2, 0, sizeof(nwk_pan_descriptor_t));
173178
info2.pan_descriptor = &pan2;
174179
pan2.LogicalChannel = 2;
175180
pan2.CoordPANId = 2;
@@ -179,7 +184,9 @@ bool test_beacon_received()
179184
info.next = &info2;
180185

181186
mlme_pan_descriptor_t pan3;
187+
memset(&pan3, 0, sizeof(mlme_pan_descriptor_t));
182188
nwk_pan_descriptor_t info3;
189+
memset(&info3, 0, sizeof(nwk_pan_descriptor_t));
183190
info3.pan_descriptor = &pan3;
184191
pan3.LogicalChannel = 3;
185192
info2.next = &info3;

test/nanostack/unittest/6lp_mac/mac_ie_lib/test_mac_ie_lib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,9 @@ bool test_mac_ie_header_discover()
230230
bool test_mac_ie_header_sub_id_discover()
231231
{
232232
uint8_t buffer[60];
233+
memset(buffer, 0, 60);
233234
mac_header_IE_t header_ie;
235+
memset(&header_ie, 0, sizeof(mac_header_IE_t));
234236
header_ie.id = MAC_HEADER_ASSIGNED_EXTERNAL_ORG_IE_ID;
235237
if (mac_ie_header_discover(buffer, 0, &header_ie) ) {
236238
return false;

test/nanostack/unittest/6lp_mac/mac_response_handler/test_mac_response_handler.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,14 @@ void mlme_test_req(const mac_api_t* api, mlme_primitive id, const void *data)
6767
bool test_mlme_confirm_handler()
6868
{
6969
mac_api_t api;
70+
memset(&api, 0, sizeof(mac_api_t));
7071
api.mlme_req = mlme_test_req;
7172
protocol_core_stub.entry_ptr = NULL;
7273
mlme_confirm_handler(&api, 0, NULL);
7374
protocol_interface_info_entry_t entry;
75+
memset(&entry, 0, sizeof(protocol_interface_info_entry_t));
7476
arm_15_4_mac_parameters_t params;
77+
memset(&params, 0, sizeof(arm_15_4_mac_parameters_t));
7578
entry.mac_parameters = &params;
7679
entry.mac_api = &api;
7780
protocol_core_stub.entry_ptr = &entry;

test/nanostack/unittest/mac/mac_filter/test_mac_filter.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ bool test_mac_filter_modify_link_quality()
5454
//Stop is tested last to keep filter enabled during the test
5555

5656
mac_pre_parsed_frame_t frame;
57+
memset(&frame, 0, sizeof(mac_pre_parsed_frame_t));
5758
frame.fcf_dsn.SrcAddrMode = MAC_ADDR_MODE_NONE;
5859
ret = mac_filter_modify_link_quality(0, &frame);
5960
if( 0 != ret ){

test/nanostack/unittest/mac/mac_header_helper_functions/test_mac_header_helper_functions.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,7 @@ bool test_mac_header_get_dst_panid()
332332
bool test_mac_header_get_src_address()
333333
{
334334
mac_fcf_sequence_t seq;
335+
memset(&seq, 0, sizeof(mac_fcf_sequence_t));
335336
uint8_t ptr[25];
336337
memset(&ptr, 0, 25);
337338
uint8_t addr[15];
@@ -365,6 +366,7 @@ bool test_mac_header_get_src_address()
365366
bool test_mac_header_get_dst_address()
366367
{
367368
mac_fcf_sequence_t seq;
369+
memset(&seq, 0, sizeof(mac_fcf_sequence_t));
368370
uint8_t ptr[25];
369371
memset(&ptr, 0, 25);
370372
uint8_t addr[15];

test/nanostack/unittest/mac/mac_indirect_data/test_mac_indirect_data.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,9 @@ bool test_mac_indirect_data_ttl_handle()
7878
mac_indirect_data_ttl_handle(NULL, 0); //Crashes if NULL not handled
7979

8080
arm_device_driver_list_s list;
81+
memset(&list, 0, sizeof(arm_device_driver_list_s));
8182
protocol_interface_rf_mac_setup_s cur;
83+
memset(&cur, 0, sizeof(protocol_interface_rf_mac_setup_s));
8284
cur.dev_driver = &list;
8385
cur.dev_driver->phy_driver = &device_driver;
8486
cur.indirect_pd_data_request_queue = NULL;
@@ -91,6 +93,9 @@ bool test_mac_indirect_data_ttl_handle()
9193
mac_pre_build_frame_t frame;
9294
mac_pre_build_frame_t frame2;
9395
mac_pre_build_frame_t frame3;
96+
memset(&frame, 0, sizeof(mac_pre_build_frame_t));
97+
memset(&frame2, 0, sizeof(mac_pre_build_frame_t));
98+
memset(&frame3, 0, sizeof(mac_pre_build_frame_t));
9499
frame.next = &frame2;
95100
frame2.next = &frame3;
96101
frame3.next = NULL;
@@ -99,6 +104,7 @@ bool test_mac_indirect_data_ttl_handle()
99104
mac_indirect_data_ttl_handle(&cur, 0);
100105

101106
mac_api_t api;
107+
memset(&api, 0, sizeof(mac_api_t));
102108
sw_mac_stub.mac_api_ptr = &api;
103109
frame.buffer_ttl = 2;
104110
api.data_conf_cb = &test_data_confirm_cb;

test/nanostack/unittest/mac/mac_mcps_sap/test_mac_mcps_sap.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,11 +858,18 @@ bool test_mac_mcps_data_indication()
858858

859859

860860
ccm_globals_t ccm_ptr;
861+
memset(&ccm_ptr, 0, sizeof(ccm_globals_t));
861862
mac_api_t mac_api;
863+
memset(&mac_api, 0, sizeof(mac_api_t));
862864
mlme_key_descriptor_t key_description;
865+
memset(&key_description, 0, sizeof(mlme_key_descriptor_t));
863866
mlme_device_descriptor_t device_description;
867+
memset(&device_description, 0, sizeof(mlme_device_descriptor_t));
864868
mac_aux_security_header_t secuirity_params;
869+
memset(&secuirity_params, 0, sizeof(mac_aux_security_header_t));
865870
mlme_key_device_descriptor_t key_device_description;
871+
memset(&key_device_description, 0, sizeof(mlme_key_device_descriptor_t));
872+
866873
mcps_data_req_t data_req;
867874
memset(&data_req, 0, sizeof(mcps_data_req_t));
868875

@@ -2213,17 +2220,23 @@ bool test_mcps_sap_pd_confirm()
22132220
bool test_mcps_sap_data_req_handler()
22142221
{
22152222
ccm_globals_t ccm_ptr;
2223+
memset(&ccm_ptr, 0, sizeof(ccm_globals_t));
22162224
mac_api_t mac_api;
2225+
memset(&mac_api, 0, sizeof(mac_api_t));
22172226
mlme_key_descriptor_t key_description;
2227+
memset(&key_description, 0, sizeof(mlme_key_descriptor_t));
22182228
mlme_device_descriptor_t device_description;
2229+
memset(&device_description, 0, sizeof(mlme_device_descriptor_t));
22192230
mac_aux_security_header_t secuirity_params;
2231+
memset(&secuirity_params, 0, sizeof(mac_aux_security_header_t));
22202232
mcps_data_req_t data_req;
22212233
memset(&data_req, 0, sizeof(mcps_data_req_t));
22222234

22232235
uint8_t tx_buf[127];
22242236
uint8_t msdu_handle = 0;
22252237

22262238
uint8_t tx_temp[200];
2239+
memset(tx_temp, 0, 200);
22272240
protocol_interface_rf_mac_setup_s *rf_mac_setup = test_mac_rf_mac_class_allocate();
22282241
memset(tx_buf, 1, 127);
22292242

@@ -2468,10 +2481,15 @@ bool test_mac_mcps_trig_buffer_from_queue()
24682481
{
24692482

24702483
ccm_globals_t ccm_ptr;
2484+
memset(&ccm_ptr, 0, sizeof(ccm_globals_t));
24712485
mac_api_t mac_api;
2486+
memset(&mac_api, 0, sizeof(mac_api_t));
24722487
mlme_key_descriptor_t key_description;
2488+
memset(&key_description, 0, sizeof(mlme_key_descriptor_t));
24732489
mlme_device_descriptor_t device_description;
2490+
memset(&device_description, 0, sizeof(mlme_device_descriptor_t));
24742491
mac_aux_security_header_t secuirity_params;
2492+
memset(&secuirity_params, 0, sizeof(mac_aux_security_header_t));
24752493
uint8_t tx_buf[127];
24762494
protocol_interface_rf_mac_setup_s *rf_mac_setup = test_mac_rf_mac_class_allocate();
24772495
memset(tx_buf, 1, 127);

test/nanostack/unittest/mac/mac_mlme/test_mac_mlme.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,14 +230,19 @@ bool test_mac_mlme_scan_request()
230230
memset(conf, 0, sizeof(mlme_scan_conf_t));
231231
setup.mac_mlme_scan_resp = conf;
232232
mac_pre_build_frame_t fr;
233+
memset(&fr, 0, sizeof(mac_pre_build_frame_t));
233234
setup.active_pd_data_request = &fr;
234235
mlme_scan_t scan;
236+
memset(&scan, 0, sizeof(mlme_scan_t));
235237
arm_device_driver_list_s list;
238+
memset(&list, 0, sizeof(arm_device_driver_list_s));
236239
phy_device_driver_s drv;
240+
memset(&drv, 0, sizeof(phy_device_driver_s));
237241
list.phy_driver = &drv;
238242
setup.dev_driver = &list;
239243
setup.dev_driver->phy_driver->link_type = PHY_LINK_15_4_2_4GHZ_TYPE;
240244
mac_api_t api;
245+
memset(&api, 0, sizeof(mac_api_t));
241246
sw_mac_stub.mac_api_ptr = &api;
242247
api.mlme_conf_cb = &mlme_conf;
243248
scan.ScanChannels.channel_page = 0;
@@ -1249,13 +1254,17 @@ bool test_mac_mlme_event_cb()
12491254
bool test_mac_mlme_timer_cb()
12501255
{
12511256
protocol_interface_rf_mac_setup_s *setup;
1257+
12521258
uint8_t buf[8];
12531259
memset(&buf, 0, 8);
12541260
arm_device_driver_list_s list;
1261+
memset(&list, 0, sizeof(arm_device_driver_list_s));
12551262
phy_device_driver_s drv;
1256-
1263+
memset(&drv, 0, sizeof(phy_device_driver_s));
12571264
phy_device_channel_page_s phy_channel_pages;
1265+
memset(&phy_channel_pages, 0, sizeof(phy_device_channel_page_s));
12581266
phy_rf_channel_configuration_s rf_channel_configuration;
1267+
memset(&rf_channel_configuration, 0, sizeof(phy_rf_channel_configuration_s));
12591268
rf_channel_configuration.datarate = 250000;
12601269
rf_channel_configuration.number_of_channels = 16;
12611270
rf_channel_configuration.modulation = M_OQPSK;
@@ -1276,6 +1285,7 @@ bool test_mac_mlme_timer_cb()
12761285
nsdynmemlib_stub.returnCounter = 3;
12771286
drv.address_write = &addr_write;
12781287
mac_description_storage_size_t storage_sizes;
1288+
memset(&storage_sizes, 0, sizeof(mac_description_storage_size_t));
12791289
storage_sizes.device_decription_table_size = 32;
12801290
storage_sizes.key_description_table_size = 6;
12811291
storage_sizes.key_lookup_size = 1;
@@ -1318,6 +1328,7 @@ bool test_mac_mlme_set_active_state()
13181328
bool test_mac_mlme_data_base_allocate()
13191329
{
13201330
mac_description_storage_size_t storage_sizes;
1331+
memset(&storage_sizes, 0, sizeof(mac_description_storage_size_t));
13211332
storage_sizes.device_decription_table_size = 32;
13221333
storage_sizes.key_description_table_size = 6;
13231334
storage_sizes.key_lookup_size = 1;
@@ -1330,6 +1341,7 @@ bool test_mac_mlme_data_base_allocate()
13301341
uint8_t buf[8];
13311342
memset(buf, 3, 8);
13321343
arm_device_driver_list_s list;
1344+
memset(&list, 0, sizeof(arm_device_driver_list_s));
13331345
list.phy_driver = NULL;
13341346

13351347
setup = mac_mlme_data_base_allocate(NULL, &list, &storage_sizes);
@@ -1350,8 +1362,11 @@ bool test_mac_mlme_data_base_allocate()
13501362
return false;
13511363
}
13521364
phy_device_driver_s drv;
1365+
memset(&drv, 0, sizeof(phy_device_driver_s));
13531366
phy_device_channel_page_s phy_channel_pages;
1367+
memset(&phy_channel_pages, 0, sizeof(phy_device_channel_page_s));
13541368
phy_rf_channel_configuration_s rf_channel_configuration;
1369+
memset(&rf_channel_configuration, 0, sizeof(phy_rf_channel_configuration_s));
13551370
rf_channel_configuration.datarate = 250000;
13561371
rf_channel_configuration.number_of_channels = 16;
13571372
rf_channel_configuration.modulation = M_OQPSK;

0 commit comments

Comments
 (0)