[ros-kernel] accelerator.c, loop bug?

Mark IJbema mark at ijbema.xs4all.nl
Mon Feb 2 08:40:41 CET 2004


On Sun, Feb 01, 2004 at 09:29:30PM -0800, James Marjie wrote:
> Mark IJbema wrote:
> 
> >Hi, i noticed something strange about accelerator.c. It contains a for
> >loop, however it has an increment at the end of the loop, which would
> >make me think that this was a while loop, not properly converted to
> >while. If not, shouldn't it just be i+=2 in the loop increment?
> >
> >the code (last part of accelerator.c):
> >
> > for (i = 0; i < AcceleratorTable->Count; i++)
> >   {
> >     if (IntTranslateAccelerator(Window, Message->message, 
> >     Message->wParam, Message->lParam,
> >                 AcceleratorTable->Table[i].fVirt, 
> >                 AcceleratorTable->Table[i].key,
> >                 AcceleratorTable->Table[i].cmd))
> >           {
> >                 ObDereferenceObject(WindowStation);
> >         DPRINT1("NtUserTranslateAccelerator(Window %x, Table %x, Message 
> >         %p) = %i end\n",
> >           Window, Table, Message, 1);
> >         return 1;
> >               }
> >         if (((AcceleratorTable->Table[i].fVirt & 0x80) > 0))
> >           {
> >         break;
> >           }
> >         i++;
> >   }
> >
> Nope, it might not even get to that last i++, if  it breaks or returns. 
> Now if this is a bug or not is up to so someone else. 8^)

That's correct, however, i is not used outside of the loop, so the break
isn't really relevant to the problem.

Mark


More information about the Ros-kernel mailing list