From 84eff6d8e8825ee582fa780d0eb8de6bfb4ebe38 Mon Sep 17 00:00:00 2001 From: Liu Date: Sun, 3 Mar 2019 23:04:36 +0800 Subject: [PATCH] style: clear compiler warnings --- include/LCUI/gui/widget_helper.h | 2 +- include/LCUI/util/string.h | 6 +++--- src/font/textlayer.c | 7 ++++--- src/graph.c | 8 ++++---- src/gui/css_fontstyle.c | 2 +- src/gui/css_library.c | 3 ++- src/gui/widget_base.c | 2 +- src/gui/widget_helper.c | 2 +- src/gui/widget_task.c | 12 ++++++------ src/image/png.c | 6 +++--- src/util/string.c | 4 ++-- 11 files changed, 28 insertions(+), 26 deletions(-) diff --git a/include/LCUI/gui/widget_helper.h b/include/LCUI/gui/widget_helper.h index 2ac10e0d..b5c0a538 100644 --- a/include/LCUI/gui/widget_helper.h +++ b/include/LCUI/gui/widget_helper.h @@ -47,7 +47,7 @@ LCUI_API void Widget_SetBorderColor(LCUI_Widget w, LCUI_Color color); LCUI_API void Widget_SetBorderWidth(LCUI_Widget w, float width); -LCUI_API void Widget_SetBorderStyle(LCUI_Widget w, float style); +LCUI_API void Widget_SetBorderStyle(LCUI_Widget w, int style); /** 设置边框样式 */ LCUI_API void Widget_SetBorder(LCUI_Widget w, float width, int style, diff --git a/include/LCUI/util/string.h b/include/LCUI/util/string.h index a36d2217..be7f6a3b 100644 --- a/include/LCUI/util/string.h +++ b/include/LCUI/util/string.h @@ -53,9 +53,9 @@ LCUI_API size_t strntolower(char *outstr, size_t max_len, const char *instr); * @param[in] charlist 需要清除的字符列表,当为NULL时,默认清除空白符 * @return 处理后的字符串的长度 */ -LCUI_API int strtrim(char *outstr, const char *instr, const char *charlist); -LCUI_API int wcstrim(wchar_t *outstr, const wchar_t *instr, - const wchar_t *charlist); +LCUI_API size_t strtrim(char *outstr, const char *instr, const char *charlist); +LCUI_API size_t wcstrim(wchar_t *outstr, const wchar_t *instr, + const wchar_t *charlist); LCUI_API unsigned strhash(unsigned hash, const char *str); diff --git a/src/font/textlayer.c b/src/font/textlayer.c index 3c0c4310..5b95a51c 100644 --- a/src/font/textlayer.c +++ b/src/font/textlayer.c @@ -879,16 +879,17 @@ int TextLayer_SetText(LCUI_TextLayer layer, const char *utf8_text) size_t TextLayer_GetTextW(LCUI_TextLayer layer, size_t start_pos, size_t max_len, wchar_t *wstr_buff) { - size_t row, col = 0, i; + size_t i; + int row, col; LCUI_TextRow row_ptr; if (max_len == 0) { return 0; } /* 先根据一维坐标计算行列坐标 */ - for (i = 0, row = 0; row < layer->text_rows.length; ++row) { + for (i = 0, row = 0, col = 0; row < layer->text_rows.length; ++row) { if (i >= start_pos) { - col = start_pos - i; + col = (int)(start_pos - i); break; } i += layer->text_rows.rows[row]->length; diff --git a/src/graph.c b/src/graph.c index a85f15b3..dbfaeb7f 100644 --- a/src/graph.c +++ b/src/graph.c @@ -700,8 +700,8 @@ static int Graph_FillRectARGB(LCUI_Graph *graph, LCUI_Color color, static uchar_t Graph_BilinearResamplingCore(uchar_t a, uchar_t b, uchar_t c, uchar_t d, float dx, float dy) { - return a * (1 - dx) * (1 - dy) + b * (dx) * (1 - dy) + - c * (dy) * (1 - dx) + d * (dx * dy); + return (uchar_t)(a * (1 - dx) * (1 - dy) + b * (dx) * (1 - dy) + + c * (dy) * (1 - dx) + d * (dx * dy)); } /*-------------------------------- End ARGB --------------------------------*/ @@ -1092,8 +1092,8 @@ int Graph_ZoomBilinear(const LCUI_Graph *graph, LCUI_Graph *buff, */ x = (int)(scale_x * j); y = (int)(scale_y * i); - x_diff = (scale_x * j) - x; - y_diff = (scale_y * i) - y; + x_diff = (float)((scale_x * j) - x); + y_diff = (float)((scale_y * i) - y); Graph_GetPixel(graph, x + rect.x + 0, y + rect.y + 0, a); Graph_GetPixel(graph, x + rect.x + 1, y + rect.y + 0, diff --git a/src/gui/css_fontstyle.c b/src/gui/css_fontstyle.c index 6012c850..9185d8ac 100644 --- a/src/gui/css_fontstyle.c +++ b/src/gui/css_fontstyle.c @@ -64,7 +64,7 @@ static struct LCUI_CSSFontStyleModule { StyleHandler handlers[TOTAL_FONT_STYLE_KEY]; } self; -static int unescape(const wchar_t *instr, wchar_t *outstr) +static size_t unescape(const wchar_t *instr, wchar_t *outstr) { int i = -1; wchar_t buff[6]; diff --git a/src/gui/css_library.c b/src/gui/css_library.c index 6910c4ce..ee8d7535 100644 --- a/src/gui/css_library.c +++ b/src/gui/css_library.c @@ -636,8 +636,9 @@ int StyleSheet_MergeList(LCUI_StyleSheet ss, LCUI_StyleList list) int StyleSheet_Replace(LCUI_StyleSheet dest, const LCUI_StyleSheetRec *src) { + int i; LCUI_Style s; - size_t i, count, size; + size_t count, size; if (src->length > dest->length) { size = sizeof(LCUI_StyleRec) * src->length; diff --git a/src/gui/widget_base.c b/src/gui/widget_base.c index 05bf04f4..72bfd5ad 100755 --- a/src/gui/widget_base.c +++ b/src/gui/widget_base.c @@ -1,4 +1,4 @@ -/* +/* * widget_base.c -- The widget base operation set. * * Copyright (c) 2018, Liu chao All rights reserved. diff --git a/src/gui/widget_helper.c b/src/gui/widget_helper.c index e47f9cf9..4637d506 100644 --- a/src/gui/widget_helper.c +++ b/src/gui/widget_helper.c @@ -73,7 +73,7 @@ void Widget_SetBorderWidth(LCUI_Widget w, float width) Widget_UpdateStyle(w, FALSE); } -void Widget_SetBorderStyle(LCUI_Widget w, float style) +void Widget_SetBorderStyle(LCUI_Widget w, int style) { Widget_SetStyle(w, key_border_top_style, style, style); Widget_SetStyle(w, key_border_right_style, style, style); diff --git a/src/gui/widget_task.c b/src/gui/widget_task.c index 31056f21..657c8647 100644 --- a/src/gui/widget_task.c +++ b/src/gui/widget_task.c @@ -385,7 +385,7 @@ static size_t Widget_UpdateChildren(LCUI_Widget w, LCUI_WidgetTaskContext ctx) } if (data->rules.max_update_children_count > 0) { if (update_count >= - data->rules.max_update_children_count) { + (size_t)data->rules.max_update_children_count) { w->task.for_children = TRUE; break; } @@ -401,12 +401,12 @@ static size_t Widget_UpdateChildren(LCUI_Widget w, LCUI_WidgetTaskContext ctx) */ msec = (clock() - msec); if (msec < 1) { - data->default_max_update_count += 128; + data->default_max_update_count += 128; continue; } - data->default_max_update_count = - update_count * CLOCKS_PER_SEC / self.max_updates_per_frame / - LCUI_MAX_FRAMES_PER_SEC / msec; + data->default_max_update_count = update_count * CLOCKS_PER_SEC / + self.max_updates_per_frame / + LCUI_MAX_FRAMES_PER_SEC / msec; if (data->default_max_update_count < 1) { data->default_max_update_count = 32; } @@ -520,7 +520,7 @@ void LCUIWidget_UpdateWithProfile(LCUI_WidgetTasksProfile profile) } root = LCUIWidget_GetRoot(); for (i = 0; i < self.max_updates_per_frame; ++i) { - Widget_UpdateWithProfile(root, profile); + Widget_UpdateWithProfile(root, profile); } profile->time = clock() - profile->time; profile->destroy_time = clock(); diff --git a/src/image/png.c b/src/image/png.c index d6c570d6..450e04f8 100644 --- a/src/image/png.c +++ b/src/image/png.c @@ -233,7 +233,8 @@ int LCUI_WritePNGFile(const char *file_name, const LCUI_Graph *graph) png_structp png_ptr; png_infop info_ptr; png_bytep *row_pointers; - size_t x, y, row_size; + size_t x, row_size; + int y; if (!Graph_IsValid(graph)) { _DEBUG_MSG("graph is not valid\n"); @@ -322,7 +323,7 @@ int LCUI_WritePNGFile(const char *file_name, const LCUI_Graph *graph) } png_write_image(png_ptr, row_pointers); /* cleanup heap allocation */ - for (y = 0; y < (size_t)rect.height; ++y) { + for (y = 0; y < rect.height; ++y) { free(row_pointers[y]); } free(row_pointers); @@ -336,4 +337,3 @@ int LCUI_WritePNGFile(const char *file_name, const LCUI_Graph *graph) return -ENOSYS; #endif } - diff --git a/src/util/string.c b/src/util/string.c index 9ee1d552..2c303a28 100644 --- a/src/util/string.c +++ b/src/util/string.c @@ -133,12 +133,12 @@ wchar_t *wcsdup2(const wchar_t *str) return out; } -int strtrim(char *outstr, const char *instr, const char *charlist) +size_t strtrim(char *outstr, const char *instr, const char *charlist) { STRTRIM_CODE(char, outstr, instr, charlist, "\t\n\r "); } -int wcstrim(wchar_t *outstr, const wchar_t *instr, const wchar_t *charlist) +size_t wcstrim(wchar_t *outstr, const wchar_t *instr, const wchar_t *charlist) { STRTRIM_CODE(wchar_t, outstr, instr, charlist, L"\t\n\r "); }