Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1637486 > unrolled thread
| Started by | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| First post | 2017-05-08 17:10 +0200 |
| Last post | 2017-05-08 17:20 +0200 |
| Articles | 4 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 0/3] mtdswap: Fine-tuning for three function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-08 17:10 +0200
[PATCH 1/3] mtdswap: Reduce function calls for sequence output in mtdswap_show() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-08 17:10 +0200
[PATCH 3/3] mtdswap: Improve a size determination in mtdswap_erase_block() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-08 17:20 +0200
[PATCH 2/3] mtdswap: Improve two size determinations in mtdswap_add_mtd() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-05-08 17:20 +0200
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-08 17:10 +0200 |
| Subject | [PATCH 0/3] mtdswap: Fine-tuning for three function implementations |
| Message-ID | <tESsp-5wT-7@gated-at.bofh.it> |
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
[toc] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-08 17:10 +0200 |
| Subject | [PATCH 1/3] mtdswap: Reduce function calls for sequence output in mtdswap_show() |
| Message-ID | <tESsq-5wT-35@gated-at.bofh.it> |
| In reply to | #1637486 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-08 17:20 +0200 |
| Subject | [PATCH 3/3] mtdswap: Improve a size determination in mtdswap_erase_block() |
| Message-ID | <tESC6-5Ad-13@gated-at.bofh.it> |
| In reply to | #1637486 |
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
[toc] | [prev] | [next] | [standalone]
| From | SF Markus Elfring <elfring@users.sourceforge.net> |
|---|---|
| Date | 2017-05-08 17:20 +0200 |
| Subject | [PATCH 2/3] mtdswap: Improve two size determinations in mtdswap_add_mtd() |
| Message-ID | <tESC6-5Ad-19@gated-at.bofh.it> |
| In reply to | #1637486 |
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
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web