[Vm-dev] useless bogus test in sqMacUIEventsUniversal.c line 878

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Thu Aug 30 22:43:34 UTC 2012


			if ((key = findInKeyMap(keyCode)) != -1)
key is declared UniChar, which is Uint16 (MacTypes.h)
Thus key == -1 is always false as reported by Xcode

And line 1633:

static UniChar
findInKeyMap(int keyCode)
{
  int idx= indexInKeyMap(keyCode);
  return (idx != -1) ? keyMap[idx].keyChar : -1;
}

is suspect because -1 is implicitely cast to 16rFFFF (in 2 complement)

We stiil can write
			if ((key = findInKeyMap(keyCode)) != (UniChar)(-1))

if 16rFFFF is never a valid UniChar, but i have high doubts here...

I wonder why constantly ignoring compiler warnings ???

Nicolas


More information about the Vm-dev mailing list