Skip to contentSkip to conversation

ASoC: mxs-saif: Use a signed integer for error value

PATCH Superseded Fabio Estevam 2 participants 2 messages Jan 8, 2013

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: mxs-saif: Use a signed integer for error value

saif->id and saif->master_id are unsigned, so they can not be negative.

Fix the following warning when building with W=1 option:

sound/soc/mxs/mxs-saif.c: In function 'mxs_saif_probe':
sound/soc/mxs/mxs-saif.c:676:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] sound/soc/mxs/mxs-saif.c:688:3: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits] sound/soc/mxs/mxs-saif.c:692:2: warning: comparison of unsigned expression < 0 is always false [-Wtype-limits]

Use a signed variable 'ret' to handle the error values.

---
 sound/soc/mxs/mxs-saif.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
sound/soc/mxs/mxs-saif.c +7 -7
index 752675d..a920206 100644
@@ -672,9 +672,9 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	if (!saif)
 		return -ENOMEM;
 
-	saif->id = of_alias_get_id(np, "saif");
-	if (saif->id < 0)
-		return saif->id;
+	ret = of_alias_get_id(np, "saif");
+	if (ret < 0)
+		return ret;
 	/*
 	 * If there is no "fsl,saif-master" phandle, it's a saif
 	 * master.  Otherwise, it's a slave and its phandle points
@@ -684,12 +684,12 @@ static int mxs_saif_probe(struct platform_device *pdev)
 	if (!master) {
 		saif->master_id = saif->id;
 	} else {
-		saif->master_id = of_alias_get_id(master, "saif");
-		if (saif->master_id < 0)
-			return saif->master_id;
+		ret = of_alias_get_id(master, "saif");
+		if (ret < 0)
+			return ret;
 	}
 
-	if (saif->master_id < 0 || saif->master_id >= ARRAY_SIZE(mxs_saif)) {
+	if (saif->master_id >= ARRAY_SIZE(mxs_saif)) {
 		dev_err(&pdev->dev, "get wrong master id\n");
 		return -EINVAL;
 	}
Signature · 1 line
1.7.9.5
#1 lore raw

sound/soc/mxs/mxs-saif.c static int mxs_saif_probe(struct platform_device *pdev) · line 677

Quoted 6 lines · Fabio Estevam
sound/soc/mxs/mxs-saif.c +3 -3
-	saif->id = of_alias_get_id(np, "saif");
-	if (saif->id < 0)
-		return saif->id;
+	ret = of_alias_get_id(np, "saif");
+	if (ret < 0)
+		return ret;

Why not remove said->id completely if we don't need to store a value there? Alternatively, this needs to store the id if the return value is OK.