Skip to content
This repository has been archived by the owner on Apr 19, 2024. It is now read-only.

Commit

Permalink
Use correct type to print Windows error codes.
Browse files Browse the repository at this point in the history
GetLastError returns DWORD. To print it, convert it to unsigned int
and use the %u format specifier.
  • Loading branch information
codesquid authored and sgtatham committed Aug 15, 2015
1 parent 1f6504c commit 6539d39
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions windows/winmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ const char *win_strerror(int error)
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
msgtext, lenof(msgtext)-1, NULL)) {
sprintf(msgtext,
"(unable to format: FormatMessage returned %d)",
GetLastError());
"(unable to format: FormatMessage returned %u)",
(unsigned int)GetLastError());
} else {
int len = strlen(msgtext);
if (len > 0 && msgtext[len-1] == '\n')
Expand Down
4 changes: 2 additions & 2 deletions windows/winnet.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,8 +478,8 @@ const char *winsock_error_string(int error)
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
es->text + bufused, bufsize - bufused, NULL)) {
sprintf(es->text + bufused,
"Windows error code %d (and FormatMessage returned %d)",
error, GetLastError());
"Windows error code %d (and FormatMessage returned %u)",
error, (unsigned int)GetLastError());
} else {
int len = strlen(es->text);
if (len > 0 && es->text[len-1] == '\n')
Expand Down

0 comments on commit 6539d39

Please sign in to comment.