From 1205dc50e613165eb938e1c71039dfa217a4d84d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89milie=20Feral?= Date: Thu, 18 Oct 2018 17:48:35 +0200 Subject: [PATCH] [shared] StorageFunction::nameWithArgument uses SymbolAbstract::TruncateExtension instead of reimplementing it --- apps/shared/storage_function.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/apps/shared/storage_function.cpp b/apps/shared/storage_function.cpp index 36610b5c6..391ed6129 100644 --- a/apps/shared/storage_function.cpp +++ b/apps/shared/storage_function.cpp @@ -29,16 +29,9 @@ void StorageFunction::setActive(bool active) { int StorageFunction::nameWithArgument(char * buffer, size_t bufferSize, char arg) { const char * functionName = fullName(); - size_t index = 0; k_parenthesedArgument[1] = arg; - while (*functionName != Ion::Storage::k_dotChar - && index < bufferSize - k_parenthesedArgumentLength - 1) - { - // We keep room to write the final "(x)" //TODO should we? - assert(functionName < fullName() + strlen(fullName())); - buffer[index++] = *functionName++; - } - return index + strlcpy(&buffer[index], k_parenthesedArgument, bufferSize-index); + size_t baseNameLength = SymbolAbstract::TruncateExtension(buffer, functionName, bufferSize - k_parenthesedArgumentLength); + return baseNameLength + strlcpy(&buffer[baseNameLength], k_parenthesedArgument, bufferSize-baseNameLength); } template