Make FW_ASSERT conditions explicit boolean tests (JPL Rule 16)#5394
Make FW_ASSERT conditions explicit boolean tests (JPL Rule 16)#5394lestarch-autobot wants to merge 2 commits into
Conversation
Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
Coverage report — base
|
| Module | Line | Δ | Function | Δ | Branch | Δ |
|---|---|---|---|---|---|---|
Os/Posix |
62.00 | -0.40 | 84.21 | +0.00 | 43.87 | -0.23 |
Svc/TlmPacketizer |
92.15 | -0.03 | 100.00 | +0.00 | 77.85 | +0.00 |
Fw/DataStructures |
98.48 | +0.27 | 97.14 | +0.00 | 83.21 | +0.37 |
Os/Generic/Types |
92.39 | +0.36 | 92.86 | +0.00 | 74.29 | +1.91 |
Drv/TcpClient |
80.00 | +5.00 | 100.00 | +0.00 | 63.16 | +15.79 |
Modules without UTs
CFDP/Checksum/GTest, Drv/ByteStreamDriverModel, Drv/Interfaces, Drv/LinuxGpioDriver, Drv/LinuxI2cDriver, Drv/LinuxSpiDriver, Drv/LinuxUartDriver, Drv/Ports, Drv/Ports/DataTypes, FppTestProject/FppTest/interfaces, FppTestProject/FppTest/topology/async, FppTestProject/FppTest/topology/components/Comp, FppTestProject/FppTest/topology/components/Framework, FppTestProject/FppTest/topology/components/Receiver, FppTestProject/FppTest/topology/components/Sender, FppTestProject/FppTest/topology/guarded, FppTestProject/FppTest/topology/ports, FppTestProject/FppTest/topology/sync, FppTestProject/FppTest/topology/top_ports, FppTestProject/FppTest/topology/types, Fw/Cmd, Fw/Com, Fw/Comp, Fw/FilePacket/GTest, Fw/Fpy, Fw/Interfaces, Fw/Obj, Fw/Port, Fw/Ports/CompletionStatus, Fw/Ports/Ready, Fw/Ports/Signal, Fw/Ports/SuccessCondition, Fw/Prm, Fw/SerializableFile/test/TestSerializable, Fw/Sm, Fw/Test, Fw/Types/GTest, Os/Models, Svc/Cycle, Svc/DpPorts, Svc/Fatal, Svc/FatalHandler, Svc/FileDownlinkPorts, Svc/FprimeProtocol, Svc/Interfaces, Svc/PassiveConsoleTextLogger, Svc/Ping, Svc/PolyIf, Svc/Ports/CommsPorts, Svc/Ports/FilePorts, Svc/Ports/OsTimeEpoch, Svc/Ports/TlmPacketizerPorts, Svc/Ports/VersionPorts, Svc/Sched, Svc/Seq, Svc/Subtopologies/CdhCore, Svc/Subtopologies/ComCcsds, Svc/Subtopologies/ComFprime, Svc/Subtopologies/ComLoggerTee, Svc/Subtopologies/DataProducts, Svc/Subtopologies/DpCompression, Svc/Subtopologies/FileHandling, Svc/Types/TlmPacketizerTypes, Svc/WatchDog, TestDeploymentsProject/Ref/PingReceiver, TestDeploymentsProject/Ref/RecvBuffApp, TestDeploymentsProject/Ref/SendBuffApp, TestDeploymentsProject/Ref/Top, TestDeploymentsProject/Ref/TypeDemo, cmake/test/data/TestDeployment/TestBuildAutocoder, cmake/test/data/TestDeployment/TestChainedAutocoder, cmake/test/data/TestDeployment/TestHeaderAutocoder, cmake/test/data/TestDeployment/TestTargetAutocoder, cmake/test/data/test-fprime-library/TestLibrary/TestComponent, cmake/test/data/test-fprime-library2/TestLibrary2/TestComponent
…s, packetList.list) Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
Change Description
Mechanical cleanup of the 122 hand-code
cpp/fprime/jpl-c/use-of-assertions-non-boolean(JPL Rule 16: assertions must be boolean tests) CodeQL alerts. No behavioral change:FW_ASSERT(ptr)->FW_ASSERT(ptr != nullptr)(pointer expressions, e.g.getBuffAddr(), callback/member pointers)FW_ASSERT(count)->FW_ASSERT(count != 0)(integer expressions)FW_ASSERT(flags & MASK, ...)->FW_ASSERT((flags & MASK) != 0, ...)FW_ASSERT(0)/assert(0)->FW_ASSERT(false)/assert(false)(the unreachable-code idiom, 54 sites)FW_ASSERT(1)->FW_ASSERT(true)(one TODO placeholder inAosFramer)The 16 remaining alerts in
Fw/DataStructurestemplates andLinearBufferTemplate.hppare already boolean comparisons (status == Success::SUCCESS,nodeObj.m_left == Node::NONE); they are flagged only because the asserted expression's type is unresolved in the uninstantiated template copy. Those are left unchanged; a query refinement will follow separately.Rationale
JPL Rule 16 requires assertions be defined as explicit boolean tests (
assert(p != NULL)rather thanassert(p)). This clears the hand-written portion of the corresponding CodeQL run.Testing/Review Recommendations
Full
fprime-util build --allpasses. The change is textual: each modified line only appends!= nullptr/!= 0or replaces the literal0/1withfalse/trueinside an assertion.Future Work
CodeQL refinement to stop flagging boolean expressions with unresolved types in uninstantiated templates.
AI Usage (see policy)
Devin generated the edits from the CodeQL alert locations and validated with a full build. IAMAI