Some misc fixes to Prefast.
authorStefan Ginsberg <stefanginsberg@gmail.com>
Wed, 22 Feb 2012 20:58:20 +0000 (20:58 +0000)
committerStefan Ginsberg <stefanginsberg@gmail.com>
Wed, 22 Feb 2012 20:58:20 +0000 (20:58 +0000)
[DDK]
- ndis.h Don't use local variables with the same name as function parameters.
[PSDK]
- access.idl Remove incorrect annotation
- usbioctl.h Not really a Prefast issue, but switch to use ANYSIZE_ARRAY like we do everywhere else.
- winddi.h EngQueryDeviceAttribute's 6th parameter is IN, not OUT
- winefs.h Fix FileEncryptionStatus to use annotations. Its definition in winbase.h already has them and this caused a conflict.
[WINE]
- debug.h Remove unnecessary check (in ReactOS) that made Prefast sad.
- test.h Disable a false-positive C28182.

svn path=/trunk/; revision=55813

reactos/include/ddk/ndis.h
reactos/include/psdk/access.idl
reactos/include/psdk/usbioctl.h
reactos/include/psdk/winddi.h
reactos/include/psdk/winefs.h
reactos/include/reactos/wine/debug.h
reactos/include/reactos/wine/test.h

index 9eb6e2d..ba7fa0d 100644 (file)
@@ -3577,20 +3577,20 @@ NdisQueryPacket(
       UINT Offset;
       UINT PacketLength;
       PNDIS_BUFFER NdisBuffer;
-      UINT PhysicalBufferCount = 0;
-      UINT TotalPacketLength = 0;
+      UINT _PhysicalBufferCount = 0;
+      UINT _TotalPacketLength = 0;
       UINT Count = 0;
 
       for (NdisBuffer = Packet->Private.Head;
            NdisBuffer != (PNDIS_BUFFER)NULL;
            NdisBuffer = NdisBuffer->Next) {
-        PhysicalBufferCount += NDIS_BUFFER_TO_SPAN_PAGES(NdisBuffer);
+        _PhysicalBufferCount += NDIS_BUFFER_TO_SPAN_PAGES(NdisBuffer);
         NdisQueryBufferOffset(NdisBuffer, &Offset, &PacketLength);
-        TotalPacketLength += PacketLength;
+        _TotalPacketLength += PacketLength;
         Count++;
       }
-      Packet->Private.PhysicalCount = PhysicalBufferCount;
-      Packet->Private.TotalLength = TotalPacketLength;
+      Packet->Private.PhysicalCount = _PhysicalBufferCount;
+      Packet->Private.TotalLength = _TotalPacketLength;
       Packet->Private.Count = Count;
       Packet->Private.ValidCounts = TRUE;
     }
index d3d9424..397e178 100644 (file)
@@ -34,7 +34,7 @@ interface IAccessor : IUnknown
 \r
     [call_as(AddRefAccessor)]\r
     HRESULT RemoteAddRefAccessor([in] HACCESSOR hAccessor,\r
-                                 [in, out, unique, annotation("__out_opt")] DBREFCOUNT *pcRefCount,\r
+                                 [in, out, unique] DBREFCOUNT *pcRefCount,\r
                                  [out] IErrorInfo **ppErrorInfoRem);\r
 \r
     [local]\r
index 646a33a..562f9ef 100644 (file)
@@ -295,34 +295,34 @@ typedef struct _USB_NODE_CONNECTION_INFORMATION {
   USHORT DeviceAddress;
   ULONG NumberOfOpenPipes;
   USB_CONNECTION_STATUS ConnectionStatus;
-  USB_PIPE_INFO PipeList[0];
+  USB_PIPE_INFO PipeList[ANYSIZE_ARRAY];
 } USB_NODE_CONNECTION_INFORMATION, *PUSB_NODE_CONNECTION_INFORMATION;
 
 typedef struct _USB_NODE_CONNECTION_DRIVERKEY_NAME {
   ULONG ConnectionIndex;
   ULONG ActualLength;
-  WCHAR DriverKeyName[1];
+  WCHAR DriverKeyName[ANYSIZE_ARRAY];
 } USB_NODE_CONNECTION_DRIVERKEY_NAME, *PUSB_NODE_CONNECTION_DRIVERKEY_NAME;
 
 typedef struct _USB_NODE_CONNECTION_NAME {
   ULONG ConnectionIndex;
   ULONG ActualLength;
-  WCHAR NodeName[1];
+  WCHAR NodeName[ANYSIZE_ARRAY];
 } USB_NODE_CONNECTION_NAME, *PUSB_NODE_CONNECTION_NAME;
 
 typedef struct _USB_HUB_NAME {
   ULONG ActualLength;
-  WCHAR HubName[1];
+  WCHAR HubName[ANYSIZE_ARRAY];
 } USB_HUB_NAME, *PUSB_HUB_NAME;
 
 typedef struct _USB_ROOT_HUB_NAME {
   ULONG ActualLength;
-  WCHAR RootHubName[1];
+  WCHAR RootHubName[ANYSIZE_ARRAY];
 } USB_ROOT_HUB_NAME, *PUSB_ROOT_HUB_NAME;
 
 typedef struct _USB_HCD_DRIVERKEY_NAME {
   ULONG ActualLength;
-  WCHAR DriverKeyName[1];
+  WCHAR DriverKeyName[ANYSIZE_ARRAY];
 } USB_HCD_DRIVERKEY_NAME, *PUSB_HCD_DRIVERKEY_NAME;
 
 typedef struct _USB_DESCRIPTOR_REQUEST {
@@ -334,7 +334,7 @@ typedef struct _USB_DESCRIPTOR_REQUEST {
     USHORT wIndex;
     USHORT wLength;
   } SetupPacket;
-  UCHAR Data[0];
+  UCHAR Data[ANYSIZE_ARRAY];
 } USB_DESCRIPTOR_REQUEST, *PUSB_DESCRIPTOR_REQUEST;
 
 #if (_WIN32_WINNT >= 0x0501)
@@ -358,7 +358,7 @@ typedef struct _USB_NODE_CONNECTION_INFORMATION_EX {
   USHORT DeviceAddress;
   ULONG NumberOfOpenPipes;
   USB_CONNECTION_STATUS ConnectionStatus;
-  USB_PIPE_INFO PipeList[0];
+  USB_PIPE_INFO PipeList[ANYSIZE_ARRAY];
 } USB_NODE_CONNECTION_INFORMATION_EX, *PUSB_NODE_CONNECTION_INFORMATION_EX;
 
 C_ASSERT(sizeof(USB_NODE_CONNECTION_INFORMATION_EX) == sizeof(USB_NODE_CONNECTION_INFORMATION));
@@ -542,7 +542,7 @@ typedef struct _USB_BUS_NOTIFICATION {
 typedef struct _USB_ACQUIRE_INFO {
   USB_NOTIFICATION_TYPE NotificationType;
   ULONG TotalSize;
-  WCHAR Buffer[1];
+  WCHAR Buffer[ANYSIZE_ARRAY];
 } USB_ACQUIRE_INFO, *PUSB_ACQUIRE_INFO;
 
 #if (_WIN32_WINNT >= 0x0600)
@@ -577,7 +577,7 @@ typedef struct _USB_HUB_DEVICE_INFO {
   BOOLEAN HubIsRootHub;
   USB_HUB_CAPABILITIES HubCapabilities;
   ULONG NumberOfHubPorts;
-  USB_HUB_PORT_INFORMATION PortInfo[1];
+  USB_HUB_PORT_INFORMATION PortInfo[ANYSIZE_ARRAY];
 } USB_HUB_DEVICE_INFO, *PUSB_HUB_DEVICE_INFO;
 
 typedef struct _USB_COMPOSITE_FUNCTION_INFO {
@@ -592,7 +592,7 @@ typedef struct _USB_COMPOSITE_DEVICE_INFO {
   USB_CONFIGURATION_DESCRIPTOR CurrentConfigDescriptor;
   UCHAR CurrentConfigurationValue;
   UCHAR NumberOfFunctions;
-  USB_COMPOSITE_FUNCTION_INFO FunctionInfo[1];
+  USB_COMPOSITE_FUNCTION_INFO FunctionInfo[ANYSIZE_ARRAY];
 } USB_COMPOSITE_DEVICE_INFO, *PUSB_COMPOSITE_DEVICE_INFO;
 
 typedef struct _USB_CONTROLLER_DEVICE_INFO {
@@ -617,7 +617,7 @@ typedef struct _USB_DEVICE_INFO {
   WCHAR SerialNumberId[128];
   WCHAR PnpDeviceDescription[128];
   ULONG NumberOfOpenPipes;
-  USB_PIPE_INFO PipeList[1];
+  USB_PIPE_INFO PipeList[ANYSIZE_ARRAY];
 } USB_DEVICE_INFO, *PUSB_DEVICE_INFO;
 
 typedef struct _USB_DEVICE_NODE_INFO {
index 46738b5..3a06e92 100644 (file)
@@ -2075,7 +2075,7 @@ EngQueryDeviceAttribute(
     _In_reads_bytes_(cjInSize) PVOID pvIn,
     _In_ ULONG cjInSize,
     _Out_writes_bytes_(cjOutSize) PVOID pvOut,
-    _Out_ ULONG cjOutSize);
+    _In_ ULONG cjOutSize);
 
 WIN32KAPI
 LARGE_INTEGER
index f4a2282..3649c98 100644 (file)
@@ -48,8 +48,8 @@ BOOL WINAPI EncryptionDisable (
        );
 
 BOOL WINAPI FileEncryptionStatus (
-       LPCTSTR,
-       LPDWORD
+       _In_ LPCTSTR,
+       _Out_ LPDWORD
        );
 
 DWORD WINAPI QueryUsersOnEncryptedFile (
index 3e92376..2b39c6e 100644 (file)
@@ -217,7 +217,7 @@ static __inline const char *wine_dbgstr_rect( const RECT *rect )
 
 static __inline const char *wine_dbgstr_longlong( ULONGLONG ll )
 {
-    if (sizeof(ll) > sizeof(unsigned long) && ll >> 32)
+    if (/*sizeof(ll) > sizeof(unsigned long) &&*/ ll >> 32) /* ULONGLONG is always > long in ReactOS */
         return wine_dbg_sprintf( "%lx%08lx", (unsigned long)(ll >> 32), (unsigned long)ll );
     else return wine_dbg_sprintf( "%lx", (unsigned long)ll );
 }
index 921d8b7..66a18d9 100644 (file)
@@ -539,6 +539,11 @@ static void list_tests(void)
     for (test = winetest_testlist; test->name; test++) fprintf( stdout, "    %s\n", test->name );
 }
 
+/* Disable false-positive claiming "test" would be NULL-dereferenced */
+#if defined(_MSC_VER)
+#pragma warning(push)
+#pragma warning(disable:28182)
+#endif
 
 /* Run a named test, and return exit status */
 static int run_test( const char *name )
@@ -569,6 +574,9 @@ static int run_test( const char *name )
     return status;
 }
 
+#if defined(_MSC_VER)
+#pragma warning(pop)
+#endif
 
 /* Display usage and exit */
 static void usage( const char *argv0 )