1+ #![ deny( warnings) ]
2+ // Allow non upper case globals from C
3+ #![ allow( non_upper_case_globals) ]
4+ // Allow using the solana_program::entrypoint::deserialize function
5+ #![ allow( clippy:: not_unsafe_ptr_arg_deref) ]
6+
17mod c_oracle_header;
28mod deserialize;
39mod error;
@@ -16,6 +22,7 @@ use crate::log::{
1622 pre_log,
1723} ;
1824use processor:: process_instruction;
25+
1926use solana_program:: entrypoint:: deserialize;
2027use solana_program:: program_error:: ProgramError ;
2128use solana_program:: {
@@ -48,8 +55,10 @@ extern "C" {
4855}
4956
5057//make the C entrypoint a no-op when running cargo test
58+ // Missing safety doc OK because this is just a no-op
5159#[ cfg( not( target_arch = "bpf" ) ) ]
52- pub extern "C" fn c_entrypoint ( input : * mut u8 ) -> u64 {
60+ #[ allow( clippy:: missing_safety_doc) ]
61+ pub unsafe extern "C" fn c_entrypoint ( _input : * mut u8 ) -> u64 {
5362 0 //SUCCESS value
5463}
5564
@@ -68,26 +77,24 @@ pub fn c_entrypoint_wrapper(input: *mut u8) -> OracleResult {
6877pub extern "C" fn entrypoint ( input : * mut u8 ) -> u64 {
6978 let ( program_id, accounts, instruction_data) = unsafe { deserialize ( input) } ;
7079
71- match pre_log ( & accounts, instruction_data) {
72- Err ( error) => return error. into ( ) ,
73- _ => { }
80+ if let Err ( error) = pre_log ( & accounts, instruction_data) {
81+ return error. into ( ) ;
7482 }
7583
7684 let c_ret_val = match process_instruction ( program_id, & accounts, instruction_data, input) {
7785 Err ( error) => error. into ( ) ,
7886 Ok ( success_status) => success_status,
7987 } ;
8088
81- match post_log ( c_ret_val, & accounts) {
82- Err ( error) => return error. into ( ) ,
83- _ => { }
89+ if let Err ( error) = post_log ( c_ret_val, & accounts) {
90+ return error. into ( ) ;
8491 }
8592
8693 if c_ret_val == SUCCESSFULLY_UPDATED_AGGREGATE {
8794 //0 is the SUCCESS value for solana
88- return 0 ;
95+ 0
8996 } else {
90- return c_ret_val;
97+ c_ret_val
9198 }
9299}
93100
0 commit comments