From 4662b83fe92fe8f34882653da53937190b89a4c5 Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Tue, 22 May 2018 15:14:03 +0200 Subject: [PATCH] Use bzero instead of {} for initializing structs --- lib/include/srslte/common/metrics_hub.h | 3 ++- lib/src/phy/phch/test/pdcch_test.c | 2 +- srsue/hdr/upper/rrc.h | 3 ++- srsue/src/phy/phch_worker.cc | 12 ++++++++---- srsue/src/upper/nas.cc | 6 ++++-- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/lib/include/srslte/common/metrics_hub.h b/lib/include/srslte/common/metrics_hub.h index a73f3d90e..46107db34 100644 --- a/lib/include/srslte/common/metrics_hub.h +++ b/lib/include/srslte/common/metrics_hub.h @@ -63,7 +63,8 @@ private: get_time_interval(sleep_period_start); uint32_t period = sleep_period_start[0].tv_sec*1e6 + sleep_period_start[0].tv_usec; if (m) { - metrics_t metric = {}; + metrics_t metric; + bzero(&metric, sizeof(metrics_t)); m->get_metrics(metric); for (uint32_t i=0;iset_metrics(metric, period); diff --git a/lib/src/phy/phch/test/pdcch_test.c b/lib/src/phy/phch/test/pdcch_test.c index 416405c49..18f563ab8 100644 --- a/lib/src/phy/phch/test/pdcch_test.c +++ b/lib/src/phy/phch/test/pdcch_test.c @@ -147,7 +147,7 @@ typedef struct { int main(int argc, char **argv) { srslte_pdcch_t pdcch_tx, pdcch_rx; - testcase_dci_t testcases[10] = {}; + testcase_dci_t testcases[10]; srslte_ra_dl_dci_t ra_dl; srslte_regs_t regs; int i, j, k; diff --git a/srsue/hdr/upper/rrc.h b/srsue/hdr/upper/rrc.h index a381940ec..ee1c9e058 100644 --- a/srsue/hdr/upper/rrc.h +++ b/srsue/hdr/upper/rrc.h @@ -108,7 +108,8 @@ class cell_t } cell_t() { - phy_interface_rrc::phy_cell_t tmp = {}; + phy_interface_rrc::phy_cell_t tmp; + ZERO_OBJECT(tmp); cell_t(tmp, 0); } cell_t(phy_interface_rrc::phy_cell_t phy_cell, float rsrp) { diff --git a/srsue/src/phy/phch_worker.cc b/srsue/src/phy/phch_worker.cc index 746a7e430..a18fbb598 100644 --- a/srsue/src/phy/phch_worker.cc +++ b/srsue/src/phy/phch_worker.cc @@ -251,12 +251,16 @@ void phch_worker::work_imp() bool ul_grant_available = false; bool dl_ack[SRSLTE_MAX_CODEWORDS] = {false}; - mac_interface_phy::mac_grant_t dl_mac_grant = {}; - mac_interface_phy::tb_action_dl_t dl_action = {}; + mac_interface_phy::mac_grant_t dl_mac_grant; + mac_interface_phy::tb_action_dl_t dl_action; - mac_interface_phy::mac_grant_t ul_mac_grant = {}; - mac_interface_phy::tb_action_ul_t ul_action = {}; + mac_interface_phy::mac_grant_t ul_mac_grant; + mac_interface_phy::tb_action_ul_t ul_action; + ZERO_OBJECT(dl_mac_grant); + ZERO_OBJECT(dl_action); + ZERO_OBJECT(ul_mac_grant); + ZERO_OBJECT(ul_action); /** Calculate RSSI on the input signal before generating the output */ diff --git a/srsue/src/upper/nas.cc b/srsue/src/upper/nas.cc index c4f7a4584..4df7d5c31 100644 --- a/srsue/src/upper/nas.cc +++ b/srsue/src/upper/nas.cc @@ -1244,7 +1244,8 @@ void nas::send_esm_information_response(const uint8 proc_transaction_id) { 16 /* data value */ + cfg.user.length(); - uint8_t challenge[len] = {}; + uint8_t challenge[len]; + bzero(challenge, len*sizeof(uint8_t)); challenge[0] = 0x01; // challenge code challenge[1] = chap_id; // ID challenge[2] = (len >> 8) & 0xff; @@ -1263,7 +1264,8 @@ void nas::send_esm_information_response(const uint8 proc_transaction_id) { } // Generate response - uint8_t response[len] = {}; + uint8_t response[len]; + bzero(response, len*sizeof(uint8_t)); response[0] = 0x02; // response code response[1] = chap_id; response[2] = (len >> 8) & 0xff;