Skip to content

Commit a306ad7

Browse files
committed
Avoid non-trivial copy when initializing lorastack struct
Using memset generates a warning about the non-trivial operation. Use member-initializer-list instead to initialise the structs members.
1 parent bdd6cb8 commit a306ad7

File tree

1 file changed

+2
-30
lines changed

1 file changed

+2
-30
lines changed

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,12 @@ LoRaMac::LoRaMac()
7171
_mac_commands(),
7272
_channel_plan(),
7373
_lora_crypto(),
74+
_params(),
7475
_ev_queue(NULL),
7576
_mcps_indication(),
7677
_mcps_confirmation(),
7778
_mlme_indication(),
79+
_ongoing_tx_msg(),
7880
_mlme_confirmation(),
7981
_is_nwk_joined(false),
8082
_can_cancel_tx(true),
@@ -83,39 +85,9 @@ LoRaMac::LoRaMac()
8385
_prev_qos_level(LORAWAN_DEFAULT_QOS),
8486
_demod_ongoing(false)
8587
{
86-
memset(&_params, 0, sizeof(_params));
87-
_params.keys.dev_eui = NULL;
88-
_params.keys.app_eui = NULL;
89-
_params.keys.app_key = NULL;
90-
91-
memset(_params.keys.nwk_skey, 0, sizeof(_params.keys.nwk_skey));
92-
memset(_params.keys.app_skey, 0, sizeof(_params.keys.app_skey));
93-
memset(&_ongoing_tx_msg, 0, sizeof(_ongoing_tx_msg));
94-
memset(&_params.sys_params, 0, sizeof(_params.sys_params));
95-
96-
_params.dev_nonce = 0;
97-
_params.net_id = 0;
98-
_params.dev_addr = 0;
99-
_params.tx_buffer_len = 0;
100-
_params.rx_buffer_len = 0;
101-
_params.ul_frame_counter = 0;
102-
_params.dl_frame_counter = 0;
10388
_params.is_rx_window_enabled = true;
104-
_params.adr_ack_counter = 0;
105-
_params.is_node_ack_requested = false;
106-
_params.is_srv_ack_requested = false;
107-
_params.ul_nb_rep_counter = 0;
108-
_params.timers.mac_init_time = 0;
10989
_params.max_ack_timeout_retries = 1;
11090
_params.ack_timeout_retry_counter = 1;
111-
_params.is_ack_retry_timeout_expired = false;
112-
_params.timers.tx_toa = 0;
113-
114-
_params.multicast_channels = NULL;
115-
116-
117-
_params.sys_params.adr_on = false;
118-
_params.sys_params.max_duty_cycle = 0;
11991

12092
reset_mcps_confirmation();
12193
reset_mlme_confirmation();

0 commit comments

Comments
 (0)