aboutsummaryrefslogtreecommitdiffstats
path: root/src/tbf.cpp
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2016-08-21 19:38:30 +0200
committerlynxis lazus <lynxis@fe80.eu>2016-10-18 09:49:57 +0000
commitd38b92e972be130df3e6c908fb7e7bf1729ab7fb (patch)
treea6a6d5a84e0f4a227597af61c649a05b24f3307c /src/tbf.cpp
parent0a4a6c120040c8dd0744f745e08f24624df62647 (diff)
tbf: add llc_queue_size() to check llc_queue is valid before calling size()
gcc6 is optimizing if (!this) {CODE} as this is assumed to never be a std::nullptr here. Move the null check to the caller. In preparation of removing the check within llc_queue->size(), all callers must check the object before calling it. Make sure of that: make the llc_queue() access function protected and offer only a public llc_queue_size() function that incorporates the NULL check. All current callers are only interested in the llc_queue_size(). Tweaked-by: nhofmeyr Change-Id: I88cc3180f8f86785e3f07981895dabddf50b60a2
Diffstat (limited to 'src/tbf.cpp')
-rw-r--r--src/tbf.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/tbf.cpp b/src/tbf.cpp
index 97696cb2..48d89b90 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -189,6 +189,13 @@ const gprs_llc_queue *gprs_rlcmac_tbf::llc_queue() const
return m_ms ? m_ms->llc_queue() : NULL;
}
+int gprs_rlcmac_tbf::llc_queue_size() const
+{
+ /* m_ms->llc_queue() never returns NULL: GprsMs::m_llc_queue is a
+ * member instance. */
+ return m_ms ? m_ms->llc_queue()->size() : 0;
+}
+
void gprs_rlcmac_tbf::set_ms(GprsMs *ms)
{
if (m_ms == ms)