The success criteria can be specified with the _Success_(expr) annotation:
_Success_(return != FALSE) BOOL
- PathCanonicalizeA(_Out_writes_(MAX_LONGPATH) LPSTR pszBuf, LPCSTR pszPath) :
+ PathCanonicalizeA(_Out_writes_(MAX_PATH) LPSTR pszBuf, LPCSTR pszPath) :
pszBuf is only guaranteed to be NULL-terminated when TRUE is returned,
and FALSE indiates failure. In common practice, callers check for zero
vs. non-zero returns, so it is preferable to express the success
(<parameter>|return)[+n] e.g. cch, return, cb+2
If the buffer size is a constant expression use the c_ postfix.
- E.g. cap_c_(20), count_c_(MAX_LONGPATH), bytecount_c_(16)
+ E.g. cap_c_(20), count_c_(MAX_PATH), bytecount_c_(16)
If the buffer size is given by a limiting pointer use the ptrdiff_ versions
of the macros.
Advanced Annotation Examples
__success(return != FALSE) LWSTDAPI_(BOOL)
- PathCanonicalizeA(__out_ecount(MAX_LONGPATH) LPSTR pszBuf, LPCSTR pszPath) :
+ PathCanonicalizeA(__out_ecount(MAX_PATH) LPSTR pszBuf, LPCSTR pszPath) :
pszBuf is only guaranteed to be NULL-terminated when TRUE is returned.
typedef __nullterminated WCHAR* LPWSTR : Initialized LPWSTRs are NULL-terminated strings.
* Advanced Annotation Examples
*
* __success(return == TRUE) LWSTDAPI_(BOOL)
-* PathCanonicalizeA(__out_ecount(MAX_LONGPATH) LPSTR pszBuf, LPCSTR pszPath);
+* PathCanonicalizeA(__out_ecount(MAX_PATH) LPSTR pszBuf, LPCSTR pszPath);
* // pszBuf is only guaranteed to be null-terminated when TRUE is returned.
*
* // Initialized LPWSTRs are null-terminated strings.
if (strlen(lpFileName) >= MAX_LONGPATH)
{
WARN("FindFirstFileA called with a pattern whose size is "
- "%d >= MAX_PATH_FNAME (%d)\n", strlen(lpFileName), MAX_PATH_FNAME);
+ "%d >= MAX_LONGPATH (%d)\n", strlen(lpFileName), MAX_LONGPATH);
dwLastError = ERROR_FILENAME_EXCED_RANGE;
goto done;
}