Fix cellular motion signed clamp warning
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 1m58s
Foundation / checks (network) (push) Failing after 6m49s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (client) (push) Canceled after 9m8s
Foundation / checks (checks) (push) Canceled after 9m14s
Foundation / checks (postgres) (push) Canceled after 17s
Foundation / checks (deploy) (push) Successful in 6s
Foundation / checks (ecs) (push) Successful in 1m58s
Foundation / checks (network) (push) Failing after 6m49s
Foundation / checks (tsan) (push) Canceled after 0s
Foundation / postgres-tools (push) Canceled after 0s
Foundation / server-image (push) Canceled after 0s
Foundation / image (push) Canceled after 0s
Foundation / checks (client) (push) Canceled after 9m8s
Foundation / checks (checks) (push) Canceled after 9m14s
Foundation / checks (postgres) (push) Canceled after 17s
This commit is contained in:
@@ -6702,3 +6702,9 @@ but the final whole-tree format target found 25 recently edited cellular-stage
|
||||
files that were not formatted to the CI-pinned clang-format 19.1.5 style. They
|
||||
are now formatted with that exact version; the repository-wide check passes
|
||||
locally and CI is pending on the formatting-only follow-up.
|
||||
|
||||
CI run 243 found `-Werror,-Wsign-conversion` in the existing cellular-motion
|
||||
axis clamp, where mixed signed and unsigned conditional expressions selected
|
||||
their common unsigned type. The clamp now applies signed deltas in explicit
|
||||
branches and converts only their nonnegative magnitudes. Full run243 checks are
|
||||
still in progress; the client job failed at this diagnostic before tests ran.
|
||||
|
||||
@@ -91,20 +91,22 @@ propose_cellular_motion(CellularArea area, CellularPosition position, std::uint3
|
||||
cellular_intent_component_limit;
|
||||
const auto max_x = area.width_um - extent_um;
|
||||
const auto max_y = area.height_um - extent_um;
|
||||
const auto next_x =
|
||||
static_cast<std::uint64_t>(dx < 0 ? (static_cast<std::uint64_t>(-dx) > position.x_um
|
||||
? 0
|
||||
: static_cast<std::int64_t>(position.x_um) + dx)
|
||||
: (dx > static_cast<std::int64_t>(max_x - position.x_um)
|
||||
? max_x
|
||||
: static_cast<std::int64_t>(position.x_um) + dx));
|
||||
const auto next_y =
|
||||
static_cast<std::uint64_t>(dy < 0 ? (static_cast<std::uint64_t>(-dy) > position.y_um
|
||||
? 0
|
||||
: static_cast<std::int64_t>(position.y_um) + dy)
|
||||
: (dy > static_cast<std::int64_t>(max_y - position.y_um)
|
||||
? max_y
|
||||
: static_cast<std::int64_t>(position.y_um) + dy));
|
||||
const auto clamp_axis = [](std::uint64_t coordinate, std::int64_t delta,
|
||||
std::uint64_t maximum) noexcept {
|
||||
if (delta < 0) {
|
||||
const auto distance = static_cast<std::uint64_t>(-delta);
|
||||
if (distance > coordinate)
|
||||
return std::uint64_t{0};
|
||||
return coordinate - distance;
|
||||
}
|
||||
|
||||
const auto distance = static_cast<std::uint64_t>(delta);
|
||||
if (distance > maximum - coordinate)
|
||||
return maximum;
|
||||
return coordinate + distance;
|
||||
};
|
||||
const auto next_x = clamp_axis(position.x_um, dx, max_x);
|
||||
const auto next_y = clamp_axis(position.y_um, dy, max_y);
|
||||
const auto moved_x = next_x >= position.x_um ? next_x - position.x_um : position.x_um - next_x;
|
||||
const auto moved_y = next_y >= position.y_um ? next_y - position.y_um : position.y_um - next_y;
|
||||
const auto distance = integer_sqrt_ceil(moved_x * moved_x + moved_y * moved_y);
|
||||
|
||||
Reference in New Issue
Block a user