Fix warnings

Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
Pol Henarejos
2026-05-14 19:18:39 +02:00
parent 08507069bd
commit 7f53d7f748
12 changed files with 59 additions and 29 deletions

View File

@@ -34,10 +34,11 @@ extern bool app_exists(const uint8_t *aid, size_t aid_len);
extern int register_app(int (*)(app_t *, uint8_t), const uint8_t *); extern int register_app(int (*)(app_t *, uint8_t), const uint8_t *);
extern int select_app(const uint8_t *aid, size_t aid_len); extern int select_app(const uint8_t *aid, size_t aid_len);
PACK(
typedef struct cmd { typedef struct cmd {
uint8_t ins; uint8_t ins;
int (*cmd_handler)(void); int (*cmd_handler)(void);
} cmd_t; }) cmd_t;
extern uint8_t num_apps; extern uint8_t num_apps;
extern app_t apps[16]; extern app_t apps[16];

View File

@@ -20,11 +20,13 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include "compat/compat.h"
PACK(
typedef struct asn1_ctx { typedef struct asn1_ctx {
uint8_t *data; uint8_t *data;
uint16_t len; uint16_t len;
} asn1_ctx_t; }) asn1_ctx_t;
extern int asn1_ctx_init(uint8_t *, uint16_t, asn1_ctx_t *); extern int asn1_ctx_init(uint8_t *, uint16_t, asn1_ctx_t *);
extern int asn1_ctx_clear(asn1_ctx_t *ctx); extern int asn1_ctx_clear(asn1_ctx_t *ctx);

View File

@@ -34,6 +34,9 @@ typedef struct {
size_t max_elem; size_t max_elem;
uint8_t buf[1024]; uint8_t buf[1024];
bool is_init; bool is_init;
#ifdef _MSC_VER
char padding[sizeof(void *) - sizeof(bool)];
#endif
} queue_t; } queue_t;
static inline void queue_free(queue_t *a) { static inline void queue_free(queue_t *a) {

View File

@@ -254,15 +254,15 @@ int aes_decrypt_cfb_256(const uint8_t *key, const uint8_t *iv, uint8_t *data, ui
return aes_decrypt(key, iv, 256, PICOKEYS_AES_MODE_CFB, data, len); return aes_decrypt(key, iv, 256, PICOKEYS_AES_MODE_CFB, data, len);
} }
struct lv_data { PACK(struct lv_data {
unsigned char *value; unsigned char *value;
uint8_t len; uint8_t len;
}; });
struct ec_curve_mbed_id { PACK(struct ec_curve_mbed_id {
struct lv_data curve; struct lv_data curve;
mbedtls_ecp_group_id id; mbedtls_ecp_group_id id;
}; });
struct ec_curve_mbed_id ec_curves_mbed[] = { struct ec_curve_mbed_id ec_curves_mbed[] = {
{ { (unsigned char *) { { (unsigned char *)
"\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF", "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFE\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF",

View File

@@ -74,13 +74,14 @@ extern uint32_t FLASH_SIZE_BYTES;
extern const uintptr_t start_data_pool; extern const uintptr_t start_data_pool;
extern const uintptr_t end_rom_pool; extern const uintptr_t end_rom_pool;
PACK(
typedef struct page_flash { typedef struct page_flash {
uint8_t page[FLASH_SECTOR_SIZE]; uint8_t page[FLASH_SECTOR_SIZE];
uintptr_t address; uintptr_t address;
bool ready; bool ready;
bool erase; bool erase;
size_t page_size; //this param is for easy erase. It allows to erase with a single call. IT DOES NOT APPLY TO WRITE size_t page_size; //this param is for easy erase. It allows to erase with a single call. IT DOES NOT APPLY TO WRITE
} page_flash_t; }) page_flash_t;
static page_flash_t flash_pages[TOTAL_FLASH_PAGES]; static page_flash_t flash_pages[TOTAL_FLASH_PAGES];

View File

@@ -69,6 +69,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
PACK(
typedef struct phy_data { typedef struct phy_data {
union { union {
struct { struct {
@@ -99,7 +100,7 @@ typedef struct phy_data {
bool enabled_usb_itf_present; bool enabled_usb_itf_present;
bool led_driver_present; bool led_driver_present;
} phy_data_t; }) phy_data_t;
#define PHY_MAX_SIZE ((2+4)+(2+4)+(2+32)+(2+2)+(2+1)+(2+1)+(2+1)+(2+1)+(2+1)) #define PHY_MAX_SIZE ((2+4)+(2+4)+(2+32)+(2+2)+(2+1)+(2+1)+(2+1)+(2+1)+(2+1))

View File

@@ -23,13 +23,12 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#include <windows.h> #include <windows.h>
struct timezone PACK(struct timezone
{ {
__int32 tz_minuteswest; /* minutes W of Greenwich */ __int32 tz_minuteswest; /* minutes W of Greenwich */
bool tz_dsttime; /* type of dst correction */ bool tz_dsttime; /* type of dst correction */
}; });
int gettimeofday(struct timeval* tp, struct timezone* tzp) int gettimeofday(struct timeval* tp, struct timezone* tzp) {
{
(void)tzp; (void)tzp;
// Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's
// This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC)
@@ -49,8 +48,7 @@ int gettimeofday(struct timeval* tp, struct timezone* tzp)
tp->tv_usec = (long)(system_time.wMilliseconds * 1000); tp->tv_usec = (long)(system_time.wMilliseconds * 1000);
return 0; return 0;
} }
int settimeofday(const struct timeval* tp, const struct timezone* tzp) int settimeofday(const struct timeval* tp, const struct timezone* tzp) {
{
(void)tzp; (void)tzp;
SYSTEMTIME st; SYSTEMTIME st;
FILETIME ft; FILETIME ft;

View File

@@ -71,13 +71,15 @@ static int hwrng_mix_process(void) {
return 0; return 0;
} }
struct hwrng_buf { PACK(
typedef struct hwrng_buf {
uint32_t *buf; uint32_t *buf;
uint8_t head, tail; uint8_t head;
uint8_t tail;
uint8_t size; uint8_t size;
unsigned int full : 1; unsigned int full : 1;
unsigned int empty : 1; unsigned int empty : 1;
}; }) hwrng_buf_t;
static mutex_t hwrng_mutex; static mutex_t hwrng_mutex;
static bool hwrng_mutex_initialized = false; static bool hwrng_mutex_initialized = false;

View File

@@ -72,13 +72,14 @@ typedef enum {
REST_PARAM_STRING REST_PARAM_STRING
} rest_param_type_t; } rest_param_type_t;
PACK(
typedef struct { typedef struct {
union { union {
int32_t int_param; int32_t int_param;
char *str_param; char *str_param;
} param; } param;
rest_param_type_t type; rest_param_type_t type;
} rest_param_t; }) rest_param_t;
typedef enum { typedef enum {
REST_ROUTE_NONE = 0x0, REST_ROUTE_NONE = 0x0,
@@ -110,6 +111,7 @@ typedef enum {
REST_SESSION_TERMINATED = 0x6, REST_SESSION_TERMINATED = 0x6,
} rest_session_status_t; } rest_session_status_t;
PACK(
typedef struct { typedef struct {
uint8_t public_key[32]; uint8_t public_key[32];
uint8_t id[16]; uint8_t id[16];
@@ -121,13 +123,14 @@ typedef struct {
rest_session_status_t status; rest_session_status_t status;
uint8_t token[32]; uint8_t token[32];
uint8_t user_id; uint8_t user_id;
} rest_session_t; }) rest_session_t;
typedef struct { typedef struct {
const char *key; const char *key;
const char *value; const char *value;
} rest_query_t; } rest_query_t;
PACK(
typedef struct { typedef struct {
rest_http_method_t method; rest_http_method_t method;
char path[REST_MAX_PATH_SIZE]; char path[REST_MAX_PATH_SIZE];
@@ -140,19 +143,23 @@ typedef struct {
uint8_t query_count; uint8_t query_count;
rest_session_t *session; rest_session_t *session;
rest_request_conn_type_t conn_type; rest_request_conn_type_t conn_type;
} rest_request_t; }) rest_request_t;
typedef struct { typedef struct {
uint16_t status_code;
const char *content_type; const char *content_type;
char *body; // heap ! char *body; // heap !
size_t body_len; size_t body_len;
cJSON *json; cJSON *json;
char *headers[REST_HEADER_TOTAL_COUNT]; char *headers[REST_HEADER_TOTAL_COUNT];
uint16_t status_code;
#ifdef _MSC_VER
char _padding[6];
#endif
} rest_response_t; } rest_response_t;
typedef int (*rest_route_handler_t)(const rest_request_t *request, rest_response_t *response); typedef int (*rest_route_handler_t)(const rest_request_t *request, rest_response_t *response);
PACK(
typedef struct { typedef struct {
rest_http_method_t method; rest_http_method_t method;
const char *path; const char *path;
@@ -160,7 +167,7 @@ typedef struct {
rest_route_flags_t flags; rest_route_flags_t flags;
rest_route_param_parser_t param_parser; rest_route_param_parser_t param_parser;
rest_session_role_t role; // Minimum required role to access this route (only relevant if REST_ROUTE_REQUIRE_AUTH flag is set) rest_session_role_t role; // Minimum required role to access this route (only relevant if REST_ROUTE_REQUIRE_AUTH flag is set)
} rest_route_t; }) rest_route_t;
typedef struct { typedef struct {
rest_route_handler_t handler; rest_route_handler_t handler;

View File

@@ -31,6 +31,7 @@
#endif #endif
typedef SOCKET socket_t; typedef SOCKET socket_t;
typedef int socklen_t; typedef int socklen_t;
typedef SSIZE_T ssize_t;
#define close closesocket #define close closesocket
#include <string.h> #include <string.h>
#define strcasecmp _stricmp #define strcasecmp _stricmp
@@ -70,16 +71,20 @@ static pthread_t rest_thread;
#endif #endif
static rest_conn_t conns[REST_MAX_CONNS]; static rest_conn_t conns[REST_MAX_CONNS];
PACK(
typedef struct { typedef struct {
volatile long pending; volatile long pending;
rest_conn_t *conn; rest_conn_t *conn;
rest_route_handler_t handler; rest_route_handler_t handler;
rest_request_t request; rest_request_t request;
} rest_core1_job_t; }) rest_core1_job_t;
typedef struct { typedef struct {
bool ready;
rest_response_t response; rest_response_t response;
bool ready;
#ifdef _MSC_VER
char _padding[sizeof(void *) - sizeof(bool)];
#endif
} rest_core1_result_t; } rest_core1_result_t;
static rest_core1_job_t rest_core1_job = {0}; static rest_core1_job_t rest_core1_job = {0};
@@ -110,10 +115,11 @@ static void rest_core1_job_pending_store(bool pending) {
#endif #endif
} }
PACK(
typedef struct { typedef struct {
rest_header_id_t id; rest_header_id_t id;
const char *name; const char *name;
} rest_header_descriptor_t; }) rest_header_descriptor_t;
static const rest_header_descriptor_t rest_http_headers[REST_HEADER_TOTAL_COUNT] = { static const rest_header_descriptor_t rest_http_headers[REST_HEADER_TOTAL_COUNT] = {
{ REST_HEADER_USER_AGENT, "User-Agent" }, { REST_HEADER_USER_AGENT, "User-Agent" },

View File

@@ -51,24 +51,31 @@ typedef enum {
} rest_conn_type_t; } rest_conn_type_t;
typedef struct { typedef struct {
bool in_use;
#ifdef ENABLE_EMULATION #ifdef ENABLE_EMULATION
intptr_t sock; intptr_t sock;
#else #else
struct tcp_pcb *pcb; struct tcp_pcb *pcb;
#endif #endif
char request[REST_MAX_REQUEST_SIZE + 1];
size_t request_len; size_t request_len;
rest_conn_type_t conn_type; rest_conn_type_t conn_type;
#ifdef _MSC_VER
char _padding[sizeof(void *) - sizeof(rest_conn_type_t)];
#endif
mbedtls_ssl_context ssl; mbedtls_ssl_context ssl;
unsigned char rx_cipher[REST_MAX_REQUEST_SIZE]; unsigned char rx_cipher[REST_MAX_REQUEST_SIZE];
size_t rx_cipher_len; size_t rx_cipher_len;
size_t request_headers_size;
size_t request_content_length;
bool in_use;
bool handshake_done; bool handshake_done;
bool request_complete; bool request_complete;
bool request_dispatched; bool request_dispatched;
bool request_headers_parsed; bool request_headers_parsed;
size_t request_headers_size; char request[REST_MAX_REQUEST_SIZE + 1];
size_t request_content_length; #ifdef ENABLE_EMULATION
char _padding2[2];
#endif
} rest_conn_t; } rest_conn_t;
err_t rest_server_init(rest_conn_type_t conn_type); err_t rest_server_init(rest_conn_type_t conn_type);

View File

@@ -20,8 +20,10 @@
#ifdef _MSC_VER #ifdef _MSC_VER
#include <string.h> #include <string.h>
#include <BaseTsd.h>
#define strcasecmp _stricmp #define strcasecmp _stricmp
#define strncasecmp _strnicmp #define strncasecmp _strnicmp
typedef SSIZE_T ssize_t;
#else #else
#include <strings.h> #include <strings.h>
#endif #endif