devtools: Add clang-format to pre-commit.
What changed, and why it matters
This commit adds a code-formatting check (clang-format) to the project's pre-commit tooling. It does not change any executable code, protocol logic, or security-sensitive behavior. It is purely a developer workflow improvement to enforce consistent C code style before commits.
No security action required. Treat as a normal tooling/CI hygiene change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The diff modifies .pre-commit-config.yaml to register the pre-commit/mirrors-clang-format hook at v19.1.4. The hook runs clang-format –dry-run -Werror on C files during the manual stage, failing the commit if formatting suggestions exist. No source files, build scripts, or runtime configuration are changed.
Changed components
.pre-commit-config.yamlInspect captured patch +13 / −0
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 16b52dd3..9c69e945 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -18,6 +18,19 @@ repos:
- id: shellcheck
args: [ -fgcc ]
+- repo: https://github.com/pre-commit/mirrors-clang-format
+ rev: v19.1.4
+ hooks:
+ - id: clang-format
+ description: Runs formatting checks on the c code and and throws errors if suggestions
+ are detected, without modifying the code. Style is defined in `.clang-format`. When
+ encountering formatting-related errors, run `clang-format -i <path-to-file>` to make
+ (destructively) the suggestions and evalute the resulting diff for more context.
+ args: [ --dry-run, -Werror ]
+ entry: clang-format
+ types: [ c ]
+ stages: [ manual ]
+
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.30.0
hooks:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.