Skip to content

Commit b3b2051

Browse files
ujfalusiranj063
authored andcommitted
ASoC: SOF: ipc4-pcm: Move out be_rate initialization from for loop in fixup
Instead of initializing the be_rate within the loop by checking i == 0 at each iteration, move the be_rate reference initialization from the loop. For BE single rate check we will have single comparison done at each iteration compared to two in case the num_input_formats were higher than 1. We still need to run the loop from index 0 to check for FE-BE rate match. The patch also fixes bogus reports from gcc static analyzer thinking that be_rate is used uninitialized later in the function (which was not true). Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent f63ed0e commit b3b2051

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

sound/soc/sof/ipc4-pcm.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,12 +612,11 @@ static int sof_ipc4_pcm_dai_link_fixup_rate(struct snd_sof_dev *sdev,
612612
* Copier does not change sampling rate, so we
613613
* need to only consider the input pin information.
614614
*/
615+
be_rate = pin_fmts[0].audio_fmt.sampling_frequency;
615616
for (i = 0; i < num_input_formats; i++) {
616617
unsigned int val = pin_fmts[i].audio_fmt.sampling_frequency;
617618

618-
if (i == 0)
619-
be_rate = val;
620-
else if (val != be_rate)
619+
if (val != be_rate)
621620
single_be_rate = false;
622621

623622
if (val == fe_rate) {

0 commit comments

Comments
 (0)