Skip to contentSkip to conversation

fpga: dfl: Fix dead store

PATCH Superseded [email protected] 2 participants 3 messages Jun 6, 2020 – Jun 8, 2020 FPGA manager framework

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

[email protected]

author reviewer
#0 lore raw

cover fpga: dfl: Fix dead store

From: Tom Rix <[email protected]>

Repo linux-next
Tag next-20200605

A couple of fixes for dead stores found by clang's sa tool scan-build

Tom Rix (1):
Fix dead store

 drivers/fpga/fpga-bridge.c | 6 ++----
 drivers/fpga/fpga-mgr.c    | 4 +---
 2 files changed, 3 insertions(+), 7 deletions(-)
Signature · 1 line
2.26.0
author reviewer
#1 lore raw

PATCH 1/1 fpga: dfl: Fix dead store

From: Tom Rix <[email protected]>

Using clang's scan-build/view this issue was flagged in fpga-mgr.c

drivers/fpga/fpga-mgr.c:585:3: warning: Value stored to 'ret' is never read [deadcode.DeadStores]

                  ret = id;

A similar issue was flagged in fpga-bridge.

So remove the unused stores.

---
 drivers/fpga/fpga-bridge.c | 6 ++----
 drivers/fpga/fpga-mgr.c    | 4 +---
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/fpga/fpga-bridge.c +2 -4
index 4bab9028940a..2deccacc3aa7 100644
@@ -328,7 +328,7 @@ struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name,
 				       void *priv)
 {
 	struct fpga_bridge *bridge;
-	int id, ret = 0;
+	int id, ret;
 
 	if (!name || !strlen(name)) {
 		dev_err(dev, "Attempt to register with no name!\n");
@@ -340,10 +340,8 @@ struct fpga_bridge *fpga_bridge_create(struct device *dev, const char *name,
 		return NULL;
 
 	id = ida_simple_get(&fpga_bridge_ida, 0, 0, GFP_KERNEL);
-	if (id < 0) {
-		ret = id;
+	if (id < 0)
 		goto error_kfree;
-	}
 
 	mutex_init(&bridge->mutex);
 	INIT_LIST_HEAD(&bridge->node);
drivers/fpga/fpga-mgr.c +1 -3
index e05104f5e40c..f38bab01432e 100644
@@ -581,10 +581,8 @@ struct fpga_manager *fpga_mgr_create(struct device *dev, const char *name,
 		return NULL;
 
 	id = ida_simple_get(&fpga_mgr_ida, 0, 0, GFP_KERNEL);
-	if (id < 0) {
-		ret = id;
+	if (id < 0)
 		goto error_kfree;
-	}
 
 	mutex_init(&mgr->ref_mutex);
 
Signature · 1 line
2.26.0
#2 lore raw
Quoted 9 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of [email protected]
Sent: Sunday, June 7, 2020 5:03 AM
To: [email protected]
Cc: [email protected]; [email protected]; Tom Rix <[email protected]>
Subject: [PATCH 1/1] fpga: dfl: Fix dead store

Thanks for this patch, looks good to me, but this patch is not related to dfl, so please remove dfl from the title to avoid confusion. : ) or maybe it can be split into two patches:
fpga: mgr: xxx
fpga: bridge: xxx

Thanks
Hao

Quoted 64 lines

From: Tom Rix <[email protected]>

Using clang's scan-build/view this issue was flagged in fpga-mgr.c

drivers/fpga/fpga-mgr.c:585:3: warning: Value stored to 'ret' is never read
[deadcode.DeadStores]

                  ret = id;

A similar issue was flagged in fpga-bridge.

So remove the unused stores.

---
 drivers/fpga/fpga-bridge.c | 6 ++----
 drivers/fpga/fpga-mgr.c    | 4 +---
 2 files changed, 3 insertions(+), 7 deletions(-)
drivers/fpga/fpga-bridge.c +1 -1
index 4bab9028940a..2deccacc3aa7 100644
@@ -328,7 +328,7 @@ struct fpga_bridge *fpga_bridge_create(struct device
 *dev, const char *name,
 				       void *priv)
 {
 	struct fpga_bridge *bridge;
-	int id, ret = 0;
+	int id, ret;
 
 	if (!name || !strlen(name)) {
drivers/fpga/fpga-bridge.c +1 -3
 		dev_err(dev, "Attempt to register with no name!\n");
@@ -340,10 +340,8 @@ struct fpga_bridge *fpga_bridge_create(struct
 device *dev, const char *name,
 		return NULL;
 
 	id = ida_simple_get(&fpga_bridge_ida, 0, 0, GFP_KERNEL);
-	if (id < 0) {
-		ret = id;
+	if (id < 0)
 		goto error_kfree;
-	}
 
 	mutex_init(&bridge->mutex);
drivers/fpga/fpga-bridge.c +0 -0
 	INIT_LIST_HEAD(&bridge->node);
drivers/fpga/fpga-mgr.c +1 -4
index e05104f5e40c..f38bab01432e 100644
@@ -581,10 +581,8 @@ struct fpga_manager *fpga_mgr_create(struct
 device *dev, const char *name,
 		return NULL;
 
 	id = ida_simple_get(&fpga_mgr_ida, 0, 0, GFP_KERNEL);
-	if (id < 0) {
-		ret = id;
+	if (id < 0)
 		goto error_kfree;
-	}
 
 	mutex_init(&mgr->ref_mutex);
 
--

2.26.0