[ros-kernel] NtGdiPolygon code cleanup

Royce Mitchell III royce3 at ev1.net
Wed Mar 3 01:06:47 CET 2004


I was looking at the code for NtGdiPolygon and was generally unhappy 
with it. While there is nothing technically wrong with it ( that I can 
see ), it's just too ugly to live. Would anybody object to this code 
cleanup patch?

-------------- next part --------------
Index: subsys/win32k/objects/fillshap.c
===================================================================
RCS file: /CVS/ReactOS/reactos/subsys/win32k/objects/fillshap.c,v
retrieving revision 1.43
diff -u -r1.43 fillshap.c
--- subsys/win32k/objects/fillshap.c	3 Mar 2004 06:33:58 -0000	1.43
+++ subsys/win32k/objects/fillshap.c	3 Mar 2004 06:44:57 -0000
@@ -830,7 +830,6 @@
 
 #endif
 
-//This implementation is blatantly ripped off from NtGdiRectangle
 BOOL
 STDCALL
 NtGdiPolygon(HDC          hDC,
@@ -840,46 +839,35 @@
   DC *dc;
   LPPOINT Safept;
   NTSTATUS Status;
-  BOOL Ret;
+  BOOL Ret = FALSE;
   
-  dc = DC_LockDc(hDC);
-  if(!dc)
+  if ( Count < 2 )
   {
-    SetLastWin32Error(ERROR_INVALID_HANDLE);
+    SetLastWin32Error(ERROR_INVALID_PARAMETER);
     return FALSE;
   }
   
-  if(Count >= 2)
+  dc = DC_LockDc(hDC);
+  if(!dc)
+    SetLastWin32Error(ERROR_INVALID_HANDLE);
+  else
   {
     Safept = ExAllocatePoolWithTag(NonPagedPool, sizeof(POINT) * Count, TAG_SHAPE);
     if(!Safept)
-    {
-      DC_UnlockDc(hDC);
       SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY);
-      return FALSE;
-    }
-    
-    Status = MmCopyFromCaller(Safept, UnsafePoints, sizeof(POINT) * Count);
-    if(!NT_SUCCESS(Status))
+    else
     {
+      Status = MmCopyFromCaller(Safept, UnsafePoints, sizeof(POINT) * Count);
+      if(!NT_SUCCESS(Status))
+        SetLastNtError(Status);
+      else
+        Ret = IntGdiPolygon(dc, Safept, Count);
+        
       ExFreePool(Safept);
-      DC_UnlockDc(hDC);
-      SetLastNtError(Status);
-      return FALSE;
     }
-  }
-  else
-  {
     DC_UnlockDc(hDC);
-    SetLastWin32Error(ERROR_INVALID_PARAMETER);
-    return FALSE;
   }
   
-  Ret = IntGdiPolygon(dc, Safept, Count);
-
-  ExFreePool(Safept);
-  DC_UnlockDc(hDC);
-  
   return Ret;
 }
 


More information about the Ros-kernel mailing list