Skip to content

Commit b5e463a

Browse files
committed
fix stm32 build error and warnings
1 parent 2978a83 commit b5e463a

7 files changed

Lines changed: 25 additions & 47 deletions

File tree

src/base/graphic_buffer.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* File: graphic_buffer.c
33
* Author: AWTK Develop Team
44
* Brief: graphic_buffer
@@ -62,20 +62,20 @@ ret_t graphic_buffer_attach(graphic_buffer_t* buffer, void* data, uint32_t w, ui
6262
}
6363

6464
ret_t graphic_buffer_set_physical_width(graphic_buffer_t* buffer, uint32_t width) {
65-
return_value_if_fail(buffer != NULL && buffer->vt != NULL && buffer->vt->set_width != NULL, 0);
65+
return_value_if_fail(buffer != NULL && buffer->vt != NULL && buffer->vt->set_width != NULL, RET_BAD_PARAMS);
6666

6767
return buffer->vt->set_width(buffer, width);
6868
}
6969

7070
ret_t graphic_buffer_set_physical_height(graphic_buffer_t* buffer, uint32_t height) {
71-
return_value_if_fail(buffer != NULL && buffer->vt != NULL && buffer->vt->set_height != NULL, 0);
71+
return_value_if_fail(buffer != NULL && buffer->vt != NULL && buffer->vt->set_height != NULL, RET_BAD_PARAMS);
7272

7373
return buffer->vt->set_height(buffer, height);
7474
}
7575

7676
ret_t graphic_buffer_set_physical_line_length(graphic_buffer_t* buffer, uint32_t line_length) {
7777
return_value_if_fail(buffer != NULL && buffer->vt != NULL && buffer->vt->set_line_length != NULL,
78-
0);
78+
RET_BAD_PARAMS);
7979

8080
return buffer->vt->set_line_length(buffer, line_length);
8181
}

src/base/text_edit.c

Lines changed: 3 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* File: text_edit.c
33
* Author: AWTK Develop Team
44
* Brief: text_edit
@@ -1676,35 +1676,6 @@ const uint32_t* text_edit_get_lines_of_each_row(text_edit_t* text_edit) {
16761676
return lines_of_each_row;
16771677
}
16781678

1679-
static uint32_t text_edit_get_line_break_offset(text_edit_t* text_edit, uint32_t num) {
1680-
uint32_t offset = 0;
1681-
uint32_t i = 0;
1682-
wstr_t* text = NULL;
1683-
DECL_IMPL(text_edit);
1684-
return_value_if_fail(text_edit != NULL && text_edit->widget != NULL, -1);
1685-
return_value_if_fail(0 < num && num < impl->rows->capacity, -1);
1686-
1687-
if (num >= impl->rows->size) {
1688-
return -1;
1689-
}
1690-
1691-
text = &text_edit->widget->text;
1692-
1693-
for (i = 0; i < num; i++) {
1694-
offset += impl->rows->row[i].length;
1695-
}
1696-
1697-
if (offset >= 2 && TWINS_WCHAR_IS_LINE_BREAK(text->str[offset - 2], text->str[offset - 1])) {
1698-
offset -= 2;
1699-
} else if (offset >= 1 && WCHAR_IS_LINE_BREAK(text->str[offset - 1])) {
1700-
offset--;
1701-
} else {
1702-
offset = -1;
1703-
}
1704-
1705-
return offset;
1706-
}
1707-
17081679
ret_t text_edit_set_canvas(text_edit_t* text_edit, canvas_t* canvas) {
17091680
return_value_if_fail(text_edit != NULL && canvas != NULL, RET_BAD_PARAMS);
17101681

@@ -2102,8 +2073,6 @@ ret_t text_edit_key_down(text_edit_t* text_edit, key_event_t* evt) {
21022073
stb_textedit_key(text_edit, state, STB_TEXTEDIT_K_LINEEND);
21032074
}
21042075
goto layout;
2105-
2106-
return RET_OK;
21072076
}
21082077
break;
21092078
}
@@ -2295,12 +2264,12 @@ inline static bool_t text_edit_str_is_delete_key(const wchar_t* str, uint32_t si
22952264
*key = STB_TEXTEDIT_K_BACKSPACE;
22962265
*type = DELETE_BY_KEY_BACKSPACE;
22972266
return TRUE;
2298-
} break;
2267+
}
22992268
case TK_KEY_DELETE: {
23002269
*key = STB_TEXTEDIT_K_DELETE;
23012270
*type = DELETE_BY_KEY_DELETE;
23022271
return TRUE;
2303-
} break;
2272+
}
23042273
default: {
23052274
} break;
23062275
}

src/base/widget.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* File: widget.c
33
* Author: AWTK Develop Team
44
* Brief: basic class of all widget
@@ -2500,7 +2500,7 @@ ret_t widget_get_prop(widget_t* widget, const char* name, value_t* v) {
25002500
if (ret == RET_NOT_FOUND) {
25012501
if (tk_str_eq(name, WIDGET_PROP_LAYOUT_W)) {
25022502
if (widget->self_layout != NULL) {
2503-
w_attr_t w_attr = self_layouter_get_param_int(widget->self_layout, "w_attr", W_ATTR_UNDEF);
2503+
w_attr_t w_attr = (w_attr_t)self_layouter_get_param_int(widget->self_layout, "w_attr", W_ATTR_UNDEF);
25042504
if (W_ATTR_PIXEL == w_attr) {
25052505
ret = self_layouter_get_param(widget->self_layout, "w", v);
25062506
if (value_int(v) < 0) {
@@ -2514,7 +2514,7 @@ ret_t widget_get_prop(widget_t* widget, const char* name, value_t* v) {
25142514
}
25152515
} else if (tk_str_eq(name, WIDGET_PROP_LAYOUT_H)) {
25162516
if (widget->self_layout != NULL) {
2517-
h_attr_t h_attr = self_layouter_get_param_int(widget->self_layout, "h_attr", H_ATTR_UNDEF);
2517+
h_attr_t h_attr = (h_attr_t)self_layouter_get_param_int(widget->self_layout, "h_attr", H_ATTR_UNDEF);
25182518
if (H_ATTR_PIXEL == h_attr) {
25192519
ret = self_layouter_get_param(widget->self_layout, "h", v);
25202520
if (value_int(v) < 0) {

src/platforms/raw/cond_var_null.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
*/
2121

2222
#include "tkc/mem.h"
23+
#include "tkc/cond.h"
2324
#include "tkc/cond_var.h"
2425

2526
struct _tk_cond_t {

src/tkc/object_array.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* File: object_array.c
33
* Author: AWTK Develop Team
44
* Brief: object array
@@ -243,7 +243,7 @@ ret_t object_array_set(tk_object_t* obj, uint32_t index, const value_t* v) {
243243
value_t* iter = o->props + index;
244244
ret = value_replace(iter, v, TRUE);
245245
emitter_dispatch(EMITTER(o), &e);
246-
} else if (index == -1) {
246+
} else if (index == (uint32_t)-1) {
247247
ret = object_array_push(obj, v);
248248
} else {
249249
ret = RET_BAD_PARAMS;
@@ -283,7 +283,7 @@ ret_t object_array_get(tk_object_t* obj, uint32_t i, value_t* v) {
283283

284284
if (i < o->size) {
285285
iter = o->props + i;
286-
} else if (i == -1) {
286+
} else if (i == (uint32_t)1) {
287287
iter = o->props + (o->size - 1);
288288
}
289289

src/ui_loader/ui_loader_xml.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232

3333
#define TAG_PROPERTY "property"
3434

35+
#ifdef HAS_STDIO
36+
#define EXIT(code) exit(code)
37+
#else
38+
#define EXIT(code) return
39+
#endif
40+
3541
typedef enum _props_state_t {
3642
PROPS_STATE_NONE = 0,
3743
PROPS_STATE_START,
@@ -629,7 +635,7 @@ static void xml_loader_on_pi(XmlBuilder* thiz, const char* tag, const char** att
629635
} else {
630636
log_warn("!!!File name = %s error include file %s\n", bname_normalize, filename);
631637
}
632-
exit(EXIT_FAILURE);
638+
EXIT(EXIT_FAILURE);
633639
}
634640
}
635641

@@ -683,7 +689,7 @@ static void xml_loader_on_pi(XmlBuilder* thiz, const char* tag, const char** att
683689
} else {
684690
log_warn("!!!File name = %s error include file %s\n", bname_normalize, filename);
685691
}
686-
exit(EXIT_FAILURE);
692+
EXIT(EXIT_FAILURE);
687693
}
688694
b->properties_state = b_include.properties_state;
689695
b_include.is_include = FALSE;

src/window_manager/window_manager_default.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/**
1+
/**
22
* File: window_manager_default.c
33
* Author: AWTK Develop Team
44
* Brief: default window manager
@@ -122,6 +122,7 @@ static widget_t* window_manager_find_prev_normal_window(widget_t* widget) {
122122
return NULL;
123123
}
124124

125+
#ifndef WITHOUT_WINDOW_ANIMATORS
125126
static ret_t window_manager_default_set_paint_system_bar_by_window_animator(widget_t* widget,
126127
rect_t* rect) {
127128
window_manager_default_t* wm = WINDOW_MANAGER_DEFAULT(widget);
@@ -151,6 +152,7 @@ static ret_t window_manager_default_set_paint_system_bar_by_window_animator(widg
151152
WIDGET_FOR_EACH_CHILD_END()
152153
return RET_OK;
153154
}
155+
#endif
154156

155157
ret_t window_manager_default_snap_curr_window(widget_t* widget, widget_t* curr_win, bitmap_t* img) {
156158
#ifndef WITHOUT_WINDOW_ANIMATORS

0 commit comments

Comments
 (0)