Skip to content

Commit 3955017

Browse files
andrula-songkv2019i
authored andcommitted
Dummy smart_amp: copy input_pins and output_pin separately.
The original code confuses static code analyzers since it was relying on the fact that we have the 2x input and 1x output pin config in adjacent position in smart_amp_data struct similarly to the extended module configuration. While it works, it is not a good practice. Split the copy of input and output pin formats to make the code obvious and less error prone. Fixes: andrula-song@ bcc1407 ("smart_amp_test: Split the module config and blob receiving for IPC4") Signed-off-by: Andrula Song <andrula.song@intel.com>
1 parent a675edf commit 3955017

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/samples/audio/smart_amp_test_ipc4.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ static int smart_amp_init(struct processing_module *mod)
4444
struct smart_amp_data *sad;
4545
struct comp_dev *dev = mod->dev;
4646
struct module_data *mod_data = &mod->priv;
47-
int bs;
47+
const size_t in_size = sizeof(struct ipc4_input_pin_format) * SMART_AMP_NUM_IN_PINS;
48+
const size_t out_size = sizeof(struct ipc4_output_pin_format) * SMART_AMP_NUM_OUT_PINS;
4849
int ret;
4950
const struct ipc4_base_module_extended_cfg *base_cfg = mod_data->cfg.init_data;
5051

@@ -70,9 +71,10 @@ static int smart_amp_init(struct processing_module *mod)
7071
}
7172

7273
/* Copy the pin formats */
73-
bs = sizeof(sad->ipc4_cfg.input_pins) + sizeof(sad->ipc4_cfg.output_pin);
74-
memcpy_s(sad->ipc4_cfg.input_pins, bs,
75-
base_cfg->base_cfg_ext.pin_formats, bs);
74+
memcpy_s(sad->ipc4_cfg.input_pins, in_size,
75+
base_cfg->base_cfg_ext.pin_formats, in_size);
76+
memcpy_s(&sad->ipc4_cfg.output_pin, out_size,
77+
&base_cfg->base_cfg_ext.pin_formats[in_size], out_size);
7678

7779
mod->simple_copy = true;
7880

0 commit comments

Comments
 (0)