From nobody Wed Jun 17 06:05:37 2026 Received: from mail-pj1-f54.google.com (mail-pj1-f54.google.com [209.85.216.54]) (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 7175A192D8A for ; Mon, 27 Apr 2026 14:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777299393; cv=none; b=aiql3ZyYMwexGVRj/VrXEVH9Vl9HlJCc/my7+HTar0HxGwnjtQepPLTUOGvxIvVhd6qGvKiyDgtqf3KfT6moflgr6jbydcj6vRCpHwX3Xdq5HmoV4w/h9/LPcF0KbRHa3FDz9RGGqPneG3IrlJ/CiLBfj/OMWzhjM+5qiyna7wU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777299393; c=relaxed/simple; bh=D1TIb1AYdqawMmuhhOtEb3rEPPoyNZYPUhKNMa7xQ5w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To:Cc; b=se7Z9ukaQ7zxlgGl839RNl1uvfmCfEbpwtdv8oFwHKS+koNIt6c9Zz0RDlMZqLZdtgy5h6hv4I2gJv6qYCRLraMRsLY4TMSEFCa+6OH/Z3cunZXxqpfK2wvAzhMWzs9XuKG9chDUAKDAlc6+VGKH0sA1jyqw5AOJJ11EI8albTM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=l2tFK+Oq; arc=none smtp.client-ip=209.85.216.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="l2tFK+Oq" Received: by mail-pj1-f54.google.com with SMTP id 98e67ed59e1d1-35f9ab079bdso6841706a91.2 for ; Mon, 27 Apr 2026 07:16:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1777299392; x=1777904192; darn=vger.kernel.org; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:from:to:cc:subject:date:message-id:reply-to; bh=SloVXux6ndYMbOukk6el+VVoouriWlEz40pFhKl+fIU=; b=l2tFK+Oq0TGWb9a7w5Zcy44IM8HiBhx89Uzafdda7af++uS4obJJll2hXqzJAIB9oa OhXPRoUaturLua9tcst5sV6cCgBdaTbAZPwrOVkTDIRPGKtN3uJ2z1uotWlchDWvSb5L Wmp4vHHETcKqJG9XUZx8r+d/Q805EiPvWVhnFkj0PYAvYpH+sfW92+LrpbcmgC8iXxJd 9L1TPK9lKb1rH3ZzvzAd7bVFGHVJWpFH0iGwGafYm8DtQjVueMcVkmzKliIGiuOgVHg0 XMBzh9yRDgDrc9pVwnsFu+fotbN7LwUe+SXI5OA9LOQzp7/Rb4Fs862CEO06hU9oRwc6 s5og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777299392; x=1777904192; h=cc:to:message-id:content-transfer-encoding:mime-version:subject :date:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SloVXux6ndYMbOukk6el+VVoouriWlEz40pFhKl+fIU=; b=EcLR6XqLclxgsQREBacBmsnJUH1JMrrQZDQ3ibktjBPzqx07l1X/0czFf1YZhf76o2 w+abfKniIRH9xxQ/CAX01RvGUBp/B87ibhrXF9v1+88bwxAnNGH6mv/DK7BOp7p0pUpd N6irPucJ8Sey3/fVlFoGAFkfl8Ni+DiNOlPt88HFcEOD8osTyEe60++pDS1T0mBhv5n2 zr89XPCzLMr/yUqd4Knhp0wDcGomJMluX7GaUr5e6THlsJqyITHy5fEYh7x8tg3sGB81 9d8vJwgtoWgxsbRENg68AfeJVGlxf/Ombv7zrIuxSb0//MKpBlMZrAdikzPlFFffozM9 2irw== X-Forwarded-Encrypted: i=1; AFNElJ/sq4PgMUoFTaoz/1c9Y4XZDOs8+snzMDsPBaUhGG9ksEAqCroAmdWXpUzGrDqT7lf240WQVzyfo/0UEhk=@vger.kernel.org X-Gm-Message-State: AOJu0YwKQdMDxdRpia7EVCUq7IRCTqLMrXq/t7hELxlE+7BBbzPLTzaf VZQaco1fx3yPezSo7mOqhNkyU+Y/z/bc2ZpyHdW7PrmJY7UCfAWbmfjK X-Gm-Gg: AeBDiet1AlXO/tUIHkWxq7SjICqxiJQ57djdbdyrnk8C0b2S00JeK2GxlkSQAFwbL1M YR7fOTG36u+Fy3i/ZChDrEwgcd5YLe0AO82sjAg1kKMtMtB58sVbP+nCndsM+E2i0YfpBVIZ/Na CA/jCCXdPlZOMn+RW3mYL9Kq0JYiF1Av+D4L8T0ynd3WIkbuliUrorY+ueeLuWf++xs4xL9gD+h t8XiAJadQpoXa81fBBCCdpSHblX2pgiCv/WTLPDp9u0DyTaAOM1uHiG4Zj5pcj6Sqw7O4GDZkpz aCRC8Alfwl3tIiWm8JAl64F6BZAkw2vEhX5fdJqNKXlgt9DmGl46fHHYdrCgzwabR9K/aR+LLQa F3f2m1QNCq6pPNBXwOwBpz++JZXl4oOIC+nY03vx1IiEX0l9YI3WqVT8Tpv5umjDNIQmELTDCcz bEvp6WDVF+G6f8EXfpysh9TvJul6tOaGvXgVgbyuXIHw2GV+g= X-Received: by 2002:a17:90b:53c3:b0:35d:a38a:a117 with SMTP id 98e67ed59e1d1-361404745f7mr44763276a91.15.1777299391680; Mon, 27 Apr 2026 07:16:31 -0700 (PDT) Received: from yuwhisper-pc. ([49.213.140.88]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3613fb95b1csm15253337a91.5.2026.04.27.07.16.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Apr 2026 07:16:31 -0700 (PDT) From: Hsiu Che Yu Date: Mon, 27 Apr 2026 22:15:49 +0800 Subject: [PATCH] rust: alloc: fix assert in `Vec::reserve` doc test Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260427-doctest-kvec-reserve-v1-1-0623abcd9c2e@gmail.com> X-B4-Tracking: v=1; b=H4sIAJRv72kC/yXMywqDMBBG4VeRWXcgxkvFVyldaPzbTgsqmTQI4 rsbdfktzllJ4QVKbbaSRxSVaUzIbxm5Tze+wTIkkzW2NqW98zC5AA38i3DskfIIrrumRFPY3lS glM4eL1nO7eN5Wf/9Fy4cL9q2Hd9U6vx4AAAA X-Change-ID: 20260427-doctest-kvec-reserve-6a84e832b05e To: Danilo Krummrich , Lorenzo Stoakes , Vlastimil Babka , "Liam R. Howlett" , Uladzislau Rezki , Miguel Ojeda , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Alice Ryhl , Trevor Gross Cc: Alexandre Courbot , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Hsiu Che Yu , Miguel Ojeda X-Mailer: b4 0.15.2 The assert in the doctest used `>=3D 10`, which only checks that the capacity can hold `additional` elements, ignoring the existing length of `v`. The correct check should ensure there is room for `additional` *extra* elements on top of what is already in the vector. Fix the assert to use `>=3D v.len() + 10` so the example accurately reflects the actual semantics of the function. Reported-by: Miguel Ojeda Closes: https://lore.kernel.org/rust-for-linux/CANiq72nkXWhjK9iFRrhGtkMZGsv= NE_zVsu4JnxaFRfxWL7RRdg@mail.gmail.com/ Fixes: 2aac4cd7dae3d ("rust: alloc: implement kernel `Vec` type") Signed-off-by: Hsiu Che Yu Reviewed-by: Alexandre Courbot Reviewed-by: Alice Ryhl --- rust/kernel/alloc/kvec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/kernel/alloc/kvec.rs b/rust/kernel/alloc/kvec.rs index ac8d6f763ae8..d05f3835cf53 100644 --- a/rust/kernel/alloc/kvec.rs +++ b/rust/kernel/alloc/kvec.rs @@ -611,7 +611,7 @@ pub fn clear(&mut self) { /// /// v.reserve(10, GFP_KERNEL)?; /// let cap =3D v.capacity(); - /// assert!(cap >=3D 10); + /// assert!(cap >=3D v.len() + 10); /// /// v.reserve(10, GFP_KERNEL)?; /// let new_cap =3D v.capacity(); --- base-commit: b4e07588e743c989499ca24d49e752c074924a9a change-id: 20260427-doctest-kvec-reserve-6a84e832b05e Best regards, -- =20 Hsiu Che Yu