Commit 4984504 1 parent 425cfc5 commit 4984504 Copy full SHA for 4984504
File tree 1 file changed +9
-5
lines changed
1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -33,14 +33,18 @@ pub(crate) struct PortId(pub(crate) u16);
33
33
impl PortId {
34
34
pub fn new_from_device ( device : String ) -> PortId {
35
35
let mut port_id: u16 = 0 ;
36
- unsafe {
37
- let dev_name = CString :: new ( device) . unwrap ( ) ;
38
- let ret = dpdk:: rte_eth_dev_get_port_by_name ( dev_name. as_ptr ( ) , & mut port_id) ;
39
- assert_eq ! ( ret, 0 ) ;
36
+ let _device = device. clone ( ) ;
37
+ let ret =
38
+ unsafe {
39
+ let dev_name = CString :: new ( device) . unwrap ( ) ;
40
+ dpdk:: rte_eth_dev_get_port_by_name ( dev_name. as_ptr ( ) , & mut port_id)
41
+ } ;
42
+ if ret != 0 {
43
+ panic ! ( "Failed to find device by name {}" , _device) ;
40
44
}
41
45
42
46
if { unsafe { dpdk:: rte_eth_dev_is_valid_port ( port_id) } } == 0 {
43
- panic ! ( "ERROR: Invalid port." ) ;
47
+ panic ! ( "ERROR: Invalid port ID {}." , port_id ) ;
44
48
}
45
49
PortId ( port_id)
46
50
}
You can’t perform that action at this time.
0 commit comments