Re: [patch 2/2] Sort module list by pointer address to get coherent sleepable seq_file iterators

Fengguang Wu
2007-08-15T06:37:58Z

On Wed, Aug 15, 2007 at 05:18:45AM +0100, Al Viro wrote:
>> On Wed, Aug 15, 2007 at 11:39:45AM +0800, Fengguang Wu wrote:
>> seqfile: remove seq_file's assumption about iterators
>>
>> The seq_file implementation has some hardcoded index++/pos++ lines,
>> which assumes iterators to be *continuous* integers.
>
>What the fuck? It assumes no such thing and a lot of iterators are
>nothing like integers. What are you talking about?

Oh I used the wrong term...

Take for example this function from lwn.net:

static void *ct_seq_next(struct seq_file *s, void *v, loff_t *pos)
{
loff_t *spos = (loff_t *) v;
*pos = ++(*spos);
return spos;
}

I mean 'pos' is sometimes increased in ct_seq_next(), and sometimes from
seq_file.c/seq_read(), too. Thus we cannot reliably do this:

*pos = (*spos) + some_variable_offset;

You are referring to spos as the iterator, are you?

Maybe I'm wrong. I'll dip more into it.