Skip to content

Commit

Permalink
fofb_cc: work around cppcheck warning.
Browse files Browse the repository at this point in the history
Without this change, cppcheck would accuse that target_reg was
uninitialized when used, even though a reference had been captured, and
the lambda was only called after it was initialized.

We can reorder the code so this false-positive isn't triggered, and
without accidentally suppresing any warnings from other tools (as might
have happened if we had initialized target_reg to nullptr).
  • Loading branch information
ericonr committed Jan 15, 2025
1 parent 0701ce6 commit c82469e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/fofb_cc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -186,13 +186,13 @@ void Controller::encode_params()
{
get_internal_values();

uint32_t *target_reg;
uint32_t *target_reg = &regs.cfg_val;

auto insert_cfg = [&target_reg](auto option, uint32_t mask) {
if (option)
insert_bit(*target_reg, *option, mask);
};

target_reg = &regs.cfg_val;
insert_cfg(err_clr, FOFB_CC_REGS_CFG_VAL_ERR_CLR);
insert_cfg(cc_enable, FOFB_CC_REGS_CFG_VAL_CC_ENABLE);
insert_cfg(tfs_override, FOFB_CC_REGS_CFG_VAL_TFS_OVERRIDE);
Expand Down

0 comments on commit c82469e

Please sign in to comment.