[Mesa-dev] [PATCH 00/24] Massive clean up in t_dd_dmatmp.h

Emil Velikov emil.l.velikov at gmail.com
Tue Sep 22 07:00:36 PDT 2015


On 22 September 2015 at 13:43, Predut, Marius <marius.predut at 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


More information about the mesa-dev mailing list