Re: [patch 2/2] fs, proc: Introduce the /proc/<pid>/map_files/directory v6

From: Andrew Morton
Date: Wed Sep 07 2011 - 18:54:47 EST


On Thu, 8 Sep 2011 02:42:34 +0400
Cyrill Gorcunov <gorcunov@xxxxxxxxx> wrote:

> > > +err:
> > > + up_read(&mm->mmap_sem);
> > > +
> > > + for (i = 0; i < used && !ret; i++) {
> >
> > The "&& !ret" is unneeded?
>
> No, it's needed, since it makes sure that if "impossible"
> scenario happens and flex-arrays fails with preallocated
> data so we will reach this point with used > 0 and ret = -ENOMEM
> and thus will not call for proc_map_files_instantiate as needed.

Well, it doesn't need to be tested on each pass around the loop - that's
misleading and inefficient (unless the compiler is being particularly clever).
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/