From 92d3fc8fb25b044faddda19f508e8663339285f9 Mon Sep 17 00:00:00 2001 From: thawk105 Date: Wed, 13 May 2026 15:47:47 +0000 Subject: [PATCH 1/4] Phase 2: enable -Werror=sign-compare (cmake side) --- cmake/ProtocolHelpers.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/ProtocolHelpers.cmake b/cmake/ProtocolHelpers.cmake index 85e27741..d5944f90 100644 --- a/cmake/ProtocolHelpers.cmake +++ b/cmake/ProtocolHelpers.cmake @@ -55,7 +55,8 @@ function(ccbench_add_protocol name) -Werror=unused-parameter -Werror=catch-value -Werror=unused-variable - -Werror=ignored-qualifiers) + -Werror=ignored-qualifiers + -Werror=sign-compare) set_property(TARGET ${target} PROPERTY CCBENCH_PROTOCOL "${name}") set_property(TARGET ${target} PROPERTY CCBENCH_WORKLOAD "${wl}") From 475c5e2e787b276d729dcfae0c0b10aca77d77e2 Mon Sep 17 00:00:00 2001 From: thawk105 Date: Wed, 13 May 2026 15:55:09 +0000 Subject: [PATCH 2/4] Phase 2: fix sign-compare in include/bomb.hh --- include/bomb.hh | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/include/bomb.hh b/include/bomb.hh index 3c82bcd6..cf54d423 100644 --- a/include/bomb.hh +++ b/include/bomb.hh @@ -300,7 +300,7 @@ public: rnd_.init(); if (!FLAGS_bomb_mixed_mode) { - int total_threads = FLAGS_bomb_l1_thread_num + uint64_t total_threads = FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num + FLAGS_bomb_s2_thread_num + FLAGS_bomb_s3_thread_num @@ -438,22 +438,27 @@ public: TxArgs args; TxType decideType(TxExecutor& tx, [[maybe_unused]] Xoroshiro128Plus& r) { + // tx.thid_ is a non-negative thread index whose underlying type varies + // between protocols (int / size_t / uint8_t / unsigned int). Cast it + // to uint32_t once so each comparison against FLAGS_bomb_*_thread_num + // (declared as uint32) is sign-clean. + const uint32_t thid = static_cast(tx.thid_); TxType txType; - if (tx.thid_ < FLAGS_bomb_l1_thread_num) { + if (thid < FLAGS_bomb_l1_thread_num) { txType = TxType::UpdateProductCostMaster; - } else if (tx.thid_ < FLAGS_bomb_l1_thread_num + } else if (thid < FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num) { txType = TxType::UpdateMaterialCostMaster; - } else if (tx.thid_ < FLAGS_bomb_l1_thread_num + } else if (thid < FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num + FLAGS_bomb_s2_thread_num) { txType = TxType::IssueJournalVoucher; - } else if (tx.thid_ < FLAGS_bomb_l1_thread_num + } else if (thid < FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num + FLAGS_bomb_s2_thread_num + FLAGS_bomb_s3_thread_num) { txType = TxType::AddNewProduct; - } else if (tx.thid_ < FLAGS_bomb_l1_thread_num + } else if (thid < FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num + FLAGS_bomb_s2_thread_num + FLAGS_bomb_s3_thread_num @@ -467,7 +472,7 @@ public: } std::pair getRequest(TxExecutor& tx) { - if (tx.thid_ < FLAGS_bomb_l1_thread_num) { + if (static_cast(tx.thid_) < FLAGS_bomb_l1_thread_num) { timepoint start = std::chrono::high_resolution_clock::now();; return make_pair(TxType::UpdateProductCostMaster, start); } else { @@ -487,7 +492,7 @@ public: timepoint generate(BombWorkload* workload, TxExecutor& tx) { timepoint start; - if (tx.thid_ < FLAGS_bomb_l1_thread_num) { + if (static_cast(tx.thid_) < FLAGS_bomb_l1_thread_num) { type = TxType::UpdateProductCostMaster; start = std::chrono::high_resolution_clock::now(); } else if (!FLAGS_bomb_mixed_mode) { @@ -1416,7 +1421,7 @@ RETRY: while (!loadAcquire(quit)) { for (int i = 0; i < numQueues; i++) { auto start = std::chrono::high_resolution_clock::now(); - for (int j = 0; j < FLAGS_bomb_req_batch_size; j++) { + for (uint32_t j = 0; j < FLAGS_bomb_req_batch_size; j++) { requestQueues[i].push(make_pair(decideType(r, thresholds), start)); } if (FLAGS_bomb_mixed_short_rate_tps) { From c172404315b6addbc5bea660d3b33f4556ac9b6b Mon Sep 17 00:00:00 2001 From: thawk105 Date: Wed, 13 May 2026 15:57:10 +0000 Subject: [PATCH 3/4] Phase 2: fix sign-compare in include/bomb_pessimistic.hh --- include/bomb_pessimistic.hh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/include/bomb_pessimistic.hh b/include/bomb_pessimistic.hh index 3fcdcd87..1a7bbb28 100644 --- a/include/bomb_pessimistic.hh +++ b/include/bomb_pessimistic.hh @@ -334,7 +334,7 @@ public: rnd_.init(); if (!FLAGS_bomb_mixed_mode) { - int total_threads = FLAGS_bomb_l1_thread_num + uint64_t total_threads = FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num + FLAGS_bomb_s2_thread_num + FLAGS_bomb_s3_thread_num @@ -472,22 +472,27 @@ public: TxArgs args; TxType decideType(TxExecutor& tx, [[maybe_unused]] Xoroshiro128Plus& r) { + // tx.thid_ is a non-negative thread index whose underlying type varies + // between protocols (int / size_t / uint8_t / unsigned int). Cast it + // to uint32_t once so each comparison against FLAGS_bomb_*_thread_num + // (declared as uint32) is sign-clean. + const uint32_t thid = static_cast(tx.thid_); TxType txType; - if (tx.thid_ < FLAGS_bomb_l1_thread_num) { + if (thid < FLAGS_bomb_l1_thread_num) { txType = TxType::UpdateProductCostMaster; - } else if (tx.thid_ < FLAGS_bomb_l1_thread_num + } else if (thid < FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num) { txType = TxType::UpdateMaterialCostMaster; - } else if (tx.thid_ < FLAGS_bomb_l1_thread_num + } else if (thid < FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num + FLAGS_bomb_s2_thread_num) { txType = TxType::IssueJournalVoucher; - } else if (tx.thid_ < FLAGS_bomb_l1_thread_num + } else if (thid < FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num + FLAGS_bomb_s2_thread_num + FLAGS_bomb_s3_thread_num) { txType = TxType::AddNewProduct; - } else if (tx.thid_ < FLAGS_bomb_l1_thread_num + } else if (thid < FLAGS_bomb_l1_thread_num + FLAGS_bomb_s1_thread_num + FLAGS_bomb_s2_thread_num + FLAGS_bomb_s3_thread_num @@ -501,7 +506,7 @@ public: } std::pair getRequest(TxExecutor& tx) { - if (tx.thid_ < FLAGS_bomb_l1_thread_num) { + if (static_cast(tx.thid_) < FLAGS_bomb_l1_thread_num) { timepoint start = std::chrono::high_resolution_clock::now();; return make_pair(TxType::UpdateProductCostMaster, start); } else { @@ -521,7 +526,7 @@ public: timepoint generate(BombWorkload* workload, TxExecutor& tx) { timepoint start; - if (tx.thid_ < FLAGS_bomb_l1_thread_num) { + if (static_cast(tx.thid_) < FLAGS_bomb_l1_thread_num) { type = TxType::UpdateProductCostMaster; start = std::chrono::high_resolution_clock::now(); } else if (!FLAGS_bomb_mixed_mode) { @@ -1460,7 +1465,7 @@ RETRY: set_tx_name(TxType::ChangeProductQuantity, "ChangeProductQuantity"); std::cout << "load factory" << std::endl; - for (int f_id = 1; f_id <= FLAGS_bomb_factory_size; f_id++) { + for (uint32_t f_id = 1; f_id <= FLAGS_bomb_factory_size; f_id++) { insert_factory(param, f_id); } @@ -1475,7 +1480,7 @@ RETRY: for (auto &th : thv) th.join(); std::cout << "load item master" << std::endl; - for (int i_id = 1; i_id <= ItemIdCounter; i_id++) { + for (uint32_t i_id = 1; i_id <= ItemIdCounter; i_id++) { insert_item_master(param, i_id); } @@ -1540,7 +1545,7 @@ RETRY: while (!loadAcquire(quit)) { for (int i = 0; i < numQueues; i++) { auto start = std::chrono::high_resolution_clock::now(); - for (int j = 0; j < FLAGS_bomb_req_batch_size; j++) { + for (uint32_t j = 0; j < FLAGS_bomb_req_batch_size; j++) { requestQueues[i].push(make_pair(decideType(r, thresholds), start)); } if (FLAGS_bomb_mixed_short_rate_tps) { From 68bdba208e8ce2ae4b503592e7c550466a931541 Mon Sep 17 00:00:00 2001 From: thawk105 Date: Wed, 13 May 2026 15:59:50 +0000 Subject: [PATCH 4/4] Phase 2: fix sign-compare in masstree_wrapper.hh and cc/oze/util.cc --- cc/oze/util.cc | 2 +- include/masstree_wrapper.hh | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cc/oze/util.cc b/cc/oze/util.cc index d9029b41..ef4fb2c8 100644 --- a/cc/oze/util.cc +++ b/cc/oze/util.cc @@ -40,7 +40,7 @@ void init(int32_t table_num) { for (unsigned int i = 0; i < TotalThreadNum; ++i) { ThManagementTable[i] = new ThreadManagementEntry(1, FLAGS_cc_mode); } - for (unsigned int i = 0; i < table_num * 2; ++i) { + for (unsigned int i = 0; i < static_cast(table_num) * 2; ++i) { ScanHistory[i].store(nullptr); } } diff --git a/include/masstree_wrapper.hh b/include/masstree_wrapper.hh index e97aa032..2ff5680d 100644 --- a/include/masstree_wrapper.hh +++ b/include/masstree_wrapper.hh @@ -276,7 +276,8 @@ class MasstreeWrapper::SearchRangeScanner { } bool visit_value(const Str key, T *val, threadinfo &) { - if (max_scan_num_ >= 0 && scan_buffer_->size() >= max_scan_num_) { + if (max_scan_num_ >= 0 && + scan_buffer_->size() >= static_cast(max_scan_num_)) { return false; }