From 9885971549470c9d8c6caea66e95c09d7d0d11bc Mon Sep 17 00:00:00 2001 From: Sander Speetjens Date: Thu, 30 Nov 2023 10:37:38 +0100 Subject: [PATCH] tcp_cmd Remov some casting warnings --- tests/tcp_cmd.cpp | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/tests/tcp_cmd.cpp b/tests/tcp_cmd.cpp index fbaa82e..5bc79d8 100644 --- a/tests/tcp_cmd.cpp +++ b/tests/tcp_cmd.cpp @@ -208,8 +208,8 @@ static err_t tcp_cmd_recv_new(void* arg, struct tcp_pcb* pcb, struct pbuf* p, er if (p->len >= MAX_CMD_LEN) { LOG_WARN(TAG, "Command too long"); } - size_t len = p->tot_len >= MAX_CMD_LEN ? MAX_CMD_LEN : p->tot_len; - + uint16_t len = p->tot_len >= MAX_CMD_LEN ? MAX_CMD_LEN : p->tot_len; + pbuf_copy_partial(p, cmd, len, 0); cmd[len] = '\0'; @@ -242,39 +242,55 @@ TEST(TCP_CMD, tcp_data_cb) { char* cmd = (char*)calloc(50, 1); pbuf p = {.next = NULL, .payload = (void*)cmd, .tot_len = 4, .len = 0, .type_internal = 0, .flags = 0, .if_idx = 0}; strcpy(cmd, "help"); - p.tot_len = strlen(cmd); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); strcpy(cmd, "text \"This is printed on the display\""); - p.tot_len = strlen(cmd); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); - strcpy(cmd, "color 0xffffff"); - p.tot_len = strlen(cmd); + strcpy(cmd, "color 0x555555"); + p.tot_len = (uint16_t)strlen(cmd); + tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); + + strcpy(cmd, "bgcolor 0xAAAAAA"); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); strcpy(cmd, "text \"This is printed on the display\""); - p.tot_len = strlen(cmd); + p.tot_len = (uint16_t)strlen(cmd); + tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); + + strcpy(cmd, "color 255 255 255"); + p.tot_len = (uint16_t)strlen(cmd); + tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); + + strcpy(cmd, "bgcolor 255 255 255"); + p.tot_len = (uint16_t)strlen(cmd); + tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); + + strcpy(cmd, "text \"This is printed on the display\""); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); strcpy(cmd, "setImage \"test.bmp\""); - p.tot_len = strlen(cmd); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); strcpy(cmd, "setImage \"test.gif\""); - p.tot_len = strlen(cmd); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); strcpy(cmd, "setGif \"test.gif\""); - p.tot_len = strlen(cmd); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); strcpy(cmd, "setGif \"test.bmp\""); - p.tot_len = strlen(cmd); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); strcpy(cmd, "exit"); - p.tot_len = strlen(cmd); + p.tot_len = (uint16_t)strlen(cmd); tcp_cmd_recv_new(NULL, NULL, &p, ERR_OK); free(cmd);