mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-24 20:48:55 +00:00
base: simplify SharedMemory::try_clone()
Use the SafeDescriptor try_clone() function rather than reimplementing it in a roundabout way. BUG=b:242953353 TEST=tools/dev_container tools/presubmit Change-Id: Ic75ba06073eb964706b32701f0ed0184a6148bcf Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5671239 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
parent
458a5603c0
commit
64841ed4dc
1 changed files with 4 additions and 2 deletions
|
@ -57,8 +57,10 @@ impl SharedMemory {
|
|||
/// Clones the SharedMemory. The new SharedMemory will refer to the same
|
||||
/// underlying object as the original.
|
||||
pub fn try_clone(&self) -> Result<SharedMemory> {
|
||||
let shmem_descriptor = SafeDescriptor::try_from(self as &dyn AsRawDescriptor)?;
|
||||
SharedMemory::from_safe_descriptor(shmem_descriptor, self.size())
|
||||
Ok(SharedMemory {
|
||||
descriptor: self.descriptor.try_clone()?,
|
||||
size: self.size,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue