Phase 4: -Wunused-variable を潰して -Werror=unused-variable を有効化#58
Merged
Conversation
90f9475 to
1821add
Compare
Promotes -Wunused-variable to error in ccbench_add_protocol() and clears the 167 GCC 13 hits (unique file:line:col, across 36 source files) it surfaces. Continues the per-flag rollout for #43. Two of the hits were real latent bugs and got proper fixes; the rest are dead-receive locals (remove) or genuinely-discarded return values (make explicit with `(void)`). 1. include/bomb.hh `get_material_cost()` and the identical copy in include/bomb_pessimistic.hh both held the return of `tx.read()` in an unused `stat`, then only checked `tx.status_ == aborted` before dereferencing `body`. Per CLAUDE.md "tx.read returns Status - check it", `*body` is left untouched on WARN_NOT_FOUND, so a missing MaterialCostMaster row would have caused a stale-pointer `cast_to<MaterialCostMaster>` deref. Added the missing `if (stat != Status::OK) return false;` line in both copies. 2. cc/oze/{bomb,ycsb}_oze.cc computed `actual_extime` but never printed it, while every other workload binary (silo, mocc, mvto, si, ss2pl, ermia, cicada, tictoc) prints the line `"actual_extime:\t<value>"` after `ShowOptParameters()`. Added the missing print to keep the oze output schema consistent with the rest. - Dead local variables (`Result &myres = std::ref(...)`, `uint64_t epoch_timer_start/stop`, `Status stat;` at the top of long functions, `Version *expected`, `SetElement<Tuple>* re/we`, `bool isInvisible`, `int num_pages / num_skip_propagate`, `uint32_t p_id` shadowing in load loops, `SimpleKey<8> key` re-declarations inside loops, `auto n = tx.read_set_.size()` snapshots): removed. - Workload-loop temporaries that materialize a value as a deliberate side effect (the YCSB read+touch / write+materialize pattern in include/ycsb.hh, and the OrderLine touch in include/tpcc/tpcc_tx_orderstatus.hh): annotated `[[maybe_unused]]`. - Loop induction vars whose only role is N-iterations bookkeeping (`for (const auto& k : keys)` in cc/oze/transaction.cc where the body operates on the whole container, not on `k`): annotated `[[maybe_unused]]`. The redundant inner-loop body is preserved as-is to keep this PR scoped to the warning. - Discarded return values from functions whose side effect is what the caller wants (`tx.scan`, `tx.delete_record`, `Masstrees[...].remove_value`, `read_internal`, `select_im_by_factory`, `select_pc_by_factory`): made explicit with `(void)` and a brief comment, mirroring the pattern Phase 1 (#47) used for `select_im_by_factory` in BoMB. The `remove_value` `(void)` cast is duplicated across the silo/mocc/tictoc/ss2pl/d2pl writePhase DELETE branches because they all share the same code shape; consolidating them is out of scope here. ```diff target_compile_options(${target} PRIVATE -Werror=maybe-uninitialized -Werror=unused-but-set-variable - -Werror=unused-label) + -Werror=unused-label + -Werror=unused-variable) ```
1821add to
e1ab119
Compare
This was referenced May 13, 2026
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.
#43 Phase 4 のサブタスク。
-Wunused-variable167 件 (file:line:col ユニーク、36 ソースファイル) を潰し、ccbench_add_protocol()に-Werror=unused-variableを追加する。真のバグ 2 件
1.
tx.read()の戻り値 check 漏れ → stalebodyderefinclude/bomb.hhとinclude/bomb_pessimistic.hhのget_material_cost()で、tx.read()のStatusをstatで受けていたが unused のままで、tx.status_ == abortedだけ確認してbody->get_value().cast_to<MaterialCostMaster>()を呼んでいた。CLAUDE.md の "tx.readreturns Status — check it" 節そのままのパターンで、MaterialCostMaster行が無いと前回 read の stalebodyを deref する。両方にif (stat != Status::OK) return false;を追加。2.
cc/oze/{bomb,ycsb}_oze.ccのactual_extimeprint が漏れていた他の protocol の workload binary (silo / mocc / mvto / si / ss2pl / ermia / cicada / tictoc) は全て
ShowOptParameters()の後にstd::cout << \"actual_extime:\\t\" << actual_extime << std::endl;を出力しているが、oze の bomb / ycsb 版だけこの行が無く、actual_extimeが計算するだけで捨てられていた (tpcc_oze.ccは正しく出力している)。print を追加して他の binary と出力スキーマを揃えた。カテゴリ別の修正方針
tx.readの Status 無視 + stalebodyderef)if (stat != Status::OK) return false;を追加actual_extimeの print)Result &myres = std::ref(...)が<workload>_<proto>.ccの worker で完全 deaduint64_t epoch_timer_start, epoch_timer_stop;が oze の workload entry で deadStatus stat;がrun()先頭で declare されて未使用 (bomb.hh, bomb_pessimistic.hh)Version *expected, *desired;のexpectedが ermia / si のdelete_recordで deadexpectedを分離SetElement<Tuple>* re;等の dead 宣言 (ermia / si / oze)bool isInvisible;(oze)int num_pages = 0; int num_skip_propagate = 0;(oze)uint32_t p_id,SimpleKey<8> key)auto n = tx.read_set_.size();等の dead snapshot&t = ...(YCSB の read/write workload、OrderLine の touch)[[maybe_unused]]for (auto& k : keys))[[maybe_unused]]tx.scan,tx.delete_record,Masstrees[...].remove_value,read_internal,select_im_by_factory,select_pc_by_factory)(void)+ 短いコメント (Phase 1 #47 のselect_im_by_factoryのパターンを踏襲)remove_valueの(void)化は silo / mocc / tictoc / ss2pl / d2pl の writePhase DELETE branch で同じ shape のコードを 5 個別個に直しているが、共通化はこの PR のスコープ外とする。CMake
target_compile_options(${target} PRIVATE -Werror=maybe-uninitialized -Werror=unused-but-set-variable - -Werror=unused-label) + -Werror=unused-label + -Werror=unused-variable)Test plan
-DENABLE_SANITIZER=OFF: 34/34 binaries built, 0 warningsRelated