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
This commit is contained in:
parent
0a4a6c1200
commit
d38b92e972
|
@ -189,6 +189,13 @@ const gprs_llc_queue *gprs_rlcmac_tbf::llc_queue() const
|
||||||
return m_ms ? m_ms->llc_queue() : NULL;
|
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)
|
void gprs_rlcmac_tbf::set_ms(GprsMs *ms)
|
||||||
{
|
{
|
||||||
if (m_ms == ms)
|
if (m_ms == ms)
|
||||||
|
|
|
@ -142,8 +142,7 @@ struct gprs_rlcmac_tbf {
|
||||||
uint8_t ms_class() const;
|
uint8_t ms_class() const;
|
||||||
void set_ms_class(uint8_t);
|
void set_ms_class(uint8_t);
|
||||||
GprsCodingScheme current_cs() const;
|
GprsCodingScheme current_cs() const;
|
||||||
gprs_llc_queue *llc_queue();
|
int llc_queue_size() const;
|
||||||
const gprs_llc_queue *llc_queue() const;
|
|
||||||
|
|
||||||
time_t created_ts() const;
|
time_t created_ts() const;
|
||||||
uint8_t dl_slots() const;
|
uint8_t dl_slots() const;
|
||||||
|
@ -231,6 +230,9 @@ protected:
|
||||||
int set_tlli_from_ul(uint32_t new_tlli);
|
int set_tlli_from_ul(uint32_t new_tlli);
|
||||||
void merge_and_clear_ms(GprsMs *old_ms);
|
void merge_and_clear_ms(GprsMs *old_ms);
|
||||||
|
|
||||||
|
gprs_llc_queue *llc_queue();
|
||||||
|
const gprs_llc_queue *llc_queue() const;
|
||||||
|
|
||||||
static const char *tbf_state_name[7];
|
static const char *tbf_state_name[7];
|
||||||
|
|
||||||
class GprsMs *m_ms;
|
class GprsMs *m_ms;
|
||||||
|
|
|
@ -310,7 +310,7 @@ drop_frame:
|
||||||
LOGP(DRLCMACDL, LOGL_NOTICE, "%s Discarding LLC PDU "
|
LOGP(DRLCMACDL, LOGL_NOTICE, "%s Discarding LLC PDU "
|
||||||
"because lifetime limit reached, "
|
"because lifetime limit reached, "
|
||||||
"count=%u new_queue_size=%zu\n",
|
"count=%u new_queue_size=%zu\n",
|
||||||
tbf_name(this), frames, llc_queue()->size());
|
tbf_name(this), frames, llc_queue_size());
|
||||||
if (frames > 0xff)
|
if (frames > 0xff)
|
||||||
frames = 0xff;
|
frames = 0xff;
|
||||||
if (octets > 0xffffff)
|
if (octets > 0xffffff)
|
||||||
|
@ -572,7 +572,7 @@ int gprs_rlcmac_dl_tbf::create_new_bsn(const uint32_t fn, GprsCodingScheme cs)
|
||||||
m_llc.frame_length(), frames_since_last_drain(fn));
|
m_llc.frame_length(), frames_since_last_drain(fn));
|
||||||
}
|
}
|
||||||
|
|
||||||
is_final = llc_queue()->size() == 0 && !keep_open(fn);
|
is_final = llc_queue_size() == 0 && !keep_open(fn);
|
||||||
|
|
||||||
ar = Encoding::rlc_data_to_dl_append(rdbi, cs,
|
ar = Encoding::rlc_data_to_dl_append(rdbi, cs,
|
||||||
&m_llc, &write_offset, &num_chunks, data, is_final, &payload_written);
|
&m_llc, &write_offset, &num_chunks, data, is_final, &payload_written);
|
||||||
|
@ -1050,7 +1050,7 @@ int gprs_rlcmac_dl_tbf::maybe_start_new_window()
|
||||||
release();
|
release();
|
||||||
|
|
||||||
/* check for LLC PDU in the LLC Queue */
|
/* check for LLC PDU in the LLC Queue */
|
||||||
if (llc_queue()->size() > 0)
|
if (llc_queue_size() > 0)
|
||||||
/* we have more data so we will re-use this tbf */
|
/* we have more data so we will re-use this tbf */
|
||||||
establish_dl_tbf_on_pacch();
|
establish_dl_tbf_on_pacch();
|
||||||
|
|
||||||
|
@ -1168,7 +1168,7 @@ bool gprs_rlcmac_dl_tbf::need_control_ts() const
|
||||||
bool gprs_rlcmac_dl_tbf::have_data() const
|
bool gprs_rlcmac_dl_tbf::have_data() const
|
||||||
{
|
{
|
||||||
return m_llc.chunk_size() > 0 ||
|
return m_llc.chunk_size() > 0 ||
|
||||||
(llc_queue() && llc_queue()->size() > 0);
|
(llc_queue_size() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int gprs_rlcmac_dl_tbf::frames_since_last_poll(unsigned fn) const
|
int gprs_rlcmac_dl_tbf::frames_since_last_poll(unsigned fn) const
|
||||||
|
|
Loading…
Reference in New Issue