Skip to content

Commit 30a24ab

Browse files
committed
Fixing compile issues
1 parent 7180638 commit 30a24ab

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

Fw/Types/Assert.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ void defaultReportAssert(FILE_NAME_ARG file,
3030
FwAssertArgType arg6,
3131
CHAR* destBuffer,
3232
NATIVE_INT_TYPE buffSize) {
33-
static_assert(std::numeric_limits<FwSizeType>::mac() >= std::numeric_limits<NATIVE_INT_TYPE>(buffSize));
33+
static_assert(std::numeric_limits<FwSizeType>::max() >= std::numeric_limits<NATIVE_INT_TYPE>::max(),
34+
"NATIVE_INT_TYPE cannot fit into FwSizeType");
3435
switch (numArgs) {
3536
case 0:
3637
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize), fileIdFs, file, lineNo);

Fw/Types/format.hpp

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,30 @@ enum class FormatStatus {
3434
//! OTHER_ERROR: another error occurred in an underlying function call
3535
//! Otherwise SUCCESS is returned. destination may be modified even in the case of an error.
3636
//!
37-
//! \param destination: destination to fill with the formatted string.
37+
//! \param destination: destination to fill with the formatted string
3838
//! \param maximumSize: size of the buffer represented by destination
3939
//! \param formatString: format string to fill
40-
//! \param args: variable arguments.
40+
//! \param ...: variable arguments inputs
41+
//! \return: SUCCESS on successful formatting, OVERFLOWED on overflow, and something else on any error
42+
FormatStatus stringFormat(char* destination, const FwSizeType maximumSize, const char* formatString, ...);
43+
44+
//! \brief format a c-string
45+
//!
46+
//! Format a string using printf family formatting semantics. Destination will be filled with the formatted string up to
47+
//! maximumSize - 1. This function will always terminate the string with a \0.
48+
//!
49+
//! This function can return several error codes:
50+
//! OVERFLOWED: the complete string did not fit in the buffer with an appended null-terminator
51+
//! INVALID_FORMAT_STRING: the format string was null
52+
//! OTHER_ERROR: another error occurred in an underlying function call
53+
//! Otherwise SUCCESS is returned. destination may be modified even in the case of an error.
54+
//!
55+
//! This version take a variable argument list
56+
//!
57+
//! \param destination: destination to fill with the formatted string
58+
//! \param maximumSize: size of the buffer represented by destination
59+
//! \param formatString: format string to fill
60+
//! \param args: variable arguments list
4161
//! \return: SUCCESS on successful formatting, OVERFLOWED on overflow, and something else on any error
4262
FormatStatus stringFormat(char* destination, const FwSizeType maximumSize, const char* formatString, va_list args);
4363
}

Fw/Types/snprintf_format.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@
77
#include <limits>
88
#include <cstdio>
99

10+
Fw::FormatStatus Fw::stringFormat(char* destination, const FwSizeType maximumSize, const char* formatString, ...) {
11+
va_list args;
12+
va_start(args, formatString);
13+
FormatStatus status = Fw::stringFormat(destination, maximumSize, formatString, args);
14+
va_end(args);
15+
return status;
16+
}
17+
1018
Fw::FormatStatus Fw::stringFormat(char* destination, const FwSizeType maximumSize, const char* formatString, va_list args) {
1119
Fw::FormatStatus formatStatus = Fw::FormatStatus::SUCCESS;
1220
// Force null termination in error cases

0 commit comments

Comments
 (0)