Skip to contentSkip to conversation

net-SCTP: Fine-tuning for six function implementations

PATCH In review SF Markus Elfring 2 participants 5 messages May 1, 2017 – May 2, 2017

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

cover net-SCTP: Fine-tuning for six function implementations

From: Markus Elfring <[email protected]>
Date: Mon, 1 May 2017 15:25:05 +0200

A few update suggestions were taken into account
from static source code analysis.

Markus Elfring (3):
Replace six seq_printf() calls by seq_putc()
Combine two seq_printf() calls into one call in sctp_remaddr_seq_show() Replace four seq_printf() calls by seq_puts()

 net/sctp/proc.c | 39 ++++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 23 deletions(-)
Signature · 1 line
2.12.2
#1 lore raw

PATCH 1/3 sctp: Replace six seq_printf() calls by seq_putc()

From: Markus Elfring <[email protected]>
Date: Mon, 1 May 2017 14:18:52 +0200

Six single characters should be put into a sequence. Thus use the corresponding function "seq_putc".

This issue was detected by using the Coccinelle software.

---
 net/sctp/proc.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)
net/sctp/proc.c +8 -11
index a0b29d43627f..1cf4b6385418 100644
@@ -149,9 +149,8 @@ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_commo
 
 		addr = &laddr->a;
 		af = sctp_get_af_specific(addr->sa.sa_family);
-		if (primary && af->cmp_addr(addr, primary)) {
-			seq_printf(seq, "*");
-		}
+		if (primary && af->cmp_addr(addr, primary))
+			seq_putc(seq, '*');
 		af->seq_dump_addr(seq, addr);
 	}
 	rcu_read_unlock();
@@ -170,9 +169,8 @@ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_associa
 		addr = &transport->ipaddr;
 
 		af = sctp_get_af_specific(addr->sa.sa_family);
-		if (af->cmp_addr(addr, primary)) {
-			seq_printf(seq, "*");
-		}
+		if (af->cmp_addr(addr, primary))
+			seq_putc(seq, '*');
 		af->seq_dump_addr(seq, addr);
 	}
 }
@@ -232,7 +230,7 @@ static int sctp_eps_seq_show(struct seq_file *seq, void *v)
 			   sock_i_ino(sk));
 
 		sctp_seq_dump_local_addrs(seq, epb);
-		seq_printf(seq, "\n");
+		seq_putc(seq, '\n');
 	}
 	read_unlock(&head->lock);
 	local_bh_enable();
@@ -355,5 +353,5 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
 		   sock_i_ino(sk),
 		   epb->bind_addr.port,
 		   assoc->peer.port);
-	seq_printf(seq, " ");
+	seq_putc(seq, ' ');
 	sctp_seq_dump_local_addrs(seq, epb);
@@ -369,8 +367,7 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
 		sk->sk_wmem_queued,
 		sk->sk_sndbuf,
 		sk->sk_rcvbuf);
-	seq_printf(seq, "\n");
-
+	seq_putc(seq, '\n');
 	sctp_transport_put(transport);
 
 	return 0;
@@ -438,7 +435,7 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
 		 * The remote address (ADDR)
 		 */
 		tsp->af_specific->seq_dump_addr(seq, &tsp->ipaddr);
-		seq_printf(seq, " ");
+		seq_putc(seq, ' ');
 		/*
 		 * The association ID (ASSOC_ID)
 		 */
Signature · 1 line
2.12.2
#2 lore raw

PATCH 2/3 sctp: Combine two seq_printf() calls into one call in sctp_remaddr_seq_show()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 1 May 2017 14:24:34 +0200

A bit of data was put into a sequence by two separate function calls. Print the same data by a single function call instead.

This issue was detected by using the Coccinelle software.

---
 net/sctp/proc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
net/sctp/proc.c +1 -3
index 1cf4b6385418..458087681490 100644
@@ -475,9 +475,7 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
 		 * The current state of this destination. I.e.
 		 * SCTP_ACTIVE, SCTP_INACTIVE, ...
 		 */
-		seq_printf(seq, "%d", tsp->state);
-
-		seq_printf(seq, "\n");
+		seq_printf(seq, "%d\n", tsp->state);
 	}
 
 	sctp_transport_put(transport);
Signature · 1 line
2.12.2
#3 lore raw

PATCH 3/3 sctp: Replace four seq_printf() calls by seq_puts()

In reply to SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 1 May 2017 14:54:18 +0200

Strings which did not contain data format specifications should be put into a sequence. Thus use the corresponding function "seq_puts".

This issue was detected by using the Coccinelle software.

---
 net/sctp/proc.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)
net/sctp/proc.c +7 -9
index 458087681490..a9dc4538db44 100644
@@ -184,7 +184,8 @@ static void *sctp_eps_seq_start(struct seq_file *seq, loff_t *pos)
 		*pos = 0;
 
 	if (*pos = 0)
-		seq_printf(seq, " ENDPT     SOCK   STY SST HBKT LPORT   UID INODE LADDRS\n");
+		seq_puts(seq,
+			 " ENDPT     SOCK   STY SST HBKT LPORT   UID INODE LADDRS\n");
 
 	return (void *)pos;
 }
@@ -326,11 +327,8 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
 	struct sock *sk;
 
 	if (v = SEQ_START_TOKEN) {
-		seq_printf(seq, " ASSOC     SOCK   STY SST ST HBKT "
-				"ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT "
-				"RPORT LADDRS <-> RADDRS "
-				"HBINT INS OUTS MAXRT T1X T2X RTXC "
-				"wmema wmemq sndbuf rcvbuf\n");
+		seq_puts(seq,
+			 " ASSOC     SOCK   STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT RPORT LADDRS <-> RADDRS HBINT INS OUTS MAXRT T1X T2X RTXC wmema wmemq sndbuf rcvbuf\n");
 		return 0;
 	}
 
@@ -357,5 +355,5 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
 	sctp_seq_dump_local_addrs(seq, epb);
-	seq_printf(seq, "<-> ");
+	seq_puts(seq, "<-> ");
 	sctp_seq_dump_remote_addrs(seq, assoc);
 	seq_printf(seq, "\t%8lu %5d %5d %4d %4d %4d %8d "
 		   "%8d %8d %8d %8d",
@@ -419,8 +417,8 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
 	struct sctp_transport *transport, *tsp;
 
 	if (v = SEQ_START_TOKEN) {
-		seq_printf(seq, "ADDR ASSOC_ID HB_ACT RTO MAX_PATH_RTX "
-				"REM_ADDR_RTX START STATE\n");
+		seq_puts(seq,
+			 "ADDR ASSOC_ID HB_ACT RTO MAX_PATH_RTX REM_ADDR_RTX START STATE\n");
 		return 0;
 	}
 
Signature · 1 line
2.12.2
Acked-by on the v1 series
#4 lore raw
In reply to SF Markus Elfring
Quoted 6 lines · SF Markus Elfring

From: Markus Elfring <[email protected]>
Date: Mon, 1 May 2017 15:25:05 +0200

A few update suggestions were taken into account
from static source code analysis.

Quoted 12 lines

Markus Elfring (3):
Replace six seq_printf() calls by seq_putc()
Combine two seq_printf() calls into one call in sctp_remaddr_seq_show() Replace four seq_printf() calls by seq_puts()

 net/sctp/proc.c | 39 ++++++++++++++++-----------------------
 1 file changed, 16 insertions(+), 23 deletions(-)
Signature · 1 line
2.12.2