Skip to contentSkip to conversation

media: dvbdev: remove redundant initialization of variable ret

PATCH In review Colin Ian King 2 participants 2 messages Apr 24, 2022 – Apr 25, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: dvbdev: remove redundant initialization of variable ret

Variable ret is being ininitialized with a value that is never read. The ininitializtion is redundant and can be removed. Move the variable to the scope it is required.

---
 drivers/media/dvb-core/dvbdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/dvb-core/dvbdev.c +2 -1
index 675d877a67b2..d5a142ef9876 100644
@@ -243,7 +243,7 @@ static void dvb_media_device_free(struct dvb_device *dvbdev)
 static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 				    const char *name, int npads)
 {
-	int i, ret = 0;
+	int i;
 
 	dvbdev->tsout_pads = kcalloc(npads, sizeof(*dvbdev->tsout_pads),
 				     GFP_KERNEL);
@@ -260,6 +260,7 @@ static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 	for (i = 0; i < npads; i++) {
 		struct media_pad *pads = &dvbdev->tsout_pads[i];
 		struct media_entity *entity = &dvbdev->tsout_entity[i];
+		int ret;
 
 		entity->name = kasprintf(GFP_KERNEL, "%s #%d", name, i);
 		if (!entity->name)
Signature · 1 line
2.35.1
#1 lore raw
Quoted 14 lines · Colin Ian King

Variable ret is being ininitialized with a value that is never read. The ininitializtion is redundant and can be removed. Move the variable to the scope it is required.

---
 drivers/media/dvb-core/dvbdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/media/dvb-core/dvbdev.c +0 -0
index 675d877a67b2..d5a142ef9876 100644

drivers/media/dvb-core/dvbdev.c static void dvb_media_device_free(struct dvb_device *dvbdev) · line 246

Quoted 5 lines
drivers/media/dvb-core/dvbdev.c +1 -1
@@ -243,7 +243,7 @@ static void dvb_media_device_free(struct dvb_device *dvbdev)
 static int dvb_create_tsout_entity(struct dvb_device *dvbdev,
 				    const char *name, int npads)
 {
-	int i, ret = 0;
+	int i;

It's better when "ret" has function scope. Otherwise in the future when someone adds a "ret" you're going to end up with two "ret" variables.

regards,
dan carpenter