lkml.org 
[lkml]   [2021]   [Feb]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH][V2] drivers/base/cpu: remove redundant assignment of variable retval
Date
From: Colin Ian King <colin.king@canonical.com>

The variable retval is being initialized with a value that is never read
and it is being updated later with a new value. Clean this up by
initializing retval to -ENOMEM and remove the assignment to retval
on the !dev failure path.

Kudos to Rafael for the improved fix suggestion.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
V1: Remove initialization of retval
V2: Initialiation of retval with -ENOMEM and remove assignment in
!dev failure path.
---
drivers/base/cpu.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 8f1d6569564c..2b9e41377a07 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -409,13 +409,11 @@ __cpu_device_create(struct device *parent, void *drvdata,
const char *fmt, va_list args)
{
struct device *dev = NULL;
- int retval = -ENODEV;
+ int retval = -ENOMEM;

dev = kzalloc(sizeof(*dev), GFP_KERNEL);
- if (!dev) {
- retval = -ENOMEM;
+ if (!dev)
goto error;
- }

device_initialize(dev);
dev->parent = parent;
--
2.30.0
\
 
 \ /
  Last update: 2021-02-18 21:31    [W:0.042 / U:1.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site