Skip to content

Commit

Permalink
pw_multisink: Scope disabling unsigned-integer-overflow
Browse files Browse the repository at this point in the history
Scope disabling unsigned-integer-overflow to only the functions
which depend on negated-unsigned-const behavior.

Bug: 380089512
Change-Id: I9cd0531eb5c9d8bcb673deafbbf308591fcdcd7c
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/254414
Commit-Queue: Auto-Submit <auto-submit@pigweed-service-accounts.iam.gserviceaccount.com>
Lint: Lint 🤖 <android-build-ayeaye@system.gserviceaccount.com>
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Docs-Not-Needed: Dave Roth <davidroth@google.com>
Reviewed-by: Carlos Chinchilla <cachinchilla@google.com>
Pigweed-Auto-Submit: Dave Roth <davidroth@google.com>
  • Loading branch information
davexroth authored and CQ Bot Account committed Dec 13, 2024
1 parent b3e2d8c commit 303810b
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pw_multisink/multisink.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ Result<ConstByteSpan> MultiSink::PeekOrPopEntry(
Request request,
uint32_t& drain_drop_count_out,
uint32_t& ingress_drop_count_out,
uint32_t& entry_sequence_id_out) {
uint32_t& entry_sequence_id_out)
PW_NO_SANITIZE("unsigned-integer-overflow") {
size_t bytes_read = 0;
entry_sequence_id_out = 0;
drain_drop_count_out = 0;
Expand All @@ -96,8 +97,6 @@ Result<ConstByteSpan> MultiSink::PeekOrPopEntry(
if (peek_status.IsOutOfRange()) {
// If the drain has caught up, report the last handled sequence ID so that
// it can still process any dropped entries.
// Negation overflow is by design.
/// -fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const
entry_sequence_id_out = sequence_id_ - 1;
} else if (!peek_status.ok()) {
// Discard the entry if the result isn't OK or OUT_OF_RANGE and exit, as the
Expand Down Expand Up @@ -148,15 +147,14 @@ Result<ConstByteSpan> MultiSink::PeekOrPopEntry(
return as_bytes(buffer.first(bytes_read));
}

void MultiSink::AttachDrain(Drain& drain) {
void MultiSink::AttachDrain(Drain& drain)
PW_NO_SANITIZE("unsigned-integer-overflow") {
std::lock_guard lock(lock_);
PW_DCHECK_PTR_EQ(drain.multisink_, nullptr);
drain.multisink_ = this;

PW_CHECK_OK(ring_buffer_.AttachReader(drain.reader_));
if (&drain == &oldest_entry_drain_) {
// Negation overflow is by design.
/// -fsanitize-undefined-ignore-overflow-pattern=negated-unsigned-const
drain.last_handled_sequence_id_ = sequence_id_ - 1;
} else {
drain.last_handled_sequence_id_ =
Expand Down

0 comments on commit 303810b

Please sign in to comment.