Skip to content

Commit 7180638

Browse files
committed
Fixing recursive calls and other CI problems
1 parent a791f76 commit 7180638

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

Fw/Types/Assert.cpp

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <FpConfig.hpp>
22
#include <Fw/Types/Assert.hpp>
3-
#include <Fw/Types/ExternalString.hpp>
3+
#include <Fw/Types/format.hpp>
44
#include <Fw/Types/StringUtils.hpp>
55
#include <cassert>
66
#include <cstdio>
@@ -14,7 +14,9 @@
1414
namespace Fw {
1515

1616
void defaultPrintAssert(const CHAR* msg) {
17-
(void) fwrite(msg, sizeof(CHAR), static_cast<size_t>(Fw::StringUtils::string_length(msg, FW_ASSERT_TEXT_SIZE)), stderr);
17+
// Write to stderr w/o formatting
18+
(void) fputs(msg, stderr);
19+
(void) fputs("\n", stderr);
1820
}
1921

2022
void defaultReportAssert(FILE_NAME_ARG file,
@@ -28,40 +30,41 @@ void defaultReportAssert(FILE_NAME_ARG file,
2830
FwAssertArgType arg6,
2931
CHAR* destBuffer,
3032
NATIVE_INT_TYPE buffSize) {
31-
Fw::ExternalString external(destBuffer, static_cast<Fw::ExternalString::SizeType>(buffSize));
33+
static_assert(std::numeric_limits<FwSizeType>::mac() >= std::numeric_limits<NATIVE_INT_TYPE>(buffSize));
3234
switch (numArgs) {
3335
case 0:
34-
(void)external.format(fileIdFs, file, lineNo);
36+
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize), fileIdFs, file, lineNo);
3537
break;
3638
case 1:
37-
(void)external.format(fileIdFs " %" PRI_FwAssertArgType, file, lineNo, arg1);
39+
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
40+
fileIdFs " %" PRI_FwAssertArgType, file, lineNo, arg1);
3841
break;
3942
case 2:
40-
(void)external.format(fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file,
41-
lineNo, arg1, arg2);
43+
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
44+
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file, lineNo, arg1, arg2);
4245
break;
4346
case 3:
44-
(void)external.format(
45-
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file,
46-
lineNo, arg1, arg2, arg3);
47+
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
48+
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType, file,
49+
lineNo, arg1, arg2, arg3);
4750
break;
4851
case 4:
49-
(void)external.format(
50-
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
51-
" %" PRI_FwAssertArgType,
52+
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
53+
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
54+
" %" PRI_FwAssertArgType,
5255
file, lineNo, arg1, arg2, arg3, arg4);
5356
break;
5457
case 5:
55-
(void)external.format(
56-
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
57-
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
58-
file, lineNo, arg1, arg2, arg3, arg4, arg5);
58+
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
59+
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
60+
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
61+
file, lineNo, arg1, arg2, arg3, arg4, arg5);
5962
break;
6063
case 6:
61-
(void)external.format(
62-
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
63-
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
64-
file, lineNo, arg1, arg2, arg3, arg4, arg5, arg6);
64+
(void)stringFormat(destBuffer, static_cast<FwSizeType>(buffSize),
65+
fileIdFs " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType
66+
" %" PRI_FwAssertArgType " %" PRI_FwAssertArgType " %" PRI_FwAssertArgType,
67+
file, lineNo, arg1, arg2, arg3, arg4, arg5, arg6);
6568
break;
6669
default: // in an assert already, what can we do?
6770
break;

Fw/Types/snprintf_format.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,15 @@
22
// \title format.cpp
33
// \author mstarch
44
// \brief cpp file for c-string format function as a implementation using snprintf
5-
//
6-
// \copyright
7-
// Copyright (C) 2025 California Institute of Technology.
8-
// ALL RIGHTS RESERVED. United States Government Sponsorship
9-
// acknowledged.
105
// ======================================================================
116
#include <Fw/Types/format.hpp>
127
#include <limits>
138
#include <cstdio>
149

1510
Fw::FormatStatus Fw::stringFormat(char* destination, const FwSizeType maximumSize, const char* formatString, va_list args) {
1611
Fw::FormatStatus formatStatus = Fw::FormatStatus::SUCCESS;
12+
// Force null termination in error cases
13+
destination[0] = 0;
1714
// Check format string
1815
if (formatString == nullptr) {
1916
formatStatus = Fw::FormatStatus::INVALID_FORMAT_STRING;
@@ -31,4 +28,4 @@ Fw::FormatStatus Fw::stringFormat(char* destination, const FwSizeType maximumSiz
3128
}
3229
}
3330
return formatStatus;
34-
}
31+
}

0 commit comments

Comments
 (0)