Skip to content

Commit

Permalink
Fix static code analysis warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-bc committed Mar 1, 2024
1 parent 387b969 commit 75f3c04
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 6 deletions.
3 changes: 2 additions & 1 deletion Fw/Comp/ActiveComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ namespace Fw {
#if FW_OBJECT_TO_STRING == 1 && FW_OBJECT_NAMES == 1
void ActiveComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) {
FW_ASSERT(size > 0);
if (snprintf(buffer, size, "ActComp: %s", this->m_objName.toChar()) < 0) {
PlatformIntType status = snprintf(buffer, size, "ActComp: %s", this->m_objName.toChar());

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffer has not been checked.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
if (status < 0) {
buffer[0] = 0;
}
}
Expand Down
3 changes: 2 additions & 1 deletion Fw/Comp/PassiveComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ namespace Fw {
void PassiveComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) {
FW_ASSERT(buffer);
FW_ASSERT(size > 0);
if (snprintf(buffer, size, "Comp: %s", this->m_objName.toChar()) < 0) {
PlatformIntType status = snprintf(buffer, size, "Comp: %s", this->m_objName.toChar());

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
if (status < 0) {
buffer[0] = 0;
}
}
Expand Down
3 changes: 2 additions & 1 deletion Fw/Comp/QueuedComponentBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace Fw {
#if FW_OBJECT_TO_STRING == 1 && FW_OBJECT_NAMES == 1
void QueuedComponentBase::toString(char* buffer, NATIVE_INT_TYPE size) {
FW_ASSERT(size > 0);
if (snprintf(buffer, size,"QueueComp: %s", this->m_objName.toChar()) < 0) {
PlatformIntType status = snprintf(buffer, size, "QueueComp: %s", this->m_objName.toChar());

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffer has not been checked.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
if (status < 0) {
buffer[0] = 0;
}
}
Expand Down
3 changes: 2 additions & 1 deletion Fw/Obj/ObjBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ namespace Fw {
#if FW_OBJECT_TO_STRING == 1
void ObjBase::toString(char* str, NATIVE_INT_TYPE size) {
FW_ASSERT(size > 0);
if (snprintf(str, size, "Obj: %s",this->m_objName.toChar()) < 0) {
PlatformIntType status = snprintf(str, size, "Obj: %s", this->m_objName.toChar());

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter str has not been checked.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
if (status < 0) {
str[0] = 0;
}
}
Expand Down
5 changes: 3 additions & 2 deletions Fw/Port/InputPortBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ namespace Fw {
void InputPortBase::toString(char* buffer, NATIVE_INT_TYPE size) {
#if FW_OBJECT_NAMES == 1
FW_ASSERT(size > 0);
if (snprintf(buffer, size, "InputPort: %s->%s", this->m_objName.toChar(),
this->isConnected() ? this->m_connObj->getObjName() : "None") < 0) {
PlatformIntType status = snprintf(buffer, size, "InputPort: %s->%s", this->m_objName.toChar(),

Check warning

Code scanning / CodeQL

Unchecked function argument Warning

This use of parameter buffer has not been checked.

Check notice

Code scanning / CodeQL

Use of basic integral type Note

status uses the basic integral type int rather than a typedef with size and signedness.
this->isConnected() ? this->m_connObj->getObjName() : "None");
if (status < 0) {
buffer[0] = 0;
}
#else
Expand Down
2 changes: 2 additions & 0 deletions Fw/Types/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ char* Fw::StringUtils::string_copy(char* destination, const char* source, U32 nu
if(destination == source || num == 0) {
return destination;
}
FW_ASSERT(source != nullptr);
FW_ASSERT(destination != nullptr);

// Copying an overlapping range is undefined
U32 source_len = string_length(source, num) + 1;
Expand Down

0 comments on commit 75f3c04

Please sign in to comment.