diff --git a/apps/i18n.py b/apps/i18n.py index 8d316c859..fd4d00936 100644 --- a/apps/i18n.py +++ b/apps/i18n.py @@ -150,11 +150,12 @@ def print_implementation(data, path, locales): f.write("};\n") f.write("\n") f.write("const char * translate(Message m, Language l) {\n") + f.write(" assert(m != Message::UniversalMessageMarker);\n") f.write(" int universalMessageOffset = (int)Message::UniversalMessageMarker+1;\n") f.write(" if ((int)m >= universalMessageOffset) {\n") f.write(" assert(universalMessages[(int)m - universalMessageOffset] != nullptr);\n") f.write(" return universalMessages[(int)m - universalMessageOffset];\n") - f.write(" }") + f.write(" }\n") f.write(" int languageIndex = (int)l;\n") f.write(" if (l == Language::Default) {\n") f.write(" languageIndex = (int) GlobalPreferences::sharedGlobalPreferences()->language();\n") diff --git a/apps/probability/cell.cpp b/apps/probability/cell.cpp index ace6d3c35..7c711b0f6 100644 --- a/apps/probability/cell.cpp +++ b/apps/probability/cell.cpp @@ -5,7 +5,9 @@ namespace Probability { Cell::Cell() : HighlightCell(), - m_labelView(KDText::FontSize::Large, (I18n::Message)0, 0, 0.5, KDColorBlack, KDColorWhite) + m_labelView(KDText::FontSize::Large, (I18n::Message)0, 0, 0.5, KDColorBlack, KDColorWhite), + m_icon(nullptr), + m_focusedIcon(nullptr) { } diff --git a/apps/probability/image_table_view.h b/apps/probability/image_table_view.h index f8ffbe872..20a046250 100644 --- a/apps/probability/image_table_view.h +++ b/apps/probability/image_table_view.h @@ -54,7 +54,6 @@ private: ImageCell m_imageCells[k_numberOfImages]; SelectableTableView m_selectableTableView; bool m_isSelected; - int m_selectedIcon; Law * m_law; Calculation * m_calculation; CalculationController * m_calculationController; diff --git a/apps/regression/store.cpp b/apps/regression/store.cpp index d08446066..93937fb25 100644 --- a/apps/regression/store.cpp +++ b/apps/regression/store.cpp @@ -160,6 +160,9 @@ double Store::columnProductSum() { } double Store::meanOfColumn(int i) { + if (m_numberOfPairs == 0) { + return 0; + } return sumOfColumn(i)/m_numberOfPairs; } diff --git a/apps/sequence/list/list_parameter_controller.cpp b/apps/sequence/list/list_parameter_controller.cpp index 4b76153f6..de4818b53 100644 --- a/apps/sequence/list/list_parameter_controller.cpp +++ b/apps/sequence/list/list_parameter_controller.cpp @@ -10,7 +10,8 @@ ListParameterController::ListParameterController(ListController * listController Shared::ListParameterController(listController, sequenceStore, I18n::Message::SequenceColor, I18n::Message::DeleteSequence), m_typeCell(I18n::Message::SequenceType), m_typeParameterController(this, sequenceStore, listController, TableCell::Layout::Horizontal, Metric::CommonTopMargin, Metric::CommonRightMargin, - Metric::CommonBottomMargin, Metric::CommonLeftMargin) + Metric::CommonBottomMargin, Metric::CommonLeftMargin), + m_sequence(nullptr) { } diff --git a/apps/shared/interval.cpp b/apps/shared/interval.cpp index ab8637fe7..c6e6cf96e 100644 --- a/apps/shared/interval.cpp +++ b/apps/shared/interval.cpp @@ -4,6 +4,7 @@ namespace Shared { Interval::Interval() : + m_numberOfElements(0), m_start(0), m_end(0), m_step(0), diff --git a/apps/shared/list_parameter_controller.cpp b/apps/shared/list_parameter_controller.cpp index ef3da85ca..1a495e36d 100644 --- a/apps/shared/list_parameter_controller.cpp +++ b/apps/shared/list_parameter_controller.cpp @@ -8,6 +8,7 @@ ListParameterController::ListParameterController(Responder * parentResponder, Fu m_selectableTableView(this, this, 0, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin, this), m_functionStore(functionStore), + m_function(nullptr), #if FUNCTION_COLOR_CHOICE m_colorCell(functionColorMessage), #endif diff --git a/apps/shared/values_function_parameter_controller.cpp b/apps/shared/values_function_parameter_controller.cpp index 0f75ab3f8..262048bcb 100644 --- a/apps/shared/values_function_parameter_controller.cpp +++ b/apps/shared/values_function_parameter_controller.cpp @@ -15,7 +15,7 @@ ValuesFunctionParameterController::ValuesFunctionParameterController(char symbol const char * ValuesFunctionParameterController::title() { strlcpy(m_pageTitle, I18n::translate(I18n::Message::FunctionColumn), k_maxNumberOfCharsInTitle); - for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) { + for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle-1; currentChar++) { if (m_pageTitle[currentChar] == '(') { m_pageTitle[currentChar-1] = *m_function->name(); m_pageTitle[currentChar+1] = m_symbol; diff --git a/apps/variable_box_controller.cpp b/apps/variable_box_controller.cpp index 0b6ce0c01..33327e63a 100644 --- a/apps/variable_box_controller.cpp +++ b/apps/variable_box_controller.cpp @@ -10,6 +10,7 @@ using namespace Poincare; VariableBoxController::ContentViewController::ContentViewController(Responder * parentResponder, GlobalContext * context) : ViewController(parentResponder), m_context(context), + m_textFieldCaller(nullptr), m_firstSelectedRow(0), m_previousSelectedRow(0), m_currentPage(Page::RootMenu), diff --git a/escher/include/escher/text_area.h b/escher/include/escher/text_area.h index b75c50cf5..f2a6a4a38 100644 --- a/escher/include/escher/text_area.h +++ b/escher/include/escher/text_area.h @@ -73,7 +73,7 @@ private: char removeChar(size_t index); int removeRemainingLine(size_t index, int direction); char operator[](size_t index) { - assert(index >= 0 && index < m_bufferSize); + assert(index < m_bufferSize); return m_buffer[index]; } size_t bufferSize() const { diff --git a/escher/src/button_row_controller.cpp b/escher/src/button_row_controller.cpp index c2bda0b88..886ef3c87 100644 --- a/escher/src/button_row_controller.cpp +++ b/escher/src/button_row_controller.cpp @@ -73,7 +73,7 @@ void ButtonRowController::ContentView::layoutSubviews() { Button * button = buttonAtIndex(i); totalButtonWidth += button->minimalSizeForOptimalDisplay().width(); } - widthMargin = std::round((float)((bounds().width() - totalButtonWidth)/(nbOfButtons+1))); + widthMargin = std::round(((float)(bounds().width() - totalButtonWidth))/((float)(nbOfButtons+1))); buttonHeightMargin = m_size == Size::Small ? k_embossedStyleHeightMarginSmall : k_embossedStyleHeightMarginLarge; buttonHeight = rowHeight- 2*buttonHeightMargin; } @@ -121,7 +121,7 @@ void ButtonRowController::ContentView::drawRect(KDContext * ctx, KDRect rect) co Button * button = buttonAtIndex(i); totalButtonWidth += button->minimalSizeForOptimalDisplay().width(); } - KDCoordinate widthMargin = std::round((float)((bounds().width() - totalButtonWidth)/(numberOfButtons()+1))); + KDCoordinate widthMargin = std::round(((float)(bounds().width() - totalButtonWidth))/((float)(numberOfButtons()+1))); int currentXOrigin = widthMargin-1; for (int i = 0; i < numberOfButtons(); i++) { diff --git a/escher/src/stack_view.cpp b/escher/src/stack_view.cpp index f1e0e809b..5f125bea5 100644 --- a/escher/src/stack_view.cpp +++ b/escher/src/stack_view.cpp @@ -4,7 +4,8 @@ extern "C" { } StackView::StackView() : - View() + View(), + m_controller(nullptr) { } diff --git a/escher/src/text_area.cpp b/escher/src/text_area.cpp index cde013d68..4729a6eb1 100644 --- a/escher/src/text_area.cpp +++ b/escher/src/text_area.cpp @@ -108,7 +108,7 @@ char TextArea::Text::removeChar(size_t index) { int TextArea::Text::removeRemainingLine(size_t index, int direction) { assert(m_buffer != nullptr); - assert(index >= 0 && index < m_bufferSize); + assert(index < m_bufferSize); int jump = index; while (m_buffer[jump] != '\n' && m_buffer[jump] != 0 && jump >= 0) { jump += direction; @@ -267,6 +267,7 @@ void TextArea::ContentView::removeStartOfLine() { } int removedLine = m_text.removeRemainingLine(m_cursorIndex-1, -1); if (removedLine > 0) { + assert(m_cursorIndex >= removedLine); m_cursorIndex -= removedLine; layoutSubviews(); markRectAsDirty(dirtyRectFromCursorPosition(m_cursorIndex, false)); diff --git a/poincare/src/layout/grid_layout.cpp b/poincare/src/layout/grid_layout.cpp index 495e4e9c7..92dae7a72 100644 --- a/poincare/src/layout/grid_layout.cpp +++ b/poincare/src/layout/grid_layout.cpp @@ -79,7 +79,7 @@ KDSize GridLayout::computeSize() { } ExpressionLayout * GridLayout::child(uint16_t index) { - if (index >= 0 && index < m_numberOfColumns*m_numberOfRows) { + if (index < m_numberOfColumns*m_numberOfRows) { return m_entryLayouts[index]; } return nullptr; diff --git a/poincare/src/least_common_multiple.cpp b/poincare/src/least_common_multiple.cpp index 71f048e6d..43bb02e92 100644 --- a/poincare/src/least_common_multiple.cpp +++ b/poincare/src/least_common_multiple.cpp @@ -83,7 +83,7 @@ Complex * LeastCommonMultiple::templatedApproximate(Context& context, AngleUn a = b; b = r; } - return new Complex(Complex::Float(std::round((T)(product/a)))); + return new Complex(Complex::Float(product/a)); } }