[PATCH] SLIP: simplify sl_free_bufs

From: Jesper Juhl
Date: Wed Jun 15 2005 - 14:46:05 EST


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@xxxxxx>
---

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


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