From 5b57ab6332edc407524a353d3965a4870c33fe00 Mon Sep 17 00:00:00 2001 From: iphydf Date: Mon, 5 Sep 2016 14:43:58 +0100 Subject: Improve C standard compliance. - Don't cast between object and function pointers. - Use standard compliant `__VA_ARGS__` in macros. - Add explicit `__extension__` on unnamed union in struct (it's a GNU extension). - Remove ; after function definitions. - Replace `const T foo = 3;` for integral types `T` with `enum { foo = 3 };`. Folding integral constants like that as compile time constants is a GNU extension. Arrays allocated with `foo` as dimension are VLAs on strictly compliant C99 compilers. - Replace empty initialiser list `{}` with zero-initialiser-list `{0}`. The former is a GNU extension meaning the latter. - Cast `T*` (where `T != void`) to `void *` in format arguments. While any object pointer can be implicitly converted to and from `void *`, this conversion does not happen in variadic function calls. - Replace arithmetic on `void *` with arithmetic on `char *`. The former is non-compliant. - Replace non-`int`-derived types (like `uint16_t`, which is `short`-derived) in bit fields with `int`-derived types. Using any type other than `int` or `unsigned int` (or any of their aliases) in bit fields is a GNU extension. --- toxav/rtp.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'toxav/rtp.h') diff --git a/toxav/rtp.h b/toxav/rtp.h index 18929e12..4d60682a 100644 --- a/toxav/rtp.h +++ b/toxav/rtp.h @@ -37,21 +37,21 @@ enum { struct RTPHeader { /* Standard RTP header */ #ifndef WORDS_BIGENDIAN - uint16_t cc: 4; /* Contributing sources count */ - uint16_t xe: 1; /* Extra header */ - uint16_t pe: 1; /* Padding */ - uint16_t ve: 2; /* Version */ + unsigned cc: 4; /* Contributing sources count */ + unsigned xe: 1; /* Extra header */ + unsigned pe: 1; /* Padding */ + unsigned ve: 2; /* Version */ - uint16_t pt: 7; /* Payload type */ - uint16_t ma: 1; /* Marker */ + unsigned pt: 7; /* Payload type */ + unsigned ma: 1; /* Marker */ #else - uint16_t ve: 2; /* Version */ - uint16_t pe: 1; /* Padding */ - uint16_t xe: 1; /* Extra header */ - uint16_t cc: 4; /* Contributing sources count */ + unsigned ve: 2; /* Version */ + unsigned pe: 1; /* Padding */ + unsigned xe: 1; /* Extra header */ + unsigned cc: 4; /* Contributing sources count */ - uint16_t ma: 1; /* Marker */ - uint16_t pt: 7; /* Payload type */ + unsigned ma: 1; /* Marker */ + unsigned pt: 7; /* Payload type */ #endif uint16_t sequnum; -- cgit v1.2.3