Repository navigation
fix(clang-tidy): resolve cppcoreguidelines-init-variables findings - #1014
Merged
LittleHuba merged 1 commit intoAug 26, 2026
Merged
Conversation
castler
requested review from
LittleHuba,
bemerybmw,
crimson11,
hoe-jo and
limdor
as code owners
August 26, 2026 08:22
LittleHuba
approved these changes
Aug 26, 2026
LittleHuba
enabled auto-merge
August 26, 2026 08:27
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>
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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes all
cppcoreguidelines-init-variablesclang-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_eventis an out-parameter for a rawread()syscall that always overwrites it before use; initialized toPipeEvent::QUIT(a valid enumerator) as a safe default.unix_domain_server.cpp:std::uint8_t codeis an out-parameter forReceiveProtocolMessage(); zero-initialized.flock_test.cpp:FILE* streamwas declared then immediately assigned fromfdopen()on the next line; merged declaration and initialization (×2 occurrences).int c(loop-localfgetc()result) is zero-initialized.smokeyeyes.cpp: theboost::program_options-bound variables (num_clients,turns,batch_size,no_wait,num_slots) are populated bypo::store/po::notifyfrom theirdefault_value()s; initialized to matching defaults so the variable is never observably uninitialized between declaration and parsing.int wstatus, an out-parameter forwaitpid(), is zero-initialized.Verification
cppcoreguidelines-init-variablesshows 0 findings (down from 11 across 4 files).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_linuxpasses (2/2).bazel test //:format_test_C++_with_clang-formatpasses — no formatting issues introduced.Scope
This PR intentionally contains only
cppcoreguidelines-init-variablesfixes, per the project convention of one clang-tidy check per PR (see #995, #999, #1000, #1001, #1003, #1012, #1013).