Skip to content

Make FW_ASSERT conditions explicit boolean tests (JPL Rule 16)#5394

Open
lestarch-autobot wants to merge 2 commits into
nasa:develfrom
JPL-Devin:devin/1783654048-nonboolean-asserts
Open

Make FW_ASSERT conditions explicit boolean tests (JPL Rule 16)#5394
lestarch-autobot wants to merge 2 commits into
nasa:develfrom
JPL-Devin:devin/1783654048-nonboolean-asserts

Conversation

@lestarch-autobot

Copy link
Copy Markdown
Collaborator
Related Issue(s)
Has Unit Tests (y/n) n
Documentation Included (y/n) n
Generative AI was used in this contribution (y/n) AI

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 in AosFramer)

The 16 remaining alerts in Fw/DataStructures templates and LinearBufferTemplate.hpp are 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 than assert(p)). This clears the hand-written portion of the corresponding CodeQL run.

Testing/Review Recommendations

Full fprime-util build --all passes. The change is textual: each modified line only appends != nullptr/!= 0 or replaces the literal 0/1 with false/true inside 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

Co-Authored-By: michael.d.starch <michael.d.starch@jpl.nasa.gov>
@github-actions

github-actions Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Coverage report — base devel

Overall (line): 82.08% → 82.06% (-0.02)
Regression threshold: 0.50% (line).

Regressions

(none over threshold)

Modules changed

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants