Skip to content

Commit

Permalink
Return error when dup buf is not empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jackpot51 committed Jul 22, 2017
1 parent ce78f9c commit 473ac85
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 5 deletions.
6 changes: 5 additions & 1 deletion ahcid/src/scheme.rs
Expand Up @@ -70,7 +70,11 @@ impl Scheme for DiskScheme {
}
}

fn dup(&self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}

let mut handles = self.handles.lock();
let new_handle = {
let handle = handles.get(&id).ok_or(Error::new(EBADF))?;
Expand Down
6 changes: 5 additions & 1 deletion alxd/src/device/mod.rs
Expand Up @@ -1797,7 +1797,11 @@ impl scheme::SchemeMut for Alx {
}
}

fn dup(&mut self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&mut self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}

Ok(id)
}

Expand Down
6 changes: 5 additions & 1 deletion e1000d/src/device.rs
Expand Up @@ -110,7 +110,11 @@ impl Scheme for Intel8254x {
}
}

fn dup(&self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}

Ok(id)
}

Expand Down
6 changes: 5 additions & 1 deletion rtl8168d/src/device.rs
Expand Up @@ -83,7 +83,11 @@ impl SchemeMut for Rtl8168 {
}
}

fn dup(&mut self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&mut self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}

Ok(id)
}

Expand Down
6 changes: 5 additions & 1 deletion vesad/src/scheme.rs
Expand Up @@ -114,7 +114,11 @@ impl SchemeMut for DisplayScheme {
}
}

fn dup(&mut self, id: usize, _buf: &[u8]) -> Result<usize> {
fn dup(&mut self, id: usize, buf: &[u8]) -> Result<usize> {
if ! buf.is_empty() {
return Err(Error::new(EINVAL));
}

let handle = self.handles.get(&id).map(|handle| handle.clone()).ok_or(Error::new(EBADF))?;

let new_id = self.next_id;
Expand Down

0 comments on commit 473ac85

Please sign in to comment.