diff options
author | iphydf <iphydf@users.noreply.github.com> | 2020-04-09 23:56:19 +0000 |
---|---|---|
committer | iphydf <iphydf@users.noreply.github.com> | 2020-04-16 11:05:08 +0000 |
commit | c08b2fb3e2c3c8e8a5722e7350b61efd6992be45 (patch) | |
tree | bc6f5738bb6a948146cedb612cc12abb3e158fb4 | |
parent | 7f9f8045cd6f8d92559cdc9f7d297cf92e960e49 (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.
-rw-r--r-- | toxav/BUILD.bazel | 7 | ||||
-rw-r--r-- | toxav/toxav.api.h | 4 | ||||
-rw-r--r-- | toxav/toxav.h | 4 | ||||
-rw-r--r-- | toxcore/BUILD.bazel | 9 | ||||
-rw-r--r-- | toxcore/ccompat.h | 4 | ||||
-rw-r--r-- | toxcore/crypto_core.api.h | 2 | ||||
-rw-r--r-- | toxcore/crypto_core.h | 2 | ||||
-rw-r--r-- | toxcore/crypto_core_mem.c | 26 | ||||
-rw-r--r-- | toxcore/crypto_core_test.cc | 40 | ||||
-rw-r--r-- | toxcore/ping_array.api.h | 4 | ||||
-rw-r--r-- | toxcore/ping_array.h | 6 | ||||
-rw-r--r-- | toxcore/tox.api.h | 4 | ||||
-rw-r--r-- | toxcore/tox.h | 4 | ||||
-rw-r--r-- | toxcore/tox_api.c | 3 | ||||
-rw-r--r-- | toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c | 2 | ||||
-rw-r--r-- | toxencryptsave/defines.h | 2 |
16 files changed, 67 insertions, 56 deletions
diff --git a/toxav/BUILD.bazel b/toxav/BUILD.bazel index 33956aac..036bde3f 100644 --- a/toxav/BUILD.bazel +++ b/toxav/BUILD.bazel | |||
@@ -45,8 +45,8 @@ cc_library( | |||
45 | hdrs = ["bwcontroller.h"], | 45 | hdrs = ["bwcontroller.h"], |
46 | deps = [ | 46 | deps = [ |
47 | ":ring_buffer", | 47 | ":ring_buffer", |
48 | "//c-toxcore/toxcore", | ||
48 | "//c-toxcore/toxcore:Messenger", | 49 | "//c-toxcore/toxcore:Messenger", |
49 | "//c-toxcore/toxcore:toxcore", | ||
50 | ], | 50 | ], |
51 | ) | 51 | ) |
52 | 52 | ||
@@ -130,10 +130,7 @@ CIMPLE_SRCS = glob( | |||
130 | "*.c", | 130 | "*.c", |
131 | "*.h", | 131 | "*.h", |
132 | ], | 132 | ], |
133 | exclude = [ | 133 | exclude = ["*.api.h"], |
134 | "*.api.h", | ||
135 | "toxav.h", | ||
136 | ], | ||
137 | ) | 134 | ) |
138 | 135 | ||
139 | sh_test( | 136 | sh_test( |
diff --git a/toxav/toxav.api.h b/toxav/toxav.api.h index 158f74e6..269fd3d7 100644 --- a/toxav/toxav.api.h +++ b/toxav/toxav.api.h | |||
@@ -10,6 +10,8 @@ | |||
10 | #include <stddef.h> | 10 | #include <stddef.h> |
11 | #include <stdint.h> | 11 | #include <stdint.h> |
12 | 12 | ||
13 | //!TOKSTYLE- | ||
14 | |||
13 | #ifdef __cplusplus | 15 | #ifdef __cplusplus |
14 | extern "C" { | 16 | extern "C" { |
15 | #endif | 17 | #endif |
@@ -686,5 +688,7 @@ typedef TOXAV_ERR_BIT_RATE_SET Toxav_Err_Bit_Rate_Set; | |||
686 | typedef TOXAV_ERR_SEND_FRAME Toxav_Err_Send_Frame; | 688 | typedef TOXAV_ERR_SEND_FRAME Toxav_Err_Send_Frame; |
687 | typedef TOXAV_CALL_CONTROL Toxav_Call_Control; | 689 | typedef TOXAV_CALL_CONTROL Toxav_Call_Control; |
688 | 690 | ||
691 | //!TOKSTYLE+ | ||
692 | |||
689 | #endif // C_TOXCORE_TOXAV_TOXAV_H | 693 | #endif // C_TOXCORE_TOXAV_TOXAV_H |
690 | %} | 694 | %} |
diff --git a/toxav/toxav.h b/toxav/toxav.h index 141ccb89..a96c85cb 100644 --- a/toxav/toxav.h +++ b/toxav/toxav.h | |||
@@ -9,6 +9,8 @@ | |||
9 | #include <stddef.h> | 9 | #include <stddef.h> |
10 | #include <stdint.h> | 10 | #include <stdint.h> |
11 | 11 | ||
12 | //!TOKSTYLE- | ||
13 | |||
12 | #ifdef __cplusplus | 14 | #ifdef __cplusplus |
13 | extern "C" { | 15 | extern "C" { |
14 | #endif | 16 | #endif |
@@ -815,4 +817,6 @@ typedef TOXAV_ERR_BIT_RATE_SET Toxav_Err_Bit_Rate_Set; | |||
815 | typedef TOXAV_ERR_SEND_FRAME Toxav_Err_Send_Frame; | 817 | typedef TOXAV_ERR_SEND_FRAME Toxav_Err_Send_Frame; |
816 | typedef TOXAV_CALL_CONTROL Toxav_Call_Control; | 818 | typedef TOXAV_CALL_CONTROL Toxav_Call_Control; |
817 | 819 | ||
820 | //!TOKSTYLE+ | ||
821 | |||
818 | #endif // C_TOXCORE_TOXAV_TOXAV_H | 822 | #endif // C_TOXCORE_TOXAV_TOXAV_H |
diff --git a/toxcore/BUILD.bazel b/toxcore/BUILD.bazel index 2a9b4ff2..403fa7e8 100644 --- a/toxcore/BUILD.bazel +++ b/toxcore/BUILD.bazel | |||
@@ -286,14 +286,7 @@ CIMPLE_SRCS = glob( | |||
286 | "*.c", | 286 | "*.c", |
287 | "*.h", | 287 | "*.h", |
288 | ], | 288 | ], |
289 | exclude = [ | 289 | exclude = ["*.api.h"], |
290 | "*.api.h", | ||
291 | "ccompat.h", | ||
292 | "crypto_core_mem.c", | ||
293 | "ping_array.h", | ||
294 | "tox.h", | ||
295 | "tox_api.c", | ||
296 | ], | ||
297 | ) | 290 | ) |
298 | 291 | ||
299 | sh_test( | 292 | sh_test( |
diff --git a/toxcore/ccompat.h b/toxcore/ccompat.h index ba8c7fe8..8ff6563d 100644 --- a/toxcore/ccompat.h +++ b/toxcore/ccompat.h | |||
@@ -4,6 +4,8 @@ | |||
4 | #ifndef C_TOXCORE_TOXCORE_CCOMPAT_H | 4 | #ifndef C_TOXCORE_TOXCORE_CCOMPAT_H |
5 | #define C_TOXCORE_TOXCORE_CCOMPAT_H | 5 | #define C_TOXCORE_TOXCORE_CCOMPAT_H |
6 | 6 | ||
7 | //!TOKSTYLE- | ||
8 | |||
7 | // Variable length arrays. | 9 | // Variable length arrays. |
8 | // VLA(type, name, size) allocates a variable length array with automatic | 10 | // VLA(type, name, size) allocates a variable length array with automatic |
9 | // storage duration. VLA_SIZE(name) evaluates to the runtime size of that array | 11 | // storage duration. VLA_SIZE(name) evaluates to the runtime size of that array |
@@ -48,4 +50,6 @@ | |||
48 | #define GNU_PRINTF(f, a) | 50 | #define GNU_PRINTF(f, a) |
49 | #endif | 51 | #endif |
50 | 52 | ||
53 | //!TOKSTYLE+ | ||
54 | |||
51 | #endif // C_TOXCORE_TOXCORE_CCOMPAT_H | 55 | #endif // C_TOXCORE_TOXCORE_CCOMPAT_H |
diff --git a/toxcore/crypto_core.api.h b/toxcore/crypto_core.api.h index 44f541fc..0db3a420 100644 --- a/toxcore/crypto_core.api.h +++ b/toxcore/crypto_core.api.h | |||
@@ -69,7 +69,7 @@ const CRYPTO_SHA512_SIZE = 64; | |||
69 | * "aaaa" and "baaa" also takes 4 time. With a regular `memcmp`, the latter may | 69 | * "aaaa" and "baaa" also takes 4 time. With a regular `memcmp`, the latter may |
70 | * take 1 time, because it immediately knows that the two strings are not equal. | 70 | * take 1 time, because it immediately knows that the two strings are not equal. |
71 | */ | 71 | */ |
72 | static int32_t crypto_memcmp(const void *p1, const void *p2, size_t length); | 72 | static int32_t crypto_memcmp(const uint8_t *p1, const uint8_t *p2, size_t length); |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * A `bzero`-like function which won't be optimised away by the compiler. Some | 75 | * A `bzero`-like function which won't be optimised away by the compiler. Some |
diff --git a/toxcore/crypto_core.h b/toxcore/crypto_core.h index 07412e7e..425c3244 100644 --- a/toxcore/crypto_core.h +++ b/toxcore/crypto_core.h | |||
@@ -83,7 +83,7 @@ uint32_t crypto_sha512_size(void); | |||
83 | * "aaaa" and "baaa" also takes 4 time. With a regular `memcmp`, the latter may | 83 | * "aaaa" and "baaa" also takes 4 time. With a regular `memcmp`, the latter may |
84 | * take 1 time, because it immediately knows that the two strings are not equal. | 84 | * take 1 time, because it immediately knows that the two strings are not equal. |
85 | */ | 85 | */ |
86 | int32_t crypto_memcmp(const void *p1, const void *p2, size_t length); | 86 | int32_t crypto_memcmp(const uint8_t *p1, const uint8_t *p2, size_t length); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * A `bzero`-like function which won't be optimised away by the compiler. Some | 89 | * A `bzero`-like function which won't be optimised away by the compiler. Some |
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 | ||
68 | int32_t crypto_memcmp(const void *p1, const void *p2, size_t length) | 68 | int32_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 | ||
diff --git a/toxcore/crypto_core_test.cc b/toxcore/crypto_core_test.cc index ee3cb366..66569506 100644 --- a/toxcore/crypto_core_test.cc +++ b/toxcore/crypto_core_test.cc | |||
@@ -1,6 +1,7 @@ | |||
1 | #include "crypto_core.h" | 1 | #include "crypto_core.h" |
2 | 2 | ||
3 | #include <algorithm> | 3 | #include <algorithm> |
4 | #include <vector> | ||
4 | 5 | ||
5 | #include <gtest/gtest.h> | 6 | #include <gtest/gtest.h> |
6 | 7 | ||
@@ -29,7 +30,7 @@ enum { | |||
29 | CRYPTO_TEST_MEMCMP_EPS = 10, | 30 | CRYPTO_TEST_MEMCMP_EPS = 10, |
30 | }; | 31 | }; |
31 | 32 | ||
32 | clock_t memcmp_time(void *a, void *b, size_t len) { | 33 | clock_t memcmp_time(uint8_t const *a, uint8_t const *b, size_t len) { |
33 | clock_t start = clock(); | 34 | clock_t start = clock(); |
34 | volatile int result = crypto_memcmp(a, b, len); | 35 | volatile int result = crypto_memcmp(a, b, len); |
35 | (void)result; | 36 | (void)result; |
@@ -41,8 +42,8 @@ clock_t memcmp_time(void *a, void *b, size_t len) { | |||
41 | * equal and non-equal arrays to reduce the influence of external effects | 42 | * equal and non-equal arrays to reduce the influence of external effects |
42 | * such as the machine being a little more busy 1 second later. | 43 | * such as the machine being a little more busy 1 second later. |
43 | */ | 44 | */ |
44 | void memcmp_median(void *src, void *same, void *not_same, size_t len, clock_t *same_median, | 45 | std::pair<clock_t, clock_t> memcmp_median(uint8_t const *src, uint8_t const *same, |
45 | clock_t *not_same_median) { | 46 | uint8_t const *not_same, size_t len) { |
46 | clock_t same_results[CRYPTO_TEST_MEMCMP_ITERATIONS]; | 47 | clock_t same_results[CRYPTO_TEST_MEMCMP_ITERATIONS]; |
47 | clock_t not_same_results[CRYPTO_TEST_MEMCMP_ITERATIONS]; | 48 | clock_t not_same_results[CRYPTO_TEST_MEMCMP_ITERATIONS]; |
48 | 49 | ||
@@ -52,9 +53,10 @@ void memcmp_median(void *src, void *same, void *not_same, size_t len, clock_t *s | |||
52 | } | 53 | } |
53 | 54 | ||
54 | std::sort(same_results, same_results + CRYPTO_TEST_MEMCMP_ITERATIONS); | 55 | std::sort(same_results, same_results + CRYPTO_TEST_MEMCMP_ITERATIONS); |
55 | *same_median = same_results[CRYPTO_TEST_MEMCMP_ITERATIONS / 2]; | 56 | clock_t const same_median = same_results[CRYPTO_TEST_MEMCMP_ITERATIONS / 2]; |
56 | std::sort(not_same_results, not_same_results + CRYPTO_TEST_MEMCMP_ITERATIONS); | 57 | std::sort(not_same_results, not_same_results + CRYPTO_TEST_MEMCMP_ITERATIONS); |
57 | *not_same_median = not_same_results[CRYPTO_TEST_MEMCMP_ITERATIONS / 2]; | 58 | clock_t const not_same_median = not_same_results[CRYPTO_TEST_MEMCMP_ITERATIONS / 2]; |
59 | return {same_median, not_same_median}; | ||
58 | } | 60 | } |
59 | 61 | ||
60 | /** | 62 | /** |
@@ -63,32 +65,28 @@ void memcmp_median(void *src, void *same, void *not_same, size_t len, clock_t *s | |||
63 | */ | 65 | */ |
64 | TEST(CryptoCore, MemcmpTimingIsDataIndependent) { | 66 | TEST(CryptoCore, MemcmpTimingIsDataIndependent) { |
65 | // A random piece of memory. | 67 | // A random piece of memory. |
66 | auto *src = new uint8_t[CRYPTO_TEST_MEMCMP_SIZE]; | 68 | std::vector<uint8_t> src(CRYPTO_TEST_MEMCMP_SIZE); |
67 | random_bytes(src, CRYPTO_TEST_MEMCMP_SIZE); | 69 | random_bytes(src.data(), CRYPTO_TEST_MEMCMP_SIZE); |
68 | 70 | ||
69 | // A separate piece of memory containing the same data. | 71 | // A separate piece of memory containing the same data. |
70 | auto *same = new uint8_t[CRYPTO_TEST_MEMCMP_SIZE]; | 72 | std::vector<uint8_t> same = src; |
71 | memcpy(same, src, CRYPTO_TEST_MEMCMP_SIZE); | ||
72 | 73 | ||
73 | // Another piece of memory containing different data. | 74 | // Another piece of memory containing different data. |
74 | auto *not_same = new uint8_t[CRYPTO_TEST_MEMCMP_SIZE]; | 75 | std::vector<uint8_t> not_same(CRYPTO_TEST_MEMCMP_SIZE); |
75 | random_bytes(not_same, CRYPTO_TEST_MEMCMP_SIZE); | 76 | random_bytes(not_same.data(), CRYPTO_TEST_MEMCMP_SIZE); |
76 | 77 | ||
77 | clock_t same_median; | 78 | // Once we have C++17: |
78 | clock_t not_same_median; | 79 | // auto const [same_median, not_same_median] = |
79 | memcmp_median(src, same, not_same, CRYPTO_TEST_MEMCMP_SIZE, &same_median, ¬_same_median); | 80 | auto const result = |
80 | 81 | memcmp_median(src.data(), same.data(), not_same.data(), CRYPTO_TEST_MEMCMP_SIZE); | |
81 | delete[] not_same; | ||
82 | delete[] same; | ||
83 | delete[] src; | ||
84 | 82 | ||
85 | clock_t const delta = | 83 | clock_t const delta = |
86 | same_median > not_same_median ? same_median - not_same_median : not_same_median - same_median; | 84 | std::max(result.first, result.second) - std::min(result.first, result.second); |
87 | 85 | ||
88 | EXPECT_LT(delta, CRYPTO_TEST_MEMCMP_EPS) | 86 | EXPECT_LT(delta, CRYPTO_TEST_MEMCMP_EPS) |
89 | << "Delta time is too long (" << delta << " >= " << CRYPTO_TEST_MEMCMP_EPS << ")\n" | 87 | << "Delta time is too long (" << delta << " >= " << CRYPTO_TEST_MEMCMP_EPS << ")\n" |
90 | << "Time of the same data comparison: " << same_median << " clocks\n" | 88 | << "Time of the same data comparison: " << result.first << " clocks\n" |
91 | << "Time of the different data comparison: " << not_same_median << " clocks"; | 89 | << "Time of the different data comparison: " << result.second << " clocks"; |
92 | } | 90 | } |
93 | 91 | ||
94 | } // namespace | 92 | } // namespace |
diff --git a/toxcore/ping_array.api.h b/toxcore/ping_array.api.h index 81ede8fa..d36e56dc 100644 --- a/toxcore/ping_array.api.h +++ b/toxcore/ping_array.api.h | |||
@@ -20,7 +20,7 @@ extern "C" { | |||
20 | 20 | ||
21 | class mono_Time { struct this; } | 21 | class mono_Time { struct this; } |
22 | 22 | ||
23 | class ping_Array { | 23 | class ping { class array { |
24 | 24 | ||
25 | struct this; | 25 | struct this; |
26 | 26 | ||
@@ -55,7 +55,7 @@ uint64_t add(const mono_Time::this *mono_time, const uint8_t *data, uint32_t len | |||
55 | */ | 55 | */ |
56 | int32_t check(const mono_Time::this *mono_time, uint8_t[length] data, uint64_t ping_id); | 56 | int32_t check(const mono_Time::this *mono_time, uint8_t[length] data, uint64_t ping_id); |
57 | 57 | ||
58 | } | 58 | } } |
59 | 59 | ||
60 | %{ | 60 | %{ |
61 | #ifdef __cplusplus | 61 | #ifdef __cplusplus |
diff --git a/toxcore/ping_array.h b/toxcore/ping_array.h index 589573c8..70c517de 100644 --- a/toxcore/ping_array.h +++ b/toxcore/ping_array.h | |||
@@ -39,14 +39,14 @@ struct Ping_Array *ping_array_new(uint32_t size, uint32_t timeout); | |||
39 | /** | 39 | /** |
40 | * Free all the allocated memory in a Ping_Array. | 40 | * Free all the allocated memory in a Ping_Array. |
41 | */ | 41 | */ |
42 | void ping_array_kill(struct Ping_Array *_array); | 42 | void ping_array_kill(struct Ping_Array *array); |
43 | 43 | ||
44 | /** | 44 | /** |
45 | * Add a data with length to the Ping_Array list and return a ping_id. | 45 | * Add a data with length to the Ping_Array list and return a ping_id. |
46 | * | 46 | * |
47 | * @return ping_id on success, 0 on failure. | 47 | * @return ping_id on success, 0 on failure. |
48 | */ | 48 | */ |
49 | uint64_t ping_array_add(struct Ping_Array *_array, const struct Mono_Time *mono_time, const uint8_t *data, | 49 | uint64_t ping_array_add(struct Ping_Array *array, const struct Mono_Time *mono_time, const uint8_t *data, |
50 | uint32_t length); | 50 | uint32_t length); |
51 | 51 | ||
52 | /** | 52 | /** |
@@ -56,7 +56,7 @@ uint64_t ping_array_add(struct Ping_Array *_array, const struct Mono_Time *mono_ | |||
56 | * | 56 | * |
57 | * @return length of data copied on success, -1 on failure. | 57 | * @return length of data copied on success, -1 on failure. |
58 | */ | 58 | */ |
59 | int32_t ping_array_check(struct Ping_Array *_array, const struct Mono_Time *mono_time, uint8_t *data, size_t length, | 59 | int32_t ping_array_check(struct Ping_Array *array, const struct Mono_Time *mono_time, uint8_t *data, size_t length, |
60 | uint64_t ping_id); | 60 | uint64_t ping_id); |
61 | 61 | ||
62 | #ifdef __cplusplus | 62 | #ifdef __cplusplus |
diff --git a/toxcore/tox.api.h b/toxcore/tox.api.h index fcd43f7a..5e42b866 100644 --- a/toxcore/tox.api.h +++ b/toxcore/tox.api.h | |||
@@ -14,6 +14,8 @@ | |||
14 | #include <stddef.h> | 14 | #include <stddef.h> |
15 | #include <stdint.h> | 15 | #include <stdint.h> |
16 | 16 | ||
17 | //!TOKSTYLE- | ||
18 | |||
17 | #ifdef __cplusplus | 19 | #ifdef __cplusplus |
18 | extern "C" { | 20 | extern "C" { |
19 | #endif | 21 | #endif |
@@ -2854,5 +2856,7 @@ typedef TOX_CONNECTION Tox_Connection; | |||
2854 | typedef TOX_FILE_CONTROL Tox_File_Control; | 2856 | typedef TOX_FILE_CONTROL Tox_File_Control; |
2855 | typedef TOX_CONFERENCE_TYPE Tox_Conference_Type; | 2857 | typedef TOX_CONFERENCE_TYPE Tox_Conference_Type; |
2856 | 2858 | ||
2859 | //!TOKSTYLE+ | ||
2860 | |||
2857 | #endif // C_TOXCORE_TOXCORE_TOX_H | 2861 | #endif // C_TOXCORE_TOXCORE_TOX_H |
2858 | %} | 2862 | %} |
diff --git a/toxcore/tox.h b/toxcore/tox.h index dc873f3b..be6f6d34 100644 --- a/toxcore/tox.h +++ b/toxcore/tox.h | |||
@@ -13,6 +13,8 @@ | |||
13 | #include <stddef.h> | 13 | #include <stddef.h> |
14 | #include <stdint.h> | 14 | #include <stdint.h> |
15 | 15 | ||
16 | //!TOKSTYLE- | ||
17 | |||
16 | #ifdef __cplusplus | 18 | #ifdef __cplusplus |
17 | extern "C" { | 19 | extern "C" { |
18 | #endif | 20 | #endif |
@@ -3251,4 +3253,6 @@ typedef TOX_CONNECTION Tox_Connection; | |||
3251 | typedef TOX_FILE_CONTROL Tox_File_Control; | 3253 | typedef TOX_FILE_CONTROL Tox_File_Control; |
3252 | typedef TOX_CONFERENCE_TYPE Tox_Conference_Type; | 3254 | typedef TOX_CONFERENCE_TYPE Tox_Conference_Type; |
3253 | 3255 | ||
3256 | //!TOKSTYLE+ | ||
3257 | |||
3254 | #endif // C_TOXCORE_TOXCORE_TOX_H | 3258 | #endif // C_TOXCORE_TOXCORE_TOX_H |
diff --git a/toxcore/tox_api.c b/toxcore/tox_api.c index 8503f237..63b4bea3 100644 --- a/toxcore/tox_api.c +++ b/toxcore/tox_api.c | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #define SET_ERROR_PARAMETER(param, x) do { if (param) { *param = x; } } while (0) | 8 | #define SET_ERROR_PARAMETER(param, x) do { if (param) { *param = x; } } while (0) |
9 | 9 | ||
10 | //!TOKSTYLE- | ||
10 | 11 | ||
11 | #define CONST_FUNCTION(lowercase, uppercase) \ | 12 | #define CONST_FUNCTION(lowercase, uppercase) \ |
12 | uint32_t tox_##lowercase(void) \ | 13 | uint32_t tox_##lowercase(void) \ |
@@ -60,6 +61,8 @@ ACCESSORS(void *, log_, user_data) | |||
60 | ACCESSORS(bool,, local_discovery_enabled) | 61 | ACCESSORS(bool,, local_discovery_enabled) |
61 | ACCESSORS(bool,, experimental_thread_safety) | 62 | ACCESSORS(bool,, experimental_thread_safety) |
62 | 63 | ||
64 | //!TOKSTYLE+ | ||
65 | |||
63 | const uint8_t *tox_options_get_savedata_data(const struct Tox_Options *options) | 66 | const uint8_t *tox_options_get_savedata_data(const struct Tox_Options *options) |
64 | { | 67 | { |
65 | return options->savedata_data; | 68 | return options->savedata_data; |
diff --git a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c index e2de3e5f..3aab156f 100644 --- a/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c +++ b/toxencryptsave/crypto_pwhash_scryptsalsa208sha256/pwhash_scryptsalsa208sha256.c | |||
@@ -201,7 +201,7 @@ crypto_pwhash_scryptsalsa208sha256_str_verify(const char str[crypto_pwhash_scryp | |||
201 | return -1; | 201 | return -1; |
202 | } | 202 | } |
203 | escrypt_free_local(&escrypt_local); | 203 | escrypt_free_local(&escrypt_local); |
204 | ret = crypto_memcmp(wanted, str, sizeof wanted); | 204 | ret = crypto_memcmp((const uint8_t *) wanted, (const uint8_t *) str, sizeof wanted); |
205 | crypto_memzero(wanted, sizeof wanted); | 205 | crypto_memzero(wanted, sizeof wanted); |
206 | 206 | ||
207 | return ret; | 207 | return ret; |
diff --git a/toxencryptsave/defines.h b/toxencryptsave/defines.h index 0bc1d9ed..8a490344 100644 --- a/toxencryptsave/defines.h +++ b/toxencryptsave/defines.h | |||
@@ -1,7 +1,7 @@ | |||
1 | #ifndef C_TOXCORE_TOXENCRYPTSAVE_DEFINES_H | 1 | #ifndef C_TOXCORE_TOXENCRYPTSAVE_DEFINES_H |
2 | #define C_TOXCORE_TOXENCRYPTSAVE_DEFINES_H | 2 | #define C_TOXCORE_TOXENCRYPTSAVE_DEFINES_H |
3 | 3 | ||
4 | #define TOX_ENC_SAVE_MAGIC_NUMBER "toxEsave" | 4 | #define TOX_ENC_SAVE_MAGIC_NUMBER ((const uint8_t *)"toxEsave") |
5 | #define TOX_ENC_SAVE_MAGIC_LENGTH 8 | 5 | #define TOX_ENC_SAVE_MAGIC_LENGTH 8 |
6 | 6 | ||
7 | #endif | 7 | #endif |