[PATCH] Explicitly initialize m_v_n and m_v_b

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/osmocom-net-gprs@lists.osmocom.org/.

msuraev at sysmocom.de msuraev at sysmocom.de
Thu Feb 25 16:28:09 UTC 2016


From: Max <msuraev at sysmocom.de>

Call reset() to initialize m_v_b in gprs_rlc_dl_window() and
m_v_n in gprs_rlc_ul_window() constructors. Add constructors to
gprs_rlc_v_b and gprs_rlc_v_n. Not sure about all the intimate details
of constructor calls in c++ so used both.

Fixes: Coverity: CID 1351738, 1351737
---
 src/rlc.h | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/src/rlc.h b/src/rlc.h
index 54f28df..eb527a0 100644
--- a/src/rlc.h
+++ b/src/rlc.h
@@ -143,8 +143,7 @@ struct gprs_rlc_v_b {
 	void mark_invalid(int bsn);
 
 	void reset();
-
-
+	gprs_rlc_v_b();
 private:
 	bool is_state(int bsn, const gprs_rlc_dl_bsn_state state) const;
 	void mark(int bsn, const gprs_rlc_dl_bsn_state state);
@@ -216,6 +215,7 @@ struct gprs_rlc_v_n {
 	bool is_received(int bsn) const;
 
 	gprs_rlc_ul_bsn_state state(int bsn) const;
+	gprs_rlc_v_n();
 private:
 	bool is_state(int bsn, const gprs_rlc_ul_bsn_state state) const;
 	void mark(int bsn, const gprs_rlc_ul_bsn_state state);
@@ -448,6 +448,7 @@ inline gprs_rlc_dl_window::gprs_rlc_dl_window()
 	: m_v_s(0)
 	, m_v_a(0)
 {
+	m_v_b.reset();
 }
 
 inline const uint16_t gprs_rlc_dl_window::v_s() const
@@ -490,10 +491,21 @@ inline const int16_t gprs_rlc_dl_window::distance() const
 	return (m_v_s - m_v_a) & mod_sns();
 }
 
+inline gprs_rlc_v_b::gprs_rlc_v_b()
+{
+	reset();
+}
+
+inline gprs_rlc_v_n::gprs_rlc_v_n()
+{
+	reset();
+}
+
 inline gprs_rlc_ul_window::gprs_rlc_ul_window()
 	: m_v_r(0)
 	, m_v_q(0)
 {
+	m_v_n.reset();
 }
 
 inline bool gprs_rlc_ul_window::is_in_window(uint16_t bsn) const
-- 
2.7.2




More information about the osmocom-net-gprs mailing list