All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next] appletalk: use remove_proc_subtree to simplify procfs code
@ 2019-02-27 15:00 Yue Haibing
  2019-02-27 18:32 ` kbuild test robot
  2019-02-27 23:28 ` kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Yue Haibing @ 2019-02-27 15:00 UTC (permalink / raw)
  To: davem, joe, gregkh; +Cc: linux-kernel, netdev, YueHaibing

From: YueHaibing <yuehaibing@huawei.com>

Use remove_proc_subtree to remove the whole subtree
on cleanup.Also do some cleanup.

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
---
 net/appletalk/atalk_proc.c | 56 ++++++++++++++--------------------------------
 1 file changed, 17 insertions(+), 39 deletions(-)

diff --git a/net/appletalk/atalk_proc.c b/net/appletalk/atalk_proc.c
index 8006295..398b767 100644
--- a/net/appletalk/atalk_proc.c
+++ b/net/appletalk/atalk_proc.c
@@ -210,56 +210,34 @@ static const struct seq_operations atalk_seq_socket_ops = {
 	.show   = atalk_seq_socket_show,
 };
 
-static struct proc_dir_entry *atalk_proc_dir;
-
 int __init atalk_proc_init(void)
 {
-	struct proc_dir_entry *p;
-	int rc = -ENOMEM;
+	if (!proc_mkdir("atalk", init_net.proc_net))
+		return -ENOMEM;
 
-	atalk_proc_dir = proc_mkdir("atalk", init_net.proc_net);
-	if (!atalk_proc_dir)
+	if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
+			    &atalk_seq_interface_ops));
 		goto out;
 
-	p = proc_create_seq("interface", 0444, atalk_proc_dir,
-			&atalk_seq_interface_ops);
-	if (!p)
-		goto out_interface;
-
-	p = proc_create_seq("route", 0444, atalk_proc_dir,
-			&atalk_seq_route_ops);
-	if (!p)
-		goto out_route;
+	if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
+			    &atalk_seq_route_ops));
+		goto out;
 
-	p = proc_create_seq("socket", 0444, atalk_proc_dir,
-			&atalk_seq_socket_ops);
-	if (!p)
-		goto out_socket;
+	if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
+			    &atalk_seq_socket_ops));
+		goto out;
 
-	p = proc_create_seq_private("arp", 0444, atalk_proc_dir, &aarp_seq_ops,
-			sizeof(struct aarp_iter_state), NULL);
-	if (!p)
-		goto out_arp;
+	if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
+				     &aarp_seq_ops,
+				     sizeof(struct aarp_iter_state), NULL));
+		goto out;
 
-	rc = 0;
 out:
-	return rc;
-out_arp:
-	remove_proc_entry("socket", atalk_proc_dir);
-out_socket:
-	remove_proc_entry("route", atalk_proc_dir);
-out_route:
-	remove_proc_entry("interface", atalk_proc_dir);
-out_interface:
-	remove_proc_entry("atalk", init_net.proc_net);
-	goto out;
+	remove_proc_subtree("atalk", init_net.proc_net);
+	return -ENOMEM;
 }
 
 void __exit atalk_proc_exit(void)
 {
-	remove_proc_entry("interface", atalk_proc_dir);
-	remove_proc_entry("route", atalk_proc_dir);
-	remove_proc_entry("socket", atalk_proc_dir);
-	remove_proc_entry("arp", atalk_proc_dir);
-	remove_proc_entry("atalk", init_net.proc_net);
+	remove_proc_subtree("atalk", init_net.proc_net);
 }
-- 
2.7.0



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

* Re: [PATCH -next] appletalk: use remove_proc_subtree to simplify procfs code
  2019-02-27 15:00 [PATCH -next] appletalk: use remove_proc_subtree to simplify procfs code Yue Haibing
@ 2019-02-27 18:32 ` kbuild test robot
  2019-02-27 23:28 ` kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2019-02-27 18:32 UTC (permalink / raw)
  To: Yue Haibing
  Cc: kbuild-all, davem, joe, gregkh, linux-kernel, netdev, YueHaibing

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

Hi YueHaibing,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20190227]

url:    https://github.com/0day-ci/linux/commits/Yue-Haibing/appletalk-use-remove_proc_subtree-to-simplify-procfs-code/20190228-014856
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 8.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=8.2.0 make.cross ARCH=xtensa 

All warnings (new ones prefixed by >>):

   net//appletalk/atalk_proc.c: In function 'atalk_proc_init':
>> net//appletalk/atalk_proc.c:218:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
     ^~
   net//appletalk/atalk_proc.c:220:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      goto out;
      ^~~~
   net//appletalk/atalk_proc.c:222:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
     ^~
   net//appletalk/atalk_proc.c:224:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      goto out;
      ^~~~
   net//appletalk/atalk_proc.c:226:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
     ^~
   net//appletalk/atalk_proc.c:228:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      goto out;
      ^~~~
   net//appletalk/atalk_proc.c:230:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
     ^~
   net//appletalk/atalk_proc.c:233:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
      goto out;
      ^~~~

vim +/if +218 net//appletalk/atalk_proc.c

   212	
   213	int __init atalk_proc_init(void)
   214	{
   215		if (!proc_mkdir("atalk", init_net.proc_net))
   216			return -ENOMEM;
   217	
 > 218		if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
   219				    &atalk_seq_interface_ops));
   220			goto out;
   221	
   222		if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
   223				    &atalk_seq_route_ops));
   224			goto out;
   225	
   226		if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
   227				    &atalk_seq_socket_ops));
   228			goto out;
   229	
   230		if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
   231					     &aarp_seq_ops,
   232					     sizeof(struct aarp_iter_state), NULL));
   233			goto out;
   234	
   235	out:
   236		remove_proc_subtree("atalk", init_net.proc_net);
   237		return -ENOMEM;
   238	}
   239	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 56809 bytes --]

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

* Re: [PATCH -next] appletalk: use remove_proc_subtree to simplify procfs code
  2019-02-27 15:00 [PATCH -next] appletalk: use remove_proc_subtree to simplify procfs code Yue Haibing
  2019-02-27 18:32 ` kbuild test robot
@ 2019-02-27 23:28 ` kbuild test robot
  2019-02-28  1:32   ` YueHaibing
  1 sibling, 1 reply; 4+ messages in thread
From: kbuild test robot @ 2019-02-27 23:28 UTC (permalink / raw)
  To: Yue Haibing
  Cc: kbuild-all, davem, joe, gregkh, linux-kernel, netdev, YueHaibing

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

Hi YueHaibing,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on next-20190227]

url:    https://github.com/0day-ci/linux/commits/Yue-Haibing/appletalk-use-remove_proc_subtree-to-simplify-procfs-code/20190228-014856
config: i386-randconfig-s3-02271654 (attached as .config)
compiler: gcc-6 (Debian 6.5.0-2) 6.5.0 20181026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   In file included from include/linux/init.h:5:0,
                    from net//appletalk/atalk_proc.c:11:
   net//appletalk/atalk_proc.c: In function 'atalk_proc_init':
   include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
     ^
   include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
>> net//appletalk/atalk_proc.c:218:2: note: in expansion of macro 'if'
     if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
     ^~
   net//appletalk/atalk_proc.c:220:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
      goto out;
      ^~~~
   In file included from include/linux/init.h:5:0,
                    from net//appletalk/atalk_proc.c:11:
   include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
     ^
   include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   net//appletalk/atalk_proc.c:222:2: note: in expansion of macro 'if'
     if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
     ^~
   net//appletalk/atalk_proc.c:224:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
      goto out;
      ^~~~
   In file included from include/linux/init.h:5:0,
                    from net//appletalk/atalk_proc.c:11:
   include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
     ^
   include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   net//appletalk/atalk_proc.c:226:2: note: in expansion of macro 'if'
     if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
     ^~
   net//appletalk/atalk_proc.c:228:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
      goto out;
      ^~~~
   In file included from include/linux/init.h:5:0,
                    from net//appletalk/atalk_proc.c:11:
   include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
     if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
     ^
   include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
    #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
                          ^~~~~~~~~~
   net//appletalk/atalk_proc.c:230:2: note: in expansion of macro 'if'
     if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
     ^~
   net//appletalk/atalk_proc.c:233:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
      goto out;
      ^~~~

vim +/if +218 net//appletalk/atalk_proc.c

   212	
   213	int __init atalk_proc_init(void)
   214	{
   215		if (!proc_mkdir("atalk", init_net.proc_net))
   216			return -ENOMEM;
   217	
 > 218		if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
   219				    &atalk_seq_interface_ops));
   220			goto out;
   221	
   222		if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
   223				    &atalk_seq_route_ops));
   224			goto out;
   225	
   226		if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
   227				    &atalk_seq_socket_ops));
   228			goto out;
   229	
   230		if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
   231					     &aarp_seq_ops,
   232					     sizeof(struct aarp_iter_state), NULL));
   233			goto out;
   234	
   235	out:
   236		remove_proc_subtree("atalk", init_net.proc_net);
   237		return -ENOMEM;
   238	}
   239	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 29122 bytes --]

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

* Re: [PATCH -next] appletalk: use remove_proc_subtree to simplify procfs code
  2019-02-27 23:28 ` kbuild test robot
@ 2019-02-28  1:32   ` YueHaibing
  0 siblings, 0 replies; 4+ messages in thread
From: YueHaibing @ 2019-02-28  1:32 UTC (permalink / raw)
  To: kbuild test robot; +Cc: kbuild-all, davem, joe, gregkh, linux-kernel, netdev


On 2019/2/28 7:28, kbuild test robot wrote:
> Hi YueHaibing,
> 
> Thank you for the patch! Perhaps something to improve:
> 
> [auto build test WARNING on next-20190227]
> 
> url:    https://github.com/0day-ci/linux/commits/Yue-Haibing/appletalk-use-remove_proc_subtree-to-simplify-procfs-code/20190228-014856
> config: i386-randconfig-s3-02271654 (attached as .config)
> compiler: gcc-6 (Debian 6.5.0-2) 6.5.0 20181026
> reproduce:
>         # save the attached .config to linux build tree
>         make ARCH=i386 
> 
> All warnings (new ones prefixed by >>):
> 
>    In file included from include/linux/init.h:5:0,
>                     from net//appletalk/atalk_proc.c:11:
>    net//appletalk/atalk_proc.c: In function 'atalk_proc_init':
>    include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
>      if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
>      ^
>    include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
>     #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
>                           ^~~~~~~~~~
>>> net//appletalk/atalk_proc.c:218:2: note: in expansion of macro 'if'
>      if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
>      ^~
>    net//appletalk/atalk_proc.c:220:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
>       goto out;
>       ^~~~
>    In file included from include/linux/init.h:5:0,
>                     from net//appletalk/atalk_proc.c:11:
>    include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
>      if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
>      ^
>    include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
>     #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
>                           ^~~~~~~~~~
>    net//appletalk/atalk_proc.c:222:2: note: in expansion of macro 'if'
>      if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
>      ^~
>    net//appletalk/atalk_proc.c:224:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
>       goto out;
>       ^~~~
>    In file included from include/linux/init.h:5:0,
>                     from net//appletalk/atalk_proc.c:11:
>    include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
>      if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
>      ^
>    include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
>     #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
>                           ^~~~~~~~~~
>    net//appletalk/atalk_proc.c:226:2: note: in expansion of macro 'if'
>      if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
>      ^~
>    net//appletalk/atalk_proc.c:228:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
>       goto out;
>       ^~~~
>    In file included from include/linux/init.h:5:0,
>                     from net//appletalk/atalk_proc.c:11:
>    include/linux/compiler.h:58:2: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
>      if (__builtin_constant_p(!!(cond)) ? !!(cond) :   \
>      ^
>    include/linux/compiler.h:56:23: note: in expansion of macro '__trace_if'
>     #define if(cond, ...) __trace_if( (cond , ## __VA_ARGS__) )
>                           ^~~~~~~~~~
>    net//appletalk/atalk_proc.c:230:2: note: in expansion of macro 'if'
>      if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
>      ^~
>    net//appletalk/atalk_proc.c:233:3: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
>       goto out;
>       ^~~~
> 

Thanks, will fix in v2.


> vim +/if +218 net//appletalk/atalk_proc.c
> 
>    212	
>    213	int __init atalk_proc_init(void)
>    214	{
>    215		if (!proc_mkdir("atalk", init_net.proc_net))
>    216			return -ENOMEM;
>    217	
>  > 218		if (!proc_create_seq("atalk/interface", 0444, init_net.proc_net,
>    219				    &atalk_seq_interface_ops));
>    220			goto out;
>    221	
>    222		if (!proc_create_seq("atalk/route", 0444, init_net.proc_net,
>    223				    &atalk_seq_route_ops));
>    224			goto out;
>    225	
>    226		if (!proc_create_seq("atalk/socket", 0444, init_net.proc_net,
>    227				    &atalk_seq_socket_ops));
>    228			goto out;
>    229	
>    230		if (!proc_create_seq_private("atalk/arp", 0444, init_net.proc_net,
>    231					     &aarp_seq_ops,
>    232					     sizeof(struct aarp_iter_state), NULL));
>    233			goto out;
>    234	
>    235	out:
>    236		remove_proc_subtree("atalk", init_net.proc_net);
>    237		return -ENOMEM;
>    238	}
>    239	
> 
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
> 


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

end of thread, other threads:[~2019-02-28  1:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-27 15:00 [PATCH -next] appletalk: use remove_proc_subtree to simplify procfs code Yue Haibing
2019-02-27 18:32 ` kbuild test robot
2019-02-27 23:28 ` kbuild test robot
2019-02-28  1:32   ` YueHaibing

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.