All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] Small kfree cleanup, save a local variable.
  2005-06-19 19:38 [PATCH] Small kfree cleanup, save a local variable Jesper Juhl
@ 2005-06-19 19:37 ` Michael Buesch
  2005-06-19 19:49   ` Jesper Juhl
  2005-06-19 20:13 ` Chris Wright
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Buesch @ 2005-06-19 19:37 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: Rickard E. (Rik) Faith, Rik Faith, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1003 bytes --]

Quoting Jesper Juhl <juhl-lkml@dif.dk>:
> Here's a patch with a small improvement to kernel/auditsc.c .
> There's no need for the local variable  struct audit_entry *e  , 
> we can just call kfree directly on container_of() .

Did you look at the assembly output? Does it change?
I think the compiler optimizes this variable away, anyway.
So, if there's no improvement, I would personally prefer the
original form as it's more readable.

>  kernel/auditsc.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> --- linux-2.6.12-orig/kernel/auditsc.c	2005-06-17 21:48:29.000000000 +0200
> +++ linux-2.6.12/kernel/auditsc.c	2005-06-19 21:21:37.000000000 +0200
> @@ -202,8 +202,7 @@ static inline int audit_add_rule(struct 
>  
>  static void audit_free_rule(struct rcu_head *head)
>  {
> -	struct audit_entry *e = container_of(head, struct audit_entry, rcu);
> -	kfree(e);
> +	kfree(container_of(head, struct audit_entry, rcu));
>  }

-- 
Greetings, Michael



[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

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

* [PATCH] Small kfree cleanup, save a local variable.
@ 2005-06-19 19:38 Jesper Juhl
  2005-06-19 19:37 ` Michael Buesch
  2005-06-19 20:13 ` Chris Wright
  0 siblings, 2 replies; 6+ messages in thread
From: Jesper Juhl @ 2005-06-19 19:38 UTC (permalink / raw)
  To: linux-kernel; +Cc: Rickard E. (Rik) Faith, Rik Faith

Here's a patch with a small improvement to kernel/auditsc.c .
There's no need for the local variable  struct audit_entry *e  , 
we can just call kfree directly on container_of() .
Patch also removes an extra space a little further down in the file.

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

 kernel/auditsc.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

--- linux-2.6.12-orig/kernel/auditsc.c	2005-06-17 21:48:29.000000000 +0200
+++ linux-2.6.12/kernel/auditsc.c	2005-06-19 21:21:37.000000000 +0200
@@ -202,8 +202,7 @@ static inline int audit_add_rule(struct 
 
 static void audit_free_rule(struct rcu_head *head)
 {
-	struct audit_entry *e = container_of(head, struct audit_entry, rcu);
-	kfree(e);
+	kfree(container_of(head, struct audit_entry, rcu));
 }
 
 /* Note that audit_add_rule and audit_del_rule are called via
@@ -612,7 +611,7 @@ static inline void audit_free_context(st
 		audit_free_names(context);
 		audit_free_aux(context);
 		kfree(context);
-		context  = previous;
+		context = previous;
 	} while (context);
 	if (count >= 10)
 		printk(KERN_ERR "audit: freed %d contexts\n", count);



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

* Re: [PATCH] Small kfree cleanup, save a local variable.
  2005-06-19 19:37 ` Michael Buesch
@ 2005-06-19 19:49   ` Jesper Juhl
  0 siblings, 0 replies; 6+ messages in thread
From: Jesper Juhl @ 2005-06-19 19:49 UTC (permalink / raw)
  To: Michael Buesch
  Cc: Jesper Juhl, Rickard E. (Rik) Faith, Rik Faith, linux-kernel

On 6/19/05, Michael Buesch <mbuesch@freenet.de> wrote:
> Quoting Jesper Juhl <juhl-lkml@dif.dk>:
> > Here's a patch with a small improvement to kernel/auditsc.c .
> > There's no need for the local variable  struct audit_entry *e  ,
> > we can just call kfree directly on container_of() .
> 
> Did you look at the assembly output? Does it change?
> I think the compiler optimizes this variable away, anyway.
> So, if there's no improvement, I would personally prefer the
> original form as it's more readable.
> 
gcc does optimize it away. 
Personally I find both forms equally readable, and with the change the
source matches what the code actually ends up as, but I don't care
much one way or the other.

-- 
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] 6+ messages in thread

* Re: [PATCH] Small kfree cleanup, save a local variable.
  2005-06-19 19:38 [PATCH] Small kfree cleanup, save a local variable Jesper Juhl
  2005-06-19 19:37 ` Michael Buesch
@ 2005-06-19 20:13 ` Chris Wright
  2005-06-19 20:19   ` Jesper Juhl
  1 sibling, 1 reply; 6+ messages in thread
From: Chris Wright @ 2005-06-19 20:13 UTC (permalink / raw)
  To: Jesper Juhl; +Cc: linux-kernel, Rickard E. (Rik) Faith, Rik Faith, linux-audit

* Jesper Juhl (juhl-lkml@dif.dk) wrote:
> Here's a patch with a small improvement to kernel/auditsc.c .
> There's no need for the local variable  struct audit_entry *e  , 
> we can just call kfree directly on container_of() .
> Patch also removes an extra space a little further down in the file.

Please Cc: linux-audit@redhat.com on audit patches.  I tend to agree
with Michael, it's optimized away, and readable as is.

thanks,
-chris

> Signed-off-by: Jesper Juhl <juhl-lkml@dif.dk>
> ---
> 
>  kernel/auditsc.c |    5 ++---
>  1 files changed, 2 insertions(+), 3 deletions(-)
> 
> --- linux-2.6.12-orig/kernel/auditsc.c	2005-06-17 21:48:29.000000000 +0200
> +++ linux-2.6.12/kernel/auditsc.c	2005-06-19 21:21:37.000000000 +0200
> @@ -202,8 +202,7 @@ static inline int audit_add_rule(struct 
>  
>  static void audit_free_rule(struct rcu_head *head)
>  {
> -	struct audit_entry *e = container_of(head, struct audit_entry, rcu);
> -	kfree(e);
> +	kfree(container_of(head, struct audit_entry, rcu));
>  }
>  
>  /* Note that audit_add_rule and audit_del_rule are called via
> @@ -612,7 +611,7 @@ static inline void audit_free_context(st
>  		audit_free_names(context);
>  		audit_free_aux(context);
>  		kfree(context);
> -		context  = previous;
> +		context = previous;
>  	} while (context);
>  	if (count >= 10)
>  		printk(KERN_ERR "audit: freed %d contexts\n", count);

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

* Re: [PATCH] Small kfree cleanup, save a local variable.
  2005-06-19 20:13 ` Chris Wright
@ 2005-06-19 20:19   ` Jesper Juhl
  2005-06-19 20:20     ` Chris Wright
  0 siblings, 1 reply; 6+ messages in thread
From: Jesper Juhl @ 2005-06-19 20:19 UTC (permalink / raw)
  To: Chris Wright
  Cc: Jesper Juhl, linux-kernel, Rickard E. (Rik) Faith, Rik Faith,
	linux-audit

On 6/19/05, Chris Wright <chrisw@osdl.org> wrote:
> * Jesper Juhl (juhl-lkml@dif.dk) wrote:
> > Here's a patch with a small improvement to kernel/auditsc.c .
> > There's no need for the local variable  struct audit_entry *e  ,
> > we can just call kfree directly on container_of() .
> > Patch also removes an extra space a little further down in the file.
> 
> Please Cc: linux-audit@redhat.com on audit patches.

I didn't find that address in MAINTAINERS nor in the source file. I
had no idea it existed. Perhaps it ought to be listed in MAINTAINERS
somewhere...


>  I tend to agree
> with Michael, it's optimized away, and readable as is.
> 
Fair enough, we'll just leave it as is :)


-- 
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] 6+ messages in thread

* Re: [PATCH] Small kfree cleanup, save a local variable.
  2005-06-19 20:19   ` Jesper Juhl
@ 2005-06-19 20:20     ` Chris Wright
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Wright @ 2005-06-19 20:20 UTC (permalink / raw)
  To: Jesper Juhl
  Cc: Chris Wright, Jesper Juhl, linux-kernel, Rickard E. (Rik) Faith,
	Rik Faith, linux-audit

* Jesper Juhl (jesper.juhl@gmail.com) wrote:
> On 6/19/05, Chris Wright <chrisw@osdl.org> wrote:
> > * Jesper Juhl (juhl-lkml@dif.dk) wrote:
> > > Here's a patch with a small improvement to kernel/auditsc.c .
> > > There's no need for the local variable  struct audit_entry *e  ,
> > > we can just call kfree directly on container_of() .
> > > Patch also removes an extra space a little further down in the file.
> > 
> > Please Cc: linux-audit@redhat.com on audit patches.
> 
> I didn't find that address in MAINTAINERS nor in the source file. I
> had no idea it existed. Perhaps it ought to be listed in MAINTAINERS
> somewhere...

Ahh, good point, that needs to be fixed.

thanks,
-chris

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

end of thread, other threads:[~2005-06-19 20:20 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-19 19:38 [PATCH] Small kfree cleanup, save a local variable Jesper Juhl
2005-06-19 19:37 ` Michael Buesch
2005-06-19 19:49   ` Jesper Juhl
2005-06-19 20:13 ` Chris Wright
2005-06-19 20:19   ` Jesper Juhl
2005-06-19 20:20     ` Chris Wright

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.