Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp650937rdb; Tue, 23 Jan 2024 10:19:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IF8i1DSMRCGgrgKytQkq2GWTk0xJKSfEWC3L7FTD6w72ZwCb3Mpz+fi8Fz95Kdd0g9yJSw2 X-Received: by 2002:a17:907:1681:b0:a30:4644:c1dc with SMTP id cx1-20020a170907168100b00a304644c1dcmr119606ejd.105.1706033961552; Tue, 23 Jan 2024 10:19:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706033961; cv=pass; d=google.com; s=arc-20160816; b=Hl0oL6fW3TEMxVpQSYtJ7/gLsLy3Pw/C5Q5waNkXzyRoLVWjcD2ozV4dMUWK9w0WxT sAsDt337gbsqEpUfMTncIBOf4gjoSPS1xy1isk0lDSFTczJbnvyo2hWya32sqROaytt9 2T43FBy/nmTKTO3BM9KiESTBF64Isj7Gjy/EZoNaEnMRsLQcOPE3jXwDFU1c7IBS/ARS zkfFnp6uEuad8VrCmgr3HNUxoSv/3mZHp3HPNFqPPyKfnjf+QpnsoGkRg/v44h8RZ2zs WvYyhUN3mJfUr6u/CaQ7wBk1DxyX+t++ICpPt5vnwfVHglmlOg1ulolggEx8GxAsPSnR rLbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=I7EaLHyv+zjRWE7JLMFlBZeY21iA0/68G15sTjitmic=; fh=zA5dNGKvDuS0GPjpWabWJLAjk7EHvoSXGZQznX4Ntuc=; b=nqZBgsnhEnooWFfuwOC0luN5YzS55jAH08Ir6bu0NgRYh4rTnE3SrubRe6nOSySKiP JvMDMsAK7+kGGpSlE5r/Yv33TfmoNaksosWh49rBns5zZoUfSlx1w5Ea2O0nIH6QeiSi rM0RSc3ChIXAS3uEaGFIX9ZdUDa6be4cVn9Q0XGPJMi6lSFpnSpzsupGQegW/MgixRkv PRk6DZgGDTKdAHkFJYFLLf2Y/yglQG/QY8vAKwUeIK8veKgjq2yM5ZwCt8I3MRJKjHmz mFc4Lgf7Mjeim1xqqzDOxZbhvDccXLIWLEf9Wl7p+jLG/qVrYH3xamCREigdTP18jiaA 1vIw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OpKuEnyi; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-35858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x26-20020a170906135a00b00a30afbba1acsi1078033ejb.567.2024.01.23.10.19.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jan 2024 10:19:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-35858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=OpKuEnyi; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-35858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-35858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 315331F2D7E1 for ; Tue, 23 Jan 2024 18:19:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1863B81ABA; Tue, 23 Jan 2024 18:19:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OpKuEnyi" Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) (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 E37195FDA8; Tue, 23 Jan 2024 18:19:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.175 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706033952; cv=none; b=Fu1/RJVBh329XGOpZYVBYuLenxcIBg+C3DpKhRab1waOwc4cqDzaGqVr1W+gvCbof3D5ls52KKGD0x6QqbSajxJdRFh2OZA2/DieQRNhUdzxPsmM0FqEy1FlJyPB4Z3a8Smc6y4z9Lp1f0duhSbZGqvLAAO6N5nhUaxNBi3KjtI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706033952; c=relaxed/simple; bh=I7EaLHyv+zjRWE7JLMFlBZeY21iA0/68G15sTjitmic=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=VlEZ8+E0CWPs/O/7QsO1NJ1IeASvmBW5LVxwlRWbgyZA0DySqtGpP6Mzn+mm/2uq3KuZylL7hHqZwtCcWfBlw2YjZvJ7dwlK9uU1yd3JYD6TC10dZcDZs12SPvkbY5fCSd1zGNCvDvF09w+MMQLN+19oMdjtks/l9aj+XMvx034= 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=OpKuEnyi; arc=none smtp.client-ip=209.85.128.175 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 Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-5ff828b93f0so40325947b3.3; Tue, 23 Jan 2024 10:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706033949; x=1706638749; 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=I7EaLHyv+zjRWE7JLMFlBZeY21iA0/68G15sTjitmic=; b=OpKuEnyir1x2y+q7QGDmN4HZJwzbE7+t38KTBW5nYmK6SaSZ6nzo1O2xTx94Lznt8h M38E8Kksd7gbXMhrCXKnvE+80snY5ENgq8G0Vm6M8z7tW7g5MLDUV25i3F2TgeqRFYlU T2S+QThcyY5miRic2uoRbDVFKymm4MpLJR6l/G313zZPb9F69LZCNujYBfa6/28+ARGP BgoPvl10NT5D/I2GKhElcdt1yhSEYp3991HVW/2yH+quvMzrmu5WhsEy4QyPd8pe5hyz bfcN4LI3ioEGs3aB8lsoLhH7+HODzKQDqcIiPwswamIAkK8uhGTIuzK/B0GtrlW+ieLL qHTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706033949; x=1706638749; 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=I7EaLHyv+zjRWE7JLMFlBZeY21iA0/68G15sTjitmic=; b=jfqiRQ3LqQ5M1p/TV2h9iw9dAXRINEvbDhCB5/8Etbjnpl+vXsF9PiGJAwNwyYPraB Ds7VIX474/S9tuRz++nsm4t04eMQ8FSBDQQvhSEWw2D0uN/fVCN4ATxGztx1MVSMcfPx Xo+X6G/865WVri67aVr4Z39ubWwlyzeZEvZYgSfdhzXWHJtat43J2uZWWLNgpip4aNPv hQfmYiyLiz0Axs6tiIEBtzAlIgpuLU1TtK6XUXRyRZXW65fIS8typVsJrqyDkXC99l5I K53k0Y7hRB5VW9uUziTlgGveR/bpnWXMvwD+cGqrxsdNPnAj7kT0+jl36toecZy/zAAK fw6A== X-Gm-Message-State: AOJu0YzBNmEyS3Z6OCH/3B+qxj+k1jmodbN2/TfAeGhXmKH/fKCZDuw0 3zeLwfCoZtkS0/WK/pdN3hxt5r9MkHHCFA5DJxrleh2or6cXJG7j42yOUPdt3+ejmzx3mQJnDDn 6MTiYYiLLyb8dWGm3Jwv5ptbdzFs= X-Received: by 2002:a81:69d4:0:b0:5ff:9555:79df with SMTP id e203-20020a8169d4000000b005ff955579dfmr4955779ywc.92.1706033948768; Tue, 23 Jan 2024 10:19:08 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240122184608.11863-1-dakr@redhat.com> <2024012252-attempt-tables-e3fc@gregkh> <2024012251-geriatric-morphine-a275@gregkh> In-Reply-To: From: Miguel Ojeda Date: Tue, 23 Jan 2024 19:18:57 +0100 Message-ID: Subject: Re: [PATCH] rust: str: add to_ascii_{upper,lower}case() to CString To: Danilo Krummrich Cc: Greg KH , ojeda@kernel.org, alex.gaynor@gmail.com, wedsonaf@gmail.com, boqun.feng@gmail.com, gary@garyguo.net, bjorn3_gh@protonmail.com, benno.lossin@proton.me, a.hindborg@samsung.com, aliceryhl@google.com, rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 23, 2024 at 6:24=E2=80=AFPM Danilo Krummrich = wrote: > > We also need to consider that simply wrapping tolower() and toupper() wou= ld make > slice::make_ascii_{lower,upper]case(), str::make_ascii_{lower,upper]case(= ), > char::make_ascii_{lower,upper]case() and CString::make_ascii_{lower,upper= ]case() > inconsistent. The former ones already only consider 'a' to 'z' and 'A' to= 'Z' > respectively. Latter, right? i.e. the kernel ones are the ones that consider the extended ones. > Just to clarify, personally I'm not worried about whether we consider the > extended range in this specific case or not. I think it's more interestin= g to > generlly figure out if, for such modules, we want the caller to expect C > bindings to be called or C logic to applied respectively, or if we want t= he > caller to expect that everything is aligned with the Rust std library. Yeah, it is normal to provide Rust abstractions that follow the naming and logic of the C side. Having said that, in this particular case, as you say, since some of these APIs are already in Rust's `core`, I think it is OK to have the Rust ones completed for `CString` etc. But if we are to provide the C logic, then we should use the C names. In other words, in general, what we should definitely avoid is mixing them, i.e. using the C logic when Rust std names are used, or vice versa. And maybe we need both the C and the Rust ones in some cases (should be rare, since it is likely only to come up for things in `core` like this or perhaps for well-known things in, say, `std`, but at least for those we do not use them in the kernel so it is a bit less confusing). Similarly, it does not hurt to mention whether an API has any subtle difference (or not) with a similar C API. Sadly, we cannot (easily) do that also for the existing ones already in `core` too, but it is not a big deal. Cheers, Miguel