Skip to content

Commit 1b3272a

Browse files
two-heartripatel-fd
authored andcommitted
runtime: side effect free max calc
1 parent 6b70fd0 commit 1b3272a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/flamenco/runtime/program/fd_vote_program.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1853,20 +1853,20 @@ process_vote_with_account( fd_borrowed_account_t * vote_account,
18531853
return FD_EXECUTOR_INSTR_ERR_CUSTOM_ERR;
18541854
}
18551855

1856-
ulong * max = deq_ulong_peek_head( vote->slots ) ? deq_ulong_peek_head( vote->slots ) : NULL;
1856+
ulong max = deq_ulong_peek_head( vote->slots ) ? *deq_ulong_peek_head( vote->slots ) : 0UL;
18571857
// https://github.com/anza-xyz/agave/blob/v2.0.1/programs/vote/src/vote_state/mod.rs#L1127
18581858
for( deq_ulong_iter_t iter = deq_ulong_iter_init( vote->slots );
18591859
!deq_ulong_iter_done( vote->slots, iter );
18601860
iter = deq_ulong_iter_next( vote->slots, iter ) ) {
18611861
ulong * ele = deq_ulong_iter_ele( vote->slots, iter );
1862-
*max = fd_ulong_max( *max, *ele );
1862+
max = fd_ulong_max( max, *ele );
18631863
}
18641864
if( FD_UNLIKELY( !max ) ) {
18651865
ctx->txn_ctx->custom_err = FD_VOTE_ERR_EMPTY_SLOTS;
18661866
return FD_EXECUTOR_INSTR_ERR_CUSTOM_ERR;
18671867
}
18681868
// https://github.com/anza-xyz/agave/blob/v2.0.1/programs/vote/src/vote_state/mod.rs#L1131
1869-
rc = process_timestamp( &vote_state, *max, *vote->timestamp, ctx );
1869+
rc = process_timestamp( &vote_state, max, *vote->timestamp, ctx );
18701870
if( FD_UNLIKELY( rc ) ) return rc;
18711871
}
18721872

0 commit comments

Comments
 (0)