Re: [ros-dev] [ros-diffs] [gedmurphy] 69650: The c++ bool is 1 byte, not 4. Thanks Thomas

2015-11-03 Thread Thomas Faber
It makes a difference because m_RefreshPending was initialized to 0 by
the constructor, but the three bytes behind it were not, so the first
cmpxchg could fail.
Plus of course if someone decided to add another bool or a char array
or whatever at the end, that would get overwritten.


On 2015-11-03 00:21, Timo Kreuzer wrote:
> In fact in this case it wouldn't make a difference, since the bool would 
> be converted to a LONG. But using TRUE/FALSE seems to be appropriate here.
> 
> Am 22.10.2015 um 19:37 schrieb gedmur...@svn.reactos.org:
>> Author: gedmurphy
>> Date: Thu Oct 22 17:37:51 2015
>> New Revision: 69650
>>
>> URL: http://svn.reactos.org/svn/reactos?rev=69650=rev
>> Log:
>> The c++ bool is 1 byte, not 4. Thanks Thomas
>>
>> Modified:
>>  trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
>>  trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
>>
>> Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
>> URL: 
>> http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp?rev=69650=69649=69650=diff
>> ==
>> --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp[iso-8859-1] 
>> (original)
>> +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp[iso-8859-1] 
>> Thu Oct 22 17:37:51 2015
>> @@ -786,7 +786,7 @@
>>   // we set a timer to run in 500ms, which should leave 
>> enough time for all
>>   // the messages to come through. Wrap so we don't set 
>> multiple timers
>>   //
>> -if (InterlockedCompareExchange((LONG 
>> *)>m_RefreshPending, true, false) == false)
>> +if (InterlockedCompareExchange((LONG 
>> *)>m_RefreshPending, TRUE, FALSE) == FALSE)
>>   {
>>   SetTimer(hwnd, REFRESH_TIMER, 500, NULL);
>>   }
>> @@ -807,7 +807,7 @@
>>   KillTimer(hwnd, REFRESH_TIMER);
>>   
>>   // Allow more change notifications
>> -InterlockedExchange((LONG *)>m_RefreshPending, false);
>> +InterlockedExchange((LONG *)>m_RefreshPending, FALSE);
>>   }
>>   break;
>>   }
>>
>> Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
>> URL: 
>> http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h?rev=69650=69649=69650=diff
>> ==
>> --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h  [iso-8859-1] 
>> (original)
>> +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h  [iso-8859-1] 
>> Thu Oct 22 17:37:51 2015
>> @@ -17,7 +17,7 @@
>>   HMENU m_hMenu;
>>   HMENU m_hActionMenu;
>>   int m_CmdShow;
>> -bool m_RefreshPending;
>> +BOOL m_RefreshPending;
>>   
>>   public:
>>   CDeviceManager(void);
>>
>>
>>

___
Ros-dev mailing list
Ros-dev@reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev


Re: [ros-dev] [ros-diffs] [gedmurphy] 69650: The c++ bool is 1 byte, not 4. Thanks Thomas

2015-11-03 Thread David Quintana (gigaherz)
The common computers never work with bits in memory. All the common
operations work at LEAST in bytes, and often in larger units, so
working with bits requires extra logic. Booleans are most commonly
stored as 1 byte because of that.

It is possible that come machines do use 1 bit, but they would
probably be specialized chips such as embedded microcontrollers.

On 3 November 2015 at 12:57, Javier Agustìn Fernàndez Arroyo
 wrote:
> i thought it was 1 bit, not 1 byte... thanks for correcting my mistake :)
>
> On Tue, Nov 3, 2015 at 10:00 AM, Thomas Faber 
> wrote:
>>
>> It makes a difference because m_RefreshPending was initialized to 0 by
>> the constructor, but the three bytes behind it were not, so the first
>> cmpxchg could fail.
>> Plus of course if someone decided to add another bool or a char array
>> or whatever at the end, that would get overwritten.
>>
>>
>> On 2015-11-03 00:21, Timo Kreuzer wrote:
>> > In fact in this case it wouldn't make a difference, since the bool would
>> > be converted to a LONG. But using TRUE/FALSE seems to be appropriate
>> > here.
>> >
>> > Am 22.10.2015 um 19:37 schrieb gedmur...@svn.reactos.org:
>> >> Author: gedmurphy
>> >> Date: Thu Oct 22 17:37:51 2015
>> >> New Revision: 69650
>> >>
>> >> URL: http://svn.reactos.org/svn/reactos?rev=69650=rev
>> >> Log:
>> >> The c++ bool is 1 byte, not 4. Thanks Thomas
>> >>
>> >> Modified:
>> >>  trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
>> >>  trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
>> >>
>> >> Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
>> >> URL:
>> >> http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp?rev=69650=69649=69650=diff
>> >>
>> >> ==
>> >> --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
>> >> [iso-8859-1] (original)
>> >> +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
>> >> [iso-8859-1] Thu Oct 22 17:37:51 2015
>> >> @@ -786,7 +786,7 @@
>> >>   // we set a timer to run in 500ms, which should leave
>> >> enough time for all
>> >>   // the messages to come through. Wrap so we don't set
>> >> multiple timers
>> >>   //
>> >> -if (InterlockedCompareExchange((LONG
>> >> *)>m_RefreshPending, true, false) == false)
>> >> +if (InterlockedCompareExchange((LONG
>> >> *)>m_RefreshPending, TRUE, FALSE) == FALSE)
>> >>   {
>> >>   SetTimer(hwnd, REFRESH_TIMER, 500, NULL);
>> >>   }
>> >> @@ -807,7 +807,7 @@
>> >>   KillTimer(hwnd, REFRESH_TIMER);
>> >>
>> >>   // Allow more change notifications
>> >> -InterlockedExchange((LONG *)>m_RefreshPending,
>> >> false);
>> >> +InterlockedExchange((LONG *)>m_RefreshPending,
>> >> FALSE);
>> >>   }
>> >>   break;
>> >>   }
>> >>
>> >> Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
>> >> URL:
>> >> http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h?rev=69650=69649=69650=diff
>> >>
>> >> ==
>> >> --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
>> >> [iso-8859-1] (original)
>> >> +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
>> >> [iso-8859-1] Thu Oct 22 17:37:51 2015
>> >> @@ -17,7 +17,7 @@
>> >>   HMENU m_hMenu;
>> >>   HMENU m_hActionMenu;
>> >>   int m_CmdShow;
>> >> -bool m_RefreshPending;
>> >> +BOOL m_RefreshPending;
>> >>
>> >>   public:
>> >>   CDeviceManager(void);
>> >>
>> >>
>> >>
>>
>> ___
>> Ros-dev mailing list
>> Ros-dev@reactos.org
>> http://www.reactos.org/mailman/listinfo/ros-dev
>
>
>
> ___
> Ros-dev mailing list
> Ros-dev@reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev

___
Ros-dev mailing list
Ros-dev@reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev

Re: [ros-dev] [ros-diffs] [gedmurphy] 69650: The c++ bool is 1 byte, not 4. Thanks Thomas

2015-11-03 Thread Javier Agustìn Fernàndez Arroyo
i thought it was 1 bit, not 1 byte... thanks for correcting my mistake :)

On Tue, Nov 3, 2015 at 10:00 AM, Thomas Faber 
wrote:

> It makes a difference because m_RefreshPending was initialized to 0 by
> the constructor, but the three bytes behind it were not, so the first
> cmpxchg could fail.
> Plus of course if someone decided to add another bool or a char array
> or whatever at the end, that would get overwritten.
>
>
> On 2015-11-03 00:21, Timo Kreuzer wrote:
> > In fact in this case it wouldn't make a difference, since the bool would
> > be converted to a LONG. But using TRUE/FALSE seems to be appropriate
> here.
> >
> > Am 22.10.2015 um 19:37 schrieb gedmur...@svn.reactos.org:
> >> Author: gedmurphy
> >> Date: Thu Oct 22 17:37:51 2015
> >> New Revision: 69650
> >>
> >> URL: http://svn.reactos.org/svn/reactos?rev=69650=rev
> >> Log:
> >> The c++ bool is 1 byte, not 4. Thanks Thomas
> >>
> >> Modified:
> >>  trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
> >>  trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
> >>
> >> Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
> >> URL:
> http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp?rev=69650=69649=69650=diff
> >>
> ==
> >> --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
> [iso-8859-1] (original)
> >> +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
> [iso-8859-1] Thu Oct 22 17:37:51 2015
> >> @@ -786,7 +786,7 @@
> >>   // we set a timer to run in 500ms, which should leave
> enough time for all
> >>   // the messages to come through. Wrap so we don't set
> multiple timers
> >>   //
> >> -if (InterlockedCompareExchange((LONG
> *)>m_RefreshPending, true, false) == false)
> >> +if (InterlockedCompareExchange((LONG
> *)>m_RefreshPending, TRUE, FALSE) == FALSE)
> >>   {
> >>   SetTimer(hwnd, REFRESH_TIMER, 500, NULL);
> >>   }
> >> @@ -807,7 +807,7 @@
> >>   KillTimer(hwnd, REFRESH_TIMER);
> >>
> >>   // Allow more change notifications
> >> -InterlockedExchange((LONG *)>m_RefreshPending,
> false);
> >> +InterlockedExchange((LONG *)>m_RefreshPending,
> FALSE);
> >>   }
> >>   break;
> >>   }
> >>
> >> Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
> >> URL:
> http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h?rev=69650=69649=69650=diff
> >>
> ==
> >> --- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
> [iso-8859-1] (original)
> >> +++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
> [iso-8859-1] Thu Oct 22 17:37:51 2015
> >> @@ -17,7 +17,7 @@
> >>   HMENU m_hMenu;
> >>   HMENU m_hActionMenu;
> >>   int m_CmdShow;
> >> -bool m_RefreshPending;
> >> +BOOL m_RefreshPending;
> >>
> >>   public:
> >>   CDeviceManager(void);
> >>
> >>
> >>
>
> ___
> Ros-dev mailing list
> Ros-dev@reactos.org
> http://www.reactos.org/mailman/listinfo/ros-dev
>
___
Ros-dev mailing list
Ros-dev@reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev

Re: [ros-dev] [ros-diffs] [gedmurphy] 69650: The c++ bool is 1 byte, not 4. Thanks Thomas

2015-11-03 Thread Thomas Faber
On 2015-11-03 22:02, Timo Kreuzer wrote:
> m_RefreshPending is a 32 bit BOOL and the constructor will initialize it 
> completely with 0.
> If it was initializing only the 1st byte, the new code would still be wrong, 
> since it makes no difference.
> InterlockedCompareExchange will exchange 32 bit, no matter whether you pass a 
> bool or a BOOL.


 @@ -17,7 +17,7 @@
HMENU m_hMenu;
HMENU m_hActionMenu;
int m_CmdShow;
 -bool m_RefreshPending;
 +BOOL m_RefreshPending;

public:
CDeviceManager(void);

Did you miss this part of the diff? ;)

___
Ros-dev mailing list
Ros-dev@reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev


Re: [ros-dev] [ros-diffs] [gedmurphy] 69650: The c++ bool is 1 byte, not 4. Thanks Thomas

2015-11-03 Thread Timo Kreuzer

m_RefreshPending is a 32 bit BOOL and the constructor will initialize it 
completely with 0.
If it was initializing only the 1st byte, the new code would still be wrong, 
since it makes no difference.
InterlockedCompareExchange will exchange 32 bit, no matter whether you pass a 
bool or a BOOL.


Am 03.11.2015 um 10:00 schrieb Thomas Faber:

It makes a difference because m_RefreshPending was initialized to 0 by
the constructor, but the three bytes behind it were not, so the first
cmpxchg could fail.
Plus of course if someone decided to add another bool or a char array
or whatever at the end, that would get overwritten.


On 2015-11-03 00:21, Timo Kreuzer wrote:

In fact in this case it wouldn't make a difference, since the bool would
be converted to a LONG. But using TRUE/FALSE seems to be appropriate here.

Am 22.10.2015 um 19:37 schrieb gedmur...@svn.reactos.org:

Author: gedmurphy
Date: Thu Oct 22 17:37:51 2015
New Revision: 69650

URL: http://svn.reactos.org/svn/reactos?rev=69650=rev
Log:
The c++ bool is 1 byte, not 4. Thanks Thomas

Modified:
  trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
  trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h

Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp?rev=69650=69649=69650=diff
==
--- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp   [iso-8859-1] 
(original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp   [iso-8859-1] 
Thu Oct 22 17:37:51 2015
@@ -786,7 +786,7 @@
   // we set a timer to run in 500ms, which should leave enough 
time for all
   // the messages to come through. Wrap so we don't set 
multiple timers
   //
-if (InterlockedCompareExchange((LONG 
*)>m_RefreshPending, true, false) == false)
+if (InterlockedCompareExchange((LONG 
*)>m_RefreshPending, TRUE, FALSE) == FALSE)
   {
   SetTimer(hwnd, REFRESH_TIMER, 500, NULL);
   }
@@ -807,7 +807,7 @@
   KillTimer(hwnd, REFRESH_TIMER);
   
   // Allow more change notifications

-InterlockedExchange((LONG *)>m_RefreshPending, false);
+InterlockedExchange((LONG *)>m_RefreshPending, FALSE);
   }
   break;
   }

Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h?rev=69650=69649=69650=diff
==
--- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] Thu Oct 22 
17:37:51 2015
@@ -17,7 +17,7 @@
   HMENU m_hMenu;
   HMENU m_hActionMenu;
   int m_CmdShow;
-bool m_RefreshPending;
+BOOL m_RefreshPending;
   
   public:

   CDeviceManager(void);




___
Ros-dev mailing list
Ros-dev@reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev






smime.p7s
Description: S/MIME Cryptographic Signature
___
Ros-dev mailing list
Ros-dev@reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev

Re: [ros-dev] [ros-diffs] [gedmurphy] 69650: The c++ bool is 1 byte, not 4. Thanks Thomas

2015-11-03 Thread Timo Kreuzer

Am 03.11.2015 um 22:09 schrieb Thomas Faber:

On 2015-11-03 22:02, Timo Kreuzer wrote:

m_RefreshPending is a 32 bit BOOL and the constructor will initialize it 
completely with 0.
If it was initializing only the 1st byte, the new code would still be wrong, 
since it makes no difference.
InterlockedCompareExchange will exchange 32 bit, no matter whether you pass a 
bool or a BOOL.



@@ -17,7 +17,7 @@
HMENU m_hMenu;
HMENU m_hActionMenu;
int m_CmdShow;
-bool m_RefreshPending;
+BOOL m_RefreshPending;

public:

CDeviceManager(void);

Did you miss this part of the diff? ;)

No, I just wanted to test you. *cough* ;-)




smime.p7s
Description: S/MIME Cryptographic Signature
___
Ros-dev mailing list
Ros-dev@reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev

Re: [ros-dev] [ros-diffs] [gedmurphy] 69650: The c++ bool is 1 byte, not 4. Thanks Thomas

2015-11-02 Thread Timo Kreuzer
In fact in this case it wouldn't make a difference, since the bool would 
be converted to a LONG. But using TRUE/FALSE seems to be appropriate here.


Am 22.10.2015 um 19:37 schrieb gedmur...@svn.reactos.org:

Author: gedmurphy
Date: Thu Oct 22 17:37:51 2015
New Revision: 69650

URL: http://svn.reactos.org/svn/reactos?rev=69650=rev
Log:
The c++ bool is 1 byte, not 4. Thanks Thomas

Modified:
 trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
 trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h

Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp?rev=69650=69649=69650=diff
==
--- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp   [iso-8859-1] 
(original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.cpp   [iso-8859-1] 
Thu Oct 22 17:37:51 2015
@@ -786,7 +786,7 @@
  // we set a timer to run in 500ms, which should leave enough 
time for all
  // the messages to come through. Wrap so we don't set 
multiple timers
  //
-if (InterlockedCompareExchange((LONG 
*)>m_RefreshPending, true, false) == false)
+if (InterlockedCompareExchange((LONG 
*)>m_RefreshPending, TRUE, FALSE) == FALSE)
  {
  SetTimer(hwnd, REFRESH_TIMER, 500, NULL);
  }
@@ -807,7 +807,7 @@
  KillTimer(hwnd, REFRESH_TIMER);
  
  // Allow more change notifications

-InterlockedExchange((LONG *)>m_RefreshPending, false);
+InterlockedExchange((LONG *)>m_RefreshPending, FALSE);
  }
  break;
  }

Modified: trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h?rev=69650=69649=69650=diff
==
--- trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/devmgr/devmgmt/MainWindow.h [iso-8859-1] Thu Oct 22 
17:37:51 2015
@@ -17,7 +17,7 @@
  HMENU m_hMenu;
  HMENU m_hActionMenu;
  int m_CmdShow;
-bool m_RefreshPending;
+BOOL m_RefreshPending;
  
  public:

  CDeviceManager(void);








smime.p7s
Description: S/MIME Cryptographic Signature
___
Ros-dev mailing list
Ros-dev@reactos.org
http://www.reactos.org/mailman/listinfo/ros-dev