Skip to content

Commit 8ad0b83

Browse files
plbossartbroonie
authored andcommitted
ASoC: soc-core: remove always-false path
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> Link: https://lore.kernel.org/r/20220421162505.302132-1-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 2a68ff8 commit 8ad0b83

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

sound/soc/soc-core.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2763,18 +2763,18 @@ int snd_soc_of_parse_audio_simple_widgets(struct snd_soc_card *card,
27632763
"ASoC: Property '%s' does not exist\n", propname);
27642764
return -EINVAL;
27652765
}
2766+
if (!num_widgets) {
2767+
dev_err(card->dev, "ASoC: Property '%s's length is zero\n",
2768+
propname);
2769+
return -EINVAL;
2770+
}
27662771
if (num_widgets & 1) {
27672772
dev_err(card->dev,
27682773
"ASoC: Property '%s' length is not even\n", propname);
27692774
return -EINVAL;
27702775
}
27712776

27722777
num_widgets /= 2;
2773-
if (!num_widgets) {
2774-
dev_err(card->dev, "ASoC: Property '%s's length is zero\n",
2775-
propname);
2776-
return -EINVAL;
2777-
}
27782778

27792779
widgets = devm_kcalloc(card->dev, num_widgets, sizeof(*widgets),
27802780
GFP_KERNEL);

0 commit comments

Comments
 (0)