lkml.org 
[lkml]   [2016]   [Nov]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH v2][RESEND] seq_file: don't set read position for invalid iterator
On Thu, Nov 24, 2016 at 4:23 PM, Tomasz Majchrzak
<tomasz.majchrzak@intel.com> wrote:

> I don't understand it. Is it possible to map file position to the index
> (record)? I think there is no way to determine record size without actually
> reading it.

Right. So don't update m->index when a zero size record is read.
This will result in m->index always pointing to the first record at
the given offset. You use this property for the single record case
and zero offset, but I'd consider behavior consistent if this was not
just done for this special case.

>> But I doubt that we actually need to do that. For example just special casing
>> the zero offset (always translating to zero index) would be conceptually simpler
>> and equivalent to your patch for the sysfs case.
>
> Do you mean such piece of code?
>
> if (ppos == 0)
> m->index = 0;

Yes. Which is a special case, but it's at least simple and easy to prove right.

Thanks,
Miklos

\
 
 \ /
  Last update: 2016-11-24 16:40    [W:0.060 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site