tipc: Fine-tuning for three function implementations
Subsystems (4)
cover tipc: Fine-tuning for three function implementations
From: Markus Elfring <[email protected]>
Date: Wed, 8 Nov 2017 22:30:03 +0100
Two update suggestions were taken into account
from static source code analysis.
Markus Elfring (2):
Use common error handling code in tipc_server_start() Improve a size determination in two functions
net/tipc/server.c | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-)
Signature · 1 line
2.15.0
PATCH 1/2 tipc: Use common error handling code in tipc_server_start()
From: Markus Elfring <[email protected]>
Date: Wed, 8 Nov 2017 22:18:35 +0100
* Improve jump targets so that a bit of exception handling can be better reused at the end of this function.
* Adjust two condition checks.
This issue was detected by using the Coccinelle software.
--- net/tipc/server.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
net/tipc/server.c +12 -9
@@ -670,16 +670,19 @@ int tipc_server_start(struct tipc_server *s)return -ENOMEM ; ret =tipc_work_start (s); -if (ret <0 ) { -kmem_cache_destroy (s->rcvbuf_cache); -return ret; - } +if (ret) + goto destroy_cache; + ret =tipc_open_listening_sock (s); -if (ret <0 ) { -tipc_work_stop (s); -kmem_cache_destroy (s->rcvbuf_cache); -return ret; - } +if (ret) + goto stop_work; + +return 0 ; + +stop_work: +tipc_work_stop (s); +destroy_cache: +kmem_cache_destroy (s->rcvbuf_cache);return ret; }
Signature · 1 line
2.15.0
PATCH 2/2 tipc: Improve a size determination in two functions
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 8 Nov 2017 22:23:07 +0100
Replace the specification of data structures by pointer dereferences as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- net/tipc/server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/tipc/server.c +2 -2
@@ -219,7 +219,7 @@ static struct tipc_conn *tipc_alloc_conn(struct tipc_server *s)struct tipc_conn *con;int ret; - con =kzalloc (sizeof (struct tipc_conn ),GFP_ATOMIC ); + con =kzalloc (sizeof (*con),GFP_ATOMIC );if (!con)return ERR_PTR (-ENOMEM );
@@ -410,7 +410,7 @@ static struct outqueue_entry *tipc_alloc_entry(void *data, int len)struct outqueue_entry *entry;void *buf; - entry =kmalloc (sizeof (struct outqueue_entry ),GFP_ATOMIC ); + entry =kmalloc (sizeof (*entry),GFP_ATOMIC );if (!entry)return NULL ;
Signature · 1 line
2.15.0