From 53b4a6d65e93347f9cb0cbe66317b03b0f05273e Mon Sep 17 00:00:00 2001 From: Corey Richardson Date: Sun, 28 May 2017 17:25:54 -0400 Subject: [PATCH] Don't die if there is no unique name --- src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 5c5ff72..b783ac2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -722,10 +722,14 @@ impl Device { dev.phys = Some(CString::new(vec.clone()).unwrap()); } - let uniq_len = unsafe { eviocguniq(fd, vec.as_mut_ptr(), 255) }?; - if uniq_len > 0 { - unsafe { vec.set_len(uniq_len as usize - 1) }; - dev.uniq = Some(CString::new(vec.clone()).unwrap()); + match unsafe { eviocguniq(fd, vec.as_mut_ptr(), 255) } { + Ok(uniq_len) => { + if uniq_len > 0 { + unsafe { vec.set_len(uniq_len as usize - 1) }; + dev.uniq = Some(CString::new(vec.clone()).unwrap()); + } + }, + Err(_) => { /* it's not essential */ } } do_ioctl!(eviocgid(fd, &mut dev.id));