Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Link: https://patch.msgid.link/20250206094914.21135-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Peter Ujfalusi and committed by
Mark Brown
5ea46b43 3f78762d

+2 -3
+2 -3
sound/soc/sof/ipc4-pcm.c
··· 610 610 * Copier does not change sampling rate, so we 611 611 * need to only consider the input pin information. 612 612 */ 613 + be_rate = pin_fmts[0].audio_fmt.sampling_frequency; 613 614 for (i = 0; i < num_input_formats; i++) { 614 615 unsigned int val = pin_fmts[i].audio_fmt.sampling_frequency; 615 616 616 - if (i == 0) 617 - be_rate = val; 618 - else if (val != be_rate) 617 + if (val != be_rate) 619 618 single_be_rate = false; 620 619 621 620 if (val == fe_rate) {