From 1a021e122398d110cbd4db338c35fd181e2045f4 Mon Sep 17 00:00:00 2001 From: lixianjing Date: Thu, 16 Sep 2021 17:31:41 +0800 Subject: [PATCH] fix warnings --- demos/demo_ui_app.c | 16 +++++++++------- demos/demo_ui_old_app.c | 4 ++-- design/default/ui/uiex/page_label.xml | 2 +- docs/changes.md | 1 + src/ext_widgets/mledit/mledit.c | 10 +++++----- 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/demos/demo_ui_app.c b/demos/demo_ui_app.c index f69889ebe..281f32956 100644 --- a/demos/demo_ui_app.c +++ b/demos/demo_ui_app.c @@ -419,17 +419,17 @@ static uint32_t s_chat_bubble_curr_len = 0; static ret_t add_char_to_chat_bubble(const timer_info_t* timer) { widget_t* lb_chat_bubble = timer->ctx; - str_t str; + wstr_t str; return_value_if_fail(lb_chat_bubble != NULL, RET_REMOVE); - str_init(&str, s_chat_bubble_curr_len); + wstr_init(&str, s_chat_bubble_curr_len); if (s_chat_bubble_curr_len > 0) { - str_append_with_len(&str, s_chat_bubble, s_chat_bubble_curr_len); + wstr_set_utf8_with_len(&str, s_chat_bubble, s_chat_bubble_curr_len); } else { - str_append(&str, " "); + wstr_set_utf8(&str, " "); } - widget_set_text_utf8(lb_chat_bubble, str.str); - str_reset(&str); + widget_set_text(lb_chat_bubble, str.str); + wstr_reset(&str); s_chat_bubble_curr_len = (s_chat_bubble_curr_len + 1) % (s_chat_bubble_len + 1); @@ -1029,8 +1029,10 @@ static ret_t on_page_switch(void* ctx, event_t* e) { #endif /* ENABLE_PAGE_SWITCH */ static ret_t on_page_enter(void* ctx, event_t* e) { - widget_t* page = WIDGET(e->target); +#if defined(ENABLE_PAGE_SWITCH) && ENABLE_PAGE_SWITCH widget_t* scroll_view = NULL; +#endif /* ENABLE_PAGE_SWITCH */ + widget_t* page = WIDGET(e->target); page_enter_func_t enter_func = (page_enter_func_t)ctx; return_value_if_fail(page != NULL, RET_BAD_PARAMS); diff --git a/demos/demo_ui_old_app.c b/demos/demo_ui_old_app.c index e43b9f4a4..6f63ff2a9 100644 --- a/demos/demo_ui_old_app.c +++ b/demos/demo_ui_old_app.c @@ -38,8 +38,8 @@ uint32_t tk_mem_speed_test(void* buffer, uint32_t length, uint32_t* pmemcpy_spee uint32_t i = 0; uint32_t cost = 0; uint32_t total_cost = 0; - uint32_t memcpy_speed; - uint32_t memset_speed; + uint32_t memcpy_speed = 0; + uint32_t memset_speed = 0; uint32_t max_size = 100 * 1024 * 1024; uint64_t start = time_now_ms(); uint32_t nr = max_size / length; diff --git a/design/default/ui/uiex/page_label.xml b/design/default/ui/uiex/page_label.xml index 69884e8df..c5f507c55 100644 --- a/design/default/ui/uiex/page_label.xml +++ b/design/default/ui/uiex/page_label.xml @@ -9,7 +9,7 @@ - + diff --git a/docs/changes.md b/docs/changes.md index eeb8df695..d209c78e4 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -9,6 +9,7 @@ * 补充新demoui键盘中文翻译,修改kb\_foo样式(感谢兆坤提供补丁)。 * 修复gtest编译警告(感谢智明提供补丁) * 修复编译警告(感谢智明和兆坤提供补丁) + * 修复编译demoui警告(感谢兆坤提供补丁) 2021/09/14 * 根据新增接口,完善 object\_array 以及 object\_default(感谢雨欣提供补丁) diff --git a/src/ext_widgets/mledit/mledit.c b/src/ext_widgets/mledit/mledit.c index e5db5931c..a732a114e 100644 --- a/src/ext_widgets/mledit/mledit.c +++ b/src/ext_widgets/mledit/mledit.c @@ -1,5 +1,5 @@ /** - * File: mledit.h + * File: mledit.c * Author: AWTK Develop Team * Brief: mledit * @@ -958,9 +958,9 @@ static slist_t* mledit_get_rows_by_text(widget_t* widget, slist_t* slist, const for (i = 0; i < text_size; i++) { if (i + 1 < text_size && TWINS_CHAR_IS_LINE_BREAK(text[i], text[i + 1])) { i++; - slist_append(slist, (void*)(int64_t)(i + 1)); + slist_append(slist, tk_pointer_from_int((int32_t)(i + 1))); } else if (CHAR_IS_LINE_BREAK(text[i])) { - slist_append(slist, (void*)(int64_t)(i + 1)); + slist_append(slist, tk_pointer_from_int((int32_t)(i + 1))); } } @@ -981,7 +981,7 @@ ret_t mledit_insert_text(widget_t* widget, uint32_t offset, const char* text) { if (mledit_get_rows_by_text(widget, &offset_list, text) != NULL) { uint32_t text_size = tk_strlen(text); if (mledit->max_lines == 1) { - rows_start_offset = (uint32_t)(int64_t)slist_tail_pop(&offset_list); + rows_start_offset = (uint32_t)tk_pointer_to_int(slist_tail_pop(&offset_list)); if (rows_start_offset < text_size) { wstr_reset(&widget->text); @@ -990,7 +990,7 @@ ret_t mledit_insert_text(widget_t* widget, uint32_t offset, const char* text) { } else { slist_node_t* iter = offset_list.first; while (ret == RET_OK && iter != NULL) { - uint32_t rows_end_offset = (uint32_t)(int64_t)iter->data; + uint32_t rows_end_offset = (uint32_t)tk_pointer_to_int(iter->data); ret = text_edit_overwrite_text(mledit->model, &offset, text + rows_start_offset, rows_end_offset - rows_start_offset);