summaryrefslogtreecommitdiff
path: root/toxcore/crypto_core_mem.c
diff options
context:
space:
mode:
authoriphydf <iphydf@users.noreply.github.com>2020-04-09 23:56:19 +0000
committeriphydf <iphydf@users.noreply.github.com>2020-04-16 11:05:08 +0000
commitc08b2fb3e2c3c8e8a5722e7350b61efd6992be45 (patch)
treebc6f5738bb6a948146cedb612cc12abb3e158fb4 /toxcore/crypto_core_mem.c
parent7f9f8045cd6f8d92559cdc9f7d297cf92e960e49 (diff)
Remove tokstyle exemptions from build files.
We put some tokstyle exemptions into the source files themselves, instead. This way we can check some of the code in those files, and more in the future when tokstyle supports more constructs (like apidsl). Also: hacked ping_array.api.h to not emit `_array` as parameter names. We'll need to fix apidsl to do this better. This works for now.
Diffstat (limited to 'toxcore/crypto_core_mem.c')
-rw-r--r--toxcore/crypto_core_mem.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/toxcore/crypto_core_mem.c b/toxcore/crypto_core_mem.c
index b8f4223e..b8c0bd9b 100644
--- a/toxcore/crypto_core_mem.c
+++ b/toxcore/crypto_core_mem.c
@@ -37,8 +37,7 @@ void crypto_memzero(void *data, size_t length)
37{ 37{
38#ifndef VANILLA_NACL 38#ifndef VANILLA_NACL
39 sodium_memzero(data, length); 39 sodium_memzero(data, length);
40#else 40#elif defined(_WIN32)
41#ifdef _WIN32
42 SecureZeroMemory(data, length); 41 SecureZeroMemory(data, length);
43#elif defined(HAVE_MEMSET_S) 42#elif defined(HAVE_MEMSET_S)
44 43
@@ -53,32 +52,33 @@ void crypto_memzero(void *data, size_t length)
53#elif defined(HAVE_EXPLICIT_BZERO) 52#elif defined(HAVE_EXPLICIT_BZERO)
54 explicit_bzero(data, length); 53 explicit_bzero(data, length);
55#else 54#else
56 volatile unsigned char *volatile pnt = 55 //!TOKSTYLE-
57 (volatile unsigned char *volatile) data; 56 volatile uint8_t *volatile pnt = data;
57 //!TOKSTYLE+
58 size_t i = (size_t) 0U; 58 size_t i = (size_t) 0U;
59 59
60 while (i < length) { 60 while (i < length) {
61 pnt[i++] = 0U; 61 pnt[i] = 0U;
62 ++i;
62 } 63 }
63 64
64#endif 65#endif
65#endif
66} 66}
67 67
68int32_t crypto_memcmp(const void *p1, const void *p2, size_t length) 68int32_t crypto_memcmp(const uint8_t *p1, const uint8_t *p2, size_t length)
69{ 69{
70#ifndef VANILLA_NACL 70#ifndef VANILLA_NACL
71 return sodium_memcmp(p1, p2, length); 71 return sodium_memcmp(p1, p2, length);
72#else 72#else
73 const volatile unsigned char *volatile b1 = 73 //!TOKSTYLE-
74 (const volatile unsigned char *volatile) p1; 74 const volatile uint8_t *volatile b1 = p1;
75 const volatile unsigned char *volatile b2 = 75 const volatile uint8_t *volatile b2 = p2;
76 (const volatile unsigned char *volatile) p2; 76 //!TOKSTYLE+
77 77
78 size_t i; 78 size_t i;
79 unsigned char d = (unsigned char) 0U; 79 uint8_t d = (uint8_t) 0U;
80 80
81 for (i = 0U; i < length; i++) { 81 for (i = 0U; i < length; ++i) {
82 d |= b1[i] ^ b2[i]; 82 d |= b1[i] ^ b2[i];
83 } 83 }
84 84