mirror of
https://github.com/curl/curl.git
synced 2026-08-26 05:23:33 +03:00
windows: use native error code types more
- curlx_get_winapi_error: accept DWORD (was: int), move casts one level up the callstack. - sspi: bump some types to `SECURITY_STATUS` (int -> LONG). - digest_sspi: drop unnecessary cast. Closes #18868
This commit is contained in:
parent
e7a5184fa1
commit
e9ababe9aa
8 changed files with 30 additions and 34 deletions
|
|
@ -298,7 +298,7 @@ const char *curlx_strerror(int err, char *buf, size_t buflen)
|
|||
#ifdef USE_WINSOCK
|
||||
!get_winsock_error(err, buf, buflen) &&
|
||||
#endif
|
||||
!curlx_get_winapi_error(err, buf, buflen))
|
||||
!curlx_get_winapi_error((DWORD)err, buf, buflen))
|
||||
SNPRINTF(buf, buflen, "Unknown error %d (%#x)", err, err);
|
||||
}
|
||||
#else /* !_WIN32 */
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
* codes (GetLastError) to error messages.
|
||||
* Returns NULL if no error message was found for error code.
|
||||
*/
|
||||
const char *curlx_get_winapi_error(int err, char *buf, size_t buflen)
|
||||
const char *curlx_get_winapi_error(DWORD err, char *buf, size_t buflen)
|
||||
{
|
||||
char *p;
|
||||
wchar_t wbuf[256];
|
||||
|
|
@ -64,7 +64,7 @@ const char *curlx_get_winapi_error(int err, char *buf, size_t buflen)
|
|||
expect the local codepage (eg fprintf, failf, infof).
|
||||
FormatMessageW -> wcstombs is used for Windows CE compatibility. */
|
||||
if(FormatMessageW((FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS), NULL, (DWORD)err,
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS), NULL, err,
|
||||
LANG_NEUTRAL, wbuf, CURL_ARRAYSIZE(wbuf), NULL)) {
|
||||
size_t written = wcstombs(buf, wbuf, buflen - 1);
|
||||
if(written != (size_t)-1)
|
||||
|
|
@ -96,7 +96,7 @@ const char *curlx_winapi_strerror(DWORD err, char *buf, size_t buflen)
|
|||
*buf = '\0';
|
||||
|
||||
#ifndef CURL_DISABLE_VERBOSE_STRINGS
|
||||
if(!curlx_get_winapi_error((int)err, buf, buflen)) {
|
||||
if(!curlx_get_winapi_error(err, buf, buflen)) {
|
||||
#if defined(__GNUC__) && __GNUC__ >= 7
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic warning "-Wformat-truncation=1"
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#ifdef _WIN32
|
||||
#define WINAPI_ERROR_LEN 100
|
||||
const char *curlx_get_winapi_error(int err, char *buf, size_t buflen);
|
||||
const char *curlx_get_winapi_error(DWORD err, char *buf, size_t buflen);
|
||||
const char *curlx_winapi_strerror(DWORD err, char *buf, size_t buflen);
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue