Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp36397rdb; Mon, 22 Jan 2024 11:04:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IFVwG1UOl2J9FVUQhfrrSTtW1J1ASVvZermDtTcQCvMWhZVZsdiVRTkn7tDZRi3JAEZJt/6 X-Received: by 2002:a05:6402:3190:b0:55a:640b:9dce with SMTP id di16-20020a056402319000b0055a640b9dcemr194983edb.48.1705950294381; Mon, 22 Jan 2024 11:04:54 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705950294; cv=pass; d=google.com; s=arc-20160816; b=wqnwYiBj7icV5I5pzCcZW/6tWOp6zUuy1CJdh8H97p84YlMVtxYkrNrUBs1wHRabZM 4xVtf4DiU1c+1HNPiCEDeOt6aCysgsS2JQm6/X09lwwLL1T2XYCORj562TlW+2R5ENxk KGazNWfV/+V62HO7+ypvWbWJjPb83GL7V2Oq1ui+LZHLPaZ3sKcrwZXkApyAP8kQeqdl O9IUfg9I1X5da2ChSvRVUdI6INriQU1wBqus5KLuM/heFU4lFuoSfK9u5Ey3rCjMKOdV 4wgB3renr8aKemx8RDc04hNtTk1LyHsumSnMdd+vJ8BVGtG2SfDNVx6T57IQunTK7iz2 PSAQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=9k/EegaiCDxQTsPJYM7AgRXIenTX4Qdv+pyOcBo0/BE=; fh=r7CWFz9DB7Mz6NSuRAzR7V5h8o/NL8HicmuqihPlAkU=; b=XZ8iy3aHlEvLYCtGvUcbdz+8di9uIyo94eF2R+eAWtgKXoE5fFpvVSmhnbMiM1o433 xIE/y4HxgQIwF5l2IQSSqr83ELQ4EioN60Tac5RJn4Zs8mC3LLEUSHzgAkA120dZS/ki kYUewGOejrtQkQgDF4XKIPc+odvmsa+R9jf5zo85o4VIPfVrFO2vB5bLqvZEEk63FogK 9YmnsacBe+tPURV5/QpgJBFGdQoch1ZtOXv1nANWvx4aoYGnQaPmE9aU0JqyErLLGSkl ScqQ4hdIUnrrAhDVGpChfYQMXVFsyDtdVdKeDpLA58vztPgoYhJh/cI9SYCa3ZwYJPPY V7vg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IuB9HuEB; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-34003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id b10-20020a056402084a00b005572b94d262si11228954edz.625.2024.01.22.11.04.54 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 11:04:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-34003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IuB9HuEB; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-34003-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-34003-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.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 028D11F33668 for ; Mon, 22 Jan 2024 19:04:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A7D55C915; Mon, 22 Jan 2024 18:46:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="IuB9HuEB" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2827D5C8E7 for ; Mon, 22 Jan 2024 18:46:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705949178; cv=none; b=lUaMlDcg/KkMUbPCiLyv0TWz6966RoiKHK5AKRHYORrfKROacckvOiG2D+9gHsiIweySoEN5Qac8T4T9GwvPKcvAIifZTbD51CpitmObRY6uftjdsFM7qlobZCavk3ByMlxvrpFhNaNxd/ZCU1kaLCHjDcc8FdtTdE+wMoKeKa8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705949178; c=relaxed/simple; bh=lwHcE6C75LYyexBkvNLU1jyUyNNxt7s+6RxQN71P8CA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=HGZucqd9lR62Bem9jp8SBRJjOiZ5xjmikBazsNBuSZSTwa3GyppbnDdqmCHsinC3zsaltJp28w41sYSrrh3/Vq3b77/o1MlekA+U3Fjksqq07wQhcLlU7M1Iu6BrkoJN38CPi0Lg8eaXHguU98gaKEa1U66sqM+e1LjmACI/40o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=IuB9HuEB; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705949176; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=9k/EegaiCDxQTsPJYM7AgRXIenTX4Qdv+pyOcBo0/BE=; b=IuB9HuEBS4rRHCPWKgRQdeAdDrjcfQg17DmV9JI+OMud3EMfqWUzQgKoXU6l8Lzi0NUbmT AYnhKziQKnp2J9h5J8I8UccVJazN92Gbr4xzsAd8RDE9w+NYR8g6vUiLqEe5o06xdW+s45 HTkCWAx3ZKCOui9maRO6EwGEpzRMJgc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-519-ysjZvPqyM5ijBPTkPlwEKA-1; Mon, 22 Jan 2024 13:46:14 -0500 X-MC-Unique: ysjZvPqyM5ijBPTkPlwEKA-1 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-33921b95da8so2113638f8f.1 for ; Mon, 22 Jan 2024 10:46:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705949173; x=1706553973; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9k/EegaiCDxQTsPJYM7AgRXIenTX4Qdv+pyOcBo0/BE=; b=i+XS3xwoHMoGDeUc5DjSUmrk/Hdl8zzZtMQpULDlWxII1y8VTmbwbHa3BboWC0tSyQ 4VLXG+rW2Shbw5ttDJmYc2Lh2BTS+3Yh8/dIGoQAP4Yd9QcP0fimFLNIhlE26yXpL+VK LO3sc0SsB93owtIkzaPE3wawwUy0w8wZ4AT84O8pOAIupuolfCaywEsSys2O3dJfk9pF pm49pvoaHv1h2Af8qbf3ZnCFsl9qxb3xFLBvhtF+b2FpCHGtiuM/61S8TYPfdp9L5Fn7 dxac52ESmy60JdXuZanckSBXcOSN4GUvJz+aK0VzOjg4Gy8876o1u9IlmZbTKVEijGoV rbsA== X-Gm-Message-State: AOJu0YwbZmO9/aCtrex5ch3/PYszZ4kLxBNCARwQS2RWR+1XCUZbeQXZ XPFx0klh7k14vZJVAqeiPBL27vyBuVDOjY1uB5VcEHCMsilvn1klbCV0/7MGXqdPTzMrStnhvFg 57ohbvpwuPtF1q58jnTjCAAN0wKfZLJwYebLJwRkpP6ZzzBFk6pujXDxvwRvG7w== X-Received: by 2002:a05:600c:6a12:b0:40e:5b66:f4db with SMTP id jj18-20020a05600c6a1200b0040e5b66f4dbmr2605029wmb.88.1705949173072; Mon, 22 Jan 2024 10:46:13 -0800 (PST) X-Received: by 2002:a05:600c:6a12:b0:40e:5b66:f4db with SMTP id jj18-20020a05600c6a1200b0040e5b66f4dbmr2605024wmb.88.1705949172795; Mon, 22 Jan 2024 10:46:12 -0800 (PST) Received: from cassiopeiae.. ([2a02:810d:4b3f:ee94:642:1aff:fe31:a19f]) by smtp.gmail.com with ESMTPSA id l6-20020a7bc346000000b0040d81ca11casm38940253wmj.28.2024.01.22.10.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 10:46:12 -0800 (PST) From: Danilo Krummrich To: 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 Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, Danilo Krummrich Subject: [PATCH] rust: str: add to_ascii_{upper,lower}case() to CString Date: Mon, 22 Jan 2024 19:45:57 +0100 Message-ID: <20240122184608.11863-1-dakr@redhat.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add functions to convert a CString to upper- / lowercase assuming all characters are ASCII encoded. Signed-off-by: Danilo Krummrich --- rust/kernel/str.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index 7d848b83add4..d21151d89861 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -581,6 +581,16 @@ pub fn try_from_fmt(args: fmt::Arguments<'_>) -> Result { // exist in the buffer. Ok(Self { buf }) } + + /// Converts the whole CString to lowercase. + pub fn to_ascii_lowercase(&mut self) { + self.buf.make_ascii_lowercase(); + } + + /// Converts the whole CString to uppercase. + pub fn to_ascii_uppercase(&mut self) { + self.buf.make_ascii_uppercase(); + } } impl Deref for CString { base-commit: 610347effc2ecb5ededf5037e82240b151f883ab -- 2.43.0