rust_binder: never return 0 from next_debug_id

Retry if fetch_add returns 0 in next_debug_id() so that valid debug IDs
start at 1 and 0 is never assigned, even if NEXT_DEBUG_ID wraps around.
This allows 0 to be used as a sentinel for an absent or uninitialized
debug_id (such as in TransactionInfo::to_node_debug_id and in
transaction log entries).

Assisted-by: LLM
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20260930-binder-transaction-log-v2-1-8a15e9b8cae3@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Alice Ryhl 2026-09-30 13:56:36 +00:00 committed by Greg Kroah-Hartman
parent d835f4b1ad
commit 32d0ed324f

View File

@ -98,7 +98,12 @@ fn default() -> Self {
fn next_debug_id() -> usize {
static NEXT_DEBUG_ID: Atomic<usize> = Atomic::new(0);
NEXT_DEBUG_ID.fetch_add(1, Relaxed)
loop {
let id = NEXT_DEBUG_ID.fetch_add(1, Relaxed);
if id != 0 {
return id;
}
}
}
/// Provides a single place to write Binder return values via the