* [PATCH 1/3] sctp: Replace six seq_printf() calls by seq_putc()
2017-05-01 13:30 [PATCH 0/3] net-SCTP: Fine-tuning for six function implementations SF Markus Elfring
@ 2017-05-01 13:31 ` SF Markus Elfring
2017-05-01 13:32 ` [PATCH 2/3] sctp: Combine two seq_printf() calls into one call in sctp_remaddr_seq_show() SF Markus Elfring
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-05-01 13:31 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sctp/proc.c | 19 ++++++++-----------
1 file changed, 8 insertions(+), 11 deletions(-)
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index a0b29d43627f..1cf4b6385418 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -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)
*/
--
2.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] sctp: Combine two seq_printf() calls into one call in sctp_remaddr_seq_show()
2017-05-01 13:30 [PATCH 0/3] net-SCTP: Fine-tuning for six function implementations SF Markus Elfring
2017-05-01 13:31 ` [PATCH 1/3] sctp: Replace six seq_printf() calls by seq_putc() SF Markus Elfring
@ 2017-05-01 13:32 ` SF Markus Elfring
2017-05-01 13:33 ` [PATCH 3/3] sctp: Replace four seq_printf() calls by seq_puts() SF Markus Elfring
2017-05-02 13:15 ` [PATCH 0/3] net-SCTP: Fine-tuning for six function implementations Neil Horman
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-05-01 13:32 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sctp/proc.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 1cf4b6385418..458087681490 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -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);
--
2.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] sctp: Replace four seq_printf() calls by seq_puts()
2017-05-01 13:30 [PATCH 0/3] net-SCTP: Fine-tuning for six function implementations SF Markus Elfring
2017-05-01 13:31 ` [PATCH 1/3] sctp: Replace six seq_printf() calls by seq_putc() SF Markus Elfring
2017-05-01 13:32 ` [PATCH 2/3] sctp: Combine two seq_printf() calls into one call in sctp_remaddr_seq_show() SF Markus Elfring
@ 2017-05-01 13:33 ` SF Markus Elfring
2017-05-02 13:15 ` [PATCH 0/3] net-SCTP: Fine-tuning for six function implementations Neil Horman
3 siblings, 0 replies; 5+ messages in thread
From: SF Markus Elfring @ 2017-05-01 13:33 UTC (permalink / raw)
To: linux-sctp, netdev, David S. Miller, Neil Horman, Vlad Yasevich
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
net/sctp/proc.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/net/sctp/proc.c b/net/sctp/proc.c
index 458087681490..a9dc4538db44 100644
--- a/net/sctp/proc.c
+++ b/net/sctp/proc.c
@@ -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;
}
--
2.12.2
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] net-SCTP: Fine-tuning for six function implementations
2017-05-01 13:30 [PATCH 0/3] net-SCTP: Fine-tuning for six function implementations SF Markus Elfring
` (2 preceding siblings ...)
2017-05-01 13:33 ` [PATCH 3/3] sctp: Replace four seq_printf() calls by seq_puts() SF Markus Elfring
@ 2017-05-02 13:15 ` Neil Horman
3 siblings, 0 replies; 5+ messages in thread
From: Neil Horman @ 2017-05-02 13:15 UTC (permalink / raw)
To: SF Markus Elfring
Cc: linux-sctp, netdev, David S. Miller, Vlad Yasevich, LKML,
kernel-janitors
On Mon, May 01, 2017 at 03:30:25PM +0200, SF Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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(-)
>
> --
> 2.12.2
>
>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
^ permalink raw reply [flat|nested] 5+ messages in thread