Re: [PATCH v2] sound: fix uninit-value in sof_ipc4_pcm_dai_link_fixup_rate

From: Suraj Sonawane
Date: Wed Nov 06 2024 - 03:34:36 EST


On 06/11/24 00:37, Mark Brown wrote:
On Tue, Nov 05, 2024 at 04:20:23PM +0530, Suraj Sonawane wrote:

Thank you, Mark and Péter, for the guidance. I understand now that, while
the copier should always have at least one input format, static analysis
tools can’t detect this. Based on your suggestions, I’ve considered the
following possible solutions to address the issue:

1. Add a WARN_ON_ONCE(!num_input_formats) check: This would issue a warning
and return an error if num_input_formats is unexpectedly zero, ensuring we
handle any edge cases explicitly.

2. Return an error if no input formats are available: Implementing the
following check could provide immediate feedback if num_input_formats is
zero:
if (num_input_formats <= 0) {
dev_err(sdev->dev, "No input formats available\n");
return -EINVAL; // Return an error if there are no formats
}

Would it be preferable to proceed with the WARN_ON_ONCE(!num_input_formats)
approach, or is there a preferred alternative from the options above?

I don't have a super strong preference between the two options.
Thank you for the clarification. I’ll study the best approach in more detail and will send the patch in a while.

Thanks again for your time and feedback!