From 80e66657ccfb9d9691b7369789842c7be00e854b Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Mon, 19 May 2025 09:50:44 +0200 Subject: [PATCH] misc: pci: streamline #[source] and Error This streamlines the code base to follow best practices for error handling in Rust: Each error struct implements std::error::Error (most due via thiserror::Error derive macro) and sets its source accordingly. This allows future work that nicely prints the error chains, for example. So far, the convention is that each error prints its sub error as part of its Display::fmt() impl. Signed-off-by: Philipp Schuster On-behalf-of: SAP philipp.schuster@sap.com --- pci/src/msi.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pci/src/msi.rs b/pci/src/msi.rs index 042a2a018..edae9af54 100644 --- a/pci/src/msi.rs +++ b/pci/src/msi.rs @@ -40,9 +40,9 @@ pub fn msi_num_enabled_vectors(msg_ctl: u16) -> usize { #[derive(Error, Debug)] pub enum Error { #[error("Failed enabling the interrupt route: {0}")] - EnableInterruptRoute(io::Error), + EnableInterruptRoute(#[source] io::Error), #[error("Failed updating the interrupt route: {0}")] - UpdateInterruptRoute(io::Error), + UpdateInterruptRoute(#[source] io::Error), } pub const MSI_CONFIG_ID: &str = "msi_config";