linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/6] lockdep: Fine-tuning for some function implementations
@ 2017-05-03 20:35 SF Markus Elfring
  2017-05-03 20:36 ` [PATCH 1/6] lockdep: Replace 11 seq_puts() calls by seq_putc() SF Markus Elfring
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-03 20:35 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 May 2017 22:17:03 +0200

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

Markus Elfring (6):
  Replace 11 seq_puts() calls by seq_putc()
  Use seq_putc() in seq_header()
  Replace four seq_printf() calls by seq_puts()
  Combine two seq_printf() calls into one call in l_show()
  Improve a size determination in lock_stat_open()
  Add spaces for better code readability

 kernel/locking/lockdep_proc.c | 50 ++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 27 deletions(-)

-- 
2.12.2

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

* [PATCH 1/6] lockdep: Replace 11 seq_puts() calls by seq_putc()
  2017-05-03 20:35 [PATCH 0/6] lockdep: Fine-tuning for some function implementations SF Markus Elfring
@ 2017-05-03 20:36 ` SF Markus Elfring
  2017-05-03 20:37 ` [PATCH 2/6] lockdep: Use seq_putc() in seq_header() SF Markus Elfring
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-03 20:36 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 May 2017 21:00:26 +0200

Some 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>
---
 kernel/locking/lockdep_proc.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 6d1fcc786081..825496ece766 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -81,15 +81,14 @@ static int l_show(struct seq_file *m, void *v)
 	print_name(m, class);
-	seq_puts(m, "\n");
+	seq_putc(m, '\n');
 
 	list_for_each_entry(entry, &class->locks_after, entry) {
 		if (entry->distance == 1) {
 			seq_printf(m, " -> [%p] ", entry->class->key);
 			print_name(m, entry->class);
-			seq_puts(m, "\n");
+			seq_putc(m, '\n');
 		}
 	}
-	seq_puts(m, "\n");
-
+	seq_putc(m, '\n');
 	return 0;
 }
 
@@ -156,10 +155,9 @@ static int lc_show(struct seq_file *m, void *v)
 
 		seq_printf(m, "[%p] ", class->key);
 		print_name(m, class);
-		seq_puts(m, "\n");
+		seq_putc(m, '\n');
 	}
-	seq_puts(m, "\n");
-
+	seq_putc(m, '\n');
 	return 0;
 }
 
@@ -393,10 +391,10 @@ static void seq_line(struct seq_file *m, char c, int offset, int length)
 	int i;
 
 	for (i = 0; i < offset; i++)
-		seq_puts(m, " ");
+		seq_putc(m, ' ');
 	for (i = 0; i < length; i++)
 		seq_printf(m, "%c", c);
-	seq_puts(m, "\n");
+	seq_putc(m, '\n');
 }
 
 static void snprint_time(char *buf, size_t bufsiz, s64 nr)
@@ -483,7 +481,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
 		seq_lock_time(m, &stats->write_waittime);
 		seq_printf(m, " %14lu ", stats->bounces[bounce_acquired_write]);
 		seq_lock_time(m, &stats->write_holdtime);
-		seq_puts(m, "\n");
+		seq_putc(m, '\n');
 	}
 
 	if (stats->read_holdtime.nr) {
@@ -492,7 +490,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
 		seq_lock_time(m, &stats->read_waittime);
 		seq_printf(m, " %14lu ", stats->bounces[bounce_acquired_read]);
 		seq_lock_time(m, &stats->read_holdtime);
-		seq_puts(m, "\n");
+		seq_putc(m, '\n');
 	}
 
 	if (stats->read_waittime.nr + stats->write_waittime.nr == 0)
@@ -532,9 +530,9 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
 			   ip, (void *)class->contending_point[i]);
 	}
 	if (i) {
-		seq_puts(m, "\n");
+		seq_putc(m, '\n');
 		seq_line(m, '.', 0, 40 + 1 + 12 * (14 + 1));
-		seq_puts(m, "\n");
+		seq_putc(m, '\n');
 	}
 }
 
-- 
2.12.2

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

* [PATCH 2/6] lockdep: Use seq_putc() in seq_header()
  2017-05-03 20:35 [PATCH 0/6] lockdep: Fine-tuning for some function implementations SF Markus Elfring
  2017-05-03 20:36 ` [PATCH 1/6] lockdep: Replace 11 seq_puts() calls by seq_putc() SF Markus Elfring
@ 2017-05-03 20:37 ` SF Markus Elfring
  2017-05-03 20:38 ` [PATCH 3/6] lockdep: Replace four seq_printf() calls by seq_puts() SF Markus Elfring
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-03 20:37 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 May 2017 21:30:26 +0200

A single character (line break) 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>
---
 kernel/locking/lockdep_proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 825496ece766..b1fa2ae31c0b 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -560,7 +560,7 @@ static void seq_header(struct seq_file *m)
 			"holdtime-total",
 			"holdtime-avg");
 	seq_line(m, '-', 0, 40 + 1 + 12 * (14 + 1));
-	seq_printf(m, "\n");
+	seq_putc(m, '\n');
 }
 
 static void *ls_start(struct seq_file *m, loff_t *pos)
-- 
2.12.2

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

* [PATCH 3/6] lockdep: Replace four seq_printf() calls by seq_puts()
  2017-05-03 20:35 [PATCH 0/6] lockdep: Fine-tuning for some function implementations SF Markus Elfring
  2017-05-03 20:36 ` [PATCH 1/6] lockdep: Replace 11 seq_puts() calls by seq_putc() SF Markus Elfring
  2017-05-03 20:37 ` [PATCH 2/6] lockdep: Use seq_putc() in seq_header() SF Markus Elfring
@ 2017-05-03 20:38 ` SF Markus Elfring
  2017-05-03 20:39 ` [PATCH 4/6] lockdep: Combine two seq_printf() calls into one call in l_show() SF Markus Elfring
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-03 20:38 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 May 2017 21:46:49 +0200

Four 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>
---
 kernel/locking/lockdep_proc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index b1fa2ae31c0b..a353f53b6de6 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -61,7 +61,7 @@ static int l_show(struct seq_file *m, void *v)
 	char usage[LOCK_USAGE_CHARS];
 
 	if (v == &all_lock_classes) {
-		seq_printf(m, "all lock classes:\n");
+		seq_puts(m, "all lock classes:\n");
 		return 0;
 	}
 
@@ -141,8 +141,8 @@ static int lc_show(struct seq_file *m, void *v)
 
 	if (v == SEQ_START_TOKEN) {
 		if (nr_chain_hlocks > MAX_LOCKDEP_CHAIN_HLOCKS)
-			seq_printf(m, "(buggered) ");
-		seq_printf(m, "all lock chains:\n");
+			seq_puts(m, "(buggered) ");
+		seq_puts(m, "all lock chains:\n");
 		return 0;
 	}
 
@@ -541,7 +541,7 @@ static void seq_header(struct seq_file *m)
 	seq_puts(m, "lock_stat version 0.4\n");
 
 	if (unlikely(!debug_locks))
-		seq_printf(m, "*WARNING* lock debugging disabled!! - possibly due to a lockdep warning\n");
+		seq_puts(m, "*WARNING* lock debugging disabled!! - possibly due to a lockdep warning\n");
 
 	seq_line(m, '-', 0, 40 + 1 + 12 * (14 + 1));
 	seq_printf(m, "%40s %14s %14s %14s %14s %14s %14s %14s %14s %14s %14s "
-- 
2.12.2

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

* [PATCH 4/6] lockdep: Combine two seq_printf() calls into one call in l_show()
  2017-05-03 20:35 [PATCH 0/6] lockdep: Fine-tuning for some function implementations SF Markus Elfring
                   ` (2 preceding siblings ...)
  2017-05-03 20:38 ` [PATCH 3/6] lockdep: Replace four seq_printf() calls by seq_puts() SF Markus Elfring
@ 2017-05-03 20:39 ` SF Markus Elfring
  2017-05-03 20:40 ` [PATCH 5/6] lockdep: Improve a size determination in lock_stat_open() SF Markus Elfring
  2017-05-03 20:42 ` [PATCH 6/6] lockdep: Add spaces for better code readability SF Markus Elfring
  5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-03 20:39 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 May 2017 21:56:11 +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>
---
 kernel/locking/lockdep_proc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index a353f53b6de6..2cc0ccd2b3de 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -75,7 +75,5 @@ static int l_show(struct seq_file *m, void *v)
 #endif
 
 	get_usage_chars(class, usage);
-	seq_printf(m, " %s", usage);
-
-	seq_printf(m, ": ");
+	seq_printf(m, " %s: ", usage);
 	print_name(m, class);
-- 
2.12.2

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

* [PATCH 5/6] lockdep: Improve a size determination in lock_stat_open()
  2017-05-03 20:35 [PATCH 0/6] lockdep: Fine-tuning for some function implementations SF Markus Elfring
                   ` (3 preceding siblings ...)
  2017-05-03 20:39 ` [PATCH 4/6] lockdep: Combine two seq_printf() calls into one call in l_show() SF Markus Elfring
@ 2017-05-03 20:40 ` SF Markus Elfring
  2017-05-03 20:42 ` [PATCH 6/6] lockdep: Add spaces for better code readability SF Markus Elfring
  5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-03 20:40 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 May 2017 22:05:57 +0200

Replace the specification of a data structure by a pointer dereference
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/locking/lockdep_proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 2cc0ccd2b3de..509a17f5ea01 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -607,7 +607,7 @@ static int lock_stat_open(struct inode *inode, struct file *file)
 {
 	int res;
 	struct lock_class *class;
-	struct lock_stat_seq *data = vmalloc(sizeof(struct lock_stat_seq));
+	struct lock_stat_seq *data = vmalloc(sizeof(*data));
 
 	if (!data)
 		return -ENOMEM;
-- 
2.12.2

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

* [PATCH 6/6] lockdep: Add spaces for better code readability
  2017-05-03 20:35 [PATCH 0/6] lockdep: Fine-tuning for some function implementations SF Markus Elfring
                   ` (4 preceding siblings ...)
  2017-05-03 20:40 ` [PATCH 5/6] lockdep: Improve a size determination in lock_stat_open() SF Markus Elfring
@ 2017-05-03 20:42 ` SF Markus Elfring
  5 siblings, 0 replies; 7+ messages in thread
From: SF Markus Elfring @ 2017-05-03 20:42 UTC (permalink / raw)
  To: Ingo Molnar, Peter Zijlstra; +Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 3 May 2017 22:11:28 +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>
---
 kernel/locking/lockdep_proc.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/kernel/locking/lockdep_proc.c b/kernel/locking/lockdep_proc.c
index 509a17f5ea01..22c89868e6b1 100644
--- a/kernel/locking/lockdep_proc.c
+++ b/kernel/locking/lockdep_proc.c
@@ -402,7 +402,7 @@ static void snprint_time(char *buf, size_t bufsiz, s64 nr)
 
 	nr += 5; /* for display rounding */
 	div = div_s64_rem(nr, 1000, &rem);
-	snprintf(buf, bufsiz, "%lld.%02d", (long long)div, (int)rem/10);
+	snprintf(buf, bufsiz, "%lld.%02d", (long long)div, (int)rem / 10);
 }
 
 static void seq_time(struct seq_file *m, s64 time)
@@ -461,11 +461,11 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
 
 	namelen = strlen(name);
 	if (class->name_version > 1) {
-		snprintf(name+namelen, 3, "#%d", class->name_version);
+		snprintf(name + namelen, 3, "#%d", class->name_version);
 		namelen += 2;
 	}
 	if (class->subclass) {
-		snprintf(name+namelen, 3, "/%d", class->subclass);
+		snprintf(name + namelen, 3, "/%d", class->subclass);
 		namelen += 2;
 	}
 
@@ -504,7 +504,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
 			break;
 
 		if (!i)
-			seq_line(m, '-', 40-namelen, namelen);
+			seq_line(m, '-', 40 - namelen, namelen);
 
 		snprintf(ip, sizeof(ip), "[<%p>]",
 				(void *)class->contention_point[i]);
@@ -519,7 +519,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
 			break;
 
 		if (!i)
-			seq_line(m, '-', 40-namelen, namelen);
+			seq_line(m, '-', 40 - namelen, namelen);
 
 		snprintf(ip, sizeof(ip), "[<%p>]",
 				(void *)class->contending_point[i]);
-- 
2.12.2

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

end of thread, other threads:[~2017-05-03 20:42 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-03 20:35 [PATCH 0/6] lockdep: Fine-tuning for some function implementations SF Markus Elfring
2017-05-03 20:36 ` [PATCH 1/6] lockdep: Replace 11 seq_puts() calls by seq_putc() SF Markus Elfring
2017-05-03 20:37 ` [PATCH 2/6] lockdep: Use seq_putc() in seq_header() SF Markus Elfring
2017-05-03 20:38 ` [PATCH 3/6] lockdep: Replace four seq_printf() calls by seq_puts() SF Markus Elfring
2017-05-03 20:39 ` [PATCH 4/6] lockdep: Combine two seq_printf() calls into one call in l_show() SF Markus Elfring
2017-05-03 20:40 ` [PATCH 5/6] lockdep: Improve a size determination in lock_stat_open() SF Markus Elfring
2017-05-03 20:42 ` [PATCH 6/6] lockdep: Add spaces for better code readability SF Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).