From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3CA76191F79; Tue, 8 Apr 2025 22:00:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744149603; cv=none; b=RRZuAYeu7xiLhw/P74gxAfNdlAp2Bo9vx2OlpiV80zK5ZykkmMlPkWbropGh4Vj+z15EOmp8Hekgnwrgz0kBObSCTucYaqGm5llE1mynvy8R5HCEtSrQr145uq6RcFx/56AsXUrHeR0LR9ZF2skNWCucFOa7vRgVsweYgrU1lyw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744149603; c=relaxed/simple; bh=AjMKNMsrAuLwoFrp7noFAOmIvL9BDDzrxVNpfknHieU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qAfX4vKvIy/WT4JqypVI16xnS9mDURDTgZ08h+LJSYHLZeOK7Yez9k/cJTCLW5D6b0uUbcf8OFJX2Nc0F8L9d+DPYw1nmKt5q+nGJpu85VO/prAP/TsT5pSxBFCuZ0DLQFIu9l5mJim5ibnLYTIRnHowKx5/FqWIqrXYzG7BI5Y= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pivb9WHT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pivb9WHT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57AB6C4CEE5; Tue, 8 Apr 2025 21:59:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744149602; bh=AjMKNMsrAuLwoFrp7noFAOmIvL9BDDzrxVNpfknHieU=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Pivb9WHTBk3nM3kLzdBe4Cgw3V8ZmhTAp68CWQSh4eFgVZr3Y5f6m1NzQTE+iLE22 8b3A9QxiWPKLjQRtFnBRqgDi8uMFmaRxUR07dM+ddGQiGgE8i1uwxdVOxE6SjLk3HT WprOXVNhaxds+y4eyWOJrfe9eMlSY08bd/fglj27xh8Bnb/a/rg/fhXxPUYIbxnJj+ 9tU2uNzYFQKZdvJIUVHHQtlH9KUCW3xmcJ2x2CDepzolmRN+CkRE6grim3gvruFzxx Hpl23JC0h+2S55LrQ/AlAk0xQqXzma8PRfYDky7V0Lw4JVGEABRKqA/TVa/kvD0GBo XtMIWG1FtfVJw== Date: Tue, 8 Apr 2025 23:59:56 +0200 From: Danilo Krummrich To: Benno Lossin Cc: Andreas Hindborg , Miguel Ojeda , Abdiel Janulgue , ojeda@kernel.org, Daniel Almeida , Robin Murphy , Alex Gaynor , Boqun Feng , Gary Guo , =?iso-8859-1?Q?Bj=F6rn?= Roy Baron , Alice Ryhl , Trevor Gross , "open list:DMA MAPPING HELPERS DEVICE DRIVER API [RUST]" , Marek Szyprowski , "open list:DMA MAPPING HELPERS" , open list Subject: Re: [PATCH 2/3] rust: dma: convert the read/write macros to return Result Message-ID: References: <20250326201230.3193329-1-abdiel.janulgue@gmail.com> <20250326201230.3193329-3-abdiel.janulgue@gmail.com> <87ldsahlxr.fsf@kernel.org> <87a58qh1w8.fsf@kernel.org> Precedence: bulk X-Mailing-List: rust-for-linux@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Tue, Apr 08, 2025 at 09:54:13PM +0000, Benno Lossin wrote: > On Tue Apr 8, 2025 at 9:46 PM CEST, Andreas Hindborg wrote: > > "Miguel Ojeda" writes: > >> On Tue, Apr 8, 2025 at 2:40 PM Andreas Hindborg wrote: > >>> > >>> But the `assert_eq!` would panic anyway if comparison fails, right? > >> > >> Previously the `?` generated by the macro would return out of the > >> closure written by the sample, and thus it wouldn't reach the > >> `assert_eq!`. > > > > Right, I see. So the question is whether we want to have the assert > > panic here or not, of we get an Err. I vote yes. > > The assert wouldn't be the source of the panic though, it would be the > `.unwrap()`, but I think it's better to report the error. Although I > think it would be nicer if the example could use better error handling, > but this code is in a `drop` function, so no way to bubble up a > result... We could be more explicit and assert is_ok() instead and subsequently do the assert_eq.