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>
1414namespace Fw {
1515
1616void 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
2022void 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 ;
0 commit comments