diff mbox series

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

Message ID 20240827100407.3914090-3-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: tipc-discussion@lists.sourceforge.net
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, 24 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 3 this patch: 3
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/tipc/socket.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Simon Horman Aug. 27, 2024, 4:57 p.m. UTC | #1
On Tue, Aug 27, 2024 at 06:04:04PM +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/tipc/socket.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
> index 1a0cd06f0eae..9d30e362392c 100644
> --- a/net/tipc/socket.c
> +++ b/net/tipc/socket.c
> @@ -1009,12 +1009,11 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
>  	struct tipc_member *mbr = NULL;
>  	struct net *net = sock_net(sk);
>  	u32 node, port, exclude;
> -	struct list_head dsts;
>  	int lookups = 0;
>  	int dstcnt, rc;
>  	bool cong;
> +	LIST_HEAD(dsts);

nit: Please place this new line where the old dsts line was,
     in order to preserve, within the context of this hunk,
     reverse xmas tree order - longest line to shortest -
     for local variable declarations.

>  
> -	INIT_LIST_HEAD(&dsts);
>  	ua->sa.type = msg_nametype(hdr);
>  	ua->scope = msg_lookup_scope(hdr);
>  
> @@ -1161,10 +1160,9 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
>  	struct tipc_group *grp = tsk->group;
>  	struct tipc_msg *hdr = &tsk->phdr;
>  	struct net *net = sock_net(sk);
> -	struct list_head dsts;
>  	u32 dstcnt, exclude;
> +	LIST_HEAD(dsts);
>  
> -	INIT_LIST_HEAD(&dsts);
>  	ua->sa.type = msg_nametype(hdr);
>  	ua->scope = msg_lookup_scope(hdr);
>  	exclude = tipc_group_exclude(grp);
Hongbo Li Aug. 30, 2024, 1:17 a.m. UTC | #2
On 2024/8/28 0:57, Simon Horman wrote:
> On Tue, Aug 27, 2024 at 06:04:04PM +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/tipc/socket.c | 6 ++----
>>   1 file changed, 2 insertions(+), 4 deletions(-)
>>
>> diff --git a/net/tipc/socket.c b/net/tipc/socket.c
>> index 1a0cd06f0eae..9d30e362392c 100644
>> --- a/net/tipc/socket.c
>> +++ b/net/tipc/socket.c
>> @@ -1009,12 +1009,11 @@ static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
>>   	struct tipc_member *mbr = NULL;
>>   	struct net *net = sock_net(sk);
>>   	u32 node, port, exclude;
>> -	struct list_head dsts;
>>   	int lookups = 0;
>>   	int dstcnt, rc;
>>   	bool cong;
>> +	LIST_HEAD(dsts);
> 
> nit: Please place this new line where the old dsts line was,
>       in order to preserve, within the context of this hunk,
>       reverse xmas tree order - longest line to shortest -
ok, I've learned, the reverse xmas tree order. Thank you!

Thanks,
Hongbo
>       for local variable declarations.
> 
>>   
>> -	INIT_LIST_HEAD(&dsts);
>>   	ua->sa.type = msg_nametype(hdr);
>>   	ua->scope = msg_lookup_scope(hdr);
>>   
>> @@ -1161,10 +1160,9 @@ static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
>>   	struct tipc_group *grp = tsk->group;
>>   	struct tipc_msg *hdr = &tsk->phdr;
>>   	struct net *net = sock_net(sk);
>> -	struct list_head dsts;
>>   	u32 dstcnt, exclude;
>> +	LIST_HEAD(dsts);
>>   
>> -	INIT_LIST_HEAD(&dsts);
>>   	ua->sa.type = msg_nametype(hdr);
>>   	ua->scope = msg_lookup_scope(hdr);
>>   	exclude = tipc_group_exclude(grp);
>
diff mbox series

Patch

diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 1a0cd06f0eae..9d30e362392c 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -1009,12 +1009,11 @@  static int tipc_send_group_anycast(struct socket *sock, struct msghdr *m,
 	struct tipc_member *mbr = NULL;
 	struct net *net = sock_net(sk);
 	u32 node, port, exclude;
-	struct list_head dsts;
 	int lookups = 0;
 	int dstcnt, rc;
 	bool cong;
+	LIST_HEAD(dsts);
 
-	INIT_LIST_HEAD(&dsts);
 	ua->sa.type = msg_nametype(hdr);
 	ua->scope = msg_lookup_scope(hdr);
 
@@ -1161,10 +1160,9 @@  static int tipc_send_group_mcast(struct socket *sock, struct msghdr *m,
 	struct tipc_group *grp = tsk->group;
 	struct tipc_msg *hdr = &tsk->phdr;
 	struct net *net = sock_net(sk);
-	struct list_head dsts;
 	u32 dstcnt, exclude;
+	LIST_HEAD(dsts);
 
-	INIT_LIST_HEAD(&dsts);
 	ua->sa.type = msg_nametype(hdr);
 	ua->scope = msg_lookup_scope(hdr);
 	exclude = tipc_group_exclude(grp);