-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing printf from Svc. Partially Fixed #1708 #3170
Conversation
989e5be
to
bd2f098
Compare
// Check that the API size type fits in fprime size type | ||
static_assert(std::numeric_limits<FwSizeType>::max() >= std::numeric_limits<PlatformIntType>::max(), | ||
"Range of PlatformIntType does not fit within range of FwSizeType"); | ||
PlatformIntType total_needed_size_api = vsnprintf(us, cap, formatString, args); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
// Overflow is allowed and truncation accepted | ||
Fw::InternalInterfaceString intText; | ||
(void) intText.format("EVENT: (%" PRI_FwEventIdType ") (%" PRI_FwTimeBaseStoreType ":%" PRIu32 ",%" PRIu32 ") %s: %s\n", | ||
id, static_cast<FwTimeBaseStoreType>(timeTag.getTimeBase()), timeTag.getSeconds(), timeTag.getUSeconds(), |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
// Overflow is allowed and truncation accepted | ||
Fw::InternalInterfaceString intText; | ||
(void) intText.format("EVENT: (%" PRI_FwEventIdType ") (%" PRI_FwTimeBaseStoreType ":%" PRIu32 ",%" PRIu32 ") %s: %s\n", | ||
id, static_cast<FwTimeBaseStoreType>(timeTag.getTimeBase()), timeTag.getSeconds(), timeTag.getUSeconds(), |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
Fw::InternalInterfaceString intText; | ||
(void) intText.format("EVENT: (%" PRI_FwEventIdType ") (%" PRI_FwTimeBaseStoreType ":%" PRIu32 ",%" PRIu32 ") %s: %s\n", | ||
id, static_cast<FwTimeBaseStoreType>(timeTag.getTimeBase()), timeTag.getSeconds(), timeTag.getUSeconds(), | ||
severityString, text.toChar()); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
(void) strncpy(fileNameFinal,fileName, | ||
Fw::String::STRING_SIZE); | ||
fileNameFinal[Fw::String::STRING_SIZE-1] = 0; | ||
searchFilename = fileName; |
Check warning
Code scanning / CodeQL
Unchecked return value Warning
operator=
@@ -149,7 +129,7 @@ | |||
|
|||
this->m_currentFileSize = 0; | |||
this->m_maxFileSize = maxSize; | |||
this->m_fileName = fileNameFinal; | |||
this->m_fileName = searchFilename; |
Check warning
Code scanning / CodeQL
Unchecked return value Warning
operator=
timestamp.getSeconds(), | ||
timestamp.getUSeconds()); | ||
FW_ASSERT(formatStatus == Fw::FormatStatus::SUCCESS); | ||
this->m_hashFileName.format("%s%s", this->m_fileName.toChar(), Utils::Hash::getFileExtensionString()); |
Check warning
Code scanning / CodeQL
Unchecked return value Warning
format
FW_ASSERT(static_cast<NATIVE_UINT_TYPE>(bytesCopied) < sizeof(buffer)); | ||
// Wrap that buffer in an external string for formatting purposes | ||
Fw::ExternalString stringBuffer(buffer, bufferSize); | ||
Fw::FormatStatus formatStatus = stringBuffer.format(evalStr, command.toChar(), logFileName.toChar()); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
FW_ASSERT(static_cast<NATIVE_UINT_TYPE>(bytesCopied) < sizeof(buffer)); | ||
// Wrap that buffer in an external string for formatting purposes | ||
Fw::ExternalString stringBuffer(buffer, bufferSize); | ||
Fw::FormatStatus formatStatus = stringBuffer.format(evalStr, command.toChar(), logFileName.toChar()); |
Check warning
Code scanning / CodeQL
Unchecked function argument Warning
@@ -53,25 +53,45 @@ | |||
return (result == 0); | |||
} | |||
|
|||
void StringBase::format(const CHAR* formatString, ...) { | |||
FormatStatus StringBase::format(const CHAR* formatString, ...) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
} | ||
|
||
void StringBase::vformat(const CHAR* formatString, va_list args) { | ||
FormatStatus StringBase::vformat(const CHAR* formatString, va_list args) { |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
if (formatString == nullptr) { | ||
return FormatStatus::INVALID_FORMAT_STRING; | ||
} | ||
FwSizeType total_needed_size = 0; |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
// Check that the API size type fits in fprime size type | ||
static_assert(std::numeric_limits<FwSizeType>::max() >= std::numeric_limits<PlatformIntType>::max(), | ||
"Range of PlatformIntType does not fit within range of FwSizeType"); | ||
PlatformIntType total_needed_size_api = vsnprintf(us, cap, formatString, args); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
return false; | ||
} | ||
|
||
FwSignedSizeType fileSize = 0; |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
|
||
const int status = system(buffer); | ||
// Call the system | ||
const int status = system(stringBuffer.toChar()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
Change Description
Removes
printf
from service. Switches to Fw::FileNameString for filenames to avoid the stack buffer allocation and switch to fprime string types.