Skip to contentSkip to conversation

interconnect: qcom: icc-rpm: Initialize ret variable to fix smatch error

PATCH In review [email protected] 2 participants 4 messages Jul 17, 2023

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 interconnect: qcom: icc-rpm: Initialize ret variable to fix smatch error

From: Georgi Djakov <[email protected]>

Fix the following smatch error:
drivers/interconnect/qcom/icc-rpm.c:243 qcom_icc_rpm_set() error: uninitialized symbol 'ret'.

Fixes 32846c4a8f2a ("interconnect: qcom: icc-rpm: Set bandwidth on both contexts")
---
 drivers/interconnect/qcom/icc-rpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/interconnect/qcom/icc-rpm.c +1 -1
index 612390b9eb18..6718cc648d75 100644
@@ -206,7 +206,7 @@ static int qcom_icc_qos_set(struct icc_node *node)
 
 static int qcom_icc_rpm_set(struct qcom_icc_node *qn, u64 *bw)
 {
-	int ret, rpm_ctx = 0;
+	int ret = 0, rpm_ctx = 0;
 	u64 bw_bps;
 
 	if (qn->qos.ap_owned)
#1 lore raw
Quoted 7 lines · On Mon, Jul 17, 2023 at 10:34:29AM +0300, [email protected] wrote:

From: Georgi Djakov <[email protected]>

Fix the following smatch error:
drivers/interconnect/qcom/icc-rpm.c:243 qcom_icc_rpm_set() error: uninitialized symbol 'ret'.

Fixes 32846c4a8f2a ("interconnect: qcom: icc-rpm: Set bandwidth on both contexts")

Thanks for spotting this!

Quoted 9 lines
---
 drivers/interconnect/qcom/icc-rpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/interconnect/qcom/icc-rpm.c +0 -0
index 612390b9eb18..6718cc648d75 100644

drivers/interconnect/qcom/icc-rpm.c static int qcom_icc_qos_set(struct icc_node *node) · line 212

Quoted 8 lines
drivers/interconnect/qcom/icc-rpm.c +1 -1
@@ -206,7 +206,7 @@ static int qcom_icc_qos_set(struct icc_node *node)
 
 static int qcom_icc_rpm_set(struct qcom_icc_node *qn, u64 *bw)
 {
-	int ret, rpm_ctx = 0;
+	int ret = 0, rpm_ctx = 0;
 	u64 bw_bps;
 
 	if (qn->qos.ap_owned)

I think it would be a bit clearer to change the "return ret;" at the end of the function to "return 0;". The ret variable is only used inside the for loop and always handled there, so we always want to return 0 when reaching the end of the function.

Thanks,
Stephan

author maintainer
#2 lore raw

PATCH v2 1/1 interconnect: qcom: icc-rpm: Explicitly return 0 at the end of the function

From: Georgi Djakov <[email protected]>

Fix the following smatch error:
drivers/interconnect/qcom/icc-rpm.c:243 qcom_icc_rpm_set() error: uninitialized symbol 'ret'.

Fixes 32846c4a8f2a ("interconnect: qcom: icc-rpm: Set bandwidth on both contexts")

---
v2: Just return 0 when reaching the end of the function. (Thanks Stephan!)
v1: https://lore.kernel.org/r/[email protected]

 drivers/interconnect/qcom/icc-rpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/interconnect/qcom/icc-rpm.c +1 -1
index 612390b9eb18..2c16917ba1fd 100644
@@ -240,7 +240,7 @@ static int qcom_icc_rpm_set(struct qcom_icc_node *qn, u64 *bw)
 		}
 	}
 
-	return ret;
+	return 0;
 }
 
 /**
Reviewed-by on v2 1/1
#3 lore raw

Re: [PATCH v2] interconnect: qcom: icc-rpm: Explicitly return 0 at the end of the function

Quoted 19 lines · On Mon, Jul 17, 2023 at 03:55:34PM +0300, [email protected] wrote:

From: Georgi Djakov <[email protected]>

Fix the following smatch error:
drivers/interconnect/qcom/icc-rpm.c:243 qcom_icc_rpm_set() error: uninitialized symbol 'ret'.

Fixes 32846c4a8f2a ("interconnect: qcom: icc-rpm: Set bandwidth on both contexts")

---
v2: Just return 0 when reaching the end of the function. (Thanks Stephan!)
v1: https://lore.kernel.org/r/[email protected]

 drivers/interconnect/qcom/icc-rpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/interconnect/qcom/icc-rpm.c +0 -0
index 612390b9eb18..2c16917ba1fd 100644

drivers/interconnect/qcom/icc-rpm.c static int qcom_icc_rpm_set(struct qcom_icc_node *qn, u64 *bw) · line 246

Quoted 8 lines
drivers/interconnect/qcom/icc-rpm.c +1 -1
@@ -240,7 +240,7 @@ static int qcom_icc_rpm_set(struct qcom_icc_node *qn, u64 *bw)
 		}
 	}
 
-	return ret;
+	return 0;
 }
 
 /**

Thanks!