summaryrefslogtreecommitdiff
path: root/toxav/rtp.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-09-05 16:10:48 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-09-06 11:54:37 +0100
commitad2656051697899e960694bb68ac104fcc5e92f1 (patch)
tree7e69fcd03db88b3839ee523f5d1b51ef9a38c372 /toxav/rtp.c
parent4e6c86d1cb228308678f89ff6e4e09b3f46347aa (diff)
Improve static and const correctness.
- Any non-externally-visible declarations should be `static`. - Casting away the `const` qualifier from pointers-to-const is dangerous. All but one instance of this are now correct. The one instance where we can't keep `const` is one where toxav code actually writes to a chunk of memory marked as `const`. This code also assumes 4 byte alignment of data packets. I don't know whether that is a valid assumption, but it's likely unportable, and *not* obviously correct. - Replaced empty parameter lists with `(void)` to avoid passing parameters to it. Empty parameter lists are old style declarations for unknown number and type of arguments. - Commented out (as `#if DHT_HARDENING` block) the hardening code that was never executed. - Minor style fix: don't use `default` in enum-switches unless the number of enumerators in the default case is very large. In this case, it was 2, so we want to list them both explicitly to be warned about missing one if we add one in the future. - Removed the only two function declarations from nTox.h and put them into nTox.c. They are not used outside and nTox is not a library.
Diffstat (limited to 'toxav/rtp.c')
-rw-r--r--toxav/rtp.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/toxav/rtp.c b/toxav/rtp.c
index 38e64dd7..6e0c22b2 100644
--- a/toxav/rtp.c
+++ b/toxav/rtp.c
@@ -191,7 +191,7 @@ int rtp_send_data (RTPSession *session, const uint8_t *data, uint16_t length)
191} 191}
192 192
193 193
194bool chloss (const RTPSession *session, const struct RTPHeader *header) 194static bool chloss (const RTPSession *session, const struct RTPHeader *header)
195{ 195{
196 if (ntohl(header->timestamp) < session->rtimestamp) { 196 if (ntohl(header->timestamp) < session->rtimestamp) {
197 uint16_t hosq, lost = 0; 197 uint16_t hosq, lost = 0;
@@ -213,7 +213,7 @@ bool chloss (const RTPSession *session, const struct RTPHeader *header)
213 213
214 return false; 214 return false;
215} 215}
216struct RTPMessage *new_message (size_t allocate_len, const uint8_t *data, uint16_t data_length) 216static struct RTPMessage *new_message (size_t allocate_len, const uint8_t *data, uint16_t data_length)
217{ 217{
218 assert(allocate_len >= data_length); 218 assert(allocate_len >= data_length);
219 219
@@ -246,7 +246,7 @@ int handle_rtp_packet (Messenger *m, uint32_t friendnumber, const uint8_t *data,
246 return -1; 246 return -1;
247 } 247 }
248 248
249 const struct RTPHeader *header = (struct RTPHeader *) data; 249 const struct RTPHeader *header = (const struct RTPHeader *) data;
250 250
251 if (header->pt != session->payload_type % 128) { 251 if (header->pt != session->payload_type % 128) {
252 LOGGER_WARNING(m->log, "Invalid payload type with the session"); 252 LOGGER_WARNING(m->log, "Invalid payload type with the session");