Re: [PATCH] SLIP: simplify sl_free_bufs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 <[email protected]>
> ---
> 
>  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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux