All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] net/atm: Fine-tuning for three function implementations
@ 2017-05-02 17:45 ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-05-02 17:45 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 May 2017 19:37:39 +0200

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

Markus Elfring (3):
  Combine four seq_printf() calls in mpc_show()
  Use seq_putc() in mpc_show()
  Add some spaces for better code readability

 net/atm/mpoa_proc.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

-- 
2.12.2

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 0/3] net/atm: Fine-tuning for three function implementations
@ 2017-05-02 17:45 ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-05-02 17:45 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 May 2017 19:37:39 +0200

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

Markus Elfring (3):
  Combine four seq_printf() calls in mpc_show()
  Use seq_putc() in mpc_show()
  Add some spaces for better code readability

 net/atm/mpoa_proc.c | 37 ++++++++++++++++++++-----------------
 1 file changed, 20 insertions(+), 17 deletions(-)

-- 
2.12.2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] net/atm: Combine four seq_printf() calls in mpc_show()
  2017-05-02 17:45 ` SF Markus Elfring
@ 2017-05-02 17:46   ` SF Markus Elfring
  -1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-05-02 17:46 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 May 2017 18:52:58 +0200

Some data were put into a sequence by four separate function calls.
Print the same data by two function calls instead.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/atm/mpoa_proc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 2df34eb5d65f..6ea6028fd865 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -145,8 +145,8 @@ static int mpc_show(struct seq_file *m, void *v)
 		return 0;
 	}
 
-	seq_printf(m, "\nInterface %d:\n\n", mpc->dev_num);
-	seq_printf(m, "Ingress Entries:\nIP address      State      Holding time  Packets fwded  VPI  VCI\n");
+	seq_printf(m, "\nInterface %d:\n\nIngress Entries:\nIP address      State      Holding time  Packets fwded  VPI  VCI\n",
+		   mpc->dev_num);
 	do_gettimeofday(&now);
 
 	for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) {
@@ -165,7 +165,7 @@ static int mpc_show(struct seq_file *m, void *v)
 	}
 
-	seq_printf(m, "\n");
-	seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id        State      Holding time  Packets recvd  Latest IP addr   VPI VCI\n");
+	seq_printf(m,
+		   "\nEgress Entries:\nIngress MPC ATM addr\nCache-id        State      Holding time  Packets recvd  Latest IP addr   VPI VCI\n");
 	for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) {
 		unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr;
 		for (i = 0; i < ATM_ESA_LEN; i++)
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 1/3] net/atm: Combine four seq_printf() calls in mpc_show()
@ 2017-05-02 17:46   ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-05-02 17:46 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 May 2017 18:52:58 +0200

Some data were put into a sequence by four separate function calls.
Print the same data by two function calls instead.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/atm/mpoa_proc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 2df34eb5d65f..6ea6028fd865 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -145,8 +145,8 @@ static int mpc_show(struct seq_file *m, void *v)
 		return 0;
 	}
 
-	seq_printf(m, "\nInterface %d:\n\n", mpc->dev_num);
-	seq_printf(m, "Ingress Entries:\nIP address      State      Holding time  Packets fwded  VPI  VCI\n");
+	seq_printf(m, "\nInterface %d:\n\nIngress Entries:\nIP address      State      Holding time  Packets fwded  VPI  VCI\n",
+		   mpc->dev_num);
 	do_gettimeofday(&now);
 
 	for (in_entry = mpc->in_cache; in_entry; in_entry = in_entry->next) {
@@ -165,7 +165,7 @@ static int mpc_show(struct seq_file *m, void *v)
 	}
 
-	seq_printf(m, "\n");
-	seq_printf(m, "Egress Entries:\nIngress MPC ATM addr\nCache-id        State      Holding time  Packets recvd  Latest IP addr   VPI VCI\n");
+	seq_printf(m,
+		   "\nEgress Entries:\nIngress MPC ATM addr\nCache-id        State      Holding time  Packets recvd  Latest IP addr   VPI VCI\n");
 	for (eg_entry = mpc->eg_cache; eg_entry; eg_entry = eg_entry->next) {
 		unsigned char *p = eg_entry->ctrl_info.in_MPC_data_ATM_addr;
 		for (i = 0; i < ATM_ESA_LEN; i++)
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] net/atm: Use seq_putc() in mpc_show()
  2017-05-02 17:45 ` SF Markus Elfring
@ 2017-05-02 17:48   ` SF Markus Elfring
  -1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-05-02 17:48 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 May 2017 18:58:08 +0200

Single characters (line breaks) 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/atm/mpoa_proc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 6ea6028fd865..324c4f95f4bf 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -161,7 +161,7 @@ static int mpc_show(struct seq_file *m, void *v)
 			seq_printf(m, "   %-3d  %-3d",
 				   in_entry->shortcut->vpi,
 				   in_entry->shortcut->vci);
-		seq_printf(m, "\n");
+		seq_putc(m, '\n');
 	}
 
 	seq_printf(m,
@@ -185,9 +185,9 @@ static int mpc_show(struct seq_file *m, void *v)
 			seq_printf(m, " %-3d %-3d",
 				   eg_entry->shortcut->vpi,
 				   eg_entry->shortcut->vci);
-		seq_printf(m, "\n");
+		seq_putc(m, '\n');
 	}
-	seq_printf(m, "\n");
+	seq_putc(m, '\n');
 	return 0;
 }
 
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] net/atm: Use seq_putc() in mpc_show()
@ 2017-05-02 17:48   ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-05-02 17:48 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 May 2017 18:58:08 +0200

Single characters (line breaks) 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/atm/mpoa_proc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 6ea6028fd865..324c4f95f4bf 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -161,7 +161,7 @@ static int mpc_show(struct seq_file *m, void *v)
 			seq_printf(m, "   %-3d  %-3d",
 				   in_entry->shortcut->vpi,
 				   in_entry->shortcut->vci);
-		seq_printf(m, "\n");
+		seq_putc(m, '\n');
 	}
 
 	seq_printf(m,
@@ -185,9 +185,9 @@ static int mpc_show(struct seq_file *m, void *v)
 			seq_printf(m, " %-3d %-3d",
 				   eg_entry->shortcut->vpi,
 				   eg_entry->shortcut->vci);
-		seq_printf(m, "\n");
+		seq_putc(m, '\n');
 	}
-	seq_printf(m, "\n");
+	seq_putc(m, '\n');
 	return 0;
 }
 
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] net/atm: Add some spaces for better code readability
  2017-05-02 17:45 ` SF Markus Elfring
@ 2017-05-02 17:49   ` SF Markus Elfring
  -1 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-05-02 17:49 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 May 2017 19:19:14 +0200

Use space characters at some source code places according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/atm/mpoa_proc.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 324c4f95f4bf..6a52606557f0 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -154,8 +154,8 @@ static int mpc_show(struct seq_file *m, void *v)
 		seq_printf(m, "%-16s%s%-14lu%-12u",
 			   ip_string,
 			   ingress_state_string(in_entry->entry_state),
-			   in_entry->ctrl_info.holding_time -
-			   (now.tv_sec-in_entry->tv.tv_sec),
+			   in_entry->ctrl_info.holding_time
+			   - (now.tv_sec - in_entry->tv.tv_sec),
 			   in_entry->packets_fwded);
 		if (in_entry->shortcut)
 			seq_printf(m, "   %-3d  %-3d",
@@ -173,8 +173,8 @@ static int mpc_show(struct seq_file *m, void *v)
 		seq_printf(m, "\n%-16lu%s%-14lu%-15u",
 			   (unsigned long)ntohl(eg_entry->ctrl_info.cache_id),
 			   egress_state_string(eg_entry->entry_state),
-			   (eg_entry->ctrl_info.holding_time -
-			    (now.tv_sec-eg_entry->tv.tv_sec)),
+			   eg_entry->ctrl_info.holding_time
+			   - (now.tv_sec - eg_entry->tv.tv_sec),
 			   eg_entry->packets_rcvd);
 
 		/* latest IP address */
@@ -213,7 +213,7 @@ static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
 		return 0;
 
 	if (nbytes >= PAGE_SIZE)
-		nbytes = PAGE_SIZE-1;
+		nbytes = PAGE_SIZE - 1;
 
 	page = (char *)__get_free_page(GFP_KERNEL);
 	if (!page)
@@ -251,18 +251,21 @@ static int parse_qos(const char *buff)
 	memset(&qos, 0, sizeof(struct atm_qos));
 
 	if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu",
-			ip, ip+1, ip+2, ip+3) == 4) {
+		   ip, ip + 1, ip + 2, ip + 3) == 4) {
 		ipaddr = *(__be32 *)ip;
 		return atm_mpoa_delete_qos(atm_mpoa_search_qos(ipaddr));
 	}
 
 	if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=tx",
-			ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu) == 6) {
+		   ip, ip + 1, ip + 2, ip + 3, &tx_pcr, &tx_sdu) == 6) {
 		rx_pcr = tx_pcr;
 		rx_sdu = tx_sdu;
-	} else if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=%d,%d",
-		ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
-		return 0;
+	} else {
+		if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=%d,%d",
+			   ip, ip + 1, ip + 2, ip + 3,
+			   &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
+			return 0;
+	}
 
 	ipaddr = *(__be32 *)ip;
 	qos.txtp.traffic_class = ATM_CBR;
-- 
2.12.2

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] net/atm: Add some spaces for better code readability
@ 2017-05-02 17:49   ` SF Markus Elfring
  0 siblings, 0 replies; 8+ messages in thread
From: SF Markus Elfring @ 2017-05-02 17:49 UTC (permalink / raw)
  To: netdev, David S. Miller; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 2 May 2017 19:19:14 +0200

Use space characters at some source code places according to
the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 net/atm/mpoa_proc.c | 23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c
index 324c4f95f4bf..6a52606557f0 100644
--- a/net/atm/mpoa_proc.c
+++ b/net/atm/mpoa_proc.c
@@ -154,8 +154,8 @@ static int mpc_show(struct seq_file *m, void *v)
 		seq_printf(m, "%-16s%s%-14lu%-12u",
 			   ip_string,
 			   ingress_state_string(in_entry->entry_state),
-			   in_entry->ctrl_info.holding_time -
-			   (now.tv_sec-in_entry->tv.tv_sec),
+			   in_entry->ctrl_info.holding_time
+			   - (now.tv_sec - in_entry->tv.tv_sec),
 			   in_entry->packets_fwded);
 		if (in_entry->shortcut)
 			seq_printf(m, "   %-3d  %-3d",
@@ -173,8 +173,8 @@ static int mpc_show(struct seq_file *m, void *v)
 		seq_printf(m, "\n%-16lu%s%-14lu%-15u",
 			   (unsigned long)ntohl(eg_entry->ctrl_info.cache_id),
 			   egress_state_string(eg_entry->entry_state),
-			   (eg_entry->ctrl_info.holding_time -
-			    (now.tv_sec-eg_entry->tv.tv_sec)),
+			   eg_entry->ctrl_info.holding_time
+			   - (now.tv_sec - eg_entry->tv.tv_sec),
 			   eg_entry->packets_rcvd);
 
 		/* latest IP address */
@@ -213,7 +213,7 @@ static ssize_t proc_mpc_write(struct file *file, const char __user *buff,
 		return 0;
 
 	if (nbytes >= PAGE_SIZE)
-		nbytes = PAGE_SIZE-1;
+		nbytes = PAGE_SIZE - 1;
 
 	page = (char *)__get_free_page(GFP_KERNEL);
 	if (!page)
@@ -251,18 +251,21 @@ static int parse_qos(const char *buff)
 	memset(&qos, 0, sizeof(struct atm_qos));
 
 	if (sscanf(buff, "del %hhu.%hhu.%hhu.%hhu",
-			ip, ip+1, ip+2, ip+3) = 4) {
+		   ip, ip + 1, ip + 2, ip + 3) = 4) {
 		ipaddr = *(__be32 *)ip;
 		return atm_mpoa_delete_qos(atm_mpoa_search_qos(ipaddr));
 	}
 
 	if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=tx",
-			ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu) = 6) {
+		   ip, ip + 1, ip + 2, ip + 3, &tx_pcr, &tx_sdu) = 6) {
 		rx_pcr = tx_pcr;
 		rx_sdu = tx_sdu;
-	} else if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=%d,%d",
-		ip, ip+1, ip+2, ip+3, &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
-		return 0;
+	} else {
+		if (sscanf(buff, "add %hhu.%hhu.%hhu.%hhu tx=%d,%d rx=%d,%d",
+			   ip, ip + 1, ip + 2, ip + 3,
+			   &tx_pcr, &tx_sdu, &rx_pcr, &rx_sdu) != 8)
+			return 0;
+	}
 
 	ipaddr = *(__be32 *)ip;
 	qos.txtp.traffic_class = ATM_CBR;
-- 
2.12.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-05-02 17:49 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-02 17:45 [PATCH 0/3] net/atm: Fine-tuning for three function implementations SF Markus Elfring
2017-05-02 17:45 ` SF Markus Elfring
2017-05-02 17:46 ` [PATCH 1/3] net/atm: Combine four seq_printf() calls in mpc_show() SF Markus Elfring
2017-05-02 17:46   ` SF Markus Elfring
2017-05-02 17:48 ` [PATCH 2/3] net/atm: Use seq_putc() " SF Markus Elfring
2017-05-02 17:48   ` SF Markus Elfring
2017-05-02 17:49 ` [PATCH 3/3] net/atm: Add some spaces for better code readability SF Markus Elfring
2017-05-02 17:49   ` SF Markus Elfring

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.