Skip to content

fix: clang-tidy compliance + fix renoir shared pool config for camera buffers - #2

Merged
Nil69420 merged 1 commit into
masterfrom
fix/clang-tidy-and-segfault
Mar 27, 2026
Merged

fix: clang-tidy compliance + fix renoir shared pool config for camera buffers#2
Nil69420 merged 1 commit into
masterfrom
fix/clang-tidy-and-segfault

Conversation

@Nil69420

Copy link
Copy Markdown
Owner
  • 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
Copilot AI review requested due to automatic review settings March 27, 2026 09:50

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 #define constants with anonymous enums across headers; adjusted various identifiers/control-flow to satisfy readability checks.
  • Switched sensor noise generation from global drand48/srand48 to a per-manager stateful RNG and updated sensor code accordingly.
  • Updated Renoir transport topic options to size max_payload_size based 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.

Comment thread .clang-tidy
WarningsAsErrors: '*'

HeaderFilterRegex: 'include/.*\.h$'
HeaderFilterRegex: 'mujoco_drones/include/.*\.h$'

Copilot AI Mar 27, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
HeaderFilterRegex: 'mujoco_drones/include/.*\.h$'
HeaderFilterRegex: '^(?!.*(/third_party/|/external/|/build/)).*/include/.*\.h$'

Copilot uses AI. Check for mistakes.
@Nil69420
Nil69420 merged commit a8682e9 into master Mar 27, 2026
8 checks passed
@Nil69420
Nil69420 deleted the fix/clang-tidy-and-segfault branch March 27, 2026 13:39
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