Skip to content

fix(cie): address misc code quality issues#51

Merged
atsushi421 merged 2 commits intomainfrom
fix/misc-code-quality-issues
Apr 22, 2026
Merged

fix(cie): address misc code quality issues#51
atsushi421 merged 2 commits intomainfrom
fix/misc-code-quality-issues

Conversation

@atsushi421
Copy link
Copy Markdown
Collaborator

@atsushi421 atsushi421 commented Apr 22, 2026

Description

Fix several code quality issues found during repository review:

  • Reject unknown scheduling policies: issue_syscalls() now returns false and logs an error when an unrecognized policy string is encountered, instead of silently succeeding and only applying CPU affinity. Additionally, the policy string is validated at YAML load time so that typos (e.g. SCHED_OTEHR) cause an immediate std::runtime_error at startup rather than a deferred runtime failure.
  • Fix trailing comma in cpuset.cpus: set_affinity_by_cgroup() now writes "0,1,2" instead of "0,1,2," for canonical cpuset format.
  • Add inline to sched_setattr() in header: Prevents ODR violation if sched_deadline.hpp is included from multiple translation units. Currently only one TU includes it, but the header is publicly installed.
  • Remove stale CARGO_TERM_COLOR env var: Rust-specific environment variable copied into the C++ CI workflow.
  • Zero-initialize ThreadConfig members: priority, runtime, period, and deadline now have default initializers to avoid uninitialized reads if access patterns change in the future.

Related links

How was this PR tested?

Notes for reviewers

- Reject unknown scheduling policies in issue_syscalls() instead of
  silently succeeding
- Remove trailing comma when writing cpuset.cpus
- Add inline to sched_setattr() in header to prevent ODR violation
- Remove stale CARGO_TERM_COLOR env var from CI workflow
- Zero-initialize ThreadConfig members (priority, runtime, period,
  deadline)

Signed-off-by: atsushi421 <atsushi.yano.2@tier4.jp>
- Add thread_id to unknown-policy error message for consistency
- Validate policy string at YAML load time and fail fast on typos

Signed-off-by: atsushi421 <atsushi.yano.2@tier4.jp>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Improves robustness and code quality in the CIE thread configurator by tightening scheduling-policy validation/handling, fixing cpuset formatting, addressing a potential ODR issue in a public header, and cleaning up CI configuration.

Changes:

  • Validate scheduling policy strings at YAML load time and reject unknown policies in issue_syscalls().
  • Fix cpuset.cpus formatting to avoid a trailing comma.
  • Make sched_setattr() inline, remove stale CI env var, and default-initialize ThreadConfig fields.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
cie_thread_configurator/src/thread_configurator_node.cpp Adds policy validation, fixes cpuset writing, and rejects unknown policies at syscall time.
cie_thread_configurator/include/cie_thread_configurator/thread_configurator_node.hpp Default-initializes ThreadConfig scheduling fields to avoid uninitialized reads.
cie_thread_configurator/include/cie_thread_configurator/sched_deadline.hpp Marks sched_setattr() as inline to prevent ODR violations across TUs.
.github/workflows/build-and-test.yaml Removes a Rust-specific env var from the C++ CI workflow.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread cie_thread_configurator/src/thread_configurator_node.cpp
@atsushi421 atsushi421 marked this pull request as ready for review April 22, 2026 21:05
@atsushi421 atsushi421 enabled auto-merge April 22, 2026 21:09
@atsushi421 atsushi421 merged commit bbe470f into main Apr 22, 2026
7 checks passed
@atsushi421 atsushi421 deleted the fix/misc-code-quality-issues branch April 22, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants