diff mbox series

[net-next,3/5] net/netfilter: make use of the helper macro LIST_HEAD()

Message ID 20240827100407.3914090-4-lihongbo22@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series make use of the helper macro LIST_HEAD() | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 16 this patch: 16
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 1 maintainers not CCed: coreteam@netfilter.org
netdev/build_clang success Errors and warnings before: 16 this patch: 16
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 16 this patch: 16
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 11 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-27--15-00 (tests: 712)

Commit Message

Hongbo Li Aug. 27, 2024, 10:04 a.m. UTC
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD(). Here we can simplify
the code.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 net/netfilter/core.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Pablo Neira Ayuso Aug. 27, 2024, 4:15 p.m. UTC | #1
Hi,

On Tue, Aug 27, 2024 at 06:04:05PM +0800, Hongbo Li wrote:
> list_head can be initialized automatically with LIST_HEAD()
> instead of calling INIT_LIST_HEAD(). Here we can simplify
> the code.
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
>  net/netfilter/core.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/net/netfilter/core.c b/net/netfilter/core.c
> index b00fc285b334..93642fcd379c 100644
> --- a/net/netfilter/core.c
> +++ b/net/netfilter/core.c
> @@ -655,10 +655,8 @@ void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
>  		       const struct nf_hook_entries *e)
>  {
>  	struct sk_buff *skb, *next;
> -	struct list_head sublist;
>  	int ret;
> -
> -	INIT_LIST_HEAD(&sublist);
> +	LIST_HEAD(sublist);

comestic:

  	struct sk_buff *skb, *next;
	LIST_HEAD(sublist);          <- here
  	int ret;

I think this should be included in the variable declaration area at
the beginning of this function.

>  	list_for_each_entry_safe(skb, next, head, list) {
>  		skb_list_del_init(skb);
> -- 
> 2.34.1
> 
>
Hongbo Li Aug. 28, 2024, 1:35 a.m. UTC | #2
On 2024/8/28 0:15, Pablo Neira Ayuso wrote:
> Hi,
> 
> On Tue, Aug 27, 2024 at 06:04:05PM +0800, Hongbo Li wrote:
>> list_head can be initialized automatically with LIST_HEAD()
>> instead of calling INIT_LIST_HEAD(). Here we can simplify
>> the code.
>>
>> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
>> ---
>>   net/netfilter/core.c | 4 +---
>>   1 file changed, 1 insertion(+), 3 deletions(-)
>>
>> diff --git a/net/netfilter/core.c b/net/netfilter/core.c
>> index b00fc285b334..93642fcd379c 100644
>> --- a/net/netfilter/core.c
>> +++ b/net/netfilter/core.c
>> @@ -655,10 +655,8 @@ void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
>>   		       const struct nf_hook_entries *e)
>>   {
>>   	struct sk_buff *skb, *next;
>> -	struct list_head sublist;
>>   	int ret;
>> -
>> -	INIT_LIST_HEAD(&sublist);
>> +	LIST_HEAD(sublist);
> 
> comestic:
> 
>    	struct sk_buff *skb, *next;
> 	LIST_HEAD(sublist);          <- here
>    	int ret;
> 
> I think this should be included in the variable declaration area at
> the beginning of this function.

It is in the variable declaration area just after ret (with a blank line 
before list_for_each_entry_safe).

Thanks,
Hongbo
> 
>>   	list_for_each_entry_safe(skb, next, head, list) {
>>   		skb_list_del_init(skb);
>> -- 
>> 2.34.1
>>
>>
>
Pablo Neira Ayuso Aug. 28, 2024, 6:52 a.m. UTC | #3
On Wed, Aug 28, 2024 at 09:35:35AM +0800, Hongbo Li wrote:
> 
> 
> On 2024/8/28 0:15, Pablo Neira Ayuso wrote:
> > Hi,
> > 
> > On Tue, Aug 27, 2024 at 06:04:05PM +0800, Hongbo Li wrote:
> > > list_head can be initialized automatically with LIST_HEAD()
> > > instead of calling INIT_LIST_HEAD(). Here we can simplify
> > > the code.
> > > 
> > > Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> > > ---
> > >   net/netfilter/core.c | 4 +---
> > >   1 file changed, 1 insertion(+), 3 deletions(-)
> > > 
> > > diff --git a/net/netfilter/core.c b/net/netfilter/core.c
> > > index b00fc285b334..93642fcd379c 100644
> > > --- a/net/netfilter/core.c
> > > +++ b/net/netfilter/core.c
> > > @@ -655,10 +655,8 @@ void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
> > >   		       const struct nf_hook_entries *e)
> > >   {
> > >   	struct sk_buff *skb, *next;
> > > -	struct list_head sublist;
> > >   	int ret;
> > > -
> > > -	INIT_LIST_HEAD(&sublist);
> > > +	LIST_HEAD(sublist);
> > 
> > comestic:
> > 
> >    	struct sk_buff *skb, *next;
> > 	LIST_HEAD(sublist);          <- here
> >    	int ret;
> > 
> > I think this should be included in the variable declaration area at
> > the beginning of this function.
> 
> It is in the variable declaration area just after ret (with a blank line
> before list_for_each_entry_safe).

Indeed. It is reverse xmas tree what I was missing then.

Thanks.
diff mbox series

Patch

diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index b00fc285b334..93642fcd379c 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -655,10 +655,8 @@  void nf_hook_slow_list(struct list_head *head, struct nf_hook_state *state,
 		       const struct nf_hook_entries *e)
 {
 	struct sk_buff *skb, *next;
-	struct list_head sublist;
 	int ret;
-
-	INIT_LIST_HEAD(&sublist);
+	LIST_HEAD(sublist);
 
 	list_for_each_entry_safe(skb, next, head, list) {
 		skb_list_del_init(skb);