Skip to content

fix(clang-tidy): resolve cppcoreguidelines-init-variables findings - #1014

Merged
LittleHuba merged 1 commit into
eclipse-score:mainfrom
castler:fix/clang-tidy-init-variables
Aug 26, 2026
Merged

LittleHuba merged 1 commit into
eclipse-score:mainfrom
castler:fix/clang-tidy-init-variables

Conversation

@castler

@castler castler commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes all cppcoreguidelines-init-variables clang-tidy findings (11 findings across 4 files).

Approach

Initializes each flagged variable at its point of declaration instead of leaving it default-constructed/uninitialized, per the C++ Core Guidelines' recommendation that every variable be given a well-defined value as soon as it is declared. All changes are pure initialization additions — no behavioral change, since every affected variable is fully overwritten before its first read in the original code, and the chosen initial values (enum default, 0, false) match the variables' subsequent overwritten semantics.

Fixes

  • unix_domain_engine.cpp: PipeEvent pipe_event is an out-parameter for a raw read() syscall that always overwrites it before use; initialized to PipeEvent::QUIT (a valid enumerator) as a safe default.
  • unix_domain_server.cpp: std::uint8_t code is an out-parameter for ReceiveProtocolMessage(); zero-initialized.
  • flock_test.cpp: FILE* stream was declared then immediately assigned from fdopen() on the next line; merged declaration and initialization (×2 occurrences). int c (loop-local fgetc() result) is zero-initialized.
  • smokeyeyes.cpp: the boost::program_options-bound variables (num_clients, turns, batch_size, no_wait, num_slots) are populated by po::store/po::notify from their default_value()s; initialized to matching defaults so the variable is never observably uninitialized between declaration and parsing. int wstatus, an out-parameter for waitpid(), is zero-initialized.

Verification

  • Scoped clang-tidy build isolated to cppcoreguidelines-init-variables shows 0 findings (down from 11 across 4 files).
  • Full bazel build //score/message_passing/... //score/mw/com/test/flock/... //score/mw/com/test/smokeyeyes/... passes.
  • bazel test //score/message_passing:unix_domain_test //score/message_passing:unix_domain_test_linux passes (2/2).
  • bazel test //:format_test_C++_with_clang-format passes — no formatting issues introduced.

Scope

This PR intentionally contains only cppcoreguidelines-init-variables fixes, per the project convention of one clang-tidy check per PR (see #995, #999, #1000, #1001, #1003, #1012, #1013).

@LittleHuba
LittleHuba enabled auto-merge August 26, 2026 08:27
@LittleHuba
LittleHuba added this pull request to the merge queue Aug 26, 2026
Initializes all variables at their point of declaration to eliminate
uninitialized-read risk, per the C++ Core Guidelines' recommendation
that every variable be given a well-defined value as soon as it is
declared.

Fixes:
- unix_domain_engine.cpp: `PipeEvent pipe_event` is an out-parameter
  for a raw `read()` syscall that always overwrites it before use;
  initialized to `PipeEvent::QUIT` (a valid enumerator) as a safe
  default.
- unix_domain_server.cpp: `std::uint8_t code` is an out-parameter for
  `ReceiveProtocolMessage()`; zero-initialized.
- flock_test.cpp: `FILE* stream` was declared then immediately assigned
  from `fdopen()` on the next line; merged declaration and
  initialization. Likewise `int c` (loop-local `fgetc()` result) is
  zero-initialized.
- smokeyeyes.cpp: the boost::program_options-bound variables
  (`num_clients`, `turns`, `batch_size`, `no_wait`, `num_slots`) are
  populated by `po::store`/`po::notify` from their `default_value()`s;
  initialized to those same defaults' underlying type default so the
  variable is never observably uninitialized between declaration and
  parsing. `int wstatus`, an out-parameter for `waitpid()`, is
  zero-initialized.

All changes are pure initialization additions; no behavioral change,
since every variable is fully overwritten before its first read in the
original code, and the invariants used as initial values (enum default,
0, false) match the variables' subsequent overwritten semantics.

Verified:
- Scoped clang-tidy build isolated to cppcoreguidelines-init-variables
  shows 0 findings (down from 11 findings across 4 files).
- Full build (`bazel build //score/message_passing/...
  //score/mw/com/test/flock/... //score/mw/com/test/smokeyeyes/...`)
  passes.
- `bazel test //score/message_passing:unix_domain_test
  //score/message_passing:unix_domain_test_linux` passes (2/2).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Merged via the queue into eclipse-score:main with commit 6978561 Aug 26, 2026
18 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in COM - Communication FT Aug 26, 2026
github-merge-queue Bot pushed a commit that referenced this pull request Aug 26, 2026
…indings (#1015)

## Summary

Fixes all `cppcoreguidelines-special-member-functions` clang-tidy
findings (3 findings across 3 files).

## Approach

Explicitly declares the missing copy/move special member functions
(deleted, since none of these classes support meaningful copy/move
semantics) so each class fully follows the Rule of Five instead of
relying on implicit generation, per the C++ Core Guidelines'
recommendation that if any of destructor/copy/move is user-declared, all
five should be declared.

## Fixes

- **`sample_sender_receiver.cpp`**: `TestDestructor` is a scope-guard
type that calls `stop_source_.request_stop()` in its destructor; it is
only ever used as a named local variable and was never intended to be
copied or moved. Deleted copy/move constructor and assignment.
- **`provider.cpp` (partial_restart/provider_restart)**:
`CyclicEventSender` already explicitly deleted its copy
constructor/assignment (its `std::thread` member isn't copyable) but
didn't declare move operations. Since its background thread captures
`this`, moving the object would leave the thread referencing a stale
instance, so move is deleted too, for the same reason copy already was.
- **`smokeyeyes.cpp`**: `SharedState` owns a `pthread_barrier_t` that is
placed directly into shared memory via placement-new and destroyed in
its destructor; the barrier is tied to this object's address, so copying
or moving it is not meaningful. Deleted copy/move constructor and
assignment.

All changes are pure declarations (`= delete`) with no behavioral
change, since none of these types were ever copied or moved elsewhere in
the codebase.

## Verification

- Scoped clang-tidy build isolated to
`cppcoreguidelines-special-member-functions` shows **0 findings** (down
from 3 across 3 files).
- Full `bazel build //score/mw/com/test/common_test_resources/...
//score/mw/com/test/partial_restart/...
//score/mw/com/test/smokeyeyes/...` passes.
- `bazel test
//score/mw/com/test/partial_restart/provider_restart/integration_test:provider_restart_graceful`
passes.
- `bazel test //:format_test_C++_with_clang-format` passes.

## Scope

This PR intentionally contains **only**
`cppcoreguidelines-special-member-functions` fixes, per the project
convention of one clang-tidy check per PR (see #995, #999, #1000, #1001,
#1003, #1012, #1013, #1014).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants