Re: [PATCH v4 3/7] mm/vmalloc.c: allow vread() to read out vm_map_ram areas

From: Lorenzo Stoakes
Date: Thu Feb 02 2023 - 02:17:56 EST


On Thu, Feb 02, 2023 at 11:20:07AM +0800, Baoquan He wrote:

[snip]

> > > + for_each_set_bitrange(rs, re, vb->used_map, VMAP_BBMAP_BITS) {
> > > + if (!count)
> > > + break;
> > > + start = vmap_block_vaddr(vb->va->va_start, rs);
> > > + while (addr < start) {
> > > + if (count == 0)
> > > + break;
> >
> > Bit pedantic, but you're using the `if (!count)` form of checking whether it's
> > zero above, but here you explicitly check it, would be good to keep both consistent.
>
> Yeah, sounds good. Will change.
>
> >
> > Given you're checking here, perhaps you could simply drop the previous check?
>
> Well, maybe no. The previous "if (!count)" is checking if count is 0
> after the 'count -=n;' line at the end of the for_each loop. While this
> "if (count == 0)" is checking if count is 0 after 'count--;' at the end
> of while loop. Not sure if I got your point.

You're right, sorry each break is for a different loop :) and I guess the inner
check is feeding the outer one so we're all good.