mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-04 04:25:45 +00:00
net_util: Remove unit error from Result
error: this returns a `Result<_, ()> --> net_util/src/mac.rs:68:5 | 68 | pub fn from_bytes(src: &[u8]) -> Result<MacAddr, ()> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D clippy::result-unit-err` implied by `-D warnings` = help: use a custom Error type instead = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#result_unit_err Replace with std::io::Error like other locations in the same file. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
d2de263774
commit
a4134f6b25
@ -65,9 +65,12 @@ impl MacAddr {
|
|||||||
|
|
||||||
// An error can only occur if the slice length is different from MAC_ADDR_LEN.
|
// An error can only occur if the slice length is different from MAC_ADDR_LEN.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn from_bytes(src: &[u8]) -> Result<MacAddr, ()> {
|
pub fn from_bytes(src: &[u8]) -> Result<MacAddr, io::Error> {
|
||||||
if src.len() != MAC_ADDR_LEN {
|
if src.len() != MAC_ADDR_LEN {
|
||||||
return Err(());
|
return Err(io::Error::new(
|
||||||
|
io::ErrorKind::Other,
|
||||||
|
format!("invalid length of slice: {} vs {}", src.len(), MAC_ADDR_LEN),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
Ok(MacAddr::from_bytes_unchecked(src))
|
Ok(MacAddr::from_bytes_unchecked(src))
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,7 @@ pub enum Error {
|
|||||||
NetUtil(NetUtilError),
|
NetUtil(NetUtilError),
|
||||||
InvalidIfname,
|
InvalidIfname,
|
||||||
/// Error parsing MAC data
|
/// Error parsing MAC data
|
||||||
MacParsing(()),
|
MacParsing(IoError),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = ::std::result::Result<T, Error>;
|
pub type Result<T> = ::std::result::Result<T, Error>;
|
||||||
|
Loading…
Reference in New Issue
Block a user