[INCLUDES]

- Add _PRAGMA_WARNING_SUPPRESS() macro
- Fix definition of __analysis_noreturn for PREFAST runs
- Annotate RtlAssert with __analysis_noreturn everywhere
- Add proper annotations to all DbgPrint and DbgPrintEx definitions
- Suppress warnings for use of ProbeForRead outside of SEH

svn path=/trunk/; revision=56983
This commit is contained in:
Timo Kreuzer 2012-07-29 17:25:05 +00:00
parent f59a68d66e
commit d2d680b3ae
6 changed files with 20 additions and 15 deletions

View file

@ -30,6 +30,7 @@
#ifndef RC_INVOKED #ifndef RC_INVOKED
#define _PRAGMA_WARNING_SUPPRESS(x) /* Only for MSVC */
#define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__)) #define __INTRIN_INLINE extern __inline__ __attribute__((__always_inline__,__gnu_inline__))
#ifndef _SIZE_T_DEFINED #ifndef _SIZE_T_DEFINED

View file

@ -5,6 +5,9 @@
extern "C" { extern "C" {
#endif #endif
/** Pragma support **/
#define _PRAGMA_WARNING_SUPPRESS(x) __pragma(warning(suppress: x))
/*** Stack frame juggling ***/ /*** Stack frame juggling ***/
void * _ReturnAddress(void); void * _ReturnAddress(void);
#pragma intrinsic(_ReturnAddress) #pragma intrinsic(_ReturnAddress)

View file

@ -593,6 +593,7 @@ RtlAddVectoredExceptionHandler(
IN PVECTORED_EXCEPTION_HANDLER VectoredHandler IN PVECTORED_EXCEPTION_HANDLER VectoredHandler
); );
__analysis_noreturn
NTSYSAPI NTSYSAPI
VOID VOID
NTAPI NTAPI

View file

@ -46,16 +46,17 @@
#define __in_awcount(expr,size) #define __in_awcount(expr,size)
#define __nullnullterminated #define __nullnullterminated
#define __in_data_source(src_sym) #define __in_data_source(src_sym)
#define __analysis_noreturn
#define __kernel_entry #define __kernel_entry
#if (_MSC_VER >= 1000) && !defined(__midl) && defined(_PREFAST_) #if (_MSC_VER >= 1000) && !defined(__midl) && defined(_PREFAST_)
#define __inner_data_source(src_raw) _SA_annotes1(SAL_untrusted_data_source,src_raw) #define __inner_data_source(src_raw) _SA_annotes1(SAL_untrusted_data_source,src_raw)
#define __out_data_source(src_sym) _Post_ __inner_data_source(#src_sym) #define __out_data_source(src_sym) _Post_ __inner_data_source(#src_sym)
#define __analysis_noreturn __declspec(noreturn)
#else #else
#define __out_data_source(src_sym) #define __out_data_source(src_sym)
#define __analysis_noreturn
#endif #endif

View file

@ -27,20 +27,21 @@
ULONG ULONG
__cdecl __cdecl
DbgPrint( DbgPrint(
IN PCCH Format, _In_z_ _Printf_format_string_ PCSTR Format,
IN ... ...
); );
NTSYSAPI NTSYSAPI
ULONG ULONG
__cdecl __cdecl
DbgPrintEx( DbgPrintEx(
IN ULONG ComponentId, _In_ ULONG ComponentId,
IN ULONG Level, _In_ ULONG Level,
IN PCCH Format, _In_z_ _Printf_format_string_ PCCH Format,
IN ... ...
); );
__analysis_noreturn
NTSYSAPI NTSYSAPI
VOID VOID
NTAPI NTAPI
@ -107,7 +108,7 @@ RtlAssert(
#define WARN_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__) #define WARN_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define TRACE_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__) #define TRACE_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define INFO_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__) #define INFO_(ch, fmt, ...) DbgPrintEx(DPFLTR_##ch##_ID, DPFLTR_INFO_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define ERR__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__) #define ERR__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_ERROR_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define WARN__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__) #define WARN__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_WARNING_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
#define TRACE__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__) #define TRACE__(ch, fmt, ...) DbgPrintEx(ch, DPFLTR_TRACE_LEVEL, "(%s:%d) " fmt, __FILE__, __LINE__, ##__VA_ARGS__)
@ -124,7 +125,7 @@ RtlAssert(
#define WARN_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) #define WARN_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define TRACE_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) #define TRACE_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define INFO_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) #define INFO_(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define ERR__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) #define ERR__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define WARN__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) #define WARN__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)
#define TRACE__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0) #define TRACE__(ch, ...) do { if(0) { DbgPrint(__VA_ARGS__); } } while(0)

View file

@ -109,9 +109,8 @@ ProbeArrayForRead(IN const VOID *ArrayPtr,
} }
/* Probe the array */ /* Probe the array */
ProbeForRead(ArrayPtr, _PRAGMA_WARNING_SUPPRESS(28125) /* Must be inside __try / __except block */
ArraySize, ProbeForRead(ArrayPtr, ArraySize, Alignment);
Alignment);
} }
static __inline static __inline
@ -131,9 +130,8 @@ ProbeArrayForWrite(IN OUT PVOID ArrayPtr,
} }
/* Probe the array */ /* Probe the array */
ProbeForWrite(ArrayPtr, _PRAGMA_WARNING_SUPPRESS(28125) /* Must be inside __try / __except block */
ArraySize, ProbeForWrite(ArrayPtr, ArraySize, Alignment);
Alignment);
} }
#endif /* _WIN32K_ */ #endif /* _WIN32K_ */