From patchwork Fri Jul 14 09:19:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asahi Lina X-Patchwork-Id: 120387 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:a6b2:0:b0:3e4:2afc:c1 with SMTP id c18csp2386919vqm; Fri, 14 Jul 2023 02:51:53 -0700 (PDT) X-Google-Smtp-Source: APBJJlEAHn+bMQv3F8hoZMYvrjmuL5o8ZrHqBtPWNmOhGQrpEdRcgBe26SX0HymyezmRDY8G+mGo X-Received: by 2002:a17:906:519c:b0:994:54e9:692c with SMTP id y28-20020a170906519c00b0099454e9692cmr229659ejk.1.1689328312862; Fri, 14 Jul 2023 02:51:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689328312; cv=none; d=google.com; s=arc-20160816; b=X6x54S0SSljLjyJZSB63ocJiM0i+v8mA9Y8Atr8GVXDnZGaP/7FTjxy9WmZasDV71H wS0Suvnz+81tVqw7I2J3svpyNmqX+j8JvHwJjnvdrhwoBoRqSVEDF6MjXnMVayecEPJ8 /Jp7z5liu+p3zQbXvCuXSlmhqxU76iirH+vpYVAEkqbd3Fu8LwenFhUteQEUTY5nKSd4 gd/p7chqFxNCFsc2mux4wO5yt6Pa+hfxFA7Yw2iC6TvLKSH2/PxqAEzZOkSQ+WHabGdn pCZfijjwe6RaA0U6HaytRvAr4s2EIvXggXmYqFDiFSbUlQlNikBb/SGteIdfL80sWAUs yfRA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=PmVGEihQj+siomImaPG8tYAyrCdAjUR5Pp6QeqvwLiU=; fh=YdOJwOfHm/a56O5Pkv+e9miVlZAaA9UBMsMKdv/nH38=; b=NCy2T1/CYBefXyfbzXuHCNBTT5DfWMUFpXXNSil0/JrGQ/7MhpkQfZiw8rHbI38u5q I621q72OpQltL+qZ6tFT42PQ180REDI99sLhRho10sTiFvelj43C373wEZ0v0n7xb5sJ Aj+ML6R2TxmgxWjVeU5zqjyzXISQBSytc6qiWpksYZXLhiNifnXAJ1VvJpQ7HYroJGbH /UFIl2naO3DdDKfq5WZkeZTpR7UUXhSa/XKdmIwMZWmDL3fI30h5aDouXoaDc8fEItsf s/npBgWab+x5cHifVcYlzBknx1Yd86PXuOKEyatFUvMcaN/RGB4TOHTDCVMjaigU7ZXc zOwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=SW7iC9PL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z15-20020a1709064e0f00b00992af47620esi1478478eju.509.2023.07.14.02.51.29; Fri, 14 Jul 2023 02:51:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@asahilina.net header.s=default header.b=SW7iC9PL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=asahilina.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235828AbjGNJgX (ORCPT + 99 others); Fri, 14 Jul 2023 05:36:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235742AbjGNJgI (ORCPT ); Fri, 14 Jul 2023 05:36:08 -0400 Received: from mail.marcansoft.com (marcansoft.com [212.63.210.85]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92DE6358E; Fri, 14 Jul 2023 02:36:06 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: linasend@asahilina.net) by mail.marcansoft.com (Postfix) with ESMTPSA id 64EE65BC9C; Fri, 14 Jul 2023 09:19:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=asahilina.net; s=default; t=1689326380; bh=xxvykvXcInvkp1nPJDBq3/LVlq3218mtzs6EEpgOuZM=; h=From:Date:Subject:To:Cc; b=SW7iC9PLblGwjy0uS43ESSW/CTTwGFLyA7BXzUeLnZBlYYClQOkSR1914QK8OPVTN whb4pXHsb8MzNqGrVxrGB2h9YLO9wpjogxw0VaaTMpEYJ4mc91FSi4tklMSZOvQYkg wa/lTzit4twzHZblAKxWYbB8IeWNCxSsnLOBfWc4JZQTi1xuCY8jaLuFSDIVdA0ubs nPmlbDtM0sbXxSy5V4YgYSoSVlsNLJe/tSrfJ2WXFdelBflnNAoFy5mv4YA4cpa7oy GyGrWGIvE0CvrssMJkX9Pd+m3hv64csNorB9EImvr5ZJOn6s1Ds19IHuekrBv5flOX BfJy6V18tUZlw== From: Asahi Lina Date: Fri, 14 Jul 2023 18:19:33 +0900 Subject: [PATCH] rust: kernel: str: Implement Debug for CString MIME-Version: 1.0 Message-Id: <20230714-cstring-debug-v1-1-4e7c3018dd4f@asahilina.net> X-B4-Tracking: v=1; b=H4sIACQTsWQC/x3MQQqAIBBA0avErBPUAqOrRAvT0WZj4VQE4t2Tl m/xfwHGTMgwdwUyPsR0pAbVd+B2myIK8s2gpR6kUaNwfGVKUXjc7iiclVoFlNabCVpzZgz0/r9 lrfUD7QtijV8AAAA= To: Miguel Ojeda , Alex Gaynor , Wedson Almeida Filho , Boqun Feng , Gary Guo , =?utf-8?q?Bj=C3=B6rn_Roy_Baron?= , Benno Lossin Cc: rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, asahi@lists.linux.dev, Asahi Lina X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1689326377; l=768; i=lina@asahilina.net; s=20230221; h=from:subject:message-id; bh=xxvykvXcInvkp1nPJDBq3/LVlq3218mtzs6EEpgOuZM=; b=eVRCUCVHz0ocxsEaLFf7fiwn6ZrnWFVt5xgQ3D4WiHheqp897IEhKoC3DVZkJwIzRl/SZn53S StVIW12Q8yoBFVBQFV0Nvv6Vka2cl6ohbzDV152N+F9M7CFK9B5N658 X-Developer-Key: i=lina@asahilina.net; a=ed25519; pk=Qn8jZuOtR1m5GaiDfTrAoQ4NE1XoYVZ/wmt5YtXWFC4= X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771389125165794027 X-GMAIL-MSGID: 1771389125165794027 Trivial implementation. Signed-off-by: Asahi Lina Reviewed-by: Alice Ryhl Reviewed-by: Martin Rodriguez Reboredo Reviewed-by: Benno Lossin --- rust/kernel/str.rs | 6 ++++++ 1 file changed, 6 insertions(+) --- base-commit: 06c2afb862f9da8dc5efa4b6076a0e48c3fbaaa5 change-id: 20230714-cstring-debug-ca021fe0ad78 Thank you, ~~ Lina diff --git a/rust/kernel/str.rs b/rust/kernel/str.rs index c9dd3bf59e34..a94e396d39e1 100644 --- a/rust/kernel/str.rs +++ b/rust/kernel/str.rs @@ -606,6 +606,12 @@ fn try_from(cstr: &'a CStr) -> Result { } } +impl fmt::Debug for CString { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fmt::Debug::fmt(&**self, f) + } +} + /// A convenience alias for [`core::format_args`]. #[macro_export] macro_rules! fmt {