From cac2dde2181be6f6873910f85304596cb6374c22 Mon Sep 17 00:00:00 2001 From: Frank Denis Date: Thu, 23 Feb 2017 11:24:48 +0100 Subject: [PATCH] Indent --- test/default/sodium_core.c | 17 +++--- test/default/sodium_utils.c | 98 +++++++++++++++++++---------------- test/default/sodium_utils2.c | 18 ++++--- test/default/sodium_utils3.c | 14 ++--- test/default/sodium_version.c | 3 +- 5 files changed, 81 insertions(+), 69 deletions(-) diff --git a/test/default/sodium_core.c b/test/default/sodium_core.c index b177f0d9..7f957759 100644 --- a/test/default/sodium_core.c +++ b/test/default/sodium_core.c @@ -2,17 +2,18 @@ #define TEST_NAME "sodium_core" #include "cmptest.h" -int main(void) +int +main(void) { printf("%d\n", sodium_init()); - (void)sodium_runtime_has_neon(); - (void)sodium_runtime_has_sse2(); - (void)sodium_runtime_has_sse3(); - (void)sodium_runtime_has_ssse3(); - (void)sodium_runtime_has_sse41(); - (void)sodium_runtime_has_pclmul(); - (void)sodium_runtime_has_aesni(); + (void) sodium_runtime_has_neon(); + (void) sodium_runtime_has_sse2(); + (void) sodium_runtime_has_sse3(); + (void) sodium_runtime_has_ssse3(); + (void) sodium_runtime_has_sse41(); + (void) sodium_runtime_has_pclmul(); + (void) sodium_runtime_has_aesni(); return 0; } diff --git a/test/default/sodium_utils.c b/test/default/sodium_utils.c index 1583d204..b9b93d53 100644 --- a/test/default/sodium_utils.c +++ b/test/default/sodium_utils.c @@ -1,22 +1,23 @@ #define TEST_NAME "sodium_utils" #include "cmptest.h" -int main(void) +int +main(void) { - unsigned char buf_add[1000]; - unsigned char buf1[1000]; - unsigned char buf2[1000]; - unsigned char buf1_rev[1000]; - unsigned char buf2_rev[1000]; - char buf3[33]; - unsigned char buf4[4]; - unsigned char nonce[24]; - char nonce_hex[49]; - const char *hex; - const char *hex_end; - size_t bin_len; - unsigned int i; - unsigned int j; + unsigned char buf_add[1000]; + unsigned char buf1[1000]; + unsigned char buf2[1000]; + unsigned char buf1_rev[1000]; + unsigned char buf2_rev[1000]; + char buf3[33]; + unsigned char buf4[4]; + unsigned char nonce[24]; + char nonce_hex[49]; + const char * hex; + const char * hex_end; + size_t bin_len; + unsigned int i; + unsigned int j; randombytes_buf(buf1, sizeof buf1); memcpy(buf2, buf1, sizeof buf2); @@ -29,17 +30,18 @@ int main(void) sodium_memzero(buf2, sizeof buf2 / 2); printf("%d\n", sodium_memcmp(buf1, buf2, sizeof buf1)); printf("%s\n", - sodium_bin2hex(buf3, 33U, (const unsigned char *)"0123456789ABCDEF", + sodium_bin2hex(buf3, 33U, (const unsigned char *) "0123456789ABCDEF", 16U)); hex = "Cafe : 6942"; - sodium_hex2bin(buf4, sizeof buf4, hex, strlen(hex), ": ", &bin_len, &hex_end); - printf("%lu:%02x%02x%02x%02x\n", (unsigned long)bin_len, buf4[0], buf4[1], + sodium_hex2bin(buf4, sizeof buf4, hex, strlen(hex), ": ", &bin_len, + &hex_end); + printf("%lu:%02x%02x%02x%02x\n", (unsigned long) bin_len, buf4[0], buf4[1], buf4[2], buf4[3]); printf("dt1: %ld\n", (long) (hex_end - hex)); hex = "Cafe : 6942"; sodium_hex2bin(buf4, sizeof buf4, hex, strlen(hex), ": ", &bin_len, NULL); - printf("%lu:%02x%02x%02x%02x\n", (unsigned long)bin_len, buf4[2], buf4[3], + printf("%lu:%02x%02x%02x%02x\n", (unsigned long) bin_len, buf4[2], buf4[3], buf4[2], buf4[3]); hex = "deadbeef"; @@ -50,43 +52,47 @@ int main(void) hex = "de:ad:be:eff"; if (sodium_hex2bin(buf1, 4U, hex, 12U, ":", &bin_len, &hex_end) != -1) { - printf("sodium_hex2bin() with an odd input length and a short output buffer\n"); + printf( + "sodium_hex2bin() with an odd input length and a short output " + "buffer\n"); } printf("dt3: %ld\n", (long) (hex_end - hex)); hex = "de:ad:be:eff"; - if (sodium_hex2bin(buf1, sizeof buf1, hex, 12U, ":", &bin_len, &hex_end) != 0) { + if (sodium_hex2bin(buf1, sizeof buf1, hex, 12U, ":", &bin_len, &hex_end) != + 0) { printf("sodium_hex2bin() with an odd input length\n"); } printf("dt4: %ld\n", (long) (hex_end - hex)); hex = "de:ad:be:eff"; - if (sodium_hex2bin(buf1, sizeof buf1, hex, 13U, ":", &bin_len, &hex_end) != 0) { + if (sodium_hex2bin(buf1, sizeof buf1, hex, 13U, ":", &bin_len, &hex_end) != + 0) { printf("sodium_hex2bin() with an odd input length\n"); } printf("dt5: %ld\n", (long) (hex_end - hex)); memset(nonce, 0, sizeof nonce); sodium_increment(nonce, sizeof nonce); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); memset(nonce, 255, sizeof nonce); sodium_increment(nonce, sizeof nonce); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); nonce[1] = 1U; sodium_increment(nonce, sizeof nonce); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); nonce[1] = 0U; sodium_increment(nonce, sizeof nonce); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); nonce[0] = 255U; nonce[2] = 255U; sodium_increment(nonce, sizeof nonce); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); for (i = 0U; i < 1000U; i++) { bin_len = (size_t) randombytes_uniform(sizeof buf1); randombytes_buf(buf1, bin_len); @@ -96,7 +102,8 @@ int main(void) buf2_rev[bin_len - 1 - j] = buf2[j]; } if (memcmp(buf1_rev, buf2_rev, bin_len) * - sodium_compare(buf1, buf2, bin_len) < 0) { + sodium_compare(buf1, buf2, bin_len) < + 0) { printf("sodium_compare() failure with length=%u\n", (unsigned int) bin_len); } @@ -146,37 +153,36 @@ int main(void) memset(nonce, 0xfe, 24U); memset(nonce, 0xff, 6U); sodium_increment(nonce, 8U); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); memset(nonce, 0xfe, 24U); memset(nonce, 0xff, 10U); sodium_increment(nonce, 12U); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); memset(nonce, 0xff, 22U); sodium_increment(nonce, 24U); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); - + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); assert(sizeof nonce >= 24U); memset(nonce, 0xfe, 24U); memset(nonce, 0xff, 6U); sodium_add(nonce, nonce, 7U); sodium_add(nonce, nonce, 8U); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); memset(nonce, 0xfe, 24U); memset(nonce, 0xff, 10U); sodium_add(nonce, nonce, 11U); sodium_add(nonce, nonce, 12U); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); memset(nonce, 0xff, 22U); sodium_add(nonce, nonce, 23U); sodium_add(nonce, nonce, 24U); - printf("%s\n", sodium_bin2hex(nonce_hex, sizeof nonce_hex, - nonce, sizeof nonce)); + printf("%s\n", + sodium_bin2hex(nonce_hex, sizeof nonce_hex, nonce, sizeof nonce)); return 0; } diff --git a/test/default/sodium_utils2.c b/test/default/sodium_utils2.c index d6dc8005..e688a3ba 100644 --- a/test/default/sodium_utils2.c +++ b/test/default/sodium_utils2.c @@ -9,10 +9,11 @@ #include "cmptest.h" #ifdef __SANITIZE_ADDRESS__ -# warning The sodium_utils2 test is expected to fail with address sanitizer +#warning The sodium_utils2 test is expected to fail with address sanitizer #endif -__attribute__ ((noreturn)) static void segv_handler(int sig) +__attribute__((noreturn)) static void +segv_handler(int sig) { (void) sig; @@ -30,10 +31,11 @@ __attribute__ ((noreturn)) static void segv_handler(int sig) exit(0); } -int main(void) +int +main(void) { - void *buf; - size_t size; + void * buf; + size_t size; unsigned int i; if (sodium_malloc(SIZE_MAX - 1U) != NULL) { @@ -57,7 +59,7 @@ int main(void) sodium_free(NULL); for (i = 0U; i < 10000U; i++) { size = 1U + randombytes_uniform(100000U); - buf = sodium_malloc(size); + buf = sodium_malloc(size); assert(buf != NULL); memset(buf, i, size); sodium_mprotect_noaccess(buf); @@ -75,12 +77,12 @@ int main(void) signal(SIGABRT, segv_handler); #endif size = 1U + randombytes_uniform(100000U); - buf = sodium_malloc(size); + buf = sodium_malloc(size); assert(buf != NULL); sodium_mprotect_readonly(buf); sodium_mprotect_readwrite(buf); #ifndef __EMSCRIPTEN__ - sodium_memzero(((unsigned char *)buf) + size, 1U); + sodium_memzero(((unsigned char *) buf) + size, 1U); sodium_mprotect_noaccess(buf); sodium_free(buf); printf("Overflow not caught\n"); diff --git a/test/default/sodium_utils3.c b/test/default/sodium_utils3.c index 603cf757..0bb98f26 100644 --- a/test/default/sodium_utils3.c +++ b/test/default/sodium_utils3.c @@ -9,10 +9,11 @@ #include "cmptest.h" #ifdef __SANITIZE_ADDRESS__ -# warning The sodium_utils3 test is expected to fail with address sanitizer +#warning The sodium_utils3 test is expected to fail with address sanitizer #endif -__attribute__ ((noreturn)) static void segv_handler(int sig) +__attribute__((noreturn)) static void +segv_handler(int sig) { (void) sig; @@ -30,9 +31,10 @@ __attribute__ ((noreturn)) static void segv_handler(int sig) exit(0); } -int main(void) +int +main(void) { - void *buf; + void * buf; size_t size; #ifdef SIGSEGV @@ -45,12 +47,12 @@ int main(void) signal(SIGABRT, segv_handler); #endif size = 1U + randombytes_uniform(100000U); - buf = sodium_malloc(size); + buf = sodium_malloc(size); assert(buf != NULL); sodium_mprotect_noaccess(buf); sodium_mprotect_readwrite(buf); #ifndef __EMSCRIPTEN__ - sodium_memzero(((unsigned char *)buf) - 8, 8U); + sodium_memzero(((unsigned char *) buf) - 8, 8U); sodium_mprotect_readonly(buf); sodium_free(buf); printf("Underflow not caught\n"); diff --git a/test/default/sodium_version.c b/test/default/sodium_version.c index d32fd799..1f9e335a 100644 --- a/test/default/sodium_version.c +++ b/test/default/sodium_version.c @@ -2,7 +2,8 @@ #define TEST_NAME "sodium_version" #include "cmptest.h" -int main(void) +int +main(void) { printf("%d\n", sodium_version_string() != NULL); printf("%d\n", sodium_library_version_major() > 0);