From cf8a9275def7032fe498197ef08425052c176ad3 Mon Sep 17 00:00:00 2001 From: Richard Patel Date: Thu, 28 Nov 2024 20:37:51 +0000 Subject: [PATCH] runtime: remove unreachable code --- src/ballet/shred/fuzz_shred_parse.c | 1 - src/flamenco/rewards/fd_rewards.c | 2 -- src/flamenco/runtime/fd_executor.c | 2 +- src/flamenco/runtime/fd_rocksdb.c | 2 -- src/flamenco/runtime/fd_runtime.c | 8 ++++---- src/flamenco/runtime/fd_runtime_init.c | 9 ++++----- src/flamenco/runtime/program/fd_bpf_loader_program.c | 2 +- src/flamenco/runtime/program/fd_bpf_program_util.c | 6 ++---- src/flamenco/snapshot/fd_snapshot.c | 2 -- src/flamenco/types/fd_types_yaml.c | 1 - src/funk/fd_funk_part.c | 1 - 11 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/ballet/shred/fuzz_shred_parse.c b/src/ballet/shred/fuzz_shred_parse.c index 6ab08412ce..71c6bfaea6 100644 --- a/src/ballet/shred/fuzz_shred_parse.c +++ b/src/ballet/shred/fuzz_shred_parse.c @@ -144,7 +144,6 @@ LLVMFuzzerTestOneInput( uchar const * data, default: /* unknown variant */ abort(); - break; } # undef BOUNDS_CHECK diff --git a/src/flamenco/rewards/fd_rewards.c b/src/flamenco/rewards/fd_rewards.c index 18c069a868..2021c56165 100644 --- a/src/flamenco/rewards/fd_rewards.c +++ b/src/flamenco/rewards/fd_rewards.c @@ -438,7 +438,6 @@ calculate_reward_points_partitioned( int err = fd_acc_mgr_view( slot_ctx->acc_mgr, slot_ctx->funk_txn, stake_acc, stake_acc_rec); if ( err != FD_ACC_MGR_SUCCESS && err != FD_ACC_MGR_ERR_UNKNOWN_ACCOUNT ) { FD_LOG_ERR(( "failed to read stake account from funk" )); - continue; } if ( err == FD_ACC_MGR_ERR_UNKNOWN_ACCOUNT ) { FD_LOG_DEBUG(( "stake account not found %s", FD_BASE58_ENC_32_ALLOCA( stake_acc->uc ) )); @@ -573,7 +572,6 @@ calculate_stake_vote_rewards_account( fd_vote_state_versioned_t vote_state_versioned[1] = {0}; if( fd_vote_state_versioned_decode( vote_state_versioned, &decode ) != 0 ) { FD_LOG_ERR(( "failed to decode vote state" )); - return; } /* Note, this doesn't actually redeem any rewards.. this is a misnomer. */ diff --git a/src/flamenco/runtime/fd_executor.c b/src/flamenco/runtime/fd_executor.c index 66cc982d4d..b416855057 100644 --- a/src/flamenco/runtime/fd_executor.c +++ b/src/flamenco/runtime/fd_executor.c @@ -1444,7 +1444,7 @@ fd_execute_txn_finalize( fd_exec_txn_ctx_t * txn_ctx, int ret = fd_acc_mgr_save_non_tpool( txn_ctx->acc_mgr, txn_ctx->funk_txn, acc_rec ); if( ret != FD_ACC_MGR_SUCCESS ) { - FD_LOG_ERR(( "failed to save edits to accounts" )); + FD_LOG_WARNING(( "failed to save edits to accounts" )); return -1; } diff --git a/src/flamenco/runtime/fd_rocksdb.c b/src/flamenco/runtime/fd_rocksdb.c index 780d7cbb9e..0b60c76067 100644 --- a/src/flamenco/runtime/fd_rocksdb.c +++ b/src/flamenco/runtime/fd_rocksdb.c @@ -361,8 +361,6 @@ fd_rocksdb_get_slot( ulong cf_idx, char const * key ) { default: /* all other cfs have the slot at the start */ return fd_ulong_bswap( *((ulong *)&key[0]) ); /* The key is just the slot number */ } - - return fd_ulong_bswap( *((ulong *)key) ); } void diff --git a/src/flamenco/runtime/fd_runtime.c b/src/flamenco/runtime/fd_runtime.c index 9a51de3578..f4302fcf68 100644 --- a/src/flamenco/runtime/fd_runtime.c +++ b/src/flamenco/runtime/fd_runtime.c @@ -1906,7 +1906,7 @@ fd_runtime_finalize_txns_tpool( fd_exec_slot_ctx_t * slot_ctx, // TODO: we need to use the txn ctx funk_txn, valloc, etc. int err = fd_acc_mgr_save_many_tpool( slot_ctx->acc_mgr, slot_ctx->funk_txn, accounts_to_save, acc_idx, tpool ); if( FD_UNLIKELY( err!=FD_ACC_MGR_SUCCESS ) ) { - FD_LOG_ERR(( "failed to save edits to accounts" )); + FD_LOG_WARNING(( "failed to save edits to accounts" )); return -1; } @@ -2848,9 +2848,9 @@ fd_runtime_publish_old_txns( fd_exec_slot_ctx_t * slot_ctx, FD_LOG_DEBUG(("publishing %s (slot %lu)", FD_BASE58_ENC_32_ALLOCA( &txn->xid ), txn->xid.ul[0])); fd_funk_start_write(funk); - ulong publish_err = fd_funk_txn_publish(funk, txn, 1); - if (publish_err == 0) { - FD_LOG_ERR(("publish err")); + ulong publish_err = fd_funk_txn_publish( funk, txn, 1 ); + if( publish_err == 0 ) { + FD_LOG_WARNING(( "fd_funk_txn_publish failed" )); return -1; } if( slot_ctx->status_cache ) { diff --git a/src/flamenco/runtime/fd_runtime_init.c b/src/flamenco/runtime/fd_runtime_init.c index 3ac4f01a2b..8e38b7f1bf 100644 --- a/src/flamenco/runtime/fd_runtime_init.c +++ b/src/flamenco/runtime/fd_runtime_init.c @@ -249,9 +249,9 @@ fd_runtime_delete_banks( fd_exec_slot_ctx_t * slot_ctx ) { address. */ static void -fd_feature_restore( fd_exec_slot_ctx_t * slot_ctx, +fd_feature_restore( fd_exec_slot_ctx_t * slot_ctx, fd_feature_id_t const * id, - uchar const acct[ static 32 ] ) { + uchar const acct[ static 32 ] ) { FD_BORROWED_ACCOUNT_DECL(acct_rec); int err = fd_acc_mgr_view(slot_ctx->acc_mgr, slot_ctx->funk_txn, (fd_pubkey_t *)acct, acct_rec); @@ -273,9 +273,8 @@ fd_feature_restore( fd_exec_slot_ctx_t * slot_ctx, .valloc = fd_scratch_virtual(), }; int decode_err = fd_feature_decode(feature, &ctx); - if (FD_UNLIKELY(decode_err != FD_BINCODE_SUCCESS)) - { - FD_LOG_ERR(("Failed to decode feature account %s (%d)", FD_BASE58_ENC_32_ALLOCA( acct ), decode_err)); + if( FD_UNLIKELY( decode_err != FD_BINCODE_SUCCESS ) ) { + FD_LOG_WARNING(( "Failed to decode feature account %s (%d)", FD_BASE58_ENC_32_ALLOCA( acct ), decode_err )); return; } diff --git a/src/flamenco/runtime/program/fd_bpf_loader_program.c b/src/flamenco/runtime/program/fd_bpf_loader_program.c index 0deac9cd25..e5660e9a39 100644 --- a/src/flamenco/runtime/program/fd_bpf_loader_program.c +++ b/src/flamenco/runtime/program/fd_bpf_loader_program.c @@ -886,7 +886,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) { uchar bump_seed = 0; err = fd_pubkey_find_program_address( instr_ctx, program_id, 1UL, seeds, &seed_sz, derived_address, &bump_seed ); if( FD_UNLIKELY( err ) ) { - FD_LOG_ERR(( "Unable to find a viable program address bump seed" )); // Solana panics, error code is undefined + FD_LOG_WARNING(( "fd_pubkey_find_program_address failed. Agave would panic here. Continuing ..." )); return err; } if( FD_UNLIKELY( memcmp( derived_address, programdata_key, sizeof(fd_pubkey_t) ) ) ) { diff --git a/src/flamenco/runtime/program/fd_bpf_program_util.c b/src/flamenco/runtime/program/fd_bpf_program_util.c index f331674035..24cfdc6caa 100644 --- a/src/flamenco/runtime/program/fd_bpf_program_util.c +++ b/src/flamenco/runtime/program/fd_bpf_program_util.c @@ -279,7 +279,6 @@ fd_bpf_scan_and_create_bpf_program_cache_entry_tpool( fd_exec_slot_ctx_t * slot_ fd_funk_txn_t * cache_txn = fd_funk_txn_prepare( funk, slot_ctx->funk_txn, &cache_xid, 1 ); if( !cache_txn ) { FD_LOG_ERR(( "fd_funk_txn_prepare() failed" )); - return -1; } fd_funk_txn_t * parent_txn = slot_ctx->funk_txn; @@ -322,7 +321,6 @@ fd_bpf_scan_and_create_bpf_program_cache_entry_tpool( fd_exec_slot_ctx_t * slot_ if( fd_funk_txn_publish_into_parent( funk, cache_txn, 1 ) != FD_FUNK_SUCCESS ) { FD_LOG_ERR(( "fd_funk_txn_publish_into_parent() failed" )); - return -1; } slot_ctx->funk_txn = parent_txn; @@ -345,7 +343,7 @@ fd_bpf_scan_and_create_bpf_program_cache_entry( fd_exec_slot_ctx_t * slot_ctx, fd_funk_txn_t * cache_txn = fd_funk_txn_prepare( funk, slot_ctx->funk_txn, &cache_xid, 1 ); if( !cache_txn ) { - FD_LOG_ERR(( "fd_funk_txn_prepare() failed" )); + FD_LOG_WARNING(( "fd_funk_txn_prepare() failed" )); return -1; } @@ -373,7 +371,7 @@ fd_bpf_scan_and_create_bpf_program_cache_entry( fd_exec_slot_ctx_t * slot_ctx, FD_LOG_DEBUG(( "loaded program cache: %lu", cnt)); if( fd_funk_txn_publish_into_parent( funk, cache_txn, 1 ) != FD_FUNK_SUCCESS ) { - FD_LOG_ERR(( "fd_funk_txn_publish_into_parent() failed" )); + FD_LOG_WARNING(( "fd_funk_txn_publish_into_parent() failed" )); return -1; } diff --git a/src/flamenco/snapshot/fd_snapshot.c b/src/flamenco/snapshot/fd_snapshot.c index 022a191af3..27286320a6 100644 --- a/src/flamenco/snapshot/fd_snapshot.c +++ b/src/flamenco/snapshot/fd_snapshot.c @@ -130,7 +130,6 @@ fd_snapshot_load( const char * snapshotfile, switch (snapshot_type) { case FD_SNAPSHOT_TYPE_UNSPECIFIED: FD_LOG_ERR(("fd_snapshot_load(\"%s\", verify-hash=%s, check-hash=%s, FD_SNAPSHOT_TYPE_UNSPECIFIED)", snapshotfile, verify_hash ? "true" : "false", check_hash ? "true" : "false")); - break; case FD_SNAPSHOT_TYPE_FULL: FD_LOG_NOTICE(("fd_snapshot_load(\"%s\", verify-hash=%s, check-hash=%s, FD_SNAPSHOT_TYPE_FULL)", snapshotfile, verify_hash ? "true" : "false", check_hash ? "true" : "false")); break; @@ -139,7 +138,6 @@ fd_snapshot_load( const char * snapshotfile, break; default: FD_LOG_ERR(("fd_snapshot_load(\"%s\", verify-hash=%s, check-hash=%s, huh?)", snapshotfile, verify_hash ? "true" : "false", check_hash ? "true" : "false")); - break; } fd_funk_start_write( slot_ctx->acc_mgr->funk ); diff --git a/src/flamenco/types/fd_types_yaml.c b/src/flamenco/types/fd_types_yaml.c index fd32ee8a1d..97a681c79a 100644 --- a/src/flamenco/types/fd_types_yaml.c +++ b/src/flamenco/types/fd_types_yaml.c @@ -342,7 +342,6 @@ fd_flamenco_yaml_walk( void * _self, break; default: FD_LOG_CRIT(( "unknown type %#x", (uint)type )); - break; } /* Remember that we processed an element in the current level */ diff --git a/src/funk/fd_funk_part.c b/src/funk/fd_funk_part.c index c9cac823c8..244cccc15a 100644 --- a/src/funk/fd_funk_part.c +++ b/src/funk/fd_funk_part.c @@ -163,7 +163,6 @@ fd_funk_set_num_partitions( fd_funk_t * funk, uint num_part ) { partvec = (fd_funk_partvec_t *)fd_alloc_malloc_at_least( alloc, fd_funk_partvec_align(), fd_funk_partvec_footprint(num_part), &tmp_max ); if( FD_UNLIKELY( !partvec ) ) { FD_LOG_ERR(( "partvec alloc failed" )); - return; } partvec->num_part = num_part; funk->partvec_gaddr = fd_wksp_gaddr_fast( wksp, partvec );