[PATCH] net: remove redundant NULL pointer checks prior to kfree in drivers/net/slip.c

2005-04-11 Thread Jesper Juhl
kfree() checks for NULL. Checking prior to calling it is redundant.
This patch removes these redundant checks from drivers/net/slip.c

Signed-off-by: Jesper Juhl <[EMAIL PROTECTED]>
---

 slip.c |   30 --
 1 files changed, 12 insertions(+), 18 deletions(-)

--- linux-2.6.12-rc2-mm3-orig/drivers/net/slip.c2005-03-02 
08:38:33.0 +0100
+++ linux-2.6.12-rc2-mm3/drivers/net/slip.c 2005-04-11 23:10:06.0 
+0200
@@ -185,15 +185,12 @@ sl_alloc_bufs(struct slip *sl, int mtu)
/* Cleanup */
 err_exit:
 #ifdef SL_INCLUDE_CSLIP
-   if (cbuff)
-   kfree(cbuff);
+   kfree(cbuff);
if (slcomp)
slhc_free(slcomp);
 #endif
-   if (xbuff)
-   kfree(xbuff);
-   if (rbuff)
-   kfree(rbuff);
+   kfree(xbuff);
+   kfree(rbuff);
return err;
 }
 
@@ -204,13 +201,13 @@ sl_free_bufs(struct slip *sl)
void * tmp;
 
/* Free all SLIP frame buffers. */
-   if ((tmp = xchg(>rbuff, NULL)) != NULL)
-   kfree(tmp);
-   if ((tmp = xchg(>xbuff, NULL)) != NULL)
-   kfree(tmp);
+   tmp = xchg(>rbuff, NULL);
+   kfree(tmp);
+   tmp = xchg(>xbuff, NULL);
+   kfree(tmp);
 #ifdef SL_INCLUDE_CSLIP
-   if ((tmp = xchg(>cbuff, NULL)) != NULL)
-   kfree(tmp);
+   tmp = xchg(>cbuff, NULL);
+   kfree(tmp);
if ((tmp = xchg(>slcomp, NULL)) != NULL)
slhc_free(tmp);
 #endif
@@ -297,13 +294,10 @@ done_on_bh:
spin_unlock_bh(>lock);
 
 done:
-   if (xbuff)
-   kfree(xbuff);
-   if (rbuff)
-   kfree(rbuff);
+   kfree(xbuff);
+   kfree(rbuff);
 #ifdef SL_INCLUDE_CSLIP
-   if (cbuff)
-   kfree(cbuff);
+   kfree(cbuff);
 #endif
return err;
 }


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH] net: remove redundant NULL pointer checks prior to kfree in drivers/net/slip.c

2005-04-11 Thread Jesper Juhl
kfree() checks for NULL. Checking prior to calling it is redundant.
This patch removes these redundant checks from drivers/net/slip.c

Signed-off-by: Jesper Juhl [EMAIL PROTECTED]
---

 slip.c |   30 --
 1 files changed, 12 insertions(+), 18 deletions(-)

--- linux-2.6.12-rc2-mm3-orig/drivers/net/slip.c2005-03-02 
08:38:33.0 +0100
+++ linux-2.6.12-rc2-mm3/drivers/net/slip.c 2005-04-11 23:10:06.0 
+0200
@@ -185,15 +185,12 @@ sl_alloc_bufs(struct slip *sl, int mtu)
/* Cleanup */
 err_exit:
 #ifdef SL_INCLUDE_CSLIP
-   if (cbuff)
-   kfree(cbuff);
+   kfree(cbuff);
if (slcomp)
slhc_free(slcomp);
 #endif
-   if (xbuff)
-   kfree(xbuff);
-   if (rbuff)
-   kfree(rbuff);
+   kfree(xbuff);
+   kfree(rbuff);
return err;
 }
 
@@ -204,13 +201,13 @@ sl_free_bufs(struct slip *sl)
void * tmp;
 
/* Free all SLIP frame buffers. */
-   if ((tmp = xchg(sl-rbuff, NULL)) != NULL)
-   kfree(tmp);
-   if ((tmp = xchg(sl-xbuff, NULL)) != NULL)
-   kfree(tmp);
+   tmp = xchg(sl-rbuff, NULL);
+   kfree(tmp);
+   tmp = xchg(sl-xbuff, NULL);
+   kfree(tmp);
 #ifdef SL_INCLUDE_CSLIP
-   if ((tmp = xchg(sl-cbuff, NULL)) != NULL)
-   kfree(tmp);
+   tmp = xchg(sl-cbuff, NULL);
+   kfree(tmp);
if ((tmp = xchg(sl-slcomp, NULL)) != NULL)
slhc_free(tmp);
 #endif
@@ -297,13 +294,10 @@ done_on_bh:
spin_unlock_bh(sl-lock);
 
 done:
-   if (xbuff)
-   kfree(xbuff);
-   if (rbuff)
-   kfree(rbuff);
+   kfree(xbuff);
+   kfree(rbuff);
 #ifdef SL_INCLUDE_CSLIP
-   if (cbuff)
-   kfree(cbuff);
+   kfree(cbuff);
 #endif
return err;
 }


-
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/