From 4e3c6f64c0a4969126ba75fefbb3124ff20db829 Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 30 Dec 2015 11:45:13 +0100 Subject: [PATCH] Various minor fixes following a pass of cppcheck static analyzer --- extra_fonts/binary_to_compressed_c.cpp | 1 - imgui.cpp | 4 ++-- imgui_internal.h | 3 +++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/extra_fonts/binary_to_compressed_c.cpp b/extra_fonts/binary_to_compressed_c.cpp index a9b3b77f8..57b24079e 100644 --- a/extra_fonts/binary_to_compressed_c.cpp +++ b/extra_fonts/binary_to_compressed_c.cpp @@ -79,7 +79,6 @@ bool binary_to_compressed_c(const char* filename, const char* symbol, bool use_b if (use_base85_encoding) { fprintf(out, "static const char %s_%sdata_base85[%d+1] =\n \"", symbol, compressed_str, (int)((compressed_sz+3)/4)*5); - int column = 0; for (int i = 0; i < compressed_sz; i += 4) { unsigned int d = *(unsigned int*)(compressed + i); diff --git a/imgui.cpp b/imgui.cpp index cbe012cc1..bfa2a49c4 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -774,7 +774,7 @@ void ImGuiIO::AddInputCharactersUTF8(const char* utf8_chars) const int wchars_buf_len = sizeof(ImGuiIO::InputCharacters) / sizeof(ImWchar); ImWchar wchars[wchars_buf_len]; ImTextStrFromUtf8(wchars, wchars_buf_len, utf8_chars, NULL); - for (int i = 0; wchars[i] != 0 && i < wchars_buf_len; i++) + for (int i = 0; i < wchars_buf_len && wchars[i] != 0; i++) AddInputCharacter(wchars[i]); } @@ -7323,7 +7323,6 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2 } bool value_changed = false; - bool cancel_edit = false; bool enter_pressed = false; if (g.ActiveId == id) @@ -7388,6 +7387,7 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2 } // Handle various key-presses + bool cancel_edit = false; const int k_mask = (is_shift_down ? STB_TEXTEDIT_K_SHIFT : 0); const bool is_ctrl_only = is_ctrl_down && !is_alt_down && !is_shift_down; if (IsKeyPressedMap(ImGuiKey_LeftArrow)) { edit_state.OnKeyPressed(is_ctrl_down ? STB_TEXTEDIT_K_WORDLEFT | k_mask : STB_TEXTEDIT_K_LEFT | k_mask); } diff --git a/imgui_internal.h b/imgui_internal.h index 25a03e2bc..3c028c38c 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -462,6 +462,7 @@ struct ImGuiState SetNextWindowCollapsedVal = false; SetNextWindowPosCond = 0; SetNextWindowSizeCond = 0; + SetNextWindowContentSizeCond = 0; SetNextWindowCollapsedCond = 0; SetNextWindowFocus = false; SetNextTreeNodeOpenedVal = false; @@ -482,6 +483,7 @@ struct ImGuiState ModalWindowDarkeningRatio = 0.0f; OverlayDrawList._OwnerName = "##Overlay"; // Give it a name for debugging MouseCursor = ImGuiMouseCursor_Arrow; + memset(MouseCursorData, 0, sizeof(MouseCursorData)); LogEnabled = false; LogFile = NULL; @@ -493,6 +495,7 @@ struct ImGuiState FramerateSecPerFrameIdx = 0; FramerateSecPerFrameAccum = 0.0f; CaptureMouseNextFrame = CaptureKeyboardNextFrame = false; + memset(TempBuffer, 0, sizeof(TempBuffer)); } };