-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add Fw::ObjectName to hold Fw::ObjBase name #2497
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few very minor style guidelines.
This looks great! I suggest we do the following:
|
Added the recommended changes. I wanted to apply them to the other |
Don't include ObjectName header unless object names are enabled
I am working on integrating this PR with FPP. It's looking good so far. Here is one issue I see: |
@bocchino this also applies to |
Since this is a breaking change for projects that define their own |
I agree, let's defer this to a separate issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the CI warnings that we shouldn't fix. You should address the rest.
With the "side effect in boolean" we should fix that by assigning to a const variable and then checking.
The others I think are mostly checking return of string_copy. It should check and null terminate if possible.
Finally nullptr
checks on CHAR* pointers
@@ -13,7 +13,8 @@ | |||
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) < 0) { | |||
PlatformIntType status = snprintf(buffer, size, "Comp: %s", this->m_objName.toChar()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -22,7 +22,8 @@ | |||
#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) < 0) { | |||
PlatformIntType status = snprintf(buffer, size, "QueueComp: %s", this->m_objName.toChar()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -45,7 +45,8 @@ | |||
#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) < 0) { | |||
PlatformIntType status = snprintf(buffer, size, "ActComp: %s", this->m_objName.toChar()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
@@ -29,8 +29,9 @@ | |||
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, | |||
this->isConnected() ? this->m_connObj->getObjName() : "None") < 0) { | |||
PlatformIntType status = snprintf(buffer, size, "InputPort: %s->%s", this->m_objName.toChar(), |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
} | ||
#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) < 0) { | ||
PlatformIntType status = snprintf(str, size, "Obj: %s", this->m_objName.toChar()); |
Check notice
Code scanning / CodeQL
Use of basic integral type Note
Change Description
Implements
Fw::ObjectName
to hold names ofObjBase
objects instead of raw char arrays.I tried to keep the changes to a minimum, so I'm using
.toChar()
in most places.Let me know if there's other patterns you think I should add here, or any other desired changes.
Associated PR to FPP: nasa/fpp#385
Rationale
See #2493