This is an automated email from the ASF dual-hosted git repository.

mssun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-teaclave.git


The following commit(s) were added to refs/heads/master by this push:
     new 40e099f  Replace transmute with primitives::to_be_bytes after Rust 
1.32 (#391)
40e099f is described below

commit 40e099f2093d78b53322676f8bc022ab827dcc95
Author: Bing Duan <[email protected]>
AuthorDate: Tue Jul 14 12:22:09 2020 +0800

    Replace transmute with primitives::to_be_bytes after Rust 1.32 (#391)
---
 rpc/src/protocol.rs | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/rpc/src/protocol.rs b/rpc/src/protocol.rs
index 2e00c5f..482b348 100644
--- a/rpc/src/protocol.rs
+++ b/rpc/src/protocol.rs
@@ -18,7 +18,6 @@
 use log::debug;
 use serde::{Deserialize, Serialize};
 use std::io;
-use std::mem::transmute;
 use std::prelude::v1::*;
 use std::vec::Vec;
 use teaclave_types::TeaclaveServiceResponseError;
@@ -77,8 +76,7 @@ where
         let mut header = [0u8; 8];
 
         self.transport.read_exact(&mut header)?;
-        let buf_len = u64::from_be(unsafe { transmute::<[u8; 8], u64>(header) 
});
-
+        let buf_len = u64::from_be_bytes(header);
         if buf_len > self.max_frame_len {
             return Err(ProtocolError::Other(anyhow::anyhow!(
                 "Exceed max frame length"
@@ -103,7 +101,7 @@ where
         debug!("Send: {}", std::string::String::from_utf8_lossy(&send_buf));
 
         let buf_len = send_buf.len() as u64;
-        let header = unsafe { transmute::<u64, [u8; 8]>(buf_len.to_be()) };
+        let header = buf_len.to_be_bytes();
 
         self.transport.write(&header)?;
         self.transport.write_all(&send_buf)?;


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to