* [PATCH] ASoC: soc-core: remove always-false path
@ 2022-04-21 16:25 Pierre-Louis Bossart
2022-04-22 23:17 ` Mark Brown
0 siblings, 1 reply; 2+ messages in thread
From: Pierre-Louis Bossart @ 2022-04-21 16:25 UTC (permalink / raw)
To: alsa-devel
Cc: tiwai, Bard Liao, Pierre-Louis Bossart, Rander Wang, broonie,
Péter Ujfalusi
cppcheck throws the following warning:
sound/soc/soc-core.c:2773:6: style: Condition '!num_widgets' is always
false [knownConditionTrueFalse]
if (!num_widgets) {
^
sound/soc/soc-core.c:2761:18: note: Assuming that condition
'num_widgets<0' is not redundant
if (num_widgets < 0) {
^
sound/soc/soc-core.c:2766:18: note: Assuming condition is false
if (num_widgets & 1) {
^
sound/soc/soc-core.c:2772:2: note: Compound assignment '/=', assigned
value is 0
num_widgets /= 2;
^
We should check upfront all error conditions.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com>
Reviewed-by: Rander Wang <rander.wang@intel.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
---
sound/soc/soc-core.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
index aa687fd126db2..d68e64b73eea7 100644
--- a/sound/soc/soc-core.c
+++ b/sound/soc/soc-core.c
@@ -2763,6 +2763,11 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
"ASoC: Property '%s' does not exist\n", propname);
return -EINVAL;
}
+ if (!num_widgets) {
+ dev_err(card->dev, "ASoC: Property '%s's length is zero\n",
+ propname);
+ return -EINVAL;
+ }
if (num_widgets & 1) {
dev_err(card->dev,
"ASoC: Property '%s' length is not even\n", propname);
@@ -2770,11 +2775,6 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
}
num_widgets /= 2;
- if (!num_widgets) {
- dev_err(card->dev, "ASoC: Property '%s's length is zero\n",
- propname);
- return -EINVAL;
- }
widgets = devm_kcalloc(card->dev, num_widgets, sizeof(*widgets),
GFP_KERNEL);
--
2.30.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ASoC: soc-core: remove always-false path
2022-04-21 16:25 [PATCH] ASoC: soc-core: remove always-false path Pierre-Louis Bossart
@ 2022-04-22 23:17 ` Mark Brown
0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2022-04-22 23:17 UTC (permalink / raw)
To: alsa-devel, pierre-louis.bossart
Cc: tiwai, peter.ujfalusi, yung-chuan.liao, rander.wang
On Thu, 21 Apr 2022 11:25:05 -0500, Pierre-Louis Bossart wrote:
> cppcheck throws the following warning:
>
> sound/soc/soc-core.c:2773:6: style: Condition '!num_widgets' is always
> false [knownConditionTrueFalse]
> if (!num_widgets) {
> ^
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: soc-core: remove always-false path
commit: 8ad0b83e0079564989ccbe5b864cc265a0f5a14d
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-22 23:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-21 16:25 [PATCH] ASoC: soc-core: remove always-false path Pierre-Louis Bossart
2022-04-22 23:17 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.