[ros-dev] [ros-diffs] [jgardou] 52339: [NTOSKRNL] - don't rely on a boolean being 1 or 0, it's a bad idea (tm)
Alex Ionescu
ionucu at videotron.ca
Sun Jun 19 13:29:40 UTC 2011
This is a completely different issue. You're confusing bitmask math
with BOOLEAN.
Best regards,
Alex Ionescu
2011/6/19 Jérôme Gardou <jerome.gardou at laposte.net>:
> Well, just try this snippet of code in VS 2010, and tell me what you see as
> result :-)
> BOOLEAN is what it is : a typedef to BYTE.
> PS : no fancy optimization option or whatever
>
> // test_boolean.cpp : définit le point d'entrée pour l'application console.
> //
>
> #include <iostream>
> #include <Windows.h>
> #include <tchar.h>
>
> using namespace std;
>
> BOOLEAN test0x10(int i)
> {
> return i & 0x10;
> }
>
>
> int _tmain(int argc, _TCHAR* argv[])
> {
> if(test0x10(0x10) == 1)
> cout << "Alex Ionescu is right" << endl;
> else if(test0x10(0x10))
> cout << "Sometimes Alex Ionescu is wrong" << endl;
> else
> cout << "Unexpected behaviour!!!" << endl;
>
> return 0;
> }
>
>
> Le 18/06/2011 17:22, Alex Ionescu a écrit :
>>
>> Or rather
>>
>> 1 ? 1 : 0
>>
>> (just as retarded).
>>
>> Of course a BOOLEAN is 0 or 1!!!
>>
>> Best regards,
>> Alex Ionescu
>>
>>
>>
>> On Sat, Jun 18, 2011 at 4:22 PM, Alex Ionescu<ionucu at videotron.ca> wrote:
>>>
>>> ???
>>>
>>> This is retarded.
>>>
>>> You're doing
>>>
>>> 0 ? 0 : 1
>>>
>>> Best regards,
>>> Alex Ionescu
>>>
>>>
>>>
>>> On Sat, Jun 18, 2011 at 3:45 PM,<jgardou at svn.reactos.org> wrote:
>>>>
>>>> Author: jgardou
>>>> Date: Sat Jun 18 14:45:08 2011
>>>> New Revision: 52339
>>>>
>>>> URL: http://svn.reactos.org/svn/reactos?rev=52339&view=rev
>>>> Log:
>>>> [NTOSKRNL]
>>>> - don't rely on a boolean being 1 or 0, it's a bad idea (tm)
>>>>
>>>> Modified:
>>>> trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
>>>>
>>>> Modified: trunk/reactos/ntoskrnl/ke/i386/traphdlr.c
>>>> URL:
>>>> http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/ke/i386/traphdlr.c?rev=52339&r1=52338&r2=52339&view=diff
>>>>
>>>> ==============================================================================
>>>> --- trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] (original)
>>>> +++ trunk/reactos/ntoskrnl/ke/i386/traphdlr.c [iso-8859-1] Sat Jun 18
>>>> 14:45:08 2011
>>>> @@ -1510,7 +1510,7 @@
>>>>
>>>> /* Set thread fields */
>>>> Thread->TrapFrame = TrapFrame;
>>>> - Thread->PreviousMode = KiUserTrap(TrapFrame);
>>>> + Thread->PreviousMode = KiUserTrap(TrapFrame) ? UserMode :
>>>> KernelMode;
>>>>
>>>> /* Enable interrupts */
>>>> _enable();
>>>>
>>>>
>>>>
>> _______________________________________________
>> Ros-dev mailing list
>> Ros-dev at reactos.org
>> http://www.reactos.org/mailman/listinfo/ros-dev
>
>
> _______________________________________________
> Ros-dev mailing list
> Ros-dev at reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev
>
More information about the Ros-dev
mailing list