Skip to contentSkip to conversation

xen/gntdev: remove redundant non-zero check on ret

PATCH In review Colin King 2 participants 5 messages Nov 11, 2019

Subsystems (2)
lore
Share & tools
lore

Colin King

author
#0 lore raw

PATCH 1/1 xen/gntdev: remove redundant non-zero check on ret

From: Colin Ian King <[email protected]>

The non-zero check on ret is always going to be false because ret was initialized as zero and the only place it is set to non-zero contains a return path before the non-zero check. Hence the check is redundant and can be removed.

Addresses-Coverity: ("Logically dead code")

---
 drivers/xen/gntdev.c | 5 -----
 1 file changed, 5 deletions(-)
drivers/xen/gntdev.c +0 -5
index 10cc5e9e612a..07d80b176118 100644
@@ -524,11 +524,6 @@ static int gntdev_open(struct inode *inode, struct file *flip)
 	}
 #endif
 
-	if (ret) {
-		kfree(priv);
-		return ret;
-	}
-
 	flip->private_data = priv;
 #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
 	priv->dma_dev = gntdev_miscdev.this_device;
Signature · 1 line
2.20.1
maintainer
#1 lore raw
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

The non-zero check on ret is always going to be false because ret was initialized as zero and the only place it is set to non-zero contains a return path before the non-zero check. Hence the check is redundant and can be removed.

Which version did you patch against? In current master the above statement is not true.

Juergen

Quoted 24 lines

Addresses-Coverity: ("Logically dead code")

---
  drivers/xen/gntdev.c | 5 -----
  1 file changed, 5 deletions(-)
drivers/xen/gntdev.c +0 -5
index 10cc5e9e612a..07d80b176118 100644
@@ -524,11 +524,6 @@ static int gntdev_open(struct inode *inode, struct file *flip)
  	}
  #endif
 
-	if (ret) {
-		kfree(priv);
-		return ret;
-	}
-
  	flip->private_data = priv;
  #ifdef CONFIG_XEN_GRANT_DMA_ALLOC
  	priv->dma_dev = gntdev_miscdev.this_device;
#2 lore raw
Quoted 10 lines · Jürgen Groß
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

The non-zero check on ret is always going to be false because ret was initialized as zero and the only place it is set to non-zero contains a return path before the non-zero check. Hence the check is redundant and can be removed.

Which version did you patch against? In current master the above statement is not true.

against today's linux-next

Colin

Quoted 29 lines

Juergen

Quoted 24 lines

Addresses-Coverity: ("Logically dead code")

---
  drivers/xen/gntdev.c | 5 -----

  1 file changed, 5 deletions(-)
drivers/xen/gntdev.c +0 -4
index 10cc5e9e612a..07d80b176118 100644
@@ -524,11 +524,6 @@ static int gntdev_open(struct inode *inode,
 struct file *flip)
       }
   #endif
   -    if (ret) {
-        kfree(priv);
-        return ret;
-    }
-
       flip->private_data = priv;
   #ifdef CONFIG_XEN_GRANT_DMA_ALLOC

      priv->dma_dev = gntdev_miscdev.this_device;

maintainer
#3 lore raw
Quoted 9 lines · Colin Ian King
Quoted 8 lines · Jürgen Groß
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

The non-zero check on ret is always going to be false because ret was initialized as zero and the only place it is set to non-zero contains a return path before the non-zero check. Hence the check is redundant and can be removed.

Quoted 4 lines
Quoted 2 lines

Which version did you patch against? In current master the above statement is not true.

against today's linux-next

Ah, okay, this is likely the result of the recent mm-notifier patch series. I'll put this patch on hold until the recent patches have hit master.

Juergen

#4 lore raw
Quoted 10 lines · Jürgen Groß
Quoted 9 lines · Colin Ian King
Quoted 8 lines · Jürgen Groß
Quoted 6 lines · Colin King

From: Colin Ian King <[email protected]>

The non-zero check on ret is always going to be false because ret was initialized as zero and the only place it is set to non-zero contains a return path before the non-zero check. Hence the check is redundant and can be removed.

Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

Which version did you patch against? In current master the above statement is not true.

against today's linux-next

Ah, okay, this is likely the result of the recent mm-notifier patch series. I'll put this patch on hold until the recent patches have hit master.

Cool, thanks!

Quoted 3 lines

Juergen