From 00de81166de77eb2939788a76a2ab7ffc9084216 Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Jul 2026 19:33:49 -0700 Subject: [PATCH] Fix clang-tidy dead store warnings in util.cpp and model_based_opt.cpp (#10334) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Three `clang-analyzer-deadcode.DeadStores` warnings flagged by clang-tidy: redundant bit-shifts in the log2 functions and an unreachable assignment in `def::from_row()`. ## Changes - **`src/util/util.cpp`** — `log2()` and `uint64_log2()`: Remove `v >>= 1` in the final `if (v & 0x2)` block. Only `r |= 1` matters; `v` is never read after that point. ```cpp // Before if (v & 0x2) { v >>= 1; // dead store r |= 1; } // After if (v & 0x2) { r |= 1; } ``` - **`src/math/simplex/model_based_opt.cpp`** — `def::from_row()`: Remove `sign = true` assignment when `div < 0`. `sign` is only consumed earlier in the function (`if (!sign)`) and is not read again after this point. - Fixes #10333 --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> --- src/math/simplex/model_based_opt.cpp | 1 - src/util/util.cpp | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/math/simplex/model_based_opt.cpp b/src/math/simplex/model_based_opt.cpp index ded6aa6450..d22d0fb8bd 100644 --- a/src/math/simplex/model_based_opt.cpp +++ b/src/math/simplex/model_based_opt.cpp @@ -73,7 +73,6 @@ namespace opt { } if (div < 0) { - sign = true; div.neg(); lc.neg(); coeff.neg(); diff --git a/src/util/util.cpp b/src/util/util.cpp index b158cf9508..fbc13c6e0d 100644 --- a/src/util/util.cpp +++ b/src/util/util.cpp @@ -86,7 +86,6 @@ unsigned log2(unsigned v) { r |= 2; } if (v & 0x2) { - v >>= 1; r |= 1; } return r; @@ -115,7 +114,6 @@ unsigned uint64_log2(uint64_t v) { r |= 2; } if (v & 0x2) { - v >>= 1; r |= 1; } return r;