Author: tkreuzer Date: Sat Aug 15 02:40:09 2009 New Revision: 42672
URL: http://svn.reactos.org/svn/reactos?rev=42672&view=rev Log: Fix screwed logic in LIST_FOR_EACH and LIST_FOR_EACH_SAFE. They were 1. using inverse logic and entering the loop when elem was NULL, 2. checking elem, whick is the result of CONTAINING_RECORD on the Flink pointer that should be checked for NULL. Anyway these macros are ugly and shouldn't be used, they only obfuscate the code.
Modified: trunk/reactos/subsystems/win32/win32k/pch.h
Modified: trunk/reactos/subsystems/win32/win32k/pch.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/pch... ============================================================================== --- trunk/reactos/subsystems/win32/win32k/pch.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/pch.h [iso-8859-1] Sat Aug 15 02:40:09 2009 @@ -152,13 +152,13 @@
#define LIST_FOR_EACH(elem, list, type, field) \ for ((elem) = CONTAINING_RECORD((list)->Flink, type, field); \ - &(elem)->field != (list) || (elem == NULL); \ + &(elem)->field != (list) && ((&((elem)->field)) != NULL); \ (elem) = CONTAINING_RECORD((elem)->field.Flink, type, field))
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list, type, field) \ for ((cursor) = CONTAINING_RECORD((list)->Flink, type, field), \ (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field); \ - &(cursor)->field != (list) || (cursor == NULL); \ + &(cursor)->field != (list) && ((&((cursor)->field)) != NULL); \ (cursor) = (cursor2), \ (cursor2) = CONTAINING_RECORD((cursor)->field.Flink, type, field))