Skip to contentSkip to conversation

tipc: Fine-tuning for three function implementations

PATCH New SF Markus Elfring 1 participant 3 messages Nov 8, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

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
index acaef80fb88c..7359d37e39cd 100644
@@ -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
#2 lore raw

PATCH 2/2 tipc: Improve a size determination in two functions

In reply to SF Markus Elfring

From: 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
index 7359d37e39cd..5d001b6acbe5 100644
@@ -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