Skip to content

Commit

Permalink
cpi: change unnecessary &mut MemoryMapping to &MemoryMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrod committed Jul 5, 2023
1 parent ce4cdd4 commit b9f43cc
Showing 1 changed file with 32 additions and 32 deletions.
64 changes: 32 additions & 32 deletions programs/bpf_loader/src/syscalls/cpi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ type TranslatedAccounts<'a> = Vec<(IndexOfAccount, Option<CallerAccount<'a>>)>;
trait SyscallInvokeSigned {
fn translate_instruction(
addr: u64,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &mut InvokeContext,
) -> Result<StableInstruction, Error>;
fn translate_accounts<'a>(
Expand All @@ -321,14 +321,14 @@ trait SyscallInvokeSigned {
account_infos_addr: u64,
account_infos_len: u64,
is_loader_deprecated: bool,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &mut InvokeContext,
) -> Result<TranslatedAccounts<'a>, Error>;
fn translate_signers(
program_id: &Pubkey,
signers_seeds_addr: u64,
signers_seeds_len: u64,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &InvokeContext,
) -> Result<Vec<Pubkey>, Error>;
}
Expand Down Expand Up @@ -360,7 +360,7 @@ declare_syscall!(
impl SyscallInvokeSigned for SyscallInvokeSignedRust {
fn translate_instruction(
addr: u64,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &mut InvokeContext,
) -> Result<StableInstruction, Error> {
let ix = translate_type::<StableInstruction>(
Expand Down Expand Up @@ -414,7 +414,7 @@ impl SyscallInvokeSigned for SyscallInvokeSignedRust {
account_infos_addr: u64,
account_infos_len: u64,
is_loader_deprecated: bool,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &mut InvokeContext,
) -> Result<TranslatedAccounts<'a>, Error> {
let (account_infos, account_info_keys) = translate_account_infos(
Expand Down Expand Up @@ -442,7 +442,7 @@ impl SyscallInvokeSigned for SyscallInvokeSignedRust {
program_id: &Pubkey,
signers_seeds_addr: u64,
signers_seeds_len: u64,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &InvokeContext,
) -> Result<Vec<Pubkey>, Error> {
let mut signers = Vec::new();
Expand Down Expand Up @@ -571,7 +571,7 @@ declare_syscall!(
impl SyscallInvokeSigned for SyscallInvokeSignedC {
fn translate_instruction(
addr: u64,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &mut InvokeContext,
) -> Result<StableInstruction, Error> {
let ix_c = translate_type::<SolInstruction>(
Expand Down Expand Up @@ -647,7 +647,7 @@ impl SyscallInvokeSigned for SyscallInvokeSignedC {
account_infos_addr: u64,
account_infos_len: u64,
is_loader_deprecated: bool,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &mut InvokeContext,
) -> Result<TranslatedAccounts<'a>, Error> {
let (account_infos, account_info_keys) = translate_account_infos(
Expand Down Expand Up @@ -675,7 +675,7 @@ impl SyscallInvokeSigned for SyscallInvokeSignedC {
program_id: &Pubkey,
signers_seeds_addr: u64,
signers_seeds_len: u64,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &InvokeContext,
) -> Result<Vec<Pubkey>, Error> {
if signers_seeds_len > 0 {
Expand Down Expand Up @@ -728,7 +728,7 @@ fn translate_account_infos<'a, T, F>(
account_infos_addr: u64,
account_infos_len: u64,
key_addr: F,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
invoke_context: &mut InvokeContext,
) -> Result<(&'a [T], Vec<&'a Pubkey>), Error>
where
Expand Down Expand Up @@ -990,7 +990,7 @@ fn cpi_common<S: SyscallInvokeSigned>(
account_infos_len: u64,
signers_seeds_addr: u64,
signers_seeds_len: u64,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
) -> Result<u64, Error> {
// CPI entry.
//
Expand Down Expand Up @@ -1192,7 +1192,7 @@ fn update_callee_account(
// changes.
fn update_caller_account(
invoke_context: &InvokeContext,
memory_mapping: &mut MemoryMapping,
memory_mapping: &MemoryMapping,
is_loader_deprecated: bool,
caller_account: &mut CallerAccount,
callee_account: &mut BorrowedAccount<'_>,
Expand Down Expand Up @@ -1567,11 +1567,11 @@ mod tests {
aligned_memory_mapping: false,
..Config::default()
};
let mut memory_mapping = MemoryMapping::new(vec![region], &config).unwrap();
let memory_mapping = MemoryMapping::new(vec![region], &config).unwrap();

let ins = SyscallInvokeSignedRust::translate_instruction(
vm_addr,
&mut memory_mapping,
&memory_mapping,
&mut invoke_context,
)
.unwrap();
Expand Down Expand Up @@ -1603,13 +1603,13 @@ mod tests {
aligned_memory_mapping: false,
..Config::default()
};
let mut memory_mapping = MemoryMapping::new(vec![region], &config).unwrap();
let memory_mapping = MemoryMapping::new(vec![region], &config).unwrap();

let signers = SyscallInvokeSignedRust::translate_signers(
&program_id,
vm_addr,
1,
&mut memory_mapping,
&memory_mapping,
&invoke_context,
)
.unwrap();
Expand Down Expand Up @@ -1688,7 +1688,7 @@ mod tests {
aligned_memory_mapping: false,
..Config::default()
};
let mut memory_mapping =
let memory_mapping =
MemoryMapping::new(mock_caller_account.regions.split_off(0), &config).unwrap();

let mut caller_account = mock_caller_account.caller_account();
Expand All @@ -1702,7 +1702,7 @@ mod tests {

update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand Down Expand Up @@ -1742,7 +1742,7 @@ mod tests {
aligned_memory_mapping: false,
..Config::default()
};
let mut memory_mapping =
let memory_mapping =
MemoryMapping::new(mock_caller_account.regions.split_off(0), &config).unwrap();

let data_slice = mock_caller_account.data_slice();
Expand All @@ -1766,7 +1766,7 @@ mod tests {

update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand All @@ -1791,7 +1791,7 @@ mod tests {
.unwrap();
update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand All @@ -1808,7 +1808,7 @@ mod tests {
assert!(matches!(
update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand All @@ -1824,7 +1824,7 @@ mod tests {
.unwrap();
update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand Down Expand Up @@ -1863,7 +1863,7 @@ mod tests {
aligned_memory_mapping: false,
..Config::default()
};
let mut memory_mapping =
let memory_mapping =
MemoryMapping::new(mock_caller_account.regions.split_off(0), &config).unwrap();

let data_slice = mock_caller_account.data_slice();
Expand Down Expand Up @@ -1892,7 +1892,7 @@ mod tests {

update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand Down Expand Up @@ -1965,7 +1965,7 @@ mod tests {
.unwrap();
update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand All @@ -1984,7 +1984,7 @@ mod tests {
assert!(matches!(
update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand All @@ -2000,7 +2000,7 @@ mod tests {
.unwrap();
update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand Down Expand Up @@ -2038,7 +2038,7 @@ mod tests {
aligned_memory_mapping: false,
..Config::default()
};
let mut memory_mapping =
let memory_mapping =
MemoryMapping::new(mock_caller_account.regions.split_off(0), &config).unwrap();

let mut caller_account = mock_caller_account.caller_account();
Expand All @@ -2058,7 +2058,7 @@ mod tests {

update_caller_account(
&invoke_context,
&mut memory_mapping,
&memory_mapping,
false,
&mut caller_account,
&mut callee_account,
Expand Down Expand Up @@ -2386,7 +2386,7 @@ mod tests {
aligned_memory_mapping: false,
..Config::default()
};
let mut memory_mapping = MemoryMapping::new(vec![region], &config).unwrap();
let memory_mapping = MemoryMapping::new(vec![region], &config).unwrap();

mock_invoke_context!(
invoke_context,
Expand Down Expand Up @@ -2420,7 +2420,7 @@ mod tests {
vm_addr,
1,
false,
&mut memory_mapping,
&memory_mapping,
&mut invoke_context,
)
.unwrap();
Expand Down

0 comments on commit b9f43cc

Please sign in to comment.