linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <miklos@szeredi.hu>
To: Tomasz Majchrzak <tomasz.majchrzak@intel.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	dan.j.williams@intel.com, Al Viro <viro@zeniv.linux.org.uk>,
	aleksey.obitotskiy@intel.com, pawel.baldysiak@intel.com,
	artur.paszkiewicz@intel.com, maksymilian.kunt@intel.com
Subject: Re: [PATCH v2][RESEND] seq_file: don't set read position for invalid iterator
Date: Thu, 24 Nov 2016 16:39:57 +0100	[thread overview]
Message-ID: <CAJfpegsywJWWo7ZBpN8=1uPyPpiDbF2XdN0WaEXcKr8YFdOAtQ@mail.gmail.com> (raw)
In-Reply-To: <20161124152342.GA9751@proton.igk.intel.com>

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

  reply	other threads:[~2016-11-24 15:40 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-12 12:07 [PATCH v2][RESEND] seq_file: don't set read position for invalid iterator Tomasz Majchrzak
2016-10-26  9:17 ` Miklos Szeredi
2016-10-31  9:32   ` Tomasz Majchrzak
2016-11-02  9:11     ` Miklos Szeredi
2016-11-24 15:23       ` Tomasz Majchrzak
2016-11-24 15:39         ` Miklos Szeredi [this message]
2016-11-28 15:11           ` [PATCH v3] seq_file: reset iterator to first record for zero offset Tomasz Majchrzak
2016-11-29  9:58             ` Miklos Szeredi
2016-11-29 14:18               ` [PATCH v4] " Tomasz Majchrzak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAJfpegsywJWWo7ZBpN8=1uPyPpiDbF2XdN0WaEXcKr8YFdOAtQ@mail.gmail.com' \
    --to=miklos@szeredi.hu \
    --cc=aleksey.obitotskiy@intel.com \
    --cc=artur.paszkiewicz@intel.com \
    --cc=dan.j.williams@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maksymilian.kunt@intel.com \
    --cc=pawel.baldysiak@intel.com \
    --cc=tomasz.majchrzak@intel.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).