All of lore.kernel.org
 help / color / mirror / Atom feed
* [Patch] pktgen: refactor pg_init() code
@ 2011-05-22 10:52 Américo Wang
  2011-05-23  1:02 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Américo Wang @ 2011-05-22 10:52 UTC (permalink / raw)
  To: Linux Kernel Network Developers; +Cc: David Miller

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

This also shrinks the object size a little.

   text	   data	    bss	    dec	    hex	filename
  28834	    186	      8	  29028	   7164	net/core/pktgen.o
  28816	    186	      8	  29010	   7152	net/core/pktgen.o.AFTER


Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
Cc: "David Miller" <davem@davemloft.net>,

---

[-- Attachment #2: net-pktgen-refactor-pg_init.diff --]
[-- Type: text/x-patch, Size: 1412 bytes --]

 net/core/pktgen.c |   19 ++++++++++++-------
 1 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/net/core/pktgen.c b/net/core/pktgen.c
index 67870e9..ea99464 100644
--- a/net/core/pktgen.c
+++ b/net/core/pktgen.c
@@ -3708,6 +3708,7 @@ static int __init pg_init(void)
 {
 	int cpu;
 	struct proc_dir_entry *pe;
+	int ret = 0;
 
 	pr_info("%s", version);
 
@@ -3718,11 +3719,10 @@ static int __init pg_init(void)
 	pe = proc_create(PGCTRL, 0600, pg_proc_dir, &pktgen_fops);
 	if (pe == NULL) {
 		pr_err("ERROR: cannot create %s procfs entry\n", PGCTRL);
-		proc_net_remove(&init_net, PG_PROC_DIR);
-		return -EINVAL;
+		ret = -EINVAL;
+		goto remove_dir;
 	}
 
-	/* Register us to receive netdevice events */
 	register_netdevice_notifier(&pktgen_notifier_block);
 
 	for_each_online_cpu(cpu) {
@@ -3736,13 +3736,18 @@ static int __init pg_init(void)
 
 	if (list_empty(&pktgen_threads)) {
 		pr_err("ERROR: Initialization failed for all threads\n");
-		unregister_netdevice_notifier(&pktgen_notifier_block);
-		remove_proc_entry(PGCTRL, pg_proc_dir);
-		proc_net_remove(&init_net, PG_PROC_DIR);
-		return -ENODEV;
+		ret = -ENODEV;
+		goto unregister;
 	}
 
 	return 0;
+
+ unregister:
+	unregister_netdevice_notifier(&pktgen_notifier_block);
+	remove_proc_entry(PGCTRL, pg_proc_dir);
+ remove_dir:
+	proc_net_remove(&init_net, PG_PROC_DIR);
+	return ret;
 }
 
 static void __exit pg_cleanup(void)

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

* Re: [Patch] pktgen: refactor pg_init() code
  2011-05-22 10:52 [Patch] pktgen: refactor pg_init() code Américo Wang
@ 2011-05-23  1:02 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2011-05-23  1:02 UTC (permalink / raw)
  To: xiyou.wangcong; +Cc: netdev

From: Américo Wang <xiyou.wangcong@gmail.com>
Date: Sun, 22 May 2011 18:52:08 +0800

> This also shrinks the object size a little.
> 
>    text	   data	    bss	    dec	    hex	filename
>   28834	    186	      8	  29028	   7164	net/core/pktgen.o
>   28816	    186	      8	  29010	   7152	net/core/pktgen.o.AFTER
> 
> 
> Signed-off-by: WANG Cong <xiyou.wangcong@gmail.com>
> Cc: "David Miller" <davem@davemloft.net>,

Applied.

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

end of thread, other threads:[~2011-05-23  1:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-22 10:52 [Patch] pktgen: refactor pg_init() code Américo Wang
2011-05-23  1:02 ` David Miller

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.