Skip to content

cppcheck: replace bool 0/1 assignments with false/true#2409

Merged
adeebshihadeh merged 6 commits into
commaai:masterfrom
varshneydevansh:new_zero_one
Jun 11, 2026
Merged

cppcheck: replace bool 0/1 assignments with false/true#2409
adeebshihadeh merged 6 commits into
commaai:masterfrom
varshneydevansh:new_zero_one

Conversation

@varshneydevansh

Copy link
Copy Markdown
Contributor

Completes the panda-side cleanup for:

This uses cppcheck 2.21.0, which includes the upstream
bool-literal handling changes:

Changes:

  • replace bool ret = 0; with bool ret = false;
  • replace ret = 1; with ret = true;

This branch temporarily points to the dependency branches
needed for CI:

Validation:

I used SKIP_TABLES_DIFF=1 to skip those table/checker
diffs to actually run the analysis.

What cppcheck report through panda before the opendbc fix:

 Devanshs-MacBook-Pro    \panda  ➜ (  new_zero_one)   30ms   1:26 AM   
 ⚡devanshvarshney ❯❯ SKIP_BUILD=1 SKIP_TABLES_DIFF=1 tests/misra/test_misra.sh 2>&1 | rg "misra-c2012-10.3"

/Users/devanshvarshney/panda/.venv/lib/python3.12/site-packages/opendbc/safety/modes/toyota.h:334:10: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-10.3]
/Users/devanshvarshney/panda/board/drivers/can_common.h:41:12: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-10.3]
/Users/devanshvarshney/panda/board/drivers/can_common.h:51:9: style: misra violation (use --rule-texts=<file> to get proper output) [misra-c2012-10.3]

After the fix:

 Devanshs-MacBook-Pro    \panda  ➜ (  new_zero_one)   60ms   1:48 AM   
 ⚡devanshvarshney ❯❯ SKIP_BUILD=1 SKIP_TABLES_DIFF=1 tests/misra/test_misra.sh 2>&1 | rg "misra-c2012-10.3"

# no output

@varshneydevansh

Copy link
Copy Markdown
Contributor Author

I still have this local change in my local panda repo
which I didn't pushed just to validate that the
remaining opendbc misra violation is really gone.

diff --git a/pyproject.toml b/pyproject.toml
index f3fcc9bd..cdc082e0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -14,7 +14,7 @@ classifiers = [
 dependencies = [
   "libusb1",
   "libusb-package",
-  "opendbc @ git+https://github.com/commaai/opendbc.git@master#egg=opendbc",
+  "opendbc @ git+https://github.com/varshneydevansh/opendbc.git@new_zero_one#egg=opendbc",
 
   # runtime dependency on comma four
   #"spidev; platform_system == 'Linux'",

@varshneydevansh

Copy link
Copy Markdown
Contributor Author

I should have also told about the "coverage table" earlier
when I tried to run cppcheck as whole

 Devanshs-MacBook-Pro    \panda  ➜ (  new_zero_one)   3.326s   1:58 AM   
 ⚡devanshvarshney ❯❯ tests/misra/test_misra.sh

MISRA coverage table doesn't match. Update and commit:

 Devanshs-MacBook-Pro    \panda  ➜ (  new_zero_one)   574ms   2:21 AM   
 ⚡devanshvarshney ❯❯ git status
On branch new_zero_one
Your branch is up to date with 'origin/new_zero_one'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
	modified:   pyproject.toml
	modified:   tests/misra/coverage_table

no changes added to commit (use "git add" and/or "git commit -a")

But then I moved to only validate the bool replacement check which
I've learnt at libreoffice to keep the patches atomic to the request :)

@adeebshihadeh

Copy link
Copy Markdown
Contributor

Thanks for the PR!

@adeebshihadeh adeebshihadeh merged commit 697b04d into commaai:master Jun 11, 2026
7 of 8 checks passed
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