From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (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 BE6091A4B89 for ; Wed, 21 Aug 2024 13:47:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724248068; cv=none; b=I9uq8fGs2Rrn+TRYQnntRfvTdI89kMjPO8KG2jX5DKjZ2yAyLD43G3l4zdPBJSpxw4FascIt7KwMm4HojK+fQnStBFEsFrXD6tcM2jmNbDYCFQ/l2FcEBgk1k/jeJWfUxbpo9PrnounBgq9dw73tPpuN3DnCrZ2TN3PNNB/Nkbo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724248068; c=relaxed/simple; bh=gwLjHNTsXHMmlKgeIfCrG8pO4t2Y8x/pcVf6IX7HJS0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=oqdylxslY18JprkIL2OBuh/f+JkFykF6mDlZ+37V893NCE4LrSjf1CkGTprPfpoaU+WxkW9f0YVld4o1mG0irDq785OUKBsZ5qTxwkXKefZRhUOZQ3qy9eNKY/QcUVgDc/TfEZ85lphwpyEOVA+Ij7eymf/ec3FFXAWwpnbYUfw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=dolPsNWv; arc=none smtp.client-ip=209.85.128.41 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=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="dolPsNWv" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-429ec9f2155so48418285e9.2 for ; Wed, 21 Aug 2024 06:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1724248064; x=1724852864; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+ZR2V02XpqNEW9fvu30UGOqjOdE3SQr9bcH8M/YKkZE=; b=dolPsNWvrSeN1bjtX6ZyZ4JT8coc+48QIJvDg6MwxbHw4pe3mbqEbesmqh2lL+eRSt ReiP3BYXHER5gTs/Jgp7JRX0IWMn6sHNnDz11HD7NaNDq9cJKYxk1YaAP+epj1nRgN9h Sj7nO0Ht/2ie9fOWrMi51EH3Vy6GHn3Gk0K0fchKPqn9daRfq3eI4R9HalWAJ9asFj6h GMAfKvdYGyPmjpsjCxvrZm+xtqrdrSYM4MTJ6uJQuR94rao+lhvsaPPrk/apjYCHkvpX YFgneHgTgJYG89FU7AH00ltJjxOda2SnkXlEoYvjNcTsNKeQlI8Q1W/gIeDUqATCQfRg 3ckw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724248064; x=1724852864; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+ZR2V02XpqNEW9fvu30UGOqjOdE3SQr9bcH8M/YKkZE=; b=IKadCrgWzZHSmR5QNZMvPkAIUQOyI4LFSCOk6++mhuhlsDbeKxq22Kfr9PFD4FfsVV tXppVpq6wbGaqvzb5FGmowBw5r5UxR2JbswmfVjDRJ0VDkggn6/R6HJwjjROS79OWtwN X4E9IGnY5au6O4gVK/rZuyyCF7uusdY1fiJj0GCrOyIV+Id2F7LsGHt6AdH6MiNq33uc y0G93OVIAQ7Wa11PZvi84GXTyAwBW9qEkDYqk+bZuI02sTk7C/0qgRR0PfVYnBSphg31 803DmNqYYzdCvZWIHmGwV2Taa1VSD5vR5vEXb3Ypnl+uFyjwhUNAxCTAGpJ5/EwkBKA9 vwOw== X-Forwarded-Encrypted: i=1; AJvYcCV8f2KCVc/OBxI+nOOqquSGYrBD39rHeEIsskDFcQUuYzqmSnHOv3U9R4U0tXmP61DFq1SLrJJrvS2WwYlffg==@vger.kernel.org X-Gm-Message-State: AOJu0YxKuy/WvzysfrWaFa8oJMbzCOMxx/ffExON5vss4Vs5PvypUFVN IzT+TA3Ed//djF259mN+0x0dMTWDgXiU7s9ad5n6TkK6YgABtWNHhoNbIEQCCeMojbtkugfufbh LAhZFn1XG4muTuvxh+tW1zr6mcFlkv/WVJC/3 X-Google-Smtp-Source: AGHT+IE+WRPQ5cxJkts/8lQ1Pyrz4IDfgbmZOe9kRkxkJ6+Ctq49hnrFtuGR4cuPoH3txY4c4UXweZZ+1LQnmVHuF+A= X-Received: by 2002:a05:600c:4e91:b0:426:6f5f:9da6 with SMTP id 5b1f17b1804b1-42abf096794mr15321995e9.27.1724248063553; Wed, 21 Aug 2024 06:47:43 -0700 (PDT) Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240819153656.28807-2-vadorovsky@protonmail.com> In-Reply-To: From: Alice Ryhl Date: Wed, 21 Aug 2024 15:47:31 +0200 Message-ID: Subject: Re: [PATCH RESEND v5] rust: str: Use `core::CStr`, remove the custom `CStr` implementation To: Michal Rostecki Cc: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?UTF-8?Q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin , Andreas Hindborg , Brendan Higgins , David Gow , Rae Moar , FUJITA Tomonori , Trevor Gross , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Martin Rodriguez Reboredo , Finn Behrens , Manmohan Shukla , Valentin Obst , Yutaro Ohno , Asahi Lina , Danilo Krummrich , Tiago Lam , Charalampos Mitrodimas , Tejun Heo , Roland Xu , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com, netdev@vger.kernel.org, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Aug 21, 2024 at 2:08=E2=80=AFPM Alice Ryhl w= rote: > > On Mon, Aug 19, 2024 at 5:39=E2=80=AFPM Michal Rostecki wrote: > > > > From: Michal Rostecki > > > > `CStr` became a part of `core` library in Rust 1.75. This change replac= es > > the custom `CStr` implementation with the one from `core`. > > > > `core::CStr` behaves generally the same as the removed implementation, > > with the following differences: > > > > - It does not implement `Display`. > > - It does not provide `from_bytes_with_nul_unchecked_mut` method. > > - It has `as_ptr()` method instead of `as_char_ptr()`, which also retur= ns > > `*const c_char`. > > > > The first two differences are handled by providing the `CStrExt` trait, > > with `display()` and `from_bytes_with_nul_unchecked_mut()` methods. > > `display()` returns a `CStrDisplay` wrapper, with a custom `Display` > > implementation. > > > > `DerefMut` implementation for `CString` is removed here, as it's not > > being used anywhere. > > > > Signed-off-by: Michal Rostecki > > A few comments: > > * I would probably add CStrExt to the kernel prelude. > * I would probably remove `from_bytes_with_nul_unchecked_mut` and keep > `DerefMut for CString` instead of the other way around. > * Perhaps we should remove the `c_str!` macro and use c"" instead? Ah, also, please add this tag: Closes: https://github.com/Rust-for-Linux/linux/issues/1075 Alice