fix cppcheck warnings

This commit is contained in:
lixianjing 2024-08-16 16:29:39 +08:00
parent 3a5fc9a0c5
commit ccf85d76d2
5 changed files with 9 additions and 8 deletions

View File

@ -978,7 +978,7 @@ static int text_edit_insert(STB_TEXTEDIT_STRING* str, int pos, STB_TEXTEDIT_CHAR
uint32_t i = 0;
for (i = 0; i < num; i++) {
if (i + 1 < num && TWINS_WCHAR_IS_LINE_BREAK(newtext[i], newtext[i + 1])) {
if ((i + 1) < num && (TWINS_WCHAR_IS_LINE_BREAK(newtext[i], newtext[i + 1]))) {
line_break_num--;
i++;
} else if (WCHAR_IS_LINE_BREAK(newtext[i])) {

View File

@ -1243,12 +1243,14 @@ static widget_t* widget_lookup_by_type_all(widget_t* widget, const char* type) {
return_value_if_fail(widget != NULL && type != NULL, NULL);
WIDGET_FOR_EACH_CHILD_BEGIN(widget, iter, i)
if (tk_str_eq(iter->vt->type, type)) {
if (iter == NULL) {
continue;
} else if(tk_str_eq(iter->vt->type, type)) {
return iter;
} else {
iter = widget_lookup_by_type_all(iter, type);
if (iter != NULL) {
return iter;
widget_t* ret = widget_lookup_by_type_all(iter, type);
if (ret != NULL) {
return ret;
}
}
WIDGET_FOR_EACH_CHILD_END();

View File

@ -386,7 +386,6 @@ static ret_t csv_file_object_exec(tk_object_t* obj, const char* name, const char
o->is_dirty = TRUE;
} else if (tk_str_ieq(name, TK_OBJECT_CMD_ADD)) {
if (args != NULL) {
return_value_if_fail(args != NULL, RET_FAIL);
ret = csv_file_append_row(o->csv, args) == RET_OK ? RET_ITEMS_CHANGED : RET_FAIL;
o->is_dirty = TRUE;
} else {

View File

@ -177,7 +177,7 @@ static ret_t mutable_image_init_impl(widget_t* widget) {
image_base_init(widget);
mutable_image->timer_id = widget_add_timer(widget, mutable_image_invalidate, 16);
if (widget->parent != NULL && widget != NULL) {
if (widget != NULL && widget->parent != NULL) {
mutable_image_on_attach_parent(widget, widget->parent);
}
return RET_OK;

View File

@ -3,6 +3,6 @@ import sys
sys.path.append("../common")
import awtk_files as awtk;
CPPFLAGS = '-DHAS_STD_MALLOC -DNDEBUG --enable=warning --enable=performance -DWITH_CPPCHECK '
CPPFLAGS = '-DHAS_STD_MALLOC -DNDEBUG --enable=warning --enable=performance -DWITH_CPPCHECK --check-level=exhaustive '
awtk.run('cppcheck', CPPFLAGS, awtk.getCppCheckFiles())