diff --git a/src/base/text_edit.c b/src/base/text_edit.c index 0f117b859..e3600d632 100644 --- a/src/base/text_edit.c +++ b/src/base/text_edit.c @@ -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])) { diff --git a/src/base/widget.c b/src/base/widget.c index 9a40fdc0e..018653704 100644 --- a/src/base/widget.c +++ b/src/base/widget.c @@ -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(); diff --git a/src/csv/csv_file_object.c b/src/csv/csv_file_object.c index 606a5a2c4..2f005a791 100644 --- a/src/csv/csv_file_object.c +++ b/src/csv/csv_file_object.c @@ -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 { diff --git a/src/ext_widgets/mutable_image/mutable_image.c b/src/ext_widgets/mutable_image/mutable_image.c index 015365b39..c314bc449 100644 --- a/src/ext_widgets/mutable_image/mutable_image.c +++ b/src/ext_widgets/mutable_image/mutable_image.c @@ -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; diff --git a/staticcheck/cppcheck/run.py b/staticcheck/cppcheck/run.py index f374c97fc..a8b47b685 100644 --- a/staticcheck/cppcheck/run.py +++ b/staticcheck/cppcheck/run.py @@ -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())