fix: rectify reorder

Signed-off-by: jwx1282937 <jialinbo@huawei.com>
This commit is contained in:
jwx1282937 2023-12-14 03:28:04 +00:00
parent 3f54dcf3ac
commit 4b62739925
15 changed files with 53 additions and 33 deletions

View File

@ -20,8 +20,8 @@ extern crate ipc_rust;
mod access_token;
use ipc_rust::{
IRemoteBroker, IRemoteObj, RemoteStub, IpcResult, IpcStatusCode,
RemoteObj, define_remote_object, FIRST_CALL_TRANSACTION,
IRemoteBroker, IRemoteObj, RemoteStub, IpcResult,
IpcStatusCode, RemoteObj, define_remote_object, FIRST_CALL_TRANSACTION,
};
use ipc_rust::{
MsgParcel, BorrowedMsgParcel,

View File

@ -14,8 +14,8 @@
*/
use crate::{
ipc_binding, RawData, IpcResult, IpcStatusCode, BorrowedMsgParcel, status_result,
AsRawPtr
ipc_binding, RawData, IpcResult, IpcStatusCode,
BorrowedMsgParcel, status_result, AsRawPtr
};
use crate::ipc_binding::CAshmem;
use std::ffi::{CString, c_char};
@ -153,7 +153,7 @@ impl Ashmem {
/// Write data to ashmem
pub fn write(&self, data: &[u8], offset: i32) -> bool {
let len = data.len() as i32;
if offset < 0 || offset >= len {
if (offset < 0) || (offset >= len) {
error!(LOG_LABEL, "invalid offset: {}, len: {}", offset, len);
return false;
}

View File

@ -28,7 +28,7 @@ impl Ord for RemoteObj {
let greater_than = unsafe {
ipc_binding::RemoteObjectLessThan(other.0.as_ptr(), self.0.as_ptr())
};
if !less_than && !greater_than {
if (!less_than) && (!greater_than) {
Ordering::Equal
} else if less_than {
Ordering::Less

View File

@ -19,8 +19,11 @@ use crate::{
};
use crate::ipc_binding::{CRemoteObject, CParcel};
use std::ffi::{c_void, CString, c_char};
use std::ops::{Deref};
use hilog_rust::{info, error, hilog, HiLogLabel, LogType};
use std::ops::Deref;
use hilog_rust::{
info, error, hilog, HiLogLabel,
LogType
};
const LOG_LABEL: HiLogLabel = HiLogLabel {
log_type: LogType::LogCore,

View File

@ -26,12 +26,12 @@ mod ashmem;
// Export types of this crate
pub use crate::errors::{IpcResult, status_result, IpcStatusCode, parse_status_code};
pub use crate::ipc::{
IRemoteBroker, IRemoteObj, IRemoteStub, FromRemoteObj, RemoteObjRef,
remote_obj::RemoteObj, remote_obj::death_recipient::DeathRecipient,
remote_stub::RemoteStub,
IRemoteBroker, IRemoteObj, IRemoteStub, FromRemoteObj,
RemoteObjRef, remote_obj::RemoteObj, remote_obj::death_recipient::DeathRecipient,remote_stub::RemoteStub,
};
pub use crate::ipc_async::{
IpcAsyncPool, IpcAsyncRuntime, ToAsyncIpc, ToSyncIpc, BoxFuture, Ylong, Runtime,
IpcAsyncPool, IpcAsyncRuntime, ToAsyncIpc, ToSyncIpc,
BoxFuture, Ylong, Runtime,
};
pub use crate::parcel::{
@ -40,17 +40,18 @@ pub use crate::parcel::{
};
pub use crate::parcel::parcelable::{SerArray, DeArray};
pub use crate::parcel::types::{
interface_token::InterfaceToken, file_desc::FileDesc,
string16::String16
interface_token::InterfaceToken, file_desc::FileDesc, string16::String16
};
pub use crate::ashmem::{
Ashmem, PROT_NONE, PROT_READ, PROT_WRITE, PROT_EXEC,
Ashmem, PROT_NONE, PROT_READ, PROT_WRITE,
PROT_EXEC,
};
pub use crate::process::{
get_context_object, add_service, get_service, join_work_thread, stop_work_thread,
get_calling_uid, get_calling_token_id, get_first_token_id, get_self_token_id,
get_calling_pid, set_max_work_thread, is_local_calling, set_calling_identity,
get_local_device_id, get_calling_device_id, reset_calling_identity, is_handling_transaction,
get_context_object, add_service, get_service, join_work_thread,
stop_work_thread, get_calling_uid, get_calling_token_id, get_first_token_id,
get_self_token_id, get_calling_pid, set_max_work_thread, is_local_calling,
set_calling_identity, get_local_device_id, get_calling_device_id, reset_calling_identity,
is_handling_transaction,
};
pub use crate::ipc_binding::{CRemoteObject, CIRemoteObject};

View File

@ -263,7 +263,7 @@ impl RawData{
/// The caller should ensure that the u8 slice can be
/// correctly converted to other rust types
pub fn read(&self, start: u32, len: u32) -> IpcResult<&[u8]> {
if len == 0 || len > self.len || start >= self.len || (start + len) > self.len {
if (len == 0) || (len > self.len) || (start >= self.len) || ((start + len) > self.len) {
return Err(IpcStatusCode::Failed);
}
// SAFETY:

View File

@ -13,7 +13,10 @@
* limitations under the License.
*/
use crate::{IpcResult, IpcStatusCode, status_result, BorrowedMsgParcel, ipc_binding, AsRawPtr};
use crate::{
IpcResult, IpcStatusCode, status_result, BorrowedMsgParcel,
ipc_binding, AsRawPtr
};
use std::mem::MaybeUninit;
use std::ffi::{c_void, c_ulong};
use std::ptr;

View File

@ -17,7 +17,7 @@ use super::*;
impl<T: Serialize> Serialize for Box<T> {
fn serialize(&self, parcel: &mut BorrowedMsgParcel<'_>) -> IpcResult<()> {
Serialize::serialize(&**self, parcel)
Serialize::serialize(&(**self), parcel)
}
}
@ -29,7 +29,7 @@ impl<T: Deserialize> Deserialize for Box<T> {
impl<T: SerOption> SerOption for Box<T> {
fn ser_option(this: Option<&Self>, parcel: &mut BorrowedMsgParcel<'_>) -> IpcResult<()> {
SerOption::ser_option(this.map(|inner| &**inner), parcel)
SerOption::ser_option(this.map(|inner| &(**inner)), parcel)
}
}

View File

@ -14,7 +14,10 @@
*/
use super::*;
use crate::{ipc_binding, BorrowedMsgParcel, AsRawPtr, status_result, IpcResult, IpcStatusCode};
use crate::{
ipc_binding, BorrowedMsgParcel, AsRawPtr, status_result,
IpcResult, IpcStatusCode
};
use std::fs::File;
use std::os::unix::io::{AsRawFd, FromRawFd, IntoRawFd, RawFd};

View File

@ -14,7 +14,10 @@
*/
use super::*;
use crate::{ipc_binding, BorrowedMsgParcel, IpcResult, status_result, AsRawPtr};
use crate::{
ipc_binding, BorrowedMsgParcel, IpcResult, status_result,
AsRawPtr
};
use std::mem::MaybeUninit;
impl_serde_option_for_parcelable!(i8, u8, i16, u16, i32, u32, i64, u64, f32,f64);

View File

@ -14,7 +14,10 @@
*/
use super::*;
use crate::{ipc_binding, BorrowedMsgParcel, IpcResult, IpcStatusCode, AsRawPtr, status_result};
use crate::{
ipc_binding, BorrowedMsgParcel, IpcResult, IpcStatusCode,
AsRawPtr, status_result
};
use std::convert::TryInto;
use std::ffi::{CString, c_char};
use hilog_rust::{error, hilog, HiLogLabel, LogType};

View File

@ -14,7 +14,10 @@
*/
use super::*;
use crate::{ipc_binding, BorrowedMsgParcel, IpcResult, IpcStatusCode, status_result, AsRawPtr};
use crate::{
ipc_binding, BorrowedMsgParcel, IpcResult, IpcStatusCode,
status_result, AsRawPtr
};
use std::convert::TryInto;
use std::mem::MaybeUninit;
use std::ffi::CString;

View File

@ -15,8 +15,8 @@
use super::*;
use crate::{
ipc_binding, BorrowedMsgParcel, IpcResult, IpcStatusCode, status_result,
AsRawPtr
ipc_binding, BorrowedMsgParcel, IpcResult, IpcStatusCode,
status_result, AsRawPtr
};
use std::convert::TryInto;
use std::mem::MaybeUninit;

View File

@ -14,8 +14,9 @@
*/
use crate::{
ipc_binding, MsgParcel, RemoteObj, IRemoteObj, InterfaceToken, String16,
IpcResult, IpcStatusCode, parse_status_code,
ipc_binding, MsgParcel, RemoteObj, IRemoteObj,
InterfaceToken, String16, IpcResult, IpcStatusCode,
parse_status_code
};
use crate::parcel::{vec_to_string, allocate_vec_with_buffer};
use std::ffi::{CString, c_char, c_void};

View File

@ -20,8 +20,8 @@ extern crate ipc_rust;
mod access_token;
use ipc_rust::{
IRemoteBroker, IRemoteObj, RemoteStub, IpcResult, IpcStatusCode,
RemoteObj, define_remote_object, FIRST_CALL_TRANSACTION,
IRemoteBroker, IRemoteObj, RemoteStub, IpcResult,
IpcStatusCode, RemoteObj, define_remote_object, FIRST_CALL_TRANSACTION,
};
use ipc_rust::{
MsgParcel, BorrowedMsgParcel, FileDesc, InterfaceToken,