diff options
author | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 19:12:19 +0100 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2016-08-31 20:04:16 +0100 |
commit | 633da98ae69866efb195e00d9a3a22ace6bada66 (patch) | |
tree | 875535f3d2257c4ea5bb97a553b2f1beab4a1590 /auto_tests/TCP_test.c | |
parent | 6356eb4e4fe407fa7870f2a685d0d08b5c2ec5bb (diff) |
Add braces to all if statements.
Diffstat (limited to 'auto_tests/TCP_test.c')
-rw-r--r-- | auto_tests/TCP_test.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/auto_tests/TCP_test.c b/auto_tests/TCP_test.c index 06049467..2721fbd2 100644 --- a/auto_tests/TCP_test.c +++ b/auto_tests/TCP_test.c | |||
@@ -190,8 +190,9 @@ int write_packet_TCP_secure_connection(struct sec_TCP_con *con, uint8_t *data, u | |||
190 | memcpy(packet, &c_length, sizeof(uint16_t)); | 190 | memcpy(packet, &c_length, sizeof(uint16_t)); |
191 | int len = encrypt_data_symmetric(con->shared_key, con->sent_nonce, data, length, packet + sizeof(uint16_t)); | 191 | int len = encrypt_data_symmetric(con->shared_key, con->sent_nonce, data, length, packet + sizeof(uint16_t)); |
192 | 192 | ||
193 | if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) | 193 | if ((unsigned int)len != (sizeof(packet) - sizeof(uint16_t))) { |
194 | return -1; | 194 | return -1; |
195 | } | ||
195 | 196 | ||
196 | increment_nonce(con->sent_nonce); | 197 | increment_nonce(con->sent_nonce); |
197 | 198 | ||
@@ -309,8 +310,9 @@ static uint8_t response_callback_connection_id; | |||
309 | static uint8_t response_callback_public_key[crypto_box_PUBLICKEYBYTES]; | 310 | static uint8_t response_callback_public_key[crypto_box_PUBLICKEYBYTES]; |
310 | static int response_callback(void *object, uint8_t connection_id, const uint8_t *public_key) | 311 | static int response_callback(void *object, uint8_t connection_id, const uint8_t *public_key) |
311 | { | 312 | { |
312 | if (set_tcp_connection_number(object - 2, connection_id, 7) != 0) | 313 | if (set_tcp_connection_number(object - 2, connection_id, 7) != 0) { |
313 | return 1; | 314 | return 1; |
315 | } | ||
314 | 316 | ||
315 | response_callback_connection_id = connection_id; | 317 | response_callback_connection_id = connection_id; |
316 | memcpy(response_callback_public_key, public_key, crypto_box_PUBLICKEYBYTES); | 318 | memcpy(response_callback_public_key, public_key, crypto_box_PUBLICKEYBYTES); |
@@ -322,11 +324,13 @@ static uint8_t status_callback_connection_id; | |||
322 | static uint8_t status_callback_status; | 324 | static uint8_t status_callback_status; |
323 | static int status_callback(void *object, uint32_t number, uint8_t connection_id, uint8_t status) | 325 | static int status_callback(void *object, uint32_t number, uint8_t connection_id, uint8_t status) |
324 | { | 326 | { |
325 | if (object != (void *)2) | 327 | if (object != (void *)2) { |
326 | return 1; | 328 | return 1; |
329 | } | ||
327 | 330 | ||
328 | if (number != 7) | 331 | if (number != 7) { |
329 | return 1; | 332 | return 1; |
333 | } | ||
330 | 334 | ||
331 | status_callback_connection_id = connection_id; | 335 | status_callback_connection_id = connection_id; |
332 | status_callback_status = status; | 336 | status_callback_status = status; |
@@ -337,14 +341,17 @@ static int data_callback_good; | |||
337 | static int data_callback(void *object, uint32_t number, uint8_t connection_id, const uint8_t *data, uint16_t length, | 341 | static int data_callback(void *object, uint32_t number, uint8_t connection_id, const uint8_t *data, uint16_t length, |
338 | void *userdata) | 342 | void *userdata) |
339 | { | 343 | { |
340 | if (object != (void *)3) | 344 | if (object != (void *)3) { |
341 | return 1; | 345 | return 1; |
346 | } | ||
342 | 347 | ||
343 | if (number != 7) | 348 | if (number != 7) { |
344 | return 1; | 349 | return 1; |
350 | } | ||
345 | 351 | ||
346 | if (length != 5) | 352 | if (length != 5) { |
347 | return 1; | 353 | return 1; |
354 | } | ||
348 | 355 | ||
349 | if (data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4 && data[4] == 5) { | 356 | if (data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4 && data[4] == 5) { |
350 | data_callback_good++; | 357 | data_callback_good++; |
@@ -359,14 +366,17 @@ static uint8_t oob_pubkey[crypto_box_PUBLICKEYBYTES]; | |||
359 | static int oob_data_callback(void *object, const uint8_t *public_key, const uint8_t *data, uint16_t length, | 366 | static int oob_data_callback(void *object, const uint8_t *public_key, const uint8_t *data, uint16_t length, |
360 | void *userdata) | 367 | void *userdata) |
361 | { | 368 | { |
362 | if (object != (void *)4) | 369 | if (object != (void *)4) { |
363 | return 1; | 370 | return 1; |
371 | } | ||
364 | 372 | ||
365 | if (length != 5) | 373 | if (length != 5) { |
366 | return 1; | 374 | return 1; |
375 | } | ||
367 | 376 | ||
368 | if (public_key_cmp(public_key, oob_pubkey) != 0) | 377 | if (public_key_cmp(public_key, oob_pubkey) != 0) { |
369 | return 1; | 378 | return 1; |
379 | } | ||
370 | 380 | ||
371 | if (data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4 && data[4] == 5) { | 381 | if (data[0] == 1 && data[1] == 2 && data[2] == 3 && data[3] == 4 && data[4] == 5) { |
372 | oob_data_callback_good++; | 382 | oob_data_callback_good++; |
@@ -515,17 +525,21 @@ END_TEST | |||
515 | _Bool tcp_data_callback_called; | 525 | _Bool tcp_data_callback_called; |
516 | static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t length, void *userdata) | 526 | static int tcp_data_callback(void *object, int id, const uint8_t *data, uint16_t length, void *userdata) |
517 | { | 527 | { |
518 | if (object != (void *)120397) | 528 | if (object != (void *)120397) { |
519 | return -1; | 529 | return -1; |
530 | } | ||
520 | 531 | ||
521 | if (id != 123) | 532 | if (id != 123) { |
522 | return -1; | 533 | return -1; |
534 | } | ||
523 | 535 | ||
524 | if (length != 6) | 536 | if (length != 6) { |
525 | return -1; | 537 | return -1; |
538 | } | ||
526 | 539 | ||
527 | if (memcmp(data, "Gentoo", length) != 0) | 540 | if (memcmp(data, "Gentoo", length) != 0) { |
528 | return -1; | 541 | return -1; |
542 | } | ||
529 | 543 | ||
530 | tcp_data_callback_called = 1; | 544 | tcp_data_callback_called = 1; |
531 | return 0; | 545 | return 0; |
@@ -621,14 +635,17 @@ _Bool tcp_oobdata_callback_called; | |||
621 | static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data, | 635 | static int tcp_oobdata_callback(void *object, const uint8_t *public_key, unsigned int id, const uint8_t *data, |
622 | uint16_t length) | 636 | uint16_t length) |
623 | { | 637 | { |
624 | if (length != 6) | 638 | if (length != 6) { |
625 | return -1; | 639 | return -1; |
640 | } | ||
626 | 641 | ||
627 | if (memcmp(data, "Gentoo", length) != 0) | 642 | if (memcmp(data, "Gentoo", length) != 0) { |
628 | return -1; | 643 | return -1; |
644 | } | ||
629 | 645 | ||
630 | if (tcp_send_oob_packet(object, id, public_key, data, length) == 0) | 646 | if (tcp_send_oob_packet(object, id, public_key, data, length) == 0) { |
631 | tcp_oobdata_callback_called = 1; | 647 | tcp_oobdata_callback_called = 1; |
648 | } | ||
632 | 649 | ||
633 | return 0; | 650 | return 0; |
634 | } | 651 | } |