2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

util: A generic function to convert error to string for windows.

More users will be added in an upcoming commit.

Signed-off-by: Gurucharan Shetty <gshetty@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
This commit is contained in:
Gurucharan Shetty
2014-01-16 13:49:38 -08:00
parent 9d0581fdf2
commit 06f14c92f6
3 changed files with 22 additions and 11 deletions

View File

@@ -1649,3 +1649,19 @@ exit:
return ok;
}
#ifdef _WIN32
/* Calls FormatMessage() with GetLastError() as an argument. Returns
* pointer to a buffer that receives the null-terminated string that specifies
* the formatted message and that has to be freed by the caller with
* LocalFree(). */
char *
ovs_lasterror_to_string(void)
{
char *buffer;
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), 0,
(char *)&buffer, 0, NULL);
return buffer;
}
#endif