From f73c80daa36d903bde0dfc30c5465f3a983f1fd7 Mon Sep 17 00:00:00 2001 From: Ruben Dashyan Date: Fri, 6 Sep 2019 10:54:34 +0200 Subject: [PATCH] [apps] Gather asserts about the size of function name with argument --- apps/shared/function.h | 1 + apps/variable_box_controller.cpp | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/apps/shared/function.h b/apps/shared/function.h index 4e1094763..b0fec53b3 100644 --- a/apps/shared/function.h +++ b/apps/shared/function.h @@ -26,6 +26,7 @@ public: constexpr static int k_parenthesedThetaArgumentByteLength = 4; constexpr static int k_parenthesedXNTArgumentByteLength = 3; constexpr static int k_maxNameWithArgumentSize = Poincare::SymbolAbstract::k_maxNameSize + k_parenthesedThetaArgumentByteLength; /* Function name and null-terminating char + "(θ)" */; + static_assert(k_maxNameWithArgumentSize > Poincare::SymbolAbstract::k_maxNameSize, "Forgot argument's size?"); static bool BaseNameCompliant(const char * baseName, NameNotCompliantError * error = nullptr); // Constructors diff --git a/apps/variable_box_controller.cpp b/apps/variable_box_controller.cpp index fa857dccb..df5106168 100644 --- a/apps/variable_box_controller.cpp +++ b/apps/variable_box_controller.cpp @@ -100,7 +100,6 @@ void VariableBoxController::willDisplayCellForIndex(HighlightCell * cell, int in } ExpressionTableCellWithExpression * myCell = (ExpressionTableCellWithExpression *)cell; Storage::Record record = recordAtIndex(index); - assert(Shared::Function::k_maxNameWithArgumentSize > SymbolAbstract::k_maxNameSize); char symbolName[Shared::Function::k_maxNameWithArgumentSize]; size_t symbolLength = 0; if (m_currentPage == Page::Expression) { @@ -188,8 +187,6 @@ bool VariableBoxController::selectLeaf(int selectedRow) { // Get the name text to insert Storage::Record record = recordAtIndex(selectedRow); - assert(Shared::Function::k_maxNameWithArgumentSize > 0); - assert(Shared::Function::k_maxNameWithArgumentSize > SymbolAbstract::k_maxNameSize); constexpr size_t nameToHandleMaxSize = Shared::Function::k_maxNameWithArgumentSize; char nameToHandle[nameToHandleMaxSize]; size_t nameLength = SymbolAbstract::TruncateExtension(nameToHandle, record.fullName(), nameToHandleMaxSize);