Skip to contentSkip to conversation

drivers/base/cpu: remove redundant initialization of variable retval

PATCH Superseded Colin King 2 participants 2 messages Feb 17, 2021 – Feb 18, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 drivers/base/cpu: remove redundant initialization of variable retval

From: Colin Ian King <[email protected]>

The variable retval is being initialized with a value that is never read and it is being updated later with a new value. The initialization is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/base/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/cpu.c +1 -1
index 8f1d6569564c..2e834cd315d8 100644
@@ -409,7 +409,7 @@ __cpu_device_create(struct device *parent, void *drvdata,
 		    const char *fmt, va_list args)
 {
 	struct device *dev = NULL;
-	int retval = -ENODEV;
+	int retval;
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev) {
Signature · 1 line
2.30.0
#1 lore raw
Quoted 18 lines · Colin King

From: Colin Ian King <[email protected]>

The variable retval is being initialized with a value that is never read and it is being updated later with a new value. The initialization is redundant and can be removed.

Addresses-Coverity: ("Unused value")

---
 drivers/base/cpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/cpu.c +0 -0
index 8f1d6569564c..2e834cd315d8 100644

drivers/base/cpu.c __cpu_device_create(struct device *parent, void *drvdata, · line 412

Quoted 4 lines
drivers/base/cpu.c +0 -1
@@ -409,7 +409,7 @@ __cpu_device_create(struct device *parent, void *drvdata,
                    const char *fmt, va_list args)
 {
        struct device *dev = NULL;
-       int retval = -ENODEV;

Might as well init it to -ENOMEM and drop the assignment below.

Quoted 5 lines
drivers/base/cpu.c +1 -1
+       int retval;
 
        dev = kzalloc(sizeof(*dev), GFP_KERNEL);
        if (!dev) {
--