diff --git a/.gitignore b/.gitignore index 9269e47614..79d4489ae7 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ **/*.swo tags docs/api_doc +scripts/cppcheck_res.txt diff --git a/scripts/cppcheck_run.sh b/scripts/cppcheck_run.sh index 1db16fc911..98e594cb92 100755 --- a/scripts/cppcheck_run.sh +++ b/scripts/cppcheck_run.sh @@ -1,2 +1,2 @@ -cppcheck --template="{severity}\t{file}:{line}\t{id}: {message}" --enable=all ../src/ --output-file=cppcheck_res.txt --suppress=unusedFunction --suppress=preprocessorErrorDirective --force +cppcheck -j8 --template="{severity}\t{file}:{line}\t{id}: {message}" --enable=all ../src/ --output-file=cppcheck_res.txt --suppress=unusedFunction --suppress=preprocessorErrorDirective --force diff --git a/src/lv_core/lv_debug.c b/src/lv_core/lv_debug.c index cab7c977af..ccdd7f8463 100644 --- a/src/lv_core/lv_debug.c +++ b/src/lv_core/lv_debug.c @@ -122,7 +122,7 @@ bool lv_debug_check_str(const void * str) uint32_t rep = 0; uint32_t i; - for(i = 0; s[i] != '\0' && i < LV_DEBUG_STR_MAX_LENGTH; i++) { + for(i = 0; i < LV_DEBUG_STR_MAX_LENGTH && s[i] != '\0'; i++) { if(s[i] != last_byte) { last_byte = s[i]; rep = 1; diff --git a/src/lv_core/lv_obj.h b/src/lv_core/lv_obj.h index 13984358d5..4cc26967c9 100644 --- a/src/lv_core/lv_obj.h +++ b/src/lv_core/lv_obj.h @@ -227,7 +227,7 @@ typedef struct _lv_obj_t uint8_t adv_hittest :1; /**< 1: Use advanced hit-testing (slower) */ uint8_t gesture_parent : 1; /**< 1: Parent will be gesture instead*/ - lv_drag_dir_t drag_dir :2; /**< Which directions the object can be dragged in */ + lv_drag_dir_t drag_dir :3; /**< Which directions the object can be dragged in */ lv_bidi_dir_t base_dir :2; /**< Base direction of texts related to this object */ #if LV_USE_GROUP != 0 diff --git a/src/lv_core/lv_style.c b/src/lv_core/lv_style.c index d7a4060d60..cef64183ab 100644 --- a/src/lv_core/lv_style.c +++ b/src/lv_core/lv_style.c @@ -812,7 +812,6 @@ lv_res_t lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop, attr.full = prop >> 8; int16_t weight_goal = attr.full; - int16_t weight_act; int16_t weight = -1; lv_style_int_t value_act = 0; @@ -820,7 +819,8 @@ lv_res_t lv_style_list_get_int(lv_style_list_t * list, lv_style_property_t prop, int16_t ci; for(ci = 0; ci < list->style_cnt; ci++) { lv_style_t * class = lv_style_list_get_style(list, ci); - weight_act = _lv_style_get_int(class, prop, &value_act); + int16_t weight_act = _lv_style_get_int(class, prop, &value_act); + /*On perfect match return the value immediately*/ if(weight_act == weight_goal) { *res = value_act; @@ -864,7 +864,6 @@ lv_res_t lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pro attr.full = prop >> 8; int16_t weight_goal = attr.full; - int16_t weight_act; int16_t weight = -1; lv_color_t value_act = { 0 }; @@ -872,7 +871,7 @@ lv_res_t lv_style_list_get_color(lv_style_list_t * list, lv_style_property_t pro int16_t ci; for(ci = 0; ci < list->style_cnt; ci++) { lv_style_t * class = lv_style_list_get_style(list, ci); - weight_act = _lv_style_get_color(class, prop, &value_act); + int16_t weight_act = _lv_style_get_color(class, prop, &value_act); /*On perfect match return the value immediately*/ if(weight_act == weight_goal) { *res = value_act; @@ -915,7 +914,6 @@ lv_res_t lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop, attr.full = prop >> 8; int16_t weight_goal = attr.full; - int16_t weight_act; int16_t weight = -1; lv_opa_t value_act = LV_OPA_TRANSP; @@ -923,7 +921,7 @@ lv_res_t lv_style_list_get_opa(lv_style_list_t * list, lv_style_property_t prop, int16_t ci; for(ci = 0; ci < list->style_cnt; ci++) { lv_style_t * class = lv_style_list_get_style(list, ci); - weight_act = _lv_style_get_opa(class, prop, &value_act); + int16_t weight_act = _lv_style_get_opa(class, prop, &value_act); /*On perfect match return the value immediately*/ if(weight_act == weight_goal) { *res = value_act; @@ -966,7 +964,6 @@ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, attr.full = prop >> 8; int16_t weight_goal = attr.full; - int16_t weight_act; int16_t weight = -1; void * value_act = NULL; @@ -974,7 +971,7 @@ lv_res_t lv_style_list_get_ptr(lv_style_list_t * list, lv_style_property_t prop, int16_t ci; for(ci = 0; ci < list->style_cnt; ci++) { lv_style_t * class = lv_style_list_get_style(list, ci); - weight_act = _lv_style_get_ptr(class, prop, &value_act); + int16_t weight_act = _lv_style_get_ptr(class, prop, &value_act); /*On perfect match return the value immediately*/ if(weight_act == weight_goal) { *res = value_act; diff --git a/src/lv_draw/lv_draw_arc.c b/src/lv_draw/lv_draw_arc.c index 6ae51ccc72..e7c5a1cd5c 100644 --- a/src/lv_draw/lv_draw_arc.c +++ b/src/lv_draw/lv_draw_arc.c @@ -384,7 +384,7 @@ static void get_rounded_area(int16_t angle, lv_coord_t radius, uint8_t tickness, const uint8_t pa = 127; int32_t thick_half = tickness / 2; - uint8_t thick_corr = tickness & 0x01 ? 0 : 1; + uint8_t thick_corr = (tickness & 0x01) ? 0 : 1; int32_t rx_corr; int32_t ry_corr; diff --git a/src/lv_draw/lv_draw_img.c b/src/lv_draw/lv_draw_img.c index 786e2281bb..5dce0e172f 100644 --- a/src/lv_draw/lv_draw_img.c +++ b/src/lv_draw/lv_draw_img.c @@ -348,7 +348,6 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, lv_color_t c; lv_color_t chroma_keyed_color = LV_COLOR_TRANSP; uint32_t px_i = 0; - uint32_t px_i_start; const uint8_t * map_px; @@ -393,7 +392,7 @@ static void lv_draw_map(const lv_area_t * map_area, const lv_area_t * clip_area, int32_t y; for(y = 0; y < lv_area_get_height(&draw_area); y++) { map_px = map_buf_tmp; - px_i_start = px_i; + uint32_t px_i_start = px_i; for(x = 0; x < lv_area_get_width(&draw_area); x++, map_px += px_size_byte, px_i++) { diff --git a/src/lv_draw/lv_draw_label.c b/src/lv_draw/lv_draw_label.c index fb9e26381c..d0f569598e 100644 --- a/src/lv_draw/lv_draw_label.c +++ b/src/lv_draw/lv_draw_label.c @@ -208,8 +208,6 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab /*Write all letter of a line*/ cmd_state = CMD_STATE_WAIT; i = 0; - uint32_t letter; - uint32_t letter_next; #if LV_USE_BIDI char *bidi_txt = lv_mem_buf_get(line_end - line_start + 1); lv_bidi_process_paragraph(txt + line_start, bidi_txt, line_end - line_start, dsc->bidi_dir, NULL, 0); @@ -229,9 +227,8 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab #endif } - letter = lv_txt_encoded_next(bidi_txt, &i); - letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); - + uint32_t letter = lv_txt_encoded_next(bidi_txt, &i); + uint32_t letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); /*Handle the re-color command*/ if((dsc->flag & LV_TXT_FLAG_RECOLOR) != 0) { @@ -465,7 +462,6 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph uint32_t mask_buf_size = box_w * box_h > LV_HOR_RES_MAX ? box_w * box_h : LV_HOR_RES_MAX; lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size); int32_t mask_p = 0; - int32_t mask_p_start; lv_area_t fill_area; fill_area.x1 = col_start + pos_x; @@ -477,7 +473,8 @@ static void draw_letter_normal(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph for(row = row_start ; row < row_end; row++) { bitmask = bitmask_init >> col_bit; - mask_p_start = mask_p; + + int32_t mask_p_start = mask_p; for(col = col_start; col < col_end; col++) { /*Load the pixel's opacity into the mask*/ @@ -605,7 +602,7 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_ int32_t mask_buf_size = box_w * box_h > LV_HOR_RES_MAX ? g->box_w * g->box_h : LV_HOR_RES_MAX; lv_opa_t * mask_buf = lv_mem_buf_get(mask_buf_size); int32_t mask_p = 0; - int32_t mask_p_start; + lv_color_t * color_buf = lv_mem_buf_get(mask_buf_size * sizeof(lv_color_t)); lv_disp_t * disp = lv_refr_get_disp_refreshing(); @@ -639,7 +636,8 @@ static void draw_letter_subpx(lv_coord_t pos_x, lv_coord_t pos_y, lv_font_glyph_ for(row = row_start ; row < row_end; row++) { uint32_t subpx_cnt = 0; bitmask = bitmask_init >> col_bit; - mask_p_start = mask_p; + int32_t mask_p_start = mask_p; + for(col = col_start; col < col_end; col++) { /*Load the pixel's opacity into the mask*/ letter_px = (*map_p & bitmask) >> (8 - col_bit - bpp); diff --git a/src/lv_draw/lv_draw_line.c b/src/lv_draw/lv_draw_line.c index 142da0fc46..44a20b8571 100644 --- a/src/lv_draw/lv_draw_line.c +++ b/src/lv_draw/lv_draw_line.c @@ -169,10 +169,9 @@ static void draw_line_hor(const lv_point_t * point1, const lv_point_t * point2, lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); int32_t h; - lv_draw_mask_res_t mask_res; for(h = draw_area.y1; h <= draw_area.y2; h++) { memset(mask_buf, LV_OPA_COVER, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); + lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); if(dashed) { if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) { @@ -266,10 +265,9 @@ static void draw_line_ver(const lv_point_t * point1, const lv_point_t * point2, lv_style_int_t dash_cnt = dash_start; int32_t h; - lv_draw_mask_res_t mask_res; for(h = draw_area.y1; h <= draw_area.y2; h++) { memset(mask_buf, LV_OPA_COVER, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); + lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); if(dashed) { if(mask_res != LV_DRAW_MASK_RES_FULL_TRANSP) { @@ -390,7 +388,6 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, /*Draw the background line by line*/ int32_t h; - lv_draw_mask_res_t mask_res; lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); lv_area_t fill_area; fill_area.x1 = draw_area.x1 + disp_area->x1; @@ -401,14 +398,14 @@ static void draw_line_skew(const lv_point_t * point1, const lv_point_t * point2, /*Fill the first row with 'color'*/ for(h = draw_area.y1; h <= draw_area.y2; h++) { memset(mask_buf, LV_OPA_COVER, draw_area_w); - mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); + lv_draw_mask_res_t mask_res = lv_draw_mask_apply(mask_buf, vdb->area.x1 + draw_area.x1, vdb->area.y1 + h, draw_area_w); - lv_blend_fill(clip, &fill_area, - dsc->color, mask_buf, mask_res, opa, - dsc->blend_mode); + lv_blend_fill(clip, &fill_area, + dsc->color, mask_buf, mask_res, opa, + dsc->blend_mode); - fill_area.y1++; - fill_area.y2++; + fill_area.y1++; + fill_area.y2++; } lv_mem_buf_release(mask_buf); diff --git a/src/lv_draw/lv_draw_mask.c b/src/lv_draw/lv_draw_mask.c index 5d74704866..e894ee660d 100644 --- a/src/lv_draw/lv_draw_mask.c +++ b/src/lv_draw/lv_draw_mask.c @@ -321,6 +321,7 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert start_side = LV_DRAW_MASK_LINE_SIDE_RIGHT; } else { LV_DEBUG_ASSERT(false, "Unexpected start_angle", start_angle); + return; } if(end_angle >= 0 && end_angle < 180) { @@ -330,6 +331,7 @@ void lv_draw_mask_angle_init(lv_draw_mask_angle_param_t * param, lv_coord_t vert end_side = LV_DRAW_MASK_LINE_SIDE_LEFT; } else { LV_DEBUG_ASSERT(false, "Unexpected end_angle", end_angle); + return; } lv_draw_mask_line_angle_init(¶m->start_line, vertex_x, vertex_y, start_angle, start_side); diff --git a/src/lv_draw/lv_draw_rect.c b/src/lv_draw/lv_draw_rect.c index ee8302e319..b3714e5081 100644 --- a/src/lv_draw/lv_draw_rect.c +++ b/src/lv_draw/lv_draw_rect.c @@ -136,10 +136,10 @@ static void draw_bg(const lv_area_t * coords, const lv_area_t * clip, lv_draw_re /*If the border fully covers make the bg area 1px smaller to avoid artifacts on the corners*/ if(dsc->border_width > 1 && dsc->border_opa >= LV_OPA_MAX && dsc->radius != 0) { - coords_bg.x1 += dsc->border_side & LV_BORDER_SIDE_LEFT ? 1 : 0; - coords_bg.y1 += dsc->border_side & LV_BORDER_SIDE_TOP ? 1 : 0; - coords_bg.x2 -= dsc->border_side & LV_BORDER_SIDE_RIGHT ? 1 : 0; - coords_bg.y2 -= dsc->border_side & LV_BORDER_SIDE_BOTTOM ? 1 : 0; + coords_bg.x1 += (dsc->border_side & LV_BORDER_SIDE_LEFT) ? 1 : 0; + coords_bg.y1 += (dsc->border_side & LV_BORDER_SIDE_TOP) ? 1 : 0; + coords_bg.x2 -= (dsc->border_side & LV_BORDER_SIDE_RIGHT) ? 1 : 0; + coords_bg.y2 -= (dsc->border_side & LV_BORDER_SIDE_BOTTOM) ? 1 : 0; } lv_opa_t opa = dsc->bg_opa; @@ -615,8 +615,6 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra else if(dsc->shadow_ofs_x != 0 || dsc->shadow_ofs_y != 0) simple_mode = false; else if(dsc->shadow_spread != 0) simple_mode = false; - int32_t y_max; - /*Create a mask*/ lv_draw_mask_res_t mask_res; lv_opa_t * mask_buf = lv_mem_buf_get(lv_area_get_width(&sh_rect_area)); @@ -624,8 +622,7 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra lv_draw_mask_radius_param_t mask_rout_param; lv_draw_mask_radius_init(&mask_rout_param, &bg_coords, r_bg, true); - int16_t mask_rout_id = LV_MASK_ID_INV; - mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); + int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); lv_area_t a; @@ -838,10 +835,9 @@ static void draw_shadow(const lv_area_t * coords, const lv_area_t * clip, lv_dra } if(a.x1 <= a.x2) { - sh_buf_tmp = sh_buf + corner_size - 1; - y_max = corner_size - ver_mid_dist; + int32_t y_max = corner_size - ver_mid_dist; if(simple_mode) { y_max = sw / 2 + 1; if(y_max > corner_size - ver_mid_dist) y_max = corner_size - ver_mid_dist; @@ -925,7 +921,7 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, lv_area_t sh_area; lv_area_copy(&sh_area, coords); - sh_area.x2 = sw / 2 + r -1 - (sw & 1 ? 0 : 1); + sh_area.x2 = sw / 2 + r -1 - ((sw & 1) ? 0 : 1); sh_area.y1 = sw / 2 + 1; sh_area.x1 = sh_area.x2 - lv_area_get_width(coords); @@ -940,13 +936,12 @@ static void shadow_draw_corner_buf(const lv_area_t * coords, uint16_t * sh_buf, else sw = sw_ori >> 1; #endif - lv_draw_mask_res_t mask_res; int32_t y; lv_opa_t * mask_line = lv_mem_buf_get(size); uint16_t * sh_ups_tmp_buf = (uint16_t *)sh_buf; for(y = 0; y < size; y++) { memset(mask_line, 0xFF, size); - mask_res = mask_param.dsc.cb(mask_line, 0, y, size, &mask_param); + lv_draw_mask_res_t mask_res = mask_param.dsc.cb(mask_line, 0, y, size, &mask_param); if(mask_res == LV_DRAW_MASK_RES_FULL_TRANSP) { memset(sh_ups_tmp_buf, 0x00, size * sizeof(sh_ups_tmp_buf[0])); } else { @@ -1144,10 +1139,9 @@ static void draw_outline(const lv_area_t * coords, const lv_area_t * clip, lv_dr lv_draw_mask_radius_init(&mask_rin_param, &area_inner, rin, true); int16_t mask_rin_id = lv_draw_mask_add(&mask_rin_param, NULL); - int16_t mask_rout_id = LV_MASK_ID_INV; lv_draw_mask_radius_param_t mask_rout_param; lv_draw_mask_radius_init(&mask_rout_param, &area_outer, rout, false); - mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); + int16_t mask_rout_id = lv_draw_mask_add(&mask_rout_param, NULL); lv_opa_t * mask_buf = lv_mem_buf_get(draw_area_w); diff --git a/src/lv_draw/lv_img_buf.c b/src/lv_draw/lv_img_buf.c index 9464a0c2f2..d740e5e3b0 100644 --- a/src/lv_draw/lv_img_buf.c +++ b/src/lv_draw/lv_img_buf.c @@ -646,19 +646,15 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc) a01 = lv_img_buf_get_px_alpha(&dsc->tmp.img_dsc, dsc->tmp.xs_int, dsc->tmp.ys_int + yn); a11 = lv_img_buf_get_px_alpha(&dsc->tmp.img_dsc, dsc->tmp.xs_int + xn, dsc->tmp.ys_int + yn); } - } - lv_opa_t a0; - lv_opa_t a1; lv_opa_t xr0 = xr; lv_opa_t xr1 = xr; if(dsc->tmp.has_alpha) { - a0 = (a00 * xr + (a10 * (255 - xr))) >> 8; - a1 = (a01 * xr + (a11 * (255 - xr))) >> 8; + lv_opa_t a0 = (a00 * xr + (a10 * (255 - xr))) >> 8; + lv_opa_t a1 = (a01 * xr + (a11 * (255 - xr))) >> 8; dsc->res.opa = (a0 * yr + (a1 * (255 - yr))) >> 8; - if(a0 <= LV_OPA_MIN && a1 <= LV_OPA_MIN) return false; if(a0 <= LV_OPA_MIN) yr = LV_OPA_TRANSP; if(a1 <= LV_OPA_MIN) yr = LV_OPA_COVER; @@ -666,7 +662,6 @@ static inline bool transform_anti_alias(lv_img_transform_dsc_t * dsc) if(a10 <= LV_OPA_MIN) xr0 = LV_OPA_COVER; if(a01 <= LV_OPA_MIN) xr1 = LV_OPA_TRANSP; if(a11 <= LV_OPA_MIN) xr1 = LV_OPA_COVER; - } else { xr0 = xr; xr1 = xr; diff --git a/src/lv_draw/lv_img_decoder.c b/src/lv_draw/lv_img_decoder.c index debf3b31e2..c8121681c0 100644 --- a/src/lv_draw/lv_img_decoder.c +++ b/src/lv_draw/lv_img_decoder.c @@ -287,6 +287,10 @@ lv_res_t lv_img_decoder_built_in_info(lv_img_decoder_t * decoder, const void * s if(res == LV_FS_RES_OK) { res = lv_fs_read(&file, header, sizeof(lv_img_header_t), &rn); lv_fs_close(&file); + if(res != LV_FS_RES_OK || rn != sizeof(lv_img_header_t)) { + LV_LOG_WARN("Image get info get read file header"); + return LV_RES_INV; + } } if(header->cf < CF_BUILT_IN_FIRST || header->cf > CF_BUILT_IN_LAST) return LV_RES_INV; @@ -643,9 +647,8 @@ static lv_res_t lv_img_decoder_built_in_line_alpha(lv_img_decoder_dsc_t * dsc, l #endif } - uint8_t val_act; for(i = 0; i < len; i++) { - val_act = (*data_tmp & (mask << pos)) >> pos; + uint8_t val_act = (*data_tmp & (mask << pos)) >> pos; buf[i * LV_IMG_PX_SIZE_ALPHA_BYTE + LV_IMG_PX_SIZE_ALPHA_BYTE - 1] = dsc->header.cf == LV_IMG_CF_ALPHA_8BIT ? val_act : opa_table[val_act]; @@ -729,10 +732,9 @@ static lv_res_t lv_img_decoder_built_in_line_indexed(lv_img_decoder_dsc_t * dsc, #endif } - uint8_t val_act; lv_coord_t i; for(i = 0; i < len; i++) { - val_act = (*data_tmp & (mask << pos)) >> pos; + uint8_t val_act = (*data_tmp & (mask << pos)) >> pos; lv_color_t color = user_data->palette[val_act]; #if LV_COLOR_DEPTH == 8 || LV_COLOR_DEPTH == 1 diff --git a/src/lv_hal/lv_hal_indev.h b/src/lv_hal/lv_hal_indev.h index 1a9d23559e..02e791a11a 100644 --- a/src/lv_hal/lv_hal_indev.h +++ b/src/lv_hal/lv_hal_indev.h @@ -52,10 +52,10 @@ typedef uint8_t lv_indev_state_t; enum { - LV_DRAG_DIR_HOR = 0x0, /**< Object can be dragged horizontally. */ - LV_DRAG_DIR_VER = 0x1, /**< Object can be dragged vertically. */ - LV_DRAG_DIR_BOTH = 0x2, /**< Object can be dragged in all directions. */ - LV_DRAG_DIR_ONE = 0x3, /**< Object can be dragged only one direction (the first move). */ + LV_DRAG_DIR_HOR = 0x1, /**< Object can be dragged horizontally. */ + LV_DRAG_DIR_VER = 0x2, /**< Object can be dragged vertically. */ + LV_DRAG_DIR_BOTH = 0x3, /**< Object can be dragged in all directions. */ + LV_DRAG_DIR_ONE = 0x4, /**< Object can be dragged only one direction (the first move). */ }; typedef uint8_t lv_drag_dir_t; diff --git a/src/lv_misc/lv_fs.c b/src/lv_misc/lv_fs.c index a23081cebb..dff796a0fc 100644 --- a/src/lv_misc/lv_fs.c +++ b/src/lv_misc/lv_fs.c @@ -163,11 +163,10 @@ lv_fs_res_t lv_fs_close(lv_fs_file_t * file_p) lv_fs_res_t lv_fs_remove(const char * path) { if(path == NULL) return LV_FS_RES_INV_PARAM; - lv_fs_drv_t * drv = NULL; char letter = path[0]; - drv = lv_fs_get_drv(letter); + lv_fs_drv_t * drv = lv_fs_get_drv(letter); if(drv == NULL) return LV_FS_RES_NOT_EX; if(drv->ready_cb != NULL) { if(drv->ready_cb(drv) == false) return LV_FS_RES_HW_ERR; diff --git a/src/lv_misc/lv_ll.c b/src/lv_misc/lv_ll.c index 57cbfa4182..a4f0acba41 100644 --- a/src/lv_misc/lv_ll.c +++ b/src/lv_misc/lv_ll.c @@ -105,7 +105,6 @@ void * lv_ll_ins_head(lv_ll_t * ll_p) void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act) { lv_ll_node_t * n_new; - lv_ll_node_t * n_prev; if(NULL == ll_p || NULL == n_act) return NULL; @@ -116,6 +115,7 @@ void * lv_ll_ins_prev(lv_ll_t * ll_p, void * n_act) n_new = lv_mem_alloc(ll_p->n_size + LL_NODE_META_SIZE); if(n_new == NULL) return NULL; + lv_ll_node_t * n_prev; n_prev = lv_ll_get_prev(ll_p, n_act); node_set_next(ll_p, n_prev, n_new); node_set_prev(ll_p, n_new, n_prev); diff --git a/src/lv_misc/lv_printf.c b/src/lv_misc/lv_printf.c index e05f35bebf..d5782c9102 100644 --- a/src/lv_misc/lv_printf.c +++ b/src/lv_misc/lv_printf.c @@ -38,6 +38,8 @@ #include +#define PRINTF_DISABLE_SUPPORT_FLOAT 1 + // 'ntoa' conversion buffer size, this must be big enough to hold one converted // numeric number including padded zeros (dynamically created on stack) // default: 32 byte diff --git a/src/lv_misc/lv_txt.c b/src/lv_misc/lv_txt.c index f1e0212e25..d31a2f37cd 100644 --- a/src/lv_misc/lv_txt.c +++ b/src/lv_misc/lv_txt.c @@ -102,7 +102,6 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * uint32_t line_start = 0; uint32_t new_line_start = 0; - lv_coord_t act_line_length; uint16_t letter_height = lv_font_get_line_height(font); /*Calc. the height and longest line*/ @@ -112,7 +111,7 @@ void lv_txt_get_size(lv_point_t * size_res, const char * text, const lv_font_t * size_res->y += line_space; /*Calculate the the longest line*/ - act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space, flag); + lv_coord_t act_line_length = lv_txt_get_width(&text[line_start], new_line_start - line_start, font, letter_space, flag); size_res->x = LV_MATH_MAX(act_line_length, size_res->x); line_start = new_line_start; @@ -340,13 +339,11 @@ lv_coord_t lv_txt_get_width(const char * txt, uint16_t length, const lv_font_t * uint32_t i = 0; lv_coord_t width = 0; lv_txt_cmd_state_t cmd_state = LV_TXT_CMD_STATE_WAIT; - uint32_t letter; - uint32_t letter_next; if(length != 0) { while(i < length) { - letter = lv_txt_encoded_next(txt, &i); - letter_next = lv_txt_encoded_next(&txt[i], NULL); + uint32_t letter = lv_txt_encoded_next(txt, &i); + uint32_t letter_next = lv_txt_encoded_next(&txt[i], NULL); if((flag & LV_TXT_FLAG_RECOLOR) != 0) { if(lv_txt_is_cmd(&cmd_state, letter) != false) { continue; diff --git a/src/lv_widgets/lv_btnmatrix.c b/src/lv_widgets/lv_btnmatrix.c index 52c772ddb4..6dbc7a0b78 100644 --- a/src/lv_widgets/lv_btnmatrix.c +++ b/src/lv_widgets/lv_btnmatrix.c @@ -182,17 +182,15 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]) /* Count the units and the buttons in a line * (A button can be 1,2,3... unit wide)*/ - uint16_t unit_cnt; /*Number of units in a row*/ uint16_t unit_act_cnt; /*Number of units currently put in a row*/ - uint16_t btn_cnt; /*Number of buttons in a row*/ uint16_t i_tot = 0; /*Act. index in the str map*/ uint16_t btn_i = 0; /*Act. index of button areas*/ const char ** map_p_tmp = map; /*Count the units and the buttons in a line*/ while(1) { - unit_cnt = 0; - btn_cnt = 0; + uint16_t unit_cnt = 0; /*Number of units in a row*/ + uint16_t btn_cnt = 0; /*Number of buttons in a row*/ /*Count the buttons in a line*/ while(strcmp(map_p_tmp[btn_cnt], "\n") != 0 && strlen(map_p_tmp[btn_cnt]) != 0) { /*Check a line*/ unit_cnt += get_button_width(ext->ctrl_bits[btn_i + btn_cnt]); @@ -215,13 +213,12 @@ void lv_btnmatrix_set_map(lv_obj_t * btnm, const char * map[]) uint16_t i; lv_coord_t act_x; - lv_coord_t act_unit_w; unit_act_cnt = 0; for(i = 0; i < btn_cnt; i++) { /* one_unit_w = all_unit_w / unit_cnt * act_unit_w = one_unit_w * button_width * do this two operations but the multiply first to divide a greater number */ - act_unit_w = (all_unit_w * get_button_width(ext->ctrl_bits[btn_i])) / unit_cnt; + lv_coord_t act_unit_w = (all_unit_w * get_button_width(ext->ctrl_bits[btn_i])) / unit_cnt; act_unit_w--; /*-1 because e.g. width = 100 means 101 pixels (0..100)*/ /*Always recalculate act_x because of rounding errors */ @@ -547,7 +544,7 @@ bool lv_btnmatrix_get_btn_ctrl(lv_obj_t * btnm, uint16_t btn_id, lv_btnmatrix_ct lv_btnmatrix_ext_t * ext = lv_obj_get_ext_attr(btnm); if(btn_id >= ext->btn_cnt) return false; - return ext->ctrl_bits[btn_id] & ctrl ? true : false; + return (ext->ctrl_bits[btn_id] & ctrl) ? true : false; } @@ -1074,32 +1071,32 @@ static uint8_t get_button_width(lv_btnmatrix_ctrl_t ctrl_bits) static bool button_is_hidden(lv_btnmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_HIDDEN ? true : false; + return (ctrl_bits & LV_BTNMATRIX_CTRL_HIDDEN) ? true : false; } static bool button_is_repeat_disabled(lv_btnmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_NO_REPEAT ? true : false; + return (ctrl_bits & LV_BTNMATRIX_CTRL_NO_REPEAT) ? true : false; } static bool button_is_inactive(lv_btnmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_INACTIVE ? true : false; + return (ctrl_bits & LV_BTNMATRIX_CTRL_INACTIVE) ? true : false; } static bool button_is_click_trig(lv_btnmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_CLICK_TRIG ? true : false; + return (ctrl_bits & LV_BTNMATRIX_CTRL_CLICK_TRIG) ? true : false; } static bool button_is_tgl_enabled(lv_btnmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_CHECKABLE ? true : false; + return (ctrl_bits & LV_BTNMATRIX_CTRL_CHECKABLE) ? true : false; } static bool button_get_tgl_state(lv_btnmatrix_ctrl_t ctrl_bits) { - return ctrl_bits & LV_BTNMATRIX_CTRL_CHECK_STATE ? true : false; + return (ctrl_bits & LV_BTNMATRIX_CTRL_CHECK_STATE) ? true : false; } /** diff --git a/src/lv_widgets/lv_chart.c b/src/lv_widgets/lv_chart.c index 813c82ebd9..8e593b638b 100644 --- a/src/lv_widgets/lv_chart.c +++ b/src/lv_widgets/lv_chart.c @@ -776,9 +776,6 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co lv_coord_t h = lv_area_get_height(series_area); lv_coord_t x_ofs = series_area->x1; lv_coord_t y_ofs = series_area->y1; - int32_t y_tmp; - lv_coord_t p_prev; - lv_coord_t p_act; lv_chart_series_t * ser; lv_area_t series_mask; @@ -824,9 +821,9 @@ static void draw_series_line(lv_obj_t * chart, const lv_area_t * series_area, co p1.x = 0 + x_ofs; p2.x = 0 + x_ofs; - p_act = start_point; - p_prev = start_point; - y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin) * h; + lv_coord_t p_act = start_point; + lv_coord_t p_prev = start_point; + int32_t y_tmp = (int32_t)((int32_t)ser->points[p_prev] - ext->ymin) * h; y_tmp = y_tmp / (ext->ymax - ext->ymin); p2.y = h - y_tmp + y_ofs; @@ -939,11 +936,9 @@ static void draw_series_column(lv_obj_t * chart, const lv_area_t * series_area, bool mask_ret = lv_area_intersect(&series_mask, series_area, clip_area); if(mask_ret == false) return; - lv_coord_t x_act; - /*Go through all points*/ for(i = 0; i < ext->point_cnt; i++) { - x_act = (int32_t)((int32_t)w * i) / ext->point_cnt; + lv_coord_t x_act = (int32_t)((int32_t)w * i) / ext->point_cnt; x_act += series_area->x1 + x_ofs; /*Draw the current point of all data line*/ diff --git a/src/lv_widgets/lv_dropdown.c b/src/lv_widgets/lv_dropdown.c index 97c60dc6bd..0f5199d2d1 100644 --- a/src/lv_widgets/lv_dropdown.c +++ b/src/lv_widgets/lv_dropdown.c @@ -370,7 +370,7 @@ void lv_dropdown_get_selected_str(const lv_obj_t * ddlist, char * buf, uint16_t } uint16_t c; - for(c = 0; ext->options[i] != '\n' && i < txt_len; c++, i++) { + for(c = 0; i < txt_len && ext->options[i] != '\n'; c++, i++) { if(buf_size && c >= buf_size - 1) { LV_LOG_WARN("lv_dropdown_get_selected_str: the buffer was too small") break; @@ -1094,9 +1094,8 @@ static uint16_t get_id_on_point(lv_obj_t * ddlist, lv_coord_t x, lv_coord_t y) uint32_t i_prev = 0; uint32_t letter_cnt = 0; - uint32_t letter; for(letter_cnt = 0; letter_cnt < letter_i; letter_cnt++) { - letter = lv_txt_encoded_next(txt, &i); + uint32_t letter = lv_txt_encoded_next(txt, &i); /*Count he lines to reach the clicked letter. But ignore the last '\n' because it * still belongs to the clicked line*/ if(letter == '\n' && i_prev != letter_i) opt++; diff --git a/src/lv_widgets/lv_img.c b/src/lv_widgets/lv_img.c index 24217eea3d..c7b636d332 100644 --- a/src/lv_widgets/lv_img.c +++ b/src/lv_widgets/lv_img.c @@ -61,10 +61,8 @@ lv_obj_t * lv_img_create(lv_obj_t * par, const lv_obj_t * copy) { LV_LOG_TRACE("image create started"); - lv_obj_t * img = NULL; - /*Create a basic object*/ - img = lv_obj_create(par, copy); + lv_obj_t * img = lv_obj_create(par, copy); LV_ASSERT_MEM(img); if(img == NULL) return NULL; diff --git a/src/lv_widgets/lv_keyboard.c b/src/lv_widgets/lv_keyboard.c index 05dd0c9e29..11e73ea047 100644 --- a/src/lv_widgets/lv_keyboard.c +++ b/src/lv_widgets/lv_keyboard.c @@ -156,7 +156,6 @@ lv_obj_t * lv_keyboard_create(lv_obj_t * par, const lv_obj_t * copy) /*Copy an existing keyboard*/ else { lv_keyboard_ext_t * copy_ext = lv_obj_get_ext_attr(copy); - ext->ta = NULL; ext->ta = copy_ext->ta; ext->mode = copy_ext->mode; ext->cursor_mng = copy_ext->cursor_mng; diff --git a/src/lv_widgets/lv_label.c b/src/lv_widgets/lv_label.c index d822998bf5..2c86831c98 100644 --- a/src/lv_widgets/lv_label.c +++ b/src/lv_widgets/lv_label.c @@ -254,11 +254,13 @@ void lv_label_set_text_fmt(lv_obj_t * label, const char * fmt, ...) uint32_t len = lv_vsnprintf(NULL, 0, fmt, ap); va_end(ap); - ext->text = lv_mem_alloc(len+1); LV_ASSERT_MEM(ext->text); - if(ext->text == NULL) return; + if(ext->text == NULL) { + va_end(ap2); + return; + } ext->text[len-1] = 0; /* Ensure NULL termination */ lv_vsnprintf(ext->text, len+1, fmt, ap2); @@ -736,16 +738,14 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos) uint32_t i = 0; uint32_t i_act = i; - uint32_t letter; - uint32_t letter_next; if(new_line_start > 0) { while(i + line_start < new_line_start) { /* Get the current letter.*/ - letter = lv_txt_encoded_next(bidi_txt, &i); + uint32_t letter = lv_txt_encoded_next(bidi_txt, &i); /*Get the next letter too for kerning*/ - letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); + uint32_t letter_next = lv_txt_encoded_next(&bidi_txt[i], NULL); /*Handle the recolor command*/ if((flag & LV_TXT_FLAG_RECOLOR) != 0) { diff --git a/src/lv_widgets/lv_roller.c b/src/lv_widgets/lv_roller.c index a6557c370a..717d0029dc 100644 --- a/src/lv_widgets/lv_roller.c +++ b/src/lv_widgets/lv_roller.c @@ -292,7 +292,7 @@ void lv_roller_get_selected_str(const lv_obj_t * roller, char * buf, uint16_t bu } uint16_t c; - for(c = 0; opt_txt[i] != '\n' && i < txt_len; c++, i++) { + for(c = 0; i < txt_len && opt_txt[i] != '\n'; c++, i++) { if(buf_size && c >= buf_size - 1) { LV_LOG_WARN("lv_dropdown_get_selected_str: the buffer was too small") break; @@ -758,9 +758,8 @@ static lv_res_t release_handler(lv_obj_t * roller) uint32_t i_prev = 0; uint32_t letter_cnt = 0; - uint32_t letter; for(letter_cnt = 0; letter_cnt < letter_i; letter_cnt++) { - letter = lv_txt_encoded_next(txt, &i); + uint32_t letter = lv_txt_encoded_next(txt, &i); /*Count he lines to reach the clicked letter. But ignore the last '\n' because it * still belongs to the clicked line*/ if(letter == '\n' && i_prev != letter_i) new_opt++; diff --git a/src/lv_widgets/lv_slider.c b/src/lv_widgets/lv_slider.c index 365172aeb7..a44cd3b977 100644 --- a/src/lv_widgets/lv_slider.c +++ b/src/lv_widgets/lv_slider.c @@ -255,18 +255,20 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par if(sign == LV_SIGNAL_PRESSED) { ext->dragging = true; - if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_RANGE) { - lv_indev_get_point(param, &p); - bool hor = lv_obj_get_width(slider) >= lv_obj_get_height(slider); + if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_NORMAL) { + ext->value_to_set = &ext->bar.cur_value; + } else if(lv_slider_get_type(slider) == LV_SLIDER_TYPE_RANGE) { + lv_indev_get_point(param, &p); + bool hor = lv_obj_get_width(slider) >= lv_obj_get_height(slider); - lv_coord_t dist_left, dist_right; - if(hor) { - if(p.x > ext->right_knob_area.x2) { - ext->value_to_set = &ext->bar.cur_value; - } - else if(p.x < ext->left_knob_area.x1) { + lv_coord_t dist_left, dist_right; + if(hor) { + if(p.x > ext->right_knob_area.x2) { + ext->value_to_set = &ext->bar.cur_value; + } + else if(p.x < ext->left_knob_area.x1) { ext->value_to_set = &ext->bar.start_value; - } else { + } else { /* Calculate the distance from each knob */ dist_left = LV_MATH_ABS((ext->left_knob_area.x1+(ext->left_knob_area.x2 - ext->left_knob_area.x1)/2) - p.x); dist_right = LV_MATH_ABS((ext->right_knob_area.x1+(ext->right_knob_area.x2 - ext->right_knob_area.x1)/2) - p.x); @@ -274,14 +276,24 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par /* Use whichever one is closer */ if(dist_right < dist_left)ext->value_to_set = &ext->bar.cur_value; else ext->value_to_set = &ext->bar.start_value; - } - } else { - dist_left = LV_MATH_ABS((ext->left_knob_area.y1+(ext->left_knob_area.y2 - ext->left_knob_area.y1)/2) - p.y); - dist_right = LV_MATH_ABS((ext->right_knob_area.y1+(ext->right_knob_area.y2 - ext->right_knob_area.y1)/2) - p.y); - } + } + } else { + if(p.y < ext->right_knob_area.y1) { + ext->value_to_set = &ext->bar.cur_value; + } + else if(p.y > ext->left_knob_area.y2) { + ext->value_to_set = &ext->bar.start_value; + } else { + /* Calculate the distance from each knob */ + dist_left = LV_MATH_ABS((ext->left_knob_area.y1+(ext->left_knob_area.y2 - ext->left_knob_area.y1)/2) - p.y); + dist_right = LV_MATH_ABS((ext->right_knob_area.y1+(ext->right_knob_area.y2 - ext->right_knob_area.y1)/2) - p.y); - } else - ext->value_to_set = &ext->bar.cur_value; + /* Use whichever one is closer */ + if(dist_right < dist_left)ext->value_to_set = &ext->bar.cur_value; + else ext->value_to_set = &ext->bar.start_value; + } + } + } } else if(sign == LV_SIGNAL_PRESSING && ext->value_to_set != NULL) { lv_indev_get_point(param, &p); @@ -298,11 +310,11 @@ static lv_res_t lv_slider_signal(lv_obj_t * slider, lv_signal_t sign, void * par int16_t real_max_value = ext->bar.max_value; int16_t real_min_value = ext->bar.min_value; - if(w >= h) { - lv_coord_t indic_w = w - bg_left - bg_right; - new_value = p.x - (slider->coords.x1 + bg_left); /*Make the point relative to the indicator*/ - new_value = (new_value * range) / indic_w; - new_value += ext->bar.min_value; + if(w >= h) { + lv_coord_t indic_w = w - bg_left - bg_right; + new_value = p.x - (slider->coords.x1 + bg_left); /*Make the point relative to the indicator*/ + new_value = (new_value * range) / indic_w; + new_value += ext->bar.min_value; } else { lv_coord_t indic_h = h - bg_bottom - bg_top; new_value = p.y - (slider->coords.y2 + bg_bottom); /*Make the point relative to the indicator*/ diff --git a/src/lv_widgets/lv_table.c b/src/lv_widgets/lv_table.c index 13260e35cb..553cbca949 100644 --- a/src/lv_widgets/lv_table.c +++ b/src/lv_widgets/lv_table.c @@ -584,7 +584,6 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_ lv_table_ext_t * ext = lv_obj_get_ext_attr(table); - lv_coord_t h_row; lv_point_t txt_size; lv_area_t cell_area; lv_area_t txt_area; @@ -630,7 +629,7 @@ static lv_design_res_t lv_table_design(lv_obj_t * table, const lv_area_t * clip_ cell_area.y2 = table->coords.y1 + bg_top; for(row = 0; row < ext->row_cnt; row++) { - h_row = get_row_height(table, row, font, letter_space, line_space, + lv_coord_t h_row = get_row_height(table, row, font, letter_space, line_space, cell_left, cell_right, cell_top, cell_bottom); cell_area.y1 = cell_area.y2 + 1; diff --git a/src/lv_widgets/lv_tabview.c b/src/lv_widgets/lv_tabview.c index 26e1d7908f..173d08adfa 100644 --- a/src/lv_widgets/lv_tabview.c +++ b/src/lv_widgets/lv_tabview.c @@ -169,11 +169,9 @@ lv_obj_t * lv_tabview_create(lv_obj_t * par, const lv_obj_t * copy) lv_style_list_copy(lv_obj_get_style_list(tabview, LV_TABVIEW_PART_TAB), lv_obj_get_style_list(copy, LV_TABVIEW_PART_TAB)); uint16_t i; - lv_obj_t * new_tab; - lv_obj_t * copy_tab; for(i = 0; i < copy_ext->tab_cnt; i++) { - new_tab = lv_tabview_add_tab(tabview, copy_ext->tab_name_ptr[i]); - copy_tab = lv_tabview_get_tab(copy, i); + lv_obj_t * new_tab = lv_tabview_add_tab(tabview, copy_ext->tab_name_ptr[i]); + lv_obj_t * copy_tab = lv_tabview_get_tab(copy, i); lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCRL), lv_obj_get_style_list(copy_tab, LV_PAGE_PART_SCRL)); lv_style_list_copy(lv_obj_get_style_list(new_tab, LV_PAGE_PART_SCRLBAR), lv_obj_get_style_list(copy_tab, LV_PAGE_PART_SCRLBAR)); lv_obj_refresh_style(new_tab); diff --git a/src/lv_widgets/lv_textarea.c b/src/lv_widgets/lv_textarea.c index 1438b5847e..1a4c3f6c02 100644 --- a/src/lv_widgets/lv_textarea.c +++ b/src/lv_widgets/lv_textarea.c @@ -1664,9 +1664,9 @@ static bool char_is_accepted(lv_obj_t * ta, uint32_t c) /*Accepted character?*/ if(ext->accapted_chars) { uint32_t i = 0; - uint32_t a; + while(ext->accapted_chars[i] != '\0') { - a = lv_txt_encoded_next(ext->accapted_chars, &i); + uint32_t a = lv_txt_encoded_next(ext->accapted_chars, &i); if(a == c) return true; /*Accepted*/ } diff --git a/src/lv_widgets/lv_tileview.c b/src/lv_widgets/lv_tileview.c index ff2376f799..b25f0108c7 100644 --- a/src/lv_widgets/lv_tileview.c +++ b/src/lv_widgets/lv_tileview.c @@ -256,7 +256,7 @@ void lv_tileview_set_tile_act(lv_obj_t * tileview, lv_coord_t x, lv_coord_t y, l lv_obj_set_pos(scrl, x_coord, y_coord); } - lv_res_t res = LV_RES_OK; + lv_res_t res; res = lv_event_send(tileview, LV_EVENT_VALUE_CHANGED, &tile_id); if(res != LV_RES_OK) return; /*Prevent the tile loading*/ diff --git a/src/lv_widgets/lv_win.c b/src/lv_widgets/lv_win.c index f47b34bdbd..13480c83cd 100644 --- a/src/lv_widgets/lv_win.c +++ b/src/lv_widgets/lv_win.c @@ -119,14 +119,13 @@ lv_obj_t * lv_win_create(lv_obj_t * par, const lv_obj_t * copy) strcpy(ext->title_txt, copy_ext->title_txt); ext->page = lv_page_create(new_win, copy_ext->page); - /*Copy the control buttons*/ + /*Copy the buttons*/ lv_obj_t * child; - lv_obj_t * cbtn; child = lv_obj_get_child_back(copy_ext->header, NULL); child = lv_obj_get_child_back(copy_ext->header, child); /*Sip the title*/ while(child != NULL) { - cbtn = lv_btn_create(ext->header, child); - lv_img_create(cbtn, lv_obj_get_child(child, NULL)); + lv_obj_t * btn = lv_btn_create(ext->header, child); + lv_img_create(btn, lv_obj_get_child(child, NULL)); child = lv_obj_get_child_back(copy_ext->header, child); }