Skip to content

Commit

Permalink
try to fix cppcheck error(s)
Browse files Browse the repository at this point in the history
  • Loading branch information
zoff99 committed Sep 13, 2023
1 parent e43bcb1 commit 4a237e3
Showing 1 changed file with 24 additions and 7 deletions.
31 changes: 24 additions & 7 deletions toxav/rtp.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ static int handle_video_packet(const Logger *log, RTPSession *session, const str
(int)m_new->data[1]);
update_bwc_values(session, m_new);
// Pass ownership of m_new to the callback.
session->mcb(toxav_get_av_mono_time(session->toxav), session->cs, m_new);
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
assert(mt != nullptr);
session->mcb(mt, session->cs, m_new);
// Now we no longer own m_new.
m_new = nullptr;

Expand Down Expand Up @@ -417,7 +419,9 @@ static int handle_video_packet(const Logger *log, RTPSession *session, const str
LOGGER_DEBUG(log, "-- handle_video_packet -- CALLBACK-003a b0=%d b1=%d", (int)m_new->data[0],
(int)m_new->data[1]);
update_bwc_values(session, m_new);
session->mcb(toxav_get_av_mono_time(session->toxav), session->cs, m_new);
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
assert(mt != nullptr);
session->mcb(mt, session->cs, m_new);

m_new = nullptr;
}
Expand Down Expand Up @@ -520,15 +524,19 @@ void handle_rtp_packet(Tox *tox, uint32_t friendnumber, const uint8_t *data, siz

/* Invoke processing of active multiparted message */
if (session->mp != nullptr) {
session->mcb(toxav_get_av_mono_time(session->toxav), session->cs, session->mp);
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
assert(mt != nullptr);
session->mcb(mt, session->cs, session->mp);
session->mp = nullptr;
}

/* The message came in the allowed time;
*/

session->mp = new_message(log, &header, length - RTP_HEADER_SIZE, data + RTP_HEADER_SIZE, length - RTP_HEADER_SIZE);
session->mcb(toxav_get_av_mono_time(session->toxav), session->cs, session->mp);
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
assert(mt != nullptr);
session->mcb(mt, session->cs, session->mp);
session->mp = nullptr;
return;
}
Expand Down Expand Up @@ -565,7 +573,9 @@ void handle_rtp_packet(Tox *tox, uint32_t friendnumber, const uint8_t *data, siz
/* Received a full message; now push it for the further
* processing.
*/
session->mcb(toxav_get_av_mono_time(session->toxav), session->cs, session->mp);
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
assert(mt != nullptr);
session->mcb(mt, session->cs, session->mp);
session->mp = nullptr;
}
} else {
Expand All @@ -578,7 +588,9 @@ void handle_rtp_packet(Tox *tox, uint32_t friendnumber, const uint8_t *data, siz
}

/* Push the previous message for processing */
session->mcb(toxav_get_av_mono_time(session->toxav), session->cs, session->mp);
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
assert(mt != nullptr);
session->mcb(mt, session->cs, session->mp);

session->mp = nullptr;
goto NEW_MULTIPARTED;
Expand Down Expand Up @@ -808,7 +820,12 @@ static struct RTPHeader rtp_default_header(const RTPSession *session, uint32_t l
header.ma = 0;
header.pt = session->payload_type % 128;
header.sequnum = session->sequnum;
header.timestamp = current_time_monotonic(toxav_get_av_mono_time(session->toxav));
Mono_Time *mt = toxav_get_av_mono_time(session->toxav);
if (mt) {

Check warning on line 824 in toxav/rtp.c

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

toxav/rtp.c#L824

MISRA 14.4 rule
header.timestamp = current_time_monotonic(mt);
} else {
header.timestamp = 0;
}
header.ssrc = session->ssrc;
header.offset_lower = 0;
header.data_length_lower = length_safe;
Expand Down

0 comments on commit 4a237e3

Please sign in to comment.