fix(components): Fix all components's compile warning and enable warning checking

This commit is contained in:
Dong Heng
2018-08-07 13:00:43 +08:00
parent 7c46284f50
commit 35ee995327
19 changed files with 81 additions and 55 deletions

View File

@ -42,6 +42,12 @@ extern "C" {
#endif
#include <stdint.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/unistd.h>
#include "rom/ets_sys.h"
#if 0
#define ssl_printf(fmt, args...) printf(fmt,## args)
@ -49,6 +55,10 @@ extern "C" {
#define ssl_printf(fmt, args...)
#endif
void *zalloc(size_t n);
uint32_t system_get_data_of_array_8(const uint8_t*, uint8_t);
void system_get_string_from_flash(const char *, char *, size_t n);
#define STDCALL
#define EXP_FUNC
@ -89,11 +99,11 @@ static __inline__ uint64_t be64toh(uint64_t __x) {return (((uint64_t)be32toh(__x
#endif
#ifdef MEMLEAK_DEBUG
#define SSL_MALLOC(size) ax_malloc(size, __FILE__, __LINE__)
#define SSL_REALLOC(mem_ref,size) ax_realloc(mem_ref, size, __FILE__, __LINE__)
#define SSL_CALLOC(element, size) ax_calloc(element, size, __FILE__, __LINE__)
#define SSL_ZALLOC(size) ax_zalloc(size, __FILE__, __LINE__)
#define SSL_FREE(mem_ref) ax_free(mem_ref, __FILE__, __LINE__)
#define SSL_MALLOC(size) os_malloc(size)
#define SSL_REALLOC(mem_ref,size) os_realloc(mem_ref, size)
#define SSL_CALLOC(element, size) os_calloc(element, size)
#define SSL_ZALLOC(size) os_zalloc(size)
#define SSL_FREE(mem_ref) os_free(mem_ref)
#else
#define SSL_MALLOC(size) malloc(size)
#define SSL_REALLOC(mem_ref,size) realloc(mem_ref, size)

View File

@ -266,6 +266,7 @@ int get_random_NZ(int num_rand_bytes, uint8_t *rand_data)
int hex_finish;
int hex_index;
#if 0
static void print_hex_init(int finish)
{
hex_finish = finish;
@ -297,6 +298,7 @@ static void print_hex(uint8_t hex)
ssl_printf("\n");
}
}
#endif
/**
* Spit out a blob of data for diagnostics. The data is is a nice column format
@ -402,8 +404,9 @@ EXP_FUNC int STDCALL base64_decode(const char *in, int len,
error:
#ifdef CONFIG_SSL_FULL_MODE
if (ret < 0)
if (ret < 0) {
ssl_printf("Error: Invalid base64\n"); //TTY_FLUSH();
}
#endif
//TTY_FLUSH();
SSL_FREE(base64_map);

View File

@ -224,6 +224,8 @@ static int pem_decrypt(const char *where, const char *end,
MD5_CTX md5_ctx;
AES_CTX aes_ctx;
uint8_t key[32]; /* AES256 size */
char *aes_str_0_ram = NULL;
char *aes_str_1_ram = NULL;
if (password == NULL || strlen(password) == 0)
{
@ -233,8 +235,8 @@ static int pem_decrypt(const char *where, const char *end,
goto error;
}
char *aes_str_0_ram = (char *)SSL_MALLOC(24);
char *aes_str_1_ram = (char *)SSL_MALLOC(24);
aes_str_0_ram = (char *)SSL_MALLOC(24);
aes_str_1_ram = (char *)SSL_MALLOC(24);
system_get_string_from_flash(aes_str[0], aes_str_0_ram, 24);
system_get_string_from_flash(aes_str[1], aes_str_1_ram, 24);

View File

@ -88,14 +88,14 @@ EXP_FUNC int STDCALL getdomainname(char *buf, int buf_size)
}
#endif
static const char * out_of_mem_str = "out of memory %s %d\n";
//static const char * out_of_mem_str = "out of memory %s %d\n";
#define exit_now printf
//#define SSL_LOG
#ifdef SSL_LOG
#define debug_now printf
#else
#define debug_now
#define debug_now(fmt, ...)
#endif
#if 0

View File

@ -184,6 +184,8 @@ EXP_FUNC int STDCALL esp_base64_encode(uint8_t *dst, size_t dlen, size_t *olen,
return 0;
}
return 0;
}
static char *key_password = NULL;
@ -1098,11 +1100,11 @@ void esp_ssl_sleep(uint16_t mseconds)
vTaskDelay(mseconds / portTICK_RATE_MS);
}
esp_ssl_CTX_set_client_cert_cb(){}
void esp_ssl_CTX_set_client_cert_cb(){}
esp_ssl_CTX_set_mode(){}
void esp_ssl_CTX_set_mode(){}
esp_ssl_pending()
void esp_ssl_pending()
{
}

View File

@ -54,8 +54,9 @@ EXP_FUNC SSL * STDCALL ssl_server_new(SSL_CTX *ssl_ctx, int client_fd)
ssl->next_state = HS_CLIENT_HELLO;
#ifdef CONFIG_SSL_FULL_MODE
if (ssl_ctx->chain_length == 0)
if (ssl_ctx->chain_length == 0) {
ssl_printf("Warning - no server certificate defined\n"); //TTY_FLUSH();
}
#endif
return ssl;

View File

@ -491,7 +491,7 @@ end_verify:
/**
* Used for diagnostics.
*/
static const char *not_part_of_cert = "<Not Part Of Certificate>";
//static const char *not_part_of_cert = "<Not Part Of Certificate>";
void x509_print(const X509_CTX *cert, CA_CERT_CTX *ca_cert_ctx)
{
if (cert == NULL)