From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f74.google.com (mail-wm1-f74.google.com [209.85.128.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 926C017CA1B for ; Thu, 8 May 2025 09:50:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746697814; cv=none; b=k5htLvEy25PhZvuE8n5TUukAKyjFMYTpPZ2dFjDvp7w/N9yltg/rWvXPk3ku1YHENdT7wn8EetVxTE8k6iR54W55qkky0x8q6VtkACQ/O/AZlxlV8juiyAYMqnxN2Z+vSWOnoY+IgTssS8ggiQQzuX5fd6Lwhotep/dEYwhk8tI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1746697814; c=relaxed/simple; bh=00ywMczicjvLslhDXgo4TMUmGZHD8Tveta18brDBikI=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=D/ltU+2My7CmXfAGqElBiwnrOCaaPB3ZuXKx/yhpa20zHXbOxVCo16p5hlg2EYkPUHt1GZlhcS/HLZ2f2aGl6YtJKigg+hmP1I3O8xSvgr0QpjvT3aQFvaRjN4hNa7BNrVEK/lpuXmNOl2gkBKtpqy8HRqcCU9TkV5VX3Es57Tw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=wIIKMFKQ; arc=none smtp.client-ip=209.85.128.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--aliceryhl.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="wIIKMFKQ" Received: by mail-wm1-f74.google.com with SMTP id 5b1f17b1804b1-43ceeaf1524so3351885e9.1 for ; Thu, 08 May 2025 02:50:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1746697811; x=1747302611; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=u/6uHZ3GvAkpHOsls9UjvsdvAaxsnvKcIvywoDvH3W0=; b=wIIKMFKQ+J4W5qMMJATbWRhqKd9DbBOCuFzOGtJZbhoGWG6noDQf/8NOk+J7Lw+VB9 xwrKgnwHtzm2hF9XB09yNh77U1+Mk7MCklCDSpGzBu81hgatG57qVLpqQug78//iQkzY U1wxKY+ZGrTupKlWV9b5IpB7UI0FsGQsrbJ4Gtagax2n53K/khp8TT1yxyQGf+evJ5FF 8aDpLJrBejqDcxNoApRIE471DryrqTkU9E9EKUgIWtwxVotEUBka2KurJS6b30jLLZcc i6sbEzy3YD9MlsgCxTJ5zsR/pyai1Ll5/V1iS/Nhx4xYXOhihWUkKvirIrvk9dTNhXBg d/2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1746697811; x=1747302611; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=u/6uHZ3GvAkpHOsls9UjvsdvAaxsnvKcIvywoDvH3W0=; b=b5aQOuW48Mnf0YiQyIdrYDtJwxM06WO84BNgyelQPEMqtL6eabp8ldPAVXebkMqu+R xJjOQA0MSi7RYYl/k8F/HDa3C3Q7HBXQDpxk3uAiTruU353ytiyXMKA29iQUw6+HCmjy ViDIPslwmamYqEjDwfo5FwwRdR49YyzencL93P0PysFM9Zo65vkl0o625MJg7LhGsIVY 0vDTozQbpWaCBeNjpyGt81oLHCndaLMQe4mSa9YkIvL20S/hY+tppYAoDu3Q1FkN50tZ Tx56zvKFbCwHmcQmMQ9ts9th3GeFcKvsSLRy9nHm9mwIHfHjYVoWggghvqcIwdg0c3Yb IiTQ== X-Forwarded-Encrypted: i=1; AJvYcCX+lrrjxE8pJ6F2APvpWnxvfT/0n28Zsy31PdSmOdIXDz3nIFw/G7Krv4TOyeHuWJCUwykwBJpPfFAw7bPpsQ==@vger.kernel.org X-Gm-Message-State: AOJu0YxMn0blbBkw2rRj2O08Av9dApUnmM74n9wonH8DdAr/jwgW1k40 oC+iv8mI1dLhjNarHgIJT6NwBCpznPjTpoB90Z9wS3ooNJLVQIjwKZDojaidtQrpvNqDyXTHkTx lZHHbyCCEEQ8ohQ== X-Google-Smtp-Source: AGHT+IEPrOFfcaia13QLDulHVL4VMLLoqkhxKC0rPGGEnWlVvGIpNhU24GDrXr7kYP/zkfLYYSYSLZVsywKF6Yk= X-Received: from wmbep21.prod.google.com ([2002:a05:600c:8415:b0:43d:40ea:764d]) (user=aliceryhl job=prod-delivery.src-stubby-dispatcher) by 2002:a05:600c:1e02:b0:43d:186d:a4bf with SMTP id 5b1f17b1804b1-442d0208645mr23551155e9.0.1746697811013; Thu, 08 May 2025 02:50:11 -0700 (PDT) Date: Thu, 8 May 2025 09:50:09 +0000 In-Reply-To: Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250502-vec-methods-v5-0-06d20ad9366f@google.com> <20250502-vec-methods-v5-6-06d20ad9366f@google.com> Message-ID: Subject: Re: [PATCH v5 6/7] rust: alloc: add Vec::remove From: Alice Ryhl To: Benno Lossin Cc: Danilo Krummrich , Matthew Maurer , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" On Wed, May 07, 2025 at 01:44:30PM +0200, Benno Lossin wrote: > On Fri May 2, 2025 at 3:19 PM CEST, Alice Ryhl wrote: > > This is needed by Rust Binder in the range allocator, and by upcoming > > GPU drivers during firmware initialization. > > > > Panics in the kernel are best avoided when possible, so an error is > > returned if the index is out of bounds. An error type is used rather > > than just returning Option to let callers handle errors with ?. > > > > Signed-off-by: Alice Ryhl > > One follow-up comment below. With the `# Panics` section removed: > > Reviewed-by: Benno Lossin Thanks! > > diff --git a/rust/kernel/alloc/kvec/errors.rs b/rust/kernel/alloc/kvec/errors.rs > > index 84c96ec5007ddc676283cbce07f4d670c3873c1e..06fe696e8bc6612a5e6aa2f6c28b685033acfa2f 100644 > > --- a/rust/kernel/alloc/kvec/errors.rs > > +++ b/rust/kernel/alloc/kvec/errors.rs > > @@ -21,3 +21,18 @@ fn from(_: PushError) -> Error { > > EINVAL > > } > > } > > + > > +/// Error type for [`Vec::remove`]. > > +pub struct RemoveError; > > Would it make sense as a follow-up to store the index that was accessed? Usually I think we would only store the information that the caller doesn't already know? Alice