summaryrefslogtreecommitdiff
path: root/auto_tests/TCP_test.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2016-09-05 14:43:58 +0100
committeriphydf <iphydf@users.noreply.github.com>2016-09-06 11:09:10 +0100
commit5b57ab6332edc407524a353d3965a4870c33fe00 (patch)
tree238659ca8e218307fff1476d427c94194bc24fad /auto_tests/TCP_test.c
parentaad1e0ad3f96786e0fb10d8dd144e5e6ebe93258 (diff)
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.
Diffstat (limited to 'auto_tests/TCP_test.c')
-rw-r--r--auto_tests/TCP_test.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c
index 8e6adf2e..d7312be8 100644
--- a/auto_tests/TCP_test.c
+++ b/auto_tests/TCP_test.c
@@ -310,7 +310,7 @@ static uint8_t response_callback_connection_id;
310static uint8_t response_callback_public_key[crypto_box_PUBLICKEYBYTES]; 310static uint8_t response_callback_public_key[crypto_box_PUBLICKEYBYTES];
311static int response_callback(void *object, uint8_t connection_id, const uint8_t *public_key) 311static int response_callback(void *object, uint8_t connection_id, const uint8_t *public_key)
312{ 312{
313 if (set_tcp_connection_number(object - 2, connection_id, 7) != 0) { 313 if (set_tcp_connection_number((TCP_Client_Connection *)((char *)object - 2), connection_id, 7) != 0) {
314 return 1; 314 return 1;
315 } 315 }
316 316
@@ -433,7 +433,7 @@ START_TEST(test_client)
433 crypto_box_keypair(f2_public_key, f2_secret_key); 433 crypto_box_keypair(f2_public_key, f2_secret_key);
434 ip_port_tcp_s.port = htons(ports[rand() % NUM_PORTS]); 434 ip_port_tcp_s.port = htons(ports[rand() % NUM_PORTS]);
435 TCP_Client_Connection *conn2 = new_TCP_connection(ip_port_tcp_s, self_public_key, f2_public_key, f2_secret_key, 0); 435 TCP_Client_Connection *conn2 = new_TCP_connection(ip_port_tcp_s, self_public_key, f2_public_key, f2_secret_key, 0);
436 routing_response_handler(conn, response_callback, ((void *)conn) + 2); 436 routing_response_handler(conn, response_callback, (char *)conn + 2);
437 routing_status_handler(conn, status_callback, (void *)2); 437 routing_status_handler(conn, status_callback, (void *)2);
438 routing_data_handler(conn, data_callback, (void *)3); 438 routing_data_handler(conn, data_callback, (void *)3);
439 oob_data_handler(conn, oob_data_callback, (void *)4); 439 oob_data_handler(conn, oob_data_callback, (void *)4);