public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] SLIP: simplify sl_free_bufs
@ 2005-06-15 19:46 Jesper Juhl
  2005-06-23 20:46 ` Jesper Juhl
  0 siblings, 1 reply; 5+ messages in thread
From: Jesper Juhl @ 2005-06-15 19:46 UTC (permalink / raw)
  To: David S. Miller; +Cc: Laurence Culhane, linux-serial, linux-kernel

We can avoid assignments to the local variable 'tmp' and 
actually get rid of tmp alltogether in sl_free_bufs(). This patch does 
that.  This is safe since both kfree() and slhc_free() handles NULL 
pointers gracefully.

A related question: Why the use of NULLSLCOMPR & NULLSLSTATE instead of 
plain NULL for struct slcompress and its members?
They are defined as 
	#define NULLSLCOMPR     (struct slcompress *)0
	#define NULLSLSTATE     (struct cstate *)0
Seems to me that plain NULL might as well be used (and if so I have a few 
more potential cleanups in the queue).


Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
---

 drivers/net/slip.c |   14 ++++----------
 1 files changed, 4 insertions(+), 10 deletions(-)

--- linux-2.6.12-rc6-orig/drivers/net/slip.c	2005-06-07 00:07:22.000000000 +0200
+++ linux-2.6.12-rc6-mm1/drivers/net/slip.c	2005-06-15 21:39:39.000000000 +0200
@@ -198,18 +198,12 @@ err_exit:
 static void
 sl_free_bufs(struct slip *sl)
 {
-	void * tmp;
-
 	/* Free all SLIP frame buffers. */
-	tmp = xchg(&sl->rbuff, NULL);
-	kfree(tmp);
-	tmp = xchg(&sl->xbuff, NULL);
-	kfree(tmp);
+	kfree(xchg(&sl->rbuff, NULL));
+	kfree(xchg(&sl->xbuff, NULL));
 #ifdef SL_INCLUDE_CSLIP
-	tmp = xchg(&sl->cbuff, NULL);
-	kfree(tmp);
-	if ((tmp = xchg(&sl->slcomp, NULL)) != NULL)
-		slhc_free(tmp);
+	kfree(xchg(&sl->cbuff, NULL));
+	slhc_free(xchg(&sl->slcomp, NULL));
 #endif
 }
 



Please CC me on replies.

-- 
Jesper Juhl



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-06-24  4:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-15 19:46 [PATCH] SLIP: simplify sl_free_bufs Jesper Juhl
2005-06-23 20:46 ` Jesper Juhl
2005-06-23 21:10   ` David S. Miller
2005-06-23 21:16     ` Jesper Juhl
2005-06-24  4:07   ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox