[apps] Gather asserts about the size of function name with argument

This commit is contained in:
Ruben Dashyan
2019-09-06 10:54:34 +02:00
committed by LeaNumworks
parent 8f88f7fea6
commit f73c80daa3
2 changed files with 1 additions and 3 deletions

View File

@@ -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

View File

@@ -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);