linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] mtdswap: Fine-tuning for three function implementations
@ 2017-05-08 15:07 SF Markus Elfring
  2017-05-08 15:08 ` [PATCH 1/3] mtdswap: Reduce function calls for sequence output in mtdswap_show() SF Markus Elfring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-08 15:07 UTC (permalink / raw)
  To: linux-mtd, Boris Brezillon, Brian Norris, Cyrille Pitchen,
	David Woodhouse, Marek Vasut, Richard Weinberger
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 May 2017 17:02:03 +0200

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

Markus Elfring (3):
  Reduce function calls for sequence output in mtdswap_show()
  Improve two size determinations in mtdswap_add_mtd()
  Improve a size determination in mtdswap_erase_block()

 drivers/mtd/mtdswap.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

-- 
2.12.2

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

* [PATCH 1/3] mtdswap: Reduce function calls for sequence output in mtdswap_show()
  2017-05-08 15:07 [PATCH 0/3] mtdswap: Fine-tuning for three function implementations SF Markus Elfring
@ 2017-05-08 15:08 ` SF Markus Elfring
  2017-05-08 15:09 ` [PATCH 2/3] mtdswap: Improve two size determinations in mtdswap_add_mtd() SF Markus Elfring
  2017-05-08 15:10 ` [PATCH 3/3] mtdswap: Improve a size determination in mtdswap_erase_block() SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-08 15:08 UTC (permalink / raw)
  To: linux-mtd, Boris Brezillon, Brian Norris, Cyrille Pitchen,
	David Woodhouse, Marek Vasut, Richard Weinberger
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 May 2017 16:02:34 +0200

Two line breaks were put into a sequence by separate function calls.
Print the same data together with adjusted seq_printf() calls instead.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/mtdswap.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index f12879a3d4ff..0805f45c5139 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1283,19 +1283,14 @@ static int mtdswap_show(struct seq_file *s, void *data)
 			"erased %u times\n",
 			cwp, d->pages_per_eblk - cwp, cwecount);
 
-	seq_printf(s, "total erasures: %lu\n", sum);
-
-	seq_puts(s, "\n");
-
+	seq_printf(s, "total erasures: %lu\n\n", sum);
 	seq_printf(s, "mtdswap_readsect count: %llu\n", d->sect_read_count);
 	seq_printf(s, "mtdswap_writesect count: %llu\n", d->sect_write_count);
 	seq_printf(s, "mtdswap_discard count: %llu\n", d->discard_count);
 	seq_printf(s, "mtd read count: %llu\n", d->mtd_read_count);
 	seq_printf(s, "mtd write count: %llu\n", d->mtd_write_count);
 	seq_printf(s, "discarded pages count: %llu\n", d->discard_page_count);
-
-	seq_puts(s, "\n");
-	seq_printf(s, "total pages: %u\n", pages);
+	seq_printf(s, "\ntotal pages: %u\n", pages);
 	seq_printf(s, "pages mapped: %u\n", mapped);
 
 	return 0;
-- 
2.12.2

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

* [PATCH 2/3] mtdswap: Improve two size determinations in mtdswap_add_mtd()
  2017-05-08 15:07 [PATCH 0/3] mtdswap: Fine-tuning for three function implementations SF Markus Elfring
  2017-05-08 15:08 ` [PATCH 1/3] mtdswap: Reduce function calls for sequence output in mtdswap_show() SF Markus Elfring
@ 2017-05-08 15:09 ` SF Markus Elfring
  2017-05-08 15:10 ` [PATCH 3/3] mtdswap: Improve a size determination in mtdswap_erase_block() SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-08 15:09 UTC (permalink / raw)
  To: linux-mtd, Boris Brezillon, Brian Norris, Cyrille Pitchen,
	David Woodhouse, Marek Vasut, Richard Weinberger
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 May 2017 16:18:49 +0200

Replace the specification of two 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.

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

diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index 0805f45c5139..f73fb0909b0c 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1485,11 +1485,11 @@ static void mtdswap_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)
 		"%u spare, %u bad blocks\n",
 		MTDSWAP_PREFIX, part, swap_size / 1024, spare_cnt, bad_blocks);
 
-	d = kzalloc(sizeof(struct mtdswap_dev), GFP_KERNEL);
+	d = kzalloc(sizeof(*d), GFP_KERNEL);
 	if (!d)
 		return;
 
-	mbd_dev = kzalloc(sizeof(struct mtd_blktrans_dev), GFP_KERNEL);
+	mbd_dev = kzalloc(sizeof(*mbd_dev), GFP_KERNEL);
 	if (!mbd_dev) {
 		kfree(d);
 		return;
-- 
2.12.2

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

* [PATCH 3/3] mtdswap: Improve a size determination in mtdswap_erase_block()
  2017-05-08 15:07 [PATCH 0/3] mtdswap: Fine-tuning for three function implementations SF Markus Elfring
  2017-05-08 15:08 ` [PATCH 1/3] mtdswap: Reduce function calls for sequence output in mtdswap_show() SF Markus Elfring
  2017-05-08 15:09 ` [PATCH 2/3] mtdswap: Improve two size determinations in mtdswap_add_mtd() SF Markus Elfring
@ 2017-05-08 15:10 ` SF Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-05-08 15:10 UTC (permalink / raw)
  To: linux-mtd, Boris Brezillon, Brian Norris, Cyrille Pitchen,
	David Woodhouse, Marek Vasut, Richard Weinberger
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Mon, 8 May 2017 16:51:30 +0200

Replace the specification of a data structure by a name for
a local variable as the parameter for the operator "sizeof" to make
the corresponding size determination a bit safer.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/mtd/mtdswap.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index f73fb0909b0c..c748515f8533 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -559,8 +559,7 @@ static int mtdswap_erase_block(struct mtdswap_dev *d, struct swap_eb *eb)
 
 retry:
 	init_waitqueue_head(&wq);
-	memset(&erase, 0, sizeof(struct erase_info));
-
+	memset(&erase, 0, sizeof(erase));
 	erase.mtd	= mtd;
 	erase.callback	= mtdswap_erase_callback;
 	erase.addr	= mtdswap_eb_offset(d, eb);
-- 
2.12.2

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

end of thread, other threads:[~2017-05-08 15:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-08 15:07 [PATCH 0/3] mtdswap: Fine-tuning for three function implementations SF Markus Elfring
2017-05-08 15:08 ` [PATCH 1/3] mtdswap: Reduce function calls for sequence output in mtdswap_show() SF Markus Elfring
2017-05-08 15:09 ` [PATCH 2/3] mtdswap: Improve two size determinations in mtdswap_add_mtd() SF Markus Elfring
2017-05-08 15:10 ` [PATCH 3/3] mtdswap: Improve a size determination in mtdswap_erase_block() 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).