Skip to content

Commit a9902b5

Browse files
authored
Merge pull request #2823 from cesanta/c89
Fix warnings and allow building chacha with C89 compilers
2 parents ddf3ba8 + d46798c commit a9902b5

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

Diff for: mongoose.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -9833,7 +9833,7 @@ static void mg_tls_encrypt(struct mg_connection *c, const uint8_t *msg,
98339833
#if CHACHA20
98349834
(void) tag; // tag is only used in aes gcm
98359835
{
9836-
uint8_t *enc = malloc(8192);
9836+
uint8_t *enc = (uint8_t *) malloc(8192);
98379837
if (enc == NULL) {
98389838
mg_error(c, "TLS OOM");
98399839
return;
@@ -11019,8 +11019,8 @@ static void core_block(const uint32_t *restrict start,
1101911019

1102011020
static void xor_block(uint8_t *restrict dest, const uint8_t *restrict source,
1102111021
const uint32_t *restrict pad, unsigned int chunk_size) {
11022-
unsigned int i, full_blocks = chunk_size / sizeof(uint32_t);
11023-
// have to be carefull, we are going back from uint32 to uint8, so endianess
11022+
unsigned int i, full_blocks = chunk_size / (unsigned int) sizeof(uint32_t);
11023+
// have to be carefull, we are going back from uint32 to uint8, so endianness
1102411024
// matters again
1102511025
xor32_blocks(dest, source, pad, full_blocks)
1102611026

Diff for: mongoose.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -1965,11 +1965,11 @@ extern "C" {
19651965
if possible, carefully pick your associated data.
19661966
*/
19671967

1968-
// Make sure we are either nested in C++ or running in a C99+ compiler
1968+
/* Make sure we are either nested in C++ or running in a C99+ compiler
19691969
#if !defined(__cplusplus) && !defined(_MSC_VER) && \
19701970
(!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
19711971
#error "C99 or newer required"
1972-
#endif
1972+
#endif */
19731973

19741974
// #if CHAR_BIT > 8
19751975
// # error "Systems without native octals not suppoted"

Diff for: src/tls_builtin.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ static void mg_tls_encrypt(struct mg_connection *c, const uint8_t *msg,
397397
#if CHACHA20
398398
(void) tag; // tag is only used in aes gcm
399399
{
400-
uint8_t *enc = malloc(8192);
400+
uint8_t *enc = (uint8_t *) malloc(8192);
401401
if (enc == NULL) {
402402
mg_error(c, "TLS OOM");
403403
return;

Diff for: src/tls_chacha20.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,8 @@ static void core_block(const uint32_t *restrict start,
200200

201201
static void xor_block(uint8_t *restrict dest, const uint8_t *restrict source,
202202
const uint32_t *restrict pad, unsigned int chunk_size) {
203-
unsigned int i, full_blocks = chunk_size / sizeof(uint32_t);
204-
// have to be carefull, we are going back from uint32 to uint8, so endianess
203+
unsigned int i, full_blocks = chunk_size / (unsigned int) sizeof(uint32_t);
204+
// have to be carefull, we are going back from uint32 to uint8, so endianness
205205
// matters again
206206
xor32_blocks(dest, source, pad, full_blocks)
207207

Diff for: src/tls_chacha20.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ extern "C" {
2626
if possible, carefully pick your associated data.
2727
*/
2828

29-
// Make sure we are either nested in C++ or running in a C99+ compiler
29+
/* Make sure we are either nested in C++ or running in a C99+ compiler
3030
#if !defined(__cplusplus) && !defined(_MSC_VER) && \
3131
(!defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901L)
3232
#error "C99 or newer required"
33-
#endif
33+
#endif */
3434

3535
// #if CHAR_BIT > 8
3636
// # error "Systems without native octals not suppoted"

0 commit comments

Comments
 (0)