lkml.org 
[lkml]   [2018]   [Feb]   [10]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] seq_file: remove redundant assignment of index to m->index
From
Date
On Sat, 2018-02-10 at 23:59 +0800, Donglin Peng wrote:
> There are two redundant assignments in the traverse() function, because
> the while loop will break after these two assignments, and after that
> the variable index will be assigned to m->index again.
[]
> diff --git a/fs/seq_file.c b/fs/seq_file.c
[]
> @@ -120,14 +120,12 @@ static int traverse(struct seq_file *m, loff_t offset)
> if (pos + m->count > offset) {
> m->from = offset - pos;
> m->count -= m->from;
> - m->index = index;
> break;
> }
> pos += m->count;
> m->count = 0;
> if (pos == offset) {
> index++;
> - m->index = index;
> break;
> }
> p = m->op->next(m, p, &index);

Of course this looks correct, but how
are you _absolutely sure_ about this?

Perhaps the m->op->stop(m, p) call below
the break, which takes m as an argument,
needs an updated m->index.

Unless you can verify _all_ the indirect
paths that stop() can take, this patch may
not be correct.

\
 
 \ /
  Last update: 2018-02-10 19:05    [W:0.054 / U:2.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site