Skip to content
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

Make single-argument string constructors explicit #2707

Merged
merged 150 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 146 commits
Commits
Show all changes
150 commits
Select commit Hold shift + click to select a range
6de63cc
Revise Linux platform types
bocchino Dec 7, 2022
980a26f
Fix regression in test autocoder
bocchino Dec 8, 2022
91b6c01
Revise test autocoder
bocchino Dec 8, 2022
7504de2
Revise test autocoder
bocchino Dec 8, 2022
ecf4cb7
Fix integer type mismatch in ComQueue
bocchino Dec 8, 2022
253540d
Merge branch 'linux-platform' into devel
bocchino Dec 12, 2022
31e315d
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jan 3, 2023
f60e88e
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jan 25, 2023
2204a0c
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Feb 7, 2023
8b41def
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Feb 15, 2023
2bad0d6
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Mar 3, 2023
fc0317e
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Apr 3, 2023
66a8190
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Apr 10, 2023
8e6412a
Merge branch 'nasa:devel' into devel
bocchino May 4, 2023
949a251
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jul 18, 2023
6fc15e9
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jul 18, 2023
e961a4d
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jul 26, 2023
b00486a
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Aug 1, 2023
6f999de
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Aug 9, 2023
08f7ee1
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Sep 25, 2023
b2f54cf
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Oct 9, 2023
6fcbc51
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Oct 11, 2023
0d4cf3d
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Oct 19, 2023
6514547
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Nov 7, 2023
6f3ae9f
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Nov 16, 2023
89c0e35
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Nov 28, 2023
cdc83ea
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Nov 29, 2023
4a46719
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Dec 5, 2023
7acf774
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Dec 14, 2023
ac20f12
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jan 2, 2024
50b543b
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jan 11, 2024
2bff088
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jan 19, 2024
29ef16e
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Jan 25, 2024
51c3884
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Feb 20, 2024
07d28a7
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Feb 26, 2024
7e98d5b
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Feb 28, 2024
411e09a
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Mar 5, 2024
e864b01
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Mar 7, 2024
7140d75
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Mar 12, 2024
476ba08
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Apr 8, 2024
8cb7700
Merge remote-tracking branch 'upstream/devel' into devel
bocchino Apr 9, 2024
4359574
Update fpp version
bocchino Apr 9, 2024
5f41b0c
Update fpp version
bocchino Apr 9, 2024
d8bf071
Revise DpWriter unit tests
bocchino Apr 9, 2024
b7d3a7d
Update fpp version
bocchino Apr 9, 2024
c3e0aa2
Update fpp version
bocchino Apr 10, 2024
9e04083
Revise DpTest
bocchino Apr 10, 2024
fb44afb
Reivse StringType; add ExternalString
bocchino Apr 10, 2024
eee3ec3
Merge branch 'fpp-issue-398-default-priority' into fpp-issue-392-stri…
bocchino Apr 10, 2024
b1fc19b
Revise dp test
bocchino Apr 10, 2024
800de25
Revise dp test; update fpp version
bocchino Apr 10, 2024
be54883
Revise dp test
bocchino Apr 10, 2024
c0d626a
Revise dp test
bocchino Apr 10, 2024
d4121f7
Revise dp test
bocchino Apr 10, 2024
2e3e2ef
Revise dp test
bocchino Apr 10, 2024
021e0fc
Revise dp test
bocchino Apr 11, 2024
29031f7
Revise dp test
bocchino Apr 11, 2024
03326c6
Revise dp test
bocchino Apr 11, 2024
ce90192
Revise dp test
bocchino Apr 11, 2024
4c66664
Revise dp test
bocchino Apr 11, 2024
864f15a
Merge remote-tracking branch 'upstream/devel' into fpp-issue-397-from…
bocchino Apr 11, 2024
4402937
Merge remote-tracking branch 'upstream/devel' into fpp-issue-398-defa…
bocchino Apr 11, 2024
ea00253
Merge branch 'fpp-issue-398-default-priority' into fpp-issues-397-398
bocchino Apr 11, 2024
738936f
Revise fpp version
bocchino Apr 11, 2024
3b98052
Update fpp version
bocchino Apr 11, 2024
457fc35
Merge branch 'fpp-v2.1.0a7' into fpp-issue-392-string-records
bocchino Apr 11, 2024
4ea55a6
Revise ExternalString
bocchino Apr 11, 2024
48ad464
Reformat Fw/Serializable.{hpp,cpp}
bocchino Apr 11, 2024
772cc57
Reformat StringType.{hpp,cpp}
bocchino Apr 11, 2024
8f26567
Revise StringBase
bocchino Apr 11, 2024
fff0ad6
Update fpp version
bocchino Apr 11, 2024
8f8efe0
Remove trailing space
bocchino Apr 12, 2024
e8586e6
Reformat code
bocchino Apr 12, 2024
c4b9b9a
Revise dp test
bocchino Apr 12, 2024
171781b
Reformat cpp and hpp files in Fw/Types
bocchino Apr 12, 2024
aafbd6e
Revise string types
bocchino Apr 12, 2024
94b3d32
Merge branch 'format-fw-types' into external-string
bocchino Apr 12, 2024
00fb983
Revise string types
bocchino Apr 12, 2024
4c2ad7c
Revise string types
bocchino Apr 12, 2024
e536e88
Remove EightyCharString
bocchino Apr 12, 2024
9eaec83
Revise CmdString
bocchino Apr 12, 2024
91e78f9
Revise LogString
bocchino Apr 12, 2024
24a9242
Revise PrmString
bocchino Apr 12, 2024
e078a59
Revise TextLogString
bocchino Apr 12, 2024
33d7c75
Revise Test/String
bocchino Apr 12, 2024
d3c59db
Revise TlmString
bocchino Apr 12, 2024
d5c4cb2
Revise InternalInterfaceString
bocchino Apr 12, 2024
480e9d3
Revise Os/QueueString
bocchino Apr 12, 2024
5b9a4de
Revise Os/TaskString
bocchino Apr 12, 2024
10dce0c
Add missing type qualifier
bocchino Apr 13, 2024
5fd6b34
Fix warning in String.hpp
bocchino Apr 13, 2024
058e402
Revise string types
bocchino Apr 13, 2024
a6d2b43
Remove stray character
bocchino Apr 13, 2024
ce0616a
Revise StringBase
bocchino Apr 13, 2024
028ac4b
Revise string types
bocchino Apr 13, 2024
4e7ab41
Revise String type
bocchino Apr 13, 2024
ac44ee8
Revise FileNameString
bocchino Apr 13, 2024
3e589a9
Revise string types
bocchino Apr 13, 2024
a215ab7
Add missing file
bocchino Apr 13, 2024
74a2c37
Revise InternalInterfaceString
bocchino Apr 13, 2024
883e8a9
Revise comment
bocchino Apr 13, 2024
9af1b1d
Revise TlmString
bocchino Apr 13, 2024
3628e98
Revise string types
bocchino Apr 13, 2024
6ab639a
Revise log strings
bocchino Apr 13, 2024
9fea2d7
Revise PrmString
bocchino Apr 13, 2024
1d74568
Revise Os string classes
bocchino Apr 13, 2024
ad5a348
Revise string types
bocchino Apr 13, 2024
84c7b54
Revise string types
bocchino Apr 13, 2024
77e1a3b
Revise os strings
bocchino Apr 13, 2024
fe5f6b9
Add test for ExternalString to TypesTest
bocchino Apr 13, 2024
a616fc2
Revise ExternalString
bocchino Apr 13, 2024
4db1eb0
Revise ExternalString
bocchino Apr 13, 2024
d3efd31
Update fpp version
bocchino Apr 13, 2024
85c29f7
Format Fw/Types
bocchino Apr 13, 2024
047d8b7
Merge branch 'format-fw-types' into fpp-issue-392-string-records
bocchino Apr 13, 2024
20a00c5
Merge branch 'external-string' into fpp-issue-392-string-records
bocchino Apr 13, 2024
9c575eb
Merge remote-tracking branch 'upstream/devel' into external-string
bocchino Apr 15, 2024
0df9a5b
Merge remote-tracking branch 'upstream/devel' into fpp-issue-407-dict…
bocchino Apr 15, 2024
3b41536
Add static serialized size to StringBase
bocchino Apr 16, 2024
941177b
Merge branch 'fpp-issue-392-string-records' into fpp-issue-407-dictio…
bocchino Apr 16, 2024
f0bd736
Update fpp version
bocchino Apr 16, 2024
b8edffc
Update fpp version; revise string classes
bocchino Apr 16, 2024
f09e8dd
Revise event handling in DpWriter
bocchino Apr 16, 2024
7c92d35
Revise string implementations
bocchino Apr 16, 2024
97b6985
Revise string implementations
bocchino Apr 16, 2024
1e774be
Refactor dp tests
bocchino Apr 16, 2024
c8941b4
Add static assertion to PrmBuffer
bocchino Apr 16, 2024
4416cc4
Revise string implementations; update fpp version
bocchino Apr 17, 2024
aa8f4fd
Revise StringBase
bocchino Apr 17, 2024
36662ab
Fix tests to conform to FPP changes
bocchino Apr 17, 2024
1c466ba
Merge branch 'external-string' into fpp-issue-392-string-records
bocchino Apr 17, 2024
5cd2f82
Merge branch 'fpp-issue-392-string-records' into fpp-issue-407-dictio…
bocchino Apr 17, 2024
0989621
Merge remote-tracking branch 'upstream/devel' into fpp-issue-392-stri…
bocchino Apr 18, 2024
e3f3f49
Merge branch 'fpp-issue-392-string-records' into fpp-issue-407-dictio…
bocchino Apr 18, 2024
1d99954
Merge remote-tracking branch 'upstream/devel' into fpp-issue-407-dict…
bocchino Apr 26, 2024
3e91a02
Remove helper scripts
bocchino Apr 26, 2024
48b051c
Add const qualifier
bocchino Apr 26, 2024
00a3e0c
Revise StringBase
bocchino Apr 26, 2024
4a5ae70
Revise StringBase
bocchino Apr 26, 2024
3cffcd0
Revise comment
bocchino Apr 26, 2024
5c9495b
Update fpp version
bocchino Apr 27, 2024
84d5c1f
Fix code formatting
bocchino Apr 27, 2024
519cc72
Make constructors explicit
bocchino Apr 29, 2024
498963f
Make string constructors explicit
bocchino Apr 29, 2024
d784350
Make string constructors explicit
bocchino Apr 29, 2024
172ebb0
Revise String.hpp
bocchino Apr 29, 2024
76840e2
Fixing improper null-termination in fail case
LeStarch Apr 30, 2024
895297d
Merge branch 'devel' into string-explicit
LeStarch Apr 30, 2024
f594e75
Fixing conversion warnings
LeStarch Apr 30, 2024
6067b6d
Removing broken link
LeStarch Apr 30, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions FppTest/dp/test/ut/Tester.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,7 @@ Fw::Time Tester::randomizeTestTime() {
}

void Tester::generateRandomString(Fw::StringBase& str) {
// Reserve enough space for max length plus null terminator
char buffer[MAX_STRING_LENGTH + 1];
char buffer[Fw::StringBase::BUFFER_SIZE(MAX_STRING_LENGTH)];
// Pick a random string length
const FwSizeType length = STest::Pick::lowerUpper(0, MAX_STRING_LENGTH);
// Fill buffer with a random null-terminated string with that length
Expand Down
10 changes: 5 additions & 5 deletions Fw/Cmd/CmdString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_CMD_STR,
STRING_SIZE = FW_CMD_STRING_MAX_SIZE,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE),
};

CmdStringArg() : StringBase() { *this = ""; }

CmdStringArg(const CmdStringArg& src) : StringBase() { *this = src; }
explicit CmdStringArg(const CmdStringArg& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

CmdStringArg(const StringBase& src) : StringBase() { *this = src; }
explicit CmdStringArg(const StringBase& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

CmdStringArg(const char* src) : StringBase() { *this = src; }
explicit CmdStringArg(const char* src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

src uses the basic integral type char rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

~CmdStringArg() {}

Expand All @@ -52,7 +52,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[CmdStringArg::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
4 changes: 2 additions & 2 deletions Fw/Log/LogString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_LOG_STR,
STRING_SIZE = FW_LOG_STRING_MAX_SIZE,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE)
};

LogStringArg() : StringBase() { *this = ""; }
Expand Down Expand Up @@ -52,7 +52,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[LogStringArg::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
4 changes: 2 additions & 2 deletions Fw/Log/TextLogString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_LOG_STR,
STRING_SIZE = FW_LOG_TEXT_BUFFER_SIZE,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE)
};

TextLogString() : StringBase() { *this = ""; }
Expand Down Expand Up @@ -52,7 +52,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[TextLogString::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
12 changes: 6 additions & 6 deletions Fw/Logger/test/ut/LoggerMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ TEST(LoggerTests, RandomLoggerTests) {
MockLogging::FakeLogger logger;

// Create rules, and assign them into the array
LoggerRules::Register reg("Register");
LoggerRules::LogGood log("Log Successfully");
LoggerRules::LogBad nolog("Log unsuccessfully");
LoggerRules::Register reg(Fw::String("Register"));
LoggerRules::LogGood log(Fw::String("Log Successfully"));
LoggerRules::LogBad nolog(Fw::String("Log unsuccessfully"));

// Setup a list of rules to choose from
STest::Rule<MockLogging::FakeLogger>* rules[] = {
Expand Down Expand Up @@ -55,7 +55,7 @@ TEST(LoggerTests, BasicGoodLogger) {
Fw::Logger::registerLogger(&logger);
logger.s_current = &logger;
// Basic logging
LoggerRules::LogGood log("Log Successfully");
LoggerRules::LogGood log(Fw::String("Log Successfully"));
log.apply(logger);
}
/**
Expand All @@ -66,7 +66,7 @@ TEST(LoggerTests, BasicBadLogger) {
MockLogging::FakeLogger logger;
Fw::Logger::registerLogger(nullptr);
logger.s_current = nullptr;
LoggerRules::LogBad log("Log Discarded");
LoggerRules::LogBad log(Fw::String("Log Discarded"));
log.apply(logger);
}

Expand All @@ -76,7 +76,7 @@ TEST(LoggerTests, BasicBadLogger) {
TEST(LoggerTests, BasicRegLogger) {
// Basic discard logging
MockLogging::FakeLogger logger;
LoggerRules::Register reg("Register");
LoggerRules::Register reg(Fw::String("Register"));
reg.apply(logger);
reg.apply(logger);
reg.apply(logger);
Expand Down
6 changes: 6 additions & 0 deletions Fw/Prm/PrmBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,14 @@
#include <Fw/Types/Serializable.hpp>
#include <Fw/Cfg/SerIds.hpp>

#include "Fw/Types/StringBase.hpp"


namespace Fw {

static_assert(FW_PARAM_BUFFER_MAX_SIZE >= StringBase::BUFFER_SIZE(FW_PARAM_STRING_MAX_SIZE),
"param string must fit into param buffer");

class ParamBuffer : public SerializeBufferBase {
public:

Expand Down
4 changes: 2 additions & 2 deletions Fw/Prm/PrmString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ParamString : public StringBase {
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_PRM_STR,
STRING_SIZE = FW_PARAM_STRING_MAX_SIZE,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE)
};

ParamString() : StringBase() { *this = ""; }
Expand Down Expand Up @@ -52,7 +52,7 @@ class ParamString : public StringBase {
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[ParamString::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];
};
} // namespace Fw

Expand Down
4 changes: 2 additions & 2 deletions Fw/Test/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
public:
enum {
STRING_SIZE = 256,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE),
};

String() : StringBase() { *this = ""; }
Expand Down Expand Up @@ -49,7 +49,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[String::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
4 changes: 2 additions & 2 deletions Fw/Tlm/TlmString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_TLM_STR,
STRING_SIZE = FW_TLM_STRING_MAX_SIZE,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE)
};

TlmString() : StringBase() { *this = ""; }
Expand Down Expand Up @@ -52,7 +52,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[TlmString::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
10 changes: 5 additions & 5 deletions Fw/Types/FileNameString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_FILE_NAME_STRING,
STRING_SIZE = FileNameStringSize,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE)
};

FileNameString() : StringBase() { *this = ""; }

FileNameString(const FileNameString& src) : StringBase() { *this = src; }
explicit FileNameString(const FileNameString& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

FileNameString(const StringBase& src) : StringBase() { *this = src; }
explicit FileNameString(const StringBase& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

FileNameString(const char* src) : StringBase() { *this = src; }
explicit FileNameString(const char* src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

src uses the basic integral type char rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

~FileNameString() {}

Expand All @@ -53,7 +53,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[FileNameString::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
10 changes: 5 additions & 5 deletions Fw/Types/InternalInterfaceString.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_INTERNAL_INTERFACE_STRING,
STRING_SIZE = FW_INTERNAL_INTERFACE_STRING_MAX_SIZE,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE)
};

InternalInterfaceString() : StringBase() { *this = ""; }

InternalInterfaceString(const InternalInterfaceString& src) : StringBase() { *this = src; }
explicit InternalInterfaceString(const InternalInterfaceString& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

InternalInterfaceString(const StringBase& src) : StringBase() { *this = src; }
explicit InternalInterfaceString(const StringBase& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

InternalInterfaceString(const char* src) : StringBase() { *this = src; }
explicit InternalInterfaceString(const char* src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

src uses the basic integral type char rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

~InternalInterfaceString() {}

Expand All @@ -53,7 +53,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[InternalInterfaceString::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
10 changes: 5 additions & 5 deletions Fw/Types/ObjectName.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_OBJECT_NAME,
STRING_SIZE = FW_OBJ_NAME_MAX_SIZE,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE)
};

ObjectName() : StringBase() { *this = ""; }

ObjectName(const ObjectName& src) : StringBase() { *this = src; }
explicit ObjectName(const ObjectName& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

ObjectName(const StringBase& src) : StringBase() { *this = src; }
explicit ObjectName(const StringBase& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

ObjectName(const char* src) : StringBase() { *this = src; }
explicit ObjectName(const char* src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

src uses the basic integral type char rather than a typedef with size and signedness.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

~ObjectName() {}

Expand All @@ -52,7 +52,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[ObjectName::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
8 changes: 4 additions & 4 deletions Fw/Types/String.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
enum {
SERIALIZED_TYPE_ID = FW_TYPEID_FIXED_LENGTH_STRING,
STRING_SIZE = FW_FIXED_LENGTH_STRING_SIZE,
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwSizeStoreType)
SERIALIZED_SIZE = STATIC_SERIALIZED_SIZE(STRING_SIZE),
};

String() : StringBase() { *this = ""; }

String(const String& src) : StringBase() { *this = src; }
explicit String(const String& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

String(const StringBase& src) : StringBase() { *this = src; }
explicit String(const StringBase& src) : StringBase() { *this = src; }

Check warning

Code scanning / CodeQL

Unchecked return value Warning

The return value of non-void function
operator=
is not checked.

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter src has not been checked.

Check notice

Code scanning / CodeQL

More than one statement per line Note

This line contains 3 statements; only one is allowed.

String(const char* src) : StringBase() { *this = src; }

Expand All @@ -52,7 +52,7 @@
StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }

private:
char m_buf[String::STRING_SIZE];
char m_buf[BUFFER_SIZE(STRING_SIZE)];

Check notice

Code scanning / CodeQL

Use of basic integral type Note

m_buf uses the basic integral type char rather than a typedef with size and signedness.
};
} // namespace Fw

Expand Down
41 changes: 34 additions & 7 deletions Fw/Types/StringBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,16 @@
}

StringBase::SizeType StringBase::length() const {
return static_cast<SizeType>(StringUtils::string_length(this->toChar(), this->getCapacity()));
const SizeType length = static_cast<SizeType>(StringUtils::string_length(this->toChar(), this->getCapacity()));

Check notice

Code scanning / CodeQL

Use of basic integral type Note

length uses the basic integral type unsigned int rather than a typedef with size and signedness.
FW_ASSERT(length <= this->maxLength(), static_cast<FwAssertArgType>(length),
static_cast<FwAssertArgType>(this->maxLength()));
return length;
}

StringBase::SizeType StringBase::maxLength() const {

Check notice

Code scanning / CodeQL

Use of basic integral type Note

maxLength uses the basic integral type unsigned int rather than a typedef with size and signedness.
const SizeType capacity = this->getCapacity();

Check notice

Code scanning / CodeQL

Use of basic integral type Note

capacity uses the basic integral type unsigned int rather than a typedef with size and signedness.
FW_ASSERT(capacity > 0, static_cast<FwAssertArgType>(capacity));
return capacity - 1;
}

StringBase::SizeType StringBase::serializedSize() const {
Expand All @@ -130,16 +139,34 @@
}

SerializeStatus StringBase::serialize(SerializeBufferBase& buffer, SizeType maxLength) const {
SizeType len = FW_MIN(maxLength, this->length());
return buffer.serialize(reinterpret_cast<const U8*>(this->toChar()), len);
const FwSizeType len = FW_MIN(maxLength, this->length());

Check notice

Code scanning / CodeQL

Use of basic integral type Note

len uses the basic integral type unsigned long rather than a typedef with size and signedness.
// Serialize length and then bytes
return buffer.serialize(reinterpret_cast<const U8*>(this->toChar()), len, Serialization::INCLUDE_LENGTH);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffer has not been checked.
}

SerializeStatus StringBase::deserialize(SerializeBufferBase& buffer) {
SizeType maxSize = this->getCapacity() - 1;
// Get the max size of the deserialized string
const FwSizeType maxSize = this->maxLength();

Check notice

Code scanning / CodeQL

Use of basic integral type Note

maxSize uses the basic integral type unsigned long rather than a typedef with size and signedness.
// Initial estimate of actual size is max size
// This estimate is refined when calling the deserialize function below
SizeType actualSize = maxSize;

Check notice

Code scanning / CodeQL

Use of basic integral type Note

actualSize uses the basic integral type unsigned int rather than a typedef with size and signedness.
// Public interface returns const char*, but implementation needs char*
// So use const_cast
CHAR* raw = const_cast<CHAR*>(this->toChar());
SerializeStatus stat = buffer.deserialize(reinterpret_cast<U8*>(raw), maxSize);
// Null terminate deserialized string
raw[maxSize] = 0;
// Deserialize length
// Fail if length exceeds max size (the initial value of actualSize)
// Otherwise deserialize length bytes and set actualSize to length
SerializeStatus stat = buffer.deserialize(reinterpret_cast<U8*>(raw), actualSize, Serialization::INCLUDE_LENGTH);

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffer has not been checked.
if (stat == FW_SERIALIZE_OK) {
// Deserialization succeeded: null-terminate string at actual size
FW_ASSERT(actualSize <= maxSize, static_cast<FwAssertArgType>(actualSize),
static_cast<FwAssertArgType>(maxSize));
raw[actualSize] = 0;
} else {
// Deserialization failed: leave string unmodified, but ensure that it
// is null-terminated
raw[0] = maxSize;
LeStarch marked this conversation as resolved.
Show resolved Hide resolved
}
return stat;
}
} // namespace Fw
Loading
Loading