Skip to content

Commit

Permalink
Merge pull request #2823 from cesanta/c89
Browse files Browse the repository at this point in the history
Fix warnings and allow building chacha with C89 compilers
  • Loading branch information
scaprile authored Jul 8, 2024
2 parents ddf3ba8 + d46798c commit a9902b5
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions mongoose.c
Original file line number Diff line number Diff line change
Expand Up @@ -9833,7 +9833,7 @@ static void mg_tls_encrypt(struct mg_connection *c, const uint8_t *msg,
#if CHACHA20
(void) tag; // tag is only used in aes gcm
{
uint8_t *enc = malloc(8192);
uint8_t *enc = (uint8_t *) malloc(8192);
if (enc == NULL) {
mg_error(c, "TLS OOM");
return;
Expand Down Expand Up @@ -11019,8 +11019,8 @@ static void core_block(const uint32_t *restrict start,

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

Expand Down
4 changes: 2 additions & 2 deletions mongoose.h
Original file line number Diff line number Diff line change
Expand Up @@ -1965,11 +1965,11 @@ extern "C" {
if possible, carefully pick your associated data.
*/

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

// #if CHAR_BIT > 8
// # error "Systems without native octals not suppoted"
Expand Down
2 changes: 1 addition & 1 deletion src/tls_builtin.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ static void mg_tls_encrypt(struct mg_connection *c, const uint8_t *msg,
#if CHACHA20
(void) tag; // tag is only used in aes gcm
{
uint8_t *enc = malloc(8192);
uint8_t *enc = (uint8_t *) malloc(8192);
if (enc == NULL) {
mg_error(c, "TLS OOM");
return;
Expand Down
4 changes: 2 additions & 2 deletions src/tls_chacha20.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,8 @@ static void core_block(const uint32_t *restrict start,

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

Expand Down
4 changes: 2 additions & 2 deletions src/tls_chacha20.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ extern "C" {
if possible, carefully pick your associated data.
*/

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

// #if CHAR_BIT > 8
// # error "Systems without native octals not suppoted"
Expand Down

0 comments on commit a9902b5

Please sign in to comment.