* [PATCH 1/1 linux-next] jffs2: remove multiple dereferences in debug
@ 2015-03-03 19:03 Fabian Frederick
2015-03-03 19:44 ` David Woodhouse
0 siblings, 1 reply; 3+ messages in thread
From: Fabian Frederick @ 2015-03-03 19:03 UTC (permalink / raw)
To: linux-kernel; +Cc: Fabian Frederick, linux-mtd, David Woodhouse
use jffs2_eraseblock variables to simplify the code
Signed-off-by: Fabian Frederick <fabf@skynet.be>
---
fs/jffs2/debug.c | 26 ++++++++++++++------------
1 file changed, 14 insertions(+), 12 deletions(-)
diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
index 1090eb6..2ddb967 100644
--- a/fs/jffs2/debug.c
+++ b/fs/jffs2/debug.c
@@ -160,26 +160,28 @@ __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
{
struct jffs2_eraseblock *jeb;
+ struct jffs2_eraseblock *gcb = c->gcblock;
+ struct jffs2_eraseblock *nextb = c->nextblock;
uint32_t free = 0, dirty = 0, used = 0, wasted = 0,
erasing = 0, bad = 0, unchecked = 0;
int nr_counted = 0;
int dump = 0;
- if (c->gcblock) {
+ if (gcb) {
nr_counted++;
- free += c->gcblock->free_size;
- dirty += c->gcblock->dirty_size;
- used += c->gcblock->used_size;
- wasted += c->gcblock->wasted_size;
- unchecked += c->gcblock->unchecked_size;
+ free += gcb->free_size;
+ dirty += gcb->dirty_size;
+ used += gcb->used_size;
+ wasted += gcb->wasted_size;
+ unchecked += gcb->unchecked_size;
}
- if (c->nextblock) {
+ if (nextb) {
nr_counted++;
- free += c->nextblock->free_size;
- dirty += c->nextblock->dirty_size;
- used += c->nextblock->used_size;
- wasted += c->nextblock->wasted_size;
- unchecked += c->nextblock->unchecked_size;
+ free += nextb->free_size;
+ dirty += nextb->dirty_size;
+ used += nextb->used_size;
+ wasted += nextb->wasted_size;
+ unchecked += nextb->unchecked_size;
}
list_for_each_entry(jeb, &c->clean_list, list) {
nr_counted++;
--
1.7.9.5
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1 linux-next] jffs2: remove multiple dereferences in debug
2015-03-03 19:03 [PATCH 1/1 linux-next] jffs2: remove multiple dereferences in debug Fabian Frederick
@ 2015-03-03 19:44 ` David Woodhouse
2015-03-03 20:48 ` Nicholas Krause
0 siblings, 1 reply; 3+ messages in thread
From: David Woodhouse @ 2015-03-03 19:44 UTC (permalink / raw)
To: Fabian Frederick; +Cc: linux-mtd, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2192 bytes --]
On Tue, 2015-03-03 at 20:03 +0100, Fabian Frederick wrote:
> use jffs2_eraseblock variables to simplify the code
That looks more like it's obfuscating the code to me. Now you have to
look up a few lines to see what the 'nextb' and 'gcb' variables actually
point to.
It doesn't even make it easier to read — if there were long lines with
complex formulæ it might make some sense, but in this case I think
there's really no point in this change.
> Signed-off-by: Fabian Frederick <fabf@skynet.be>
> ---
> fs/jffs2/debug.c | 26 ++++++++++++++------------
> 1 file changed, 14 insertions(+), 12 deletions(-)
>
> diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
> index 1090eb6..2ddb967 100644
> --- a/fs/jffs2/debug.c
> +++ b/fs/jffs2/debug.c
> @@ -160,26 +160,28 @@ __jffs2_dbg_prewrite_paranoia_check(struct jffs2_sb_info *c,
> void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
> {
> struct jffs2_eraseblock *jeb;
> + struct jffs2_eraseblock *gcb = c->gcblock;
> + struct jffs2_eraseblock *nextb = c->nextblock;
> uint32_t free = 0, dirty = 0, used = 0, wasted = 0,
> erasing = 0, bad = 0, unchecked = 0;
> int nr_counted = 0;
> int dump = 0;
>
> - if (c->gcblock) {
> + if (gcb) {
> nr_counted++;
> - free += c->gcblock->free_size;
> - dirty += c->gcblock->dirty_size;
> - used += c->gcblock->used_size;
> - wasted += c->gcblock->wasted_size;
> - unchecked += c->gcblock->unchecked_size;
> + free += gcb->free_size;
> + dirty += gcb->dirty_size;
> + used += gcb->used_size;
> + wasted += gcb->wasted_size;
> + unchecked += gcb->unchecked_size;
> }
> - if (c->nextblock) {
> + if (nextb) {
> nr_counted++;
> - free += c->nextblock->free_size;
> - dirty += c->nextblock->dirty_size;
> - used += c->nextblock->used_size;
> - wasted += c->nextblock->wasted_size;
> - unchecked += c->nextblock->unchecked_size;
> + free += nextb->free_size;
> + dirty += nextb->dirty_size;
> + used += nextb->used_size;
> + wasted += nextb->wasted_size;
> + unchecked += nextb->unchecked_size;
> }
> list_for_each_entry(jeb, &c->clean_list, list) {
> nr_counted++;
--
dwmw2
[-- Attachment #2: smime.p7s --]
[-- Type: application/x-pkcs7-signature, Size: 5745 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/1 linux-next] jffs2: remove multiple dereferences in debug
2015-03-03 19:44 ` David Woodhouse
@ 2015-03-03 20:48 ` Nicholas Krause
0 siblings, 0 replies; 3+ messages in thread
From: Nicholas Krause @ 2015-03-03 20:48 UTC (permalink / raw)
To: David Woodhouse, Fabian Frederick; +Cc: linux-mtd, linux-kernel
On March 3, 2015 2:44:24 PM EST, David Woodhouse <dwmw2@infradead.org> wrote:
>On Tue, 2015-03-03 at 20:03 +0100, Fabian Frederick wrote:
>> use jffs2_eraseblock variables to simplify the code
>
>That looks more like it's obfuscating the code to me. Now you have to
>look up a few lines to see what the 'nextb' and 'gcb' variables
>actually
>point to.
>
>It doesn't even make it easier to read — if there were long lines with
>complex formulæ it might make some sense, but in this case I think
>there's really no point in this change.
>
I have to agree with maintainer too as after reading the patch I found the code harder to understand too.
Nick
>
>> Signed-off-by: Fabian Frederick <fabf@skynet.be>
>> ---
>> fs/jffs2/debug.c | 26 ++++++++++++++------------
>> 1 file changed, 14 insertions(+), 12 deletions(-)
>>
>> diff --git a/fs/jffs2/debug.c b/fs/jffs2/debug.c
>> index 1090eb6..2ddb967 100644
>> --- a/fs/jffs2/debug.c
>> +++ b/fs/jffs2/debug.c
>> @@ -160,26 +160,28 @@ __jffs2_dbg_prewrite_paranoia_check(struct
>jffs2_sb_info *c,
>> void __jffs2_dbg_superblock_counts(struct jffs2_sb_info *c)
>> {
>> struct jffs2_eraseblock *jeb;
>> + struct jffs2_eraseblock *gcb = c->gcblock;
>> + struct jffs2_eraseblock *nextb = c->nextblock;
>> uint32_t free = 0, dirty = 0, used = 0, wasted = 0,
>> erasing = 0, bad = 0, unchecked = 0;
>> int nr_counted = 0;
>> int dump = 0;
>>
>> - if (c->gcblock) {
>> + if (gcb) {
>> nr_counted++;
>> - free += c->gcblock->free_size;
>> - dirty += c->gcblock->dirty_size;
>> - used += c->gcblock->used_size;
>> - wasted += c->gcblock->wasted_size;
>> - unchecked += c->gcblock->unchecked_size;
>> + free += gcb->free_size;
>> + dirty += gcb->dirty_size;
>> + used += gcb->used_size;
>> + wasted += gcb->wasted_size;
>> + unchecked += gcb->unchecked_size;
>> }
>> - if (c->nextblock) {
>> + if (nextb) {
>> nr_counted++;
>> - free += c->nextblock->free_size;
>> - dirty += c->nextblock->dirty_size;
>> - used += c->nextblock->used_size;
>> - wasted += c->nextblock->wasted_size;
>> - unchecked += c->nextblock->unchecked_size;
>> + free += nextb->free_size;
>> + dirty += nextb->dirty_size;
>> + used += nextb->used_size;
>> + wasted += nextb->wasted_size;
>> + unchecked += nextb->unchecked_size;
>> }
>> list_for_each_entry(jeb, &c->clean_list, list) {
>> nr_counted++;
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-03 20:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-03-03 19:03 [PATCH 1/1 linux-next] jffs2: remove multiple dereferences in debug Fabian Frederick
2015-03-03 19:44 ` David Woodhouse
2015-03-03 20:48 ` Nicholas Krause
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox