mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-10-03 20:15:45 +00:00
tpm: change the style of safety comments
To satisfy clippy's check. Signed-off-by: Wei Liu <liuwe@microsoft.com>
This commit is contained in:
parent
58b7057c7f
commit
7f4b5dfae5
@ -133,7 +133,7 @@ impl Emulator {
|
|||||||
let mut res: PtmResult = 0;
|
let mut res: PtmResult = 0;
|
||||||
|
|
||||||
let mut fds = [-1, -1];
|
let mut fds = [-1, -1];
|
||||||
// Safe because return value of the unsafe call is checked
|
// SAFETY: FFI calls and return value of the unsafe call is checked
|
||||||
unsafe {
|
unsafe {
|
||||||
let ret = libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM, 0, fds.as_mut_ptr());
|
let ret = libc::socketpair(libc::AF_UNIX, libc::SOCK_STREAM, 0, fds.as_mut_ptr());
|
||||||
if ret == -1 {
|
if ret == -1 {
|
||||||
@ -289,7 +289,7 @@ impl Emulator {
|
|||||||
/// Function to write to data socket and read the response from it
|
/// Function to write to data socket and read the response from it
|
||||||
fn unix_tx_bufs(&mut self) -> Result<()> {
|
fn unix_tx_bufs(&mut self) -> Result<()> {
|
||||||
let isselftest: bool;
|
let isselftest: bool;
|
||||||
// Safe as type "sockaddr_storage" is valid with an all-zero byte-pattern value
|
// SAFETY: type "sockaddr_storage" is valid with an all-zero byte-pattern value
|
||||||
let mut addr: sockaddr_storage = unsafe { mem::zeroed() };
|
let mut addr: sockaddr_storage = unsafe { mem::zeroed() };
|
||||||
let mut len = mem::size_of::<sockaddr_storage>() as socklen_t;
|
let mut len = mem::size_of::<sockaddr_storage>() as socklen_t;
|
||||||
|
|
||||||
@ -307,7 +307,7 @@ impl Emulator {
|
|||||||
iov_len: cmd.input.len(),
|
iov_len: cmd.input.len(),
|
||||||
}; 1];
|
}; 1];
|
||||||
|
|
||||||
// Safe because all zero values from the unsafe method are updated before usage
|
// SAFETY: all zero values from the unsafe method are updated before usage
|
||||||
let mut msghdr: libc::msghdr = unsafe { mem::zeroed() };
|
let mut msghdr: libc::msghdr = unsafe { mem::zeroed() };
|
||||||
msghdr.msg_name = ptr::null_mut();
|
msghdr.msg_name = ptr::null_mut();
|
||||||
msghdr.msg_namelen = 0;
|
msghdr.msg_namelen = 0;
|
||||||
@ -316,7 +316,7 @@ impl Emulator {
|
|||||||
msghdr.msg_control = ptr::null_mut();
|
msghdr.msg_control = ptr::null_mut();
|
||||||
msghdr.msg_controllen = 0;
|
msghdr.msg_controllen = 0;
|
||||||
msghdr.msg_flags = 0;
|
msghdr.msg_flags = 0;
|
||||||
// Safe as the return value of the unsafe method is checked
|
// SAFETY: FFI call and the return value of the unsafe method is checked
|
||||||
unsafe {
|
unsafe {
|
||||||
let ret = libc::sendmsg(self.data_fd, &msghdr, 0);
|
let ret = libc::sendmsg(self.data_fd, &msghdr, 0);
|
||||||
if ret == -1 {
|
if ret == -1 {
|
||||||
@ -328,7 +328,7 @@ impl Emulator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cmd.output.fill(0);
|
cmd.output.fill(0);
|
||||||
// Safe as return value from unsafe method is checked
|
// SAFETY: FFI calls and return value from unsafe method is checked
|
||||||
unsafe {
|
unsafe {
|
||||||
let ret = libc::recvfrom(
|
let ret = libc::recvfrom(
|
||||||
self.data_fd,
|
self.data_fd,
|
||||||
|
Loading…
Reference in New Issue
Block a user