Skip to content

chore: fix static analysis warnings #5148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/disco/archiver/fd_archiver_backtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ after_frag( fd_archiver_backtest_tile_ctx_t * ctx,
ulong sz FD_PARAM_UNUSED,
ulong tsorig FD_PARAM_UNUSED,
ulong tspub FD_PARAM_UNUSED,
fd_stem_context_t * stem FD_PARAM_UNUSED ) {
fd_stem_context_t * stem ) {
if( FD_LIKELY( ctx->replay_notification.type==FD_REPLAY_SLOT_TYPE ) ) {
ulong slot = ctx->replay_notification.slot_exec.slot;
ulong slot_be = fd_ulong_bswap(slot);
Expand Down
2 changes: 1 addition & 1 deletion src/discof/eqvoc/fd_eqvoc_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ during_frag( fd_eqvoc_tile_ctx_t * ctx,

uchar const * packet = fd_chunk_to_laddr_const( ctx->shred_net_in_mem, chunk );
fd_shred_t * shred = (fd_shred_t *)( packet + fd_disco_netmux_sig_hdr_sz( sig ) );
memcpy( &ctx->shred, shred, sizeof(fd_shred_t) );
ctx->shred = *shred;
Comment on lines 134 to +135
Copy link
Contributor

@ripatel-fd ripatel-fd May 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of a strict aliasing violation. It was fine before due to memcpy. Can you rewrite it like so?

memcpy( &ctx->shred, packet + fd_disco_netmux_sig_hdr_sz( sig ), sizeof(fd_shred_t) );

}
}

Expand Down
2 changes: 1 addition & 1 deletion src/discof/repair/fd_repair_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ after_frag( fd_repair_tile_ctx_t * ctx,
ulong seq FD_PARAM_UNUSED,
ulong sig FD_PARAM_UNUSED,
ulong sz,
ulong tsorig FD_PARAM_UNUSED,
ulong tsorig,
ulong tspub FD_PARAM_UNUSED,
fd_stem_context_t * stem ) {

Expand Down
10 changes: 5 additions & 5 deletions src/discof/replay/fd_replay_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,7 @@ block_finalize_tiles_cb( void * para_arg_1,
happiness, in order, executable immediately as long as the mcache
wasn't overrun. */
static int
before_frag( fd_replay_tile_ctx_t * ctx FD_PARAM_UNUSED,
before_frag( fd_replay_tile_ctx_t * ctx,
ulong in_idx,
ulong seq,
ulong sig ) {
Expand Down Expand Up @@ -1130,8 +1130,8 @@ publish_slot_notifications( fd_replay_tile_ctx_t * ctx,
msg->slot_exec.height = block_entry_block_height;
msg->slot_exec.transaction_count = fork->slot_ctx->slot_bank.transaction_count;
msg->slot_exec.shred_cnt = fork->slot_ctx->shred_cnt;
memcpy( &msg->slot_exec.bank_hash, &fork->slot_ctx->slot_bank.banks_hash, sizeof( fd_hash_t ) );
memcpy( &msg->slot_exec.block_hash, &ctx->blockhash, sizeof( fd_hash_t ) );
msg->slot_exec.bank_hash = fork->slot_ctx->slot_bank.banks_hash;
msg->slot_exec.block_hash = ctx->blockhash;
memcpy( &msg->slot_exec.identity, ctx->validator_identity_pubkey, sizeof( fd_pubkey_t ) );
msg->slot_exec.ts = tsorig;
NOTIFY_END;
Expand Down Expand Up @@ -1627,7 +1627,7 @@ exec_slice( fd_replay_tile_ctx_t * ctx,
ctx->slice_exec_ctx.wmark += pay_sz;

fd_runtime_public_txn_msg_t * exec_msg = (fd_runtime_public_txn_msg_t *)fd_chunk_to_laddr( exec_out->mem, exec_out->chunk );
memcpy( &exec_msg->txn, &txn_p, sizeof(fd_txn_p_t) );
exec_msg->txn = txn_p;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fd_txn_p_t is an atypical compound struct. IMO we should keep the memcpy here...


fd_fork_t * fork = fd_fork_frontier_ele_query( ctx->forks->frontier,
&slot,
Expand Down Expand Up @@ -1701,7 +1701,7 @@ exec_slice( fd_replay_tile_ctx_t * ctx,
FD_COMPILER_MFENCE();
block_info->flags = fd_uchar_clear_bit( block_info->flags, FD_BLOCK_FLAG_REPLAYING );
memcpy( &block_info->block_hash, hdr->hash, sizeof(fd_hash_t) );
memcpy( &block_info->bank_hash, &fork->slot_ctx->slot_bank.banks_hash, sizeof(fd_hash_t) );
block_info->bank_hash = fork->slot_ctx->slot_bank.banks_hash;

fd_block_map_publish( query );
ctx->flags = EXEC_FLAG_FINISHED_SLOT;
Expand Down
2 changes: 1 addition & 1 deletion src/discof/rpcserver/fd_rpc_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -2434,7 +2434,7 @@ fd_rpc_create_ctx(fd_rpcserver_args_t * args, fd_rpc_ctx_t ** ctx_p) {
if( bind(gctx->tpu_socket, (const struct sockaddr*)fd_type_pun_const(&addrLocal), sizeof(addrLocal)) == -1 ) {
FD_LOG_ERR(( "bind failed (%i-%s)", errno, strerror( errno ) ));
}
memcpy( &gctx->tpu_addr, &args->tpu_addr, sizeof(struct sockaddr_in) );
gctx->tpu_addr = args->tpu_addr;

void * mem = fd_valloc_malloc( valloc, fd_rpc_acct_map_align(), fd_rpc_acct_map_footprint( FD_RPC_ACCT_MAP_POOL_SIZE/2 ) );
gctx->acct_map = fd_rpc_acct_map_join( fd_rpc_acct_map_new( mem, FD_RPC_ACCT_MAP_POOL_SIZE/2, 0 ) );
Expand Down
8 changes: 4 additions & 4 deletions src/discof/store/fd_storei_tile.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,10 @@ after_frag( fd_store_tile_ctx_t * ctx,
ulong in_idx,
ulong seq FD_PARAM_UNUSED,
ulong sig FD_PARAM_UNUSED,
ulong sz FD_PARAM_UNUSED,
ulong tsorig FD_PARAM_UNUSED,
ulong tspub FD_PARAM_UNUSED,
fd_stem_context_t * stem FD_PARAM_UNUSED ) {
ulong sz,
ulong tsorig,
ulong tspub,
fd_stem_context_t * stem ) {
return;

ulong const in_kind = ctx->in_kind[ in_idx ];
Expand Down
4 changes: 2 additions & 2 deletions src/flamenco/runtime/program/fd_bpf_loader_program.c
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) {

/* copy in the authority public key into the authority address.
https://github.com/anza-xyz/agave/blob/v2.1.14/programs/bpf_loader/src/lib.rs#L926-L928 */
memcpy( account_state->inner.buffer.authority_address, new_authority, sizeof(fd_pubkey_t) );
*account_state->inner.buffer.authority_address = *new_authority;

err = fd_bpf_loader_v3_program_set_state( &account, account_state );
if( FD_UNLIKELY( err!=FD_BINCODE_SUCCESS ) ) {
Expand All @@ -1431,7 +1431,7 @@ process_loader_upgradeable_instruction( fd_exec_instr_ctx_t * instr_ctx ) {
/* copy in the authority public key into the upgrade authority address.
https://github.com/anza-xyz/agave/blob/v2.1.14/programs/bpf_loader/src/lib.rs#L946-L949 */
if( new_authority ) {
memcpy( account_state->inner.program_data.upgrade_authority_address, new_authority, sizeof(fd_pubkey_t) );
*account_state->inner.program_data.upgrade_authority_address = *new_authority;
} else {
account_state->inner.program_data.upgrade_authority_address = NULL;
}
Expand Down
Loading