fix: clang-tidy compliance + fix renoir shared pool config for camera buffers - #2
Conversation
Nil69420
commented
Mar 27, 2026
- Convert all integer #define macros to enums across headers
- Replace thread-unsafe drand48/srand48 with stateful splitmix64 PRNG
- Fix nested ternary in clampd(), rename short variables per readability checks
- Fix implicit widening casts in sha1.c and sensors.c
- Add NOLINT annotations to viewer.c file-scope globals
- Refactor bridge.c (cognitive complexity 75 -> 23) and main.c (44 -> 28)
- Set max_payload_size to actual message size in transport_renoir.c
- Update .clang-tidy HeaderFilterRegex to exclude external headers
… buffers - Convert all integer #define macros to enums across headers - Replace thread-unsafe drand48/srand48 with stateful splitmix64 PRNG - Fix nested ternary in clampd(), rename short variables per readability checks - Fix implicit widening casts in sha1.c and sensors.c - Add NOLINT annotations to viewer.c file-scope globals - Refactor bridge.c (cognitive complexity 75 -> 23) and main.c (44 -> 28) - Set max_payload_size to actual message size in transport_renoir.c - Update .clang-tidy HeaderFilterRegex to exclude external headers
There was a problem hiding this comment.
Pull request overview
This PR focuses on bringing the C codebase into clang-tidy compliance while fixing IPC transport sizing for large camera-buffer messages and reducing complexity in a few core components.
Changes:
- Replaced integer
#defineconstants with anonymous enums across headers; adjusted various identifiers/control-flow to satisfy readability checks. - Switched sensor noise generation from global
drand48/srand48to a per-manager stateful RNG and updated sensor code accordingly. - Updated Renoir transport topic options to size
max_payload_sizebased on message size, and refactored CLI parsing / Foxglove bridge logic for lower cognitive complexity.
Reviewed changes
Copilot reviewed 19 out of 20 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/viewer.c | Adds NOLINT annotations for file-scope globals; small switch handling/readability tweak. |
| src/transport/transport_renoir.c | Adjusts payload sizing behavior and replaces macro with enum constant. |
| src/sensors/sensors.c | Migrates noise calls to use per-manager RNG; fixes pointer arithmetic casts for clang-tidy. |
| src/main.c | Refactors CLI argument parsing into a helper and uses a structured args container. |
| src/foxglove/ws.c | Renames short pointer variables to satisfy readability rules. |
| src/foxglove/sha1.c | Fixes implicit cast warnings via ptrdiff_t indexing; renames temporaries. |
| src/foxglove/serialize.c | Renames message variables for readability. |
| src/foxglove/proto.c | Renames pointer variables for readability/clarity. |
| src/foxglove/bridge.c | Refactors bridge thread logic into helper functions to reduce complexity. |
| src/foxglove/base64.c | Renames variables for readability/clarity. |
| run.sh | Adds helper script to build/run/analyze configurations. |
| include/types.h | Converts NUM_ROTORS macro to enum constant. |
| include/sensors/sensors.h | Adds RNG state to sensor manager and includes noise header. |
| include/sensors/sensor_types.h | Converts LIDAR_MAX_RAYS macro to enum constant. |
| include/sensors/noise.h | Replaces drand48/srand48 with stateful splitmix64-based RNG helpers. |
| include/foxglove/ws.h | Converts websocket opcode macros to enum constants. |
| include/foxglove/proto.h | Converts FG_MAX_SUBS macro to enum constant. |
| include/foxglove/foxglove.h | Converts Foxglove constants to enum constants. |
| include/controller.h | Replaces nested ternary clamp with clearer branching. |
| .clang-tidy | Updates header filtering regex for clang-tidy runs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| WarningsAsErrors: '*' | ||
|
|
||
| HeaderFilterRegex: 'include/.*\.h$' | ||
| HeaderFilterRegex: 'mujoco_drones/include/.*\.h$' |
There was a problem hiding this comment.
HeaderFilterRegex is now hard-coded to mujoco_drones/include/..., which will stop clang-tidy from analyzing project headers when the repo is checked out into a differently named directory (common in local builds and some CI setups). Prefer a path-agnostic regex (e.g., matching /include/ anywhere) and exclude external headers via a negative match instead of baking in the repo directory name.
| HeaderFilterRegex: 'mujoco_drones/include/.*\.h$' | |
| HeaderFilterRegex: '^(?!.*(/third_party/|/external/|/build/)).*/include/.*\.h$' |