On 22 September 2015 at 13:43, Predut, Marius <marius.pre...@intel.com> wrote:
> In the upstream code , 'nr' variable is used intensively in many places for 
> things like :
> for (j = 0; j + 2 < count; j += nr ) {
>  nr = MIN2( currentsz, count - j );
>
> But first time when it is used it isn't initialized.
> I was unable to find  a place (a macro or something)  where  "nr" is 
> initialized.
> I suppose it is done somewhere because if NOT, THIS will be very strange how 
> this code  works.
> (Every time "nr" became "currentsz" because all the time nr is a big stack 
> value, so this is the reason for why code works?)
>
While I cannot quote the C spec, I'm pretty sure that  j += nr, will
be executed after nr = MIN2( currentsz, count - j ).

The following simple test confirms it.

int main(void) {
    int j, nr;

    for (j = 0; j < 10; printf("nr %d\n", nr), j += nr)
        nr = 1, printf("hello world %d\n", j);
}

hello world 0
nr 1
hello world 1
...


Cheers,
Emil
_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to