mirror of
https://github.com/outbackdingo/UltraGrid.git
synced 2026-04-07 20:06:01 +00:00
get_win_error: drop trailing <CR><LF>
Some occurences of this call (net_udp.cpp, dlfunc.c) don't expect the string to be terminated so it is perhaps better to drop it at the source.
This commit is contained in:
@@ -282,7 +282,7 @@ bool get_local_addresses(struct sockaddr_storage *addrs, size_t *len, int ip_ver
|
||||
if (dwRetVal == ERROR_NO_DATA)
|
||||
printf("\tNo addresses were found for the requested parameters\n");
|
||||
else {
|
||||
log_msg(LOG_LEVEL_ERROR, "Error: %s", get_win_error(dwRetVal));
|
||||
log_msg(LOG_LEVEL_ERROR, "Error: %s\n", get_win_error(dwRetVal));
|
||||
if (pAddresses)
|
||||
free(pAddresses);
|
||||
return false;
|
||||
|
||||
@@ -122,7 +122,7 @@ const char *hresult_to_str(HRESULT res) {
|
||||
/**
|
||||
* @param error error code (typically GetLastError())
|
||||
*
|
||||
* @note returned error string is typically <NL>-terminated
|
||||
* @note returned error string is _not_ <NL>-terminated (stripped from FormatMessage)
|
||||
*/
|
||||
const char *get_win_error(DWORD error) {
|
||||
_Thread_local static char buf[1024] = "(unknown)";
|
||||
@@ -134,10 +134,17 @@ const char *get_win_error(DWORD error) {
|
||||
sizeof buf, // size of msgbuf, bytes
|
||||
NULL) // va_list of arguments
|
||||
) {
|
||||
char *end = buf + strlen(buf) - 1;
|
||||
if (end > buf && *end == '\n') { // skip LF
|
||||
*end-- = '\0';
|
||||
}
|
||||
if (end > buf && *end == '\r') { // skip CR
|
||||
*end-- = '\0';
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
snprintf(buf, sizeof buf, "[Could not find a description for error # %#lx.]\n", error);
|
||||
snprintf(buf, sizeof buf, "[Could not find a description for error # %#lx.]", error);
|
||||
|
||||
return buf;
|
||||
}
|
||||
@@ -153,7 +160,7 @@ const char *win_wstr_to_str(const wchar_t *wstr) {
|
||||
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
|
||||
log_msg(LOG_LEVEL_ERROR, "win_wstr_to_str: Insufficient buffer length %zd, please report to %s!\n", sizeof res, PACKAGE_BUGREPORT);
|
||||
} else {
|
||||
log_msg(LOG_LEVEL_ERROR, "win_wstr_to_str: %s", get_win_error(GetLastError()));
|
||||
log_msg(LOG_LEVEL_ERROR, "win_wstr_to_str: %s\n", get_win_error(GetLastError()));
|
||||
}
|
||||
}
|
||||
return res;
|
||||
|
||||
@@ -193,7 +193,7 @@ failed:
|
||||
static void PrintError(DWORD err)
|
||||
{
|
||||
// Display the error message and exit the process
|
||||
log_msg(LOG_LEVEL_FATAL, "win32_gl_common %ld: %s", err, get_win_error(err));
|
||||
log_msg(LOG_LEVEL_FATAL, "win32_gl_common %ld: %s\n", err, get_win_error(err));
|
||||
}
|
||||
|
||||
static BOOL SetGLFormat(HDC hdc)
|
||||
|
||||
Reference in New Issue
Block a user