mirror of
git://sigrok.org/libserialport
synced 2023-08-10 21:13:24 +03:00
windows: Strip CR/LF from end of system error messages.
This fixes bug #585.
This commit is contained in:
parent
480d750c59
commit
9a0c4bbdbe
@ -2287,10 +2287,10 @@ SP_API char *sp_last_error_message(void)
|
||||
TRACE_VOID();
|
||||
|
||||
#ifdef _WIN32
|
||||
LPVOID message;
|
||||
TCHAR *message;
|
||||
DWORD error = GetLastError();
|
||||
|
||||
FormatMessage(
|
||||
DWORD length = FormatMessage(
|
||||
FORMAT_MESSAGE_ALLOCATE_BUFFER |
|
||||
FORMAT_MESSAGE_FROM_SYSTEM |
|
||||
FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
@ -2300,6 +2300,9 @@ SP_API char *sp_last_error_message(void)
|
||||
(LPTSTR) &message,
|
||||
0, NULL );
|
||||
|
||||
if (length >= 2 && message[length - 2] == '\r')
|
||||
message[length - 2] = '\0';
|
||||
|
||||
RETURN_STRING(message);
|
||||
#else
|
||||
RETURN_STRING(strerror(errno));
|
||||
|
Loading…
Reference in New Issue
Block a user