Prevent: warning: dereferencing type-punned pointer will break strict-aliasing rules
authorlace <>
Tue, 20 Dec 2005 08:39:58 +0000 (08:39 +0000)
committerlace <>
Tue, 20 Dec 2005 08:39:58 +0000 (08:39 +0000)
include/ntos/types.h
ntoskrnl/ob/handle.c

index bbee9b8..ca61201 100644 (file)
@@ -113,7 +113,10 @@ typedef wchar_t *LPWSTR;
 typedef wchar_t *PWSTR;
 typedef unsigned char *PUCHAR;
 typedef unsigned short *PUSHORT;
-typedef void *PVOID;
+/* Prevent: warning: dereferencing type-punned pointer will break strict-aliasing rules
+ * As PVOID is usually used for untyped generalized casts.
+ */
+typedef void __attribute__((__may_alias__)) *PVOID;
 typedef unsigned char BYTE;
 typedef void *LPVOID;
 typedef float *PFLOAT;
index d8a6266..ebf2b7b 100644 (file)
@@ -635,7 +635,12 @@ ObReferenceObjectByHandle(HANDLE Handle,
    if (Handle == NtCurrentProcess() && 
        (ObjectType == PsProcessType || ObjectType == NULL))
      {
+/* FIXME: How to prevent?: warning: dereferencing type-punned pointer will break strict-aliasing rules
+ * '__attribute__((__may_alias__))' for 'PULONG' does not work.
+ */
+#if 0
        DPRINT("Reference from %x\n", ((PULONG)&Handle)[-1]);
+#endif
        
        Status = ObReferenceObjectByPointer(PsGetCurrentProcess(),
                                            PROCESS_ALL_ACCESS,
@@ -710,7 +715,12 @@ ObReferenceObjectByHandle(HANDLE Handle,
    
    if (ObjectHeader->ObjectType == PsProcessType)
      {
+/* FIXME: How to prevent?: warning: dereferencing type-punned pointer will break strict-aliasing rules
+ * '__attribute__((__may_alias__))' for 'PULONG' does not work.
+ */
+#if 0
        DPRINT("Reference from %x\n", ((PULONG)&Handle)[-1]);
+#endif
      }
    
    if (DesiredAccess && AccessMode == UserMode)