* [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
* Re: [PATCH] SLIP: simplify sl_free_bufs
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-24 4:07 ` David S. Miller
0 siblings, 2 replies; 5+ messages in thread
From: Jesper Juhl @ 2005-06-23 20:46 UTC (permalink / raw)
To: David S. Miller; +Cc: Laurence Culhane, linux-serial, linux-kernel
The patch below still applies cleanly to 2.6.12 - any chance this might
get applied? or any good reasons not to apply it?
-- Jesper
On Wed, 15 Jun 2005, Jesper Juhl wrote:
> 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
* Re: [PATCH] SLIP: simplify sl_free_bufs
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
1 sibling, 1 reply; 5+ messages in thread
From: David S. Miller @ 2005-06-23 21:10 UTC (permalink / raw)
To: jesper.juhl, juhl-lkml; +Cc: loz, linux-serial, linux-kernel
From: Jesper Juhl <juhl-lkml@dif.dk>
Date: Thu, 23 Jun 2005 22:46:06 +0200 (CEST)
> The patch below still applies cleanly to 2.6.12 - any chance this might
> get applied? or any good reasons not to apply it?
I'll put it in my tree, give me a day or so.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] SLIP: simplify sl_free_bufs
2005-06-23 21:10 ` David S. Miller
@ 2005-06-23 21:16 ` Jesper Juhl
0 siblings, 0 replies; 5+ messages in thread
From: Jesper Juhl @ 2005-06-23 21:16 UTC (permalink / raw)
To: David S. Miller; +Cc: juhl-lkml, loz, linux-serial, linux-kernel
On 6/23/05, David S. Miller <davem@davemloft.net> wrote:
> From: Jesper Juhl <juhl-lkml@dif.dk>
> Date: Thu, 23 Jun 2005 22:46:06 +0200 (CEST)
>
> > The patch below still applies cleanly to 2.6.12 - any chance this might
> > get applied? or any good reasons not to apply it?
>
> I'll put it in my tree,
Thanks.
>give me a day or so.
>
No problem. :)
--
Jesper Juhl <jesper.juhl@gmail.com>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] SLIP: simplify sl_free_bufs
2005-06-23 20:46 ` Jesper Juhl
2005-06-23 21:10 ` David S. Miller
@ 2005-06-24 4:07 ` David S. Miller
1 sibling, 0 replies; 5+ messages in thread
From: David S. Miller @ 2005-06-24 4:07 UTC (permalink / raw)
To: jesper.juhl, juhl-lkml; +Cc: loz, linux-serial, linux-kernel
From: Jesper Juhl <juhl-lkml@dif.dk>
Date: Thu, 23 Jun 2005 22:46:06 +0200 (CEST)
> The patch below still applies cleanly to 2.6.12 - any chance this might
> get applied? or any good reasons not to apply it?
Patch applied, thanks Jesper.
^ 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