[winpr] use winpr_strerror instead of strerror
use the wrapper from WinPR to use the best implementation available.
This commit is contained in:
parent
c415ec1110
commit
2fffcd64b9
@ -71,7 +71,11 @@ typedef struct
|
||||
do \
|
||||
{ \
|
||||
if (_error != 0) \
|
||||
WLog_ERR(TAG, "%s: %i - %s\n", _text, _error, strerror(_error)); \
|
||||
{ \
|
||||
char buffer[256] = { 0 }; \
|
||||
WLog_ERR(TAG, "%s: %i - %s\n", _text, _error, \
|
||||
winpr_strerror(_error, buffer, sizeof(buffer))); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static UINT32 audin_oss_get_format(const AUDIO_FORMAT* format)
|
||||
|
@ -56,8 +56,9 @@ static bool is_mac_os_sonoma_or_later(void)
|
||||
int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0);
|
||||
if (ret != 0)
|
||||
{
|
||||
WLog_WARN(TAG, "sysctlbyname('kern.osrelease') failed with %s [%d]", strerror(errno),
|
||||
errno);
|
||||
char buffer[256] = { 0 };
|
||||
WLog_WARN(TAG, "sysctlbyname('kern.osrelease') failed with %s [%d]",
|
||||
winpr_strerror(errno, buffer, sizeof(buffer)), errno);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -68,7 +68,11 @@ typedef struct
|
||||
do \
|
||||
{ \
|
||||
if (_error != 0) \
|
||||
WLog_ERR(TAG, "%s: %i - %s", _text, _error, strerror(_error)); \
|
||||
{ \
|
||||
char ebuffer[256] = { 0 }; \
|
||||
WLog_ERR(TAG, "%s: %i - %s", _text, _error, \
|
||||
winpr_strerror(_error, ebuffer, sizeof(ebuffer))); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
static int rdpsnd_oss_get_format(const AUDIO_FORMAT* format)
|
||||
|
@ -188,8 +188,9 @@ int tsmf_platform_create(TSMFGstreamerDecoder* decoder)
|
||||
hdl->shmid = shm_open(get_shm_id(), (O_RDWR | O_CREAT), (PROT_READ | PROT_WRITE));
|
||||
if (hdl->shmid == -1)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "failed to get access to shared memory - shmget(%s): %i - %s", get_shm_id(),
|
||||
errno, strerror(errno));
|
||||
errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return -2;
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,12 @@ typedef struct
|
||||
do \
|
||||
{ \
|
||||
if (_error != 0) \
|
||||
WLog_ERR(TAG, "%s: %i - %s", _text, _error, strerror(_error)); \
|
||||
} while (0)
|
||||
{ \
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "%s: %i - %s", _text, _error, winpr_strerror(_error, ebuffer, sizeof(ebuffer)));
|
||||
}
|
||||
}
|
||||
while (0)
|
||||
|
||||
static BOOL tsmf_oss_open(ITSMFAudioDevice* audio, const char* device)
|
||||
{
|
||||
|
@ -650,7 +650,9 @@ JNIEXPORT jlong JNICALL Java_com_freerdp_freerdpcore_services_LibFreeRDP_freerdp
|
||||
|
||||
if (setenv("HOME", _strdup(envStr), 1) != 0)
|
||||
{
|
||||
WLog_FATAL(TAG, "Failed to set environemnt HOME=%s %s [%d]", env, strerror(errno), errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_FATAL(TAG, "Failed to set environemnt HOME=%s %s [%d]", env,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return (jlong)NULL;
|
||||
}
|
||||
|
||||
|
@ -1228,7 +1228,9 @@ static BOOL xf_process_pipe(rdpContext* context, const char* pipe)
|
||||
int fd = open(pipe, O_NONBLOCK | O_RDONLY);
|
||||
if (fd < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "pipe '%s' open returned %s [%d]", pipe, strerror(errno), errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "pipe '%s' open returned %s [%d]", pipe,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return FALSE;
|
||||
}
|
||||
while (!freerdp_shall_disconnect_context(context))
|
||||
@ -1237,6 +1239,7 @@ static BOOL xf_process_pipe(rdpContext* context, const char* pipe)
|
||||
ssize_t rd = read(fd, buffer, sizeof(buffer) - 1);
|
||||
if (rd == 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
if ((errno == EAGAIN) || (errno == 0))
|
||||
{
|
||||
Sleep(100);
|
||||
@ -1244,12 +1247,15 @@ static BOOL xf_process_pipe(rdpContext* context, const char* pipe)
|
||||
}
|
||||
|
||||
// EOF, abort reading.
|
||||
WLog_ERR(TAG, "pipe '%s' read returned %s [%d]", pipe, strerror(errno), errno);
|
||||
WLog_ERR(TAG, "pipe '%s' read returned %s [%d]", pipe,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
break;
|
||||
}
|
||||
else if (rd < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "pipe '%s' read returned %s [%d]", pipe, strerror(errno), errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "pipe '%s' read returned %s [%d]", pipe,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
break;
|
||||
}
|
||||
else
|
||||
@ -1287,7 +1293,9 @@ static DWORD WINAPI xf_handle_pipe(void* arg)
|
||||
const int rc = mkfifo(pipe, S_IWUSR | S_IRUSR);
|
||||
if (rc != 0)
|
||||
{
|
||||
WLog_ERR(TAG, "Failed to create named pipe '%s': %s [%d]", pipe, strerror(errno), errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "Failed to create named pipe '%s': %s [%d]", pipe,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return 0;
|
||||
}
|
||||
freerdp_add_signal_cleanup_handler(pipe, cleanup_pipe);
|
||||
|
@ -526,7 +526,9 @@ xfWindow* xf_CreateDesktopWindow(xfContext* xfc, char* name, int width, int heig
|
||||
int rc = ftruncate(window->shmid, sizeof(window->handle));
|
||||
if (rc != 0)
|
||||
{
|
||||
DEBUG_X11("ftruncate failed with %s [%d]", strerror(rc), rc);
|
||||
char ebuffer[256] = { 0 };
|
||||
DEBUG_X11("ftruncate failed with %s [%d]", winpr_strerror(rc, ebuffer, sizeof(ebuffer)),
|
||||
rc);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -460,8 +460,9 @@ static BOOL client_cli_authenticate_raw(freerdp* instance, rdp_auth_reason reaso
|
||||
|
||||
if (freerdp_interruptible_get_line(instance->context, username, &username_size, stdin) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "freerdp_interruptible_get_line returned %s [%d]", strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "freerdp_interruptible_get_line returned %s [%d]",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -480,8 +481,9 @@ static BOOL client_cli_authenticate_raw(freerdp* instance, rdp_auth_reason reaso
|
||||
|
||||
if (freerdp_interruptible_get_line(instance->context, domain, &domain_size, stdin) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "freerdp_interruptible_get_line returned %s [%d]", strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "freerdp_interruptible_get_line returned %s [%d]",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -1362,10 +1362,12 @@ static CliprdrLocalFile* file_for_request(CliprdrFileContext* file, UINT32 lockI
|
||||
}
|
||||
if (!f->fp)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
writelog(file->log, WLOG_WARN, __FILE__, __func__, __LINE__,
|
||||
"[lockID %" PRIu32 ", index %" PRIu32
|
||||
"] failed to open file '%s' [size %" PRId64 "] %s [%d]",
|
||||
lockId, listIndex, f->name, f->size, strerror(errno), errno);
|
||||
lockId, listIndex, f->name, f->size,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
@ -60,13 +60,16 @@ static BOOL freerdp_listener_open_from_vsock(freerdp_listener* instance, const c
|
||||
const int sockfd = socket(AF_VSOCK, SOCK_STREAM, 0);
|
||||
if (sockfd == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "Error creating socket: %s", strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "Error creating socket: %s", winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return FALSE;
|
||||
}
|
||||
const int flags = fcntl(sockfd, F_GETFL, 0);
|
||||
if (fcntl(sockfd, F_SETFL, flags | O_NONBLOCK) == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "Error making socket nonblocking: %s", strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "Error making socket nonblocking: %s",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
closesocket((SOCKET)sockfd);
|
||||
return FALSE;
|
||||
}
|
||||
@ -80,23 +83,26 @@ static BOOL freerdp_listener_open_from_vsock(freerdp_listener* instance, const c
|
||||
unsigned long val = strtoul(bind_address, &ptr, 10);
|
||||
if (errno || (val > UINT32_MAX))
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "could not extract port from '%s', value=%ul, error=%s", bind_address, val,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return FALSE;
|
||||
}
|
||||
addr.svm_cid = val;
|
||||
if (bind(sockfd, (struct sockaddr*)&addr, sizeof(struct sockaddr_vm)) == -1)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "Error binding vsock at cid %d port %d: %s", addr.svm_cid, port,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
closesocket((SOCKET)sockfd);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if (listen(sockfd, 10) == -1)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "Error listening to socket at cid %d port %d: %s", addr.svm_cid, port,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
closesocket((SOCKET)sockfd);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1124,8 +1124,9 @@ int freerdp_tcp_default_connect(rdpContext* context, rdpSettings* settings, cons
|
||||
unsigned long val = strtoul(hostname, &ptr, 10);
|
||||
if (errno || (val > UINT32_MAX))
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "could not extract port from '%s', value=%ul, error=%s", hostname, val,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return -1;
|
||||
}
|
||||
addr.svm_cid = val;
|
||||
|
@ -728,11 +728,12 @@ static void transport_bio_error_log(rdpTransport* transport, LPCSTR biofunc, BIO
|
||||
|
||||
if (ERR_peek_error() == 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
const char* fmt = "%s returned a system error %d: %s";
|
||||
if (saveerrno == 0)
|
||||
fmt = "%s retries exceeded";
|
||||
WLog_PrintMessage(transport->log, WLOG_MESSAGE_TEXT, level, line, file, func, fmt, biofunc,
|
||||
saveerrno, strerror(saveerrno));
|
||||
saveerrno, winpr_strerror(saveerrno, ebuffer, sizeof(ebuffer)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -156,7 +156,9 @@ static BOOL key_read_private(rdpPrivateKey* key)
|
||||
RSA* rsa = evp_pkey_to_rsa(key);
|
||||
if (!rsa)
|
||||
{
|
||||
WLog_ERR(TAG, "unable to load RSA key: %s.", strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "unable to load RSA key: %s.",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
@ -171,9 +173,13 @@ static BOOL key_read_private(rdpPrivateKey* key)
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "unexpected error when checking RSA key: %s.", strerror(errno));
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "unexpected error when checking RSA key: %s.",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
const BIGNUM* rsa_e = NULL;
|
||||
const BIGNUM* rsa_n = NULL;
|
||||
|
@ -238,8 +238,9 @@ BOOL freerdp_http_request(const char* url, const char* body, long* status_code,
|
||||
*response_length = strtoul(val, NULL, 10);
|
||||
if (errno)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_Print(log, WLOG_ERROR, "could not parse content length (%s): %s [%d]", val,
|
||||
strerror(errno), errno);
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
|
@ -73,14 +73,22 @@ static void lock(void)
|
||||
{
|
||||
const int rc = pthread_mutex_lock(&signal_handler_lock);
|
||||
if (rc != 0)
|
||||
WLog_ERR(TAG, "[pthread_mutex_lock] failed with %s [%d]", strerror(rc), rc);
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "[pthread_mutex_lock] failed with %s [%d]",
|
||||
winpr_strerror(rc, ebuffer, sizeof(ebuffer)), rc);
|
||||
}
|
||||
}
|
||||
|
||||
static void unlock(void)
|
||||
{
|
||||
const int rc = pthread_mutex_unlock(&signal_handler_lock);
|
||||
if (rc != 0)
|
||||
WLog_ERR(TAG, "[pthread_mutex_lock] failed with %s [%d]", strerror(rc), rc);
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "[pthread_mutex_lock] failed with %s [%d]",
|
||||
winpr_strerror(rc, ebuffer, sizeof(ebuffer)), rc);
|
||||
}
|
||||
}
|
||||
|
||||
static void term_handler(int signum)
|
||||
|
@ -1298,8 +1298,9 @@ HANDLE CommCreateFileA(LPCSTR lpDeviceName, DWORD dwDesiredAccess, DWORD dwShare
|
||||
|
||||
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
CommLog_Print(WLOG_WARN, "could not read counters.");
|
||||
/* could not initialize counters but keep on.
|
||||
*
|
||||
|
@ -241,7 +241,9 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
|
||||
|
||||
if (nbFds < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s\n", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s\n", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
goto return_false;
|
||||
}
|
||||
@ -268,9 +270,10 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
|
||||
}
|
||||
else
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN,
|
||||
"unexpected error on reading fd_read_event, errno=[%d] %s\n", errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
/* FIXME: goto return_false ? */
|
||||
}
|
||||
|
||||
@ -293,6 +296,7 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
|
||||
|
||||
if (nbRead < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN,
|
||||
"CommReadFile failed, ReadIntervalTimeout=%" PRIu32
|
||||
", ReadTotalTimeoutMultiplier=%" PRIu32
|
||||
@ -300,9 +304,9 @@ BOOL CommReadFile(HANDLE hDevice, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
|
||||
pTimeouts->ReadIntervalTimeout, pTimeouts->ReadTotalTimeoutMultiplier,
|
||||
pTimeouts->ReadTotalTimeoutConstant, currentTermios.c_cc[VMIN],
|
||||
currentTermios.c_cc[VTIME]);
|
||||
CommLog_Print(WLOG_WARN,
|
||||
"CommReadFile failed, nNumberOfBytesToRead=%" PRIu32 ", errno=[%d] %s",
|
||||
nNumberOfBytesToRead, errno, strerror(errno));
|
||||
CommLog_Print(
|
||||
WLOG_WARN, "CommReadFile failed, nNumberOfBytesToRead=%" PRIu32 ", errno=[%d] %s",
|
||||
nNumberOfBytesToRead, errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
|
||||
if (errno == EAGAIN)
|
||||
{
|
||||
@ -433,7 +437,9 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
|
||||
|
||||
if (nbFds < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s\n", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "select() failure, errno=[%d] %s\n", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
goto return_false;
|
||||
}
|
||||
@ -460,9 +466,10 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
|
||||
}
|
||||
else
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN,
|
||||
"unexpected error on reading fd_write_event, errno=[%d] %s\n",
|
||||
errno, strerror(errno));
|
||||
errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
/* FIXME: goto return_false ? */
|
||||
}
|
||||
|
||||
@ -488,10 +495,12 @@ BOOL CommWriteFile(HANDLE hDevice, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrite
|
||||
|
||||
if (nbWritten < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN,
|
||||
"CommWriteFile failed after %" PRIu32
|
||||
" bytes written, errno=[%d] %s\n",
|
||||
*lpNumberOfBytesWritten, errno, strerror(errno));
|
||||
*lpNumberOfBytesWritten, errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
|
||||
if (errno == EAGAIN)
|
||||
{
|
||||
|
@ -893,8 +893,9 @@ static BOOL _set_lines(WINPR_COMM* pComm, UINT32 lines)
|
||||
{
|
||||
if (ioctl(pComm->fd, TIOCMBIS, &lines) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCMBIS ioctl failed, lines=0x%" PRIX32 ", errno=[%d] %s", lines,
|
||||
errno, strerror(errno));
|
||||
errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
@ -906,8 +907,9 @@ static BOOL _clear_lines(WINPR_COMM* pComm, UINT32 lines)
|
||||
{
|
||||
if (ioctl(pComm->fd, TIOCMBIC, &lines) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCMBIC ioctl failed, lines=0x%" PRIX32 ", errno=[%d] %s", lines,
|
||||
errno, strerror(errno));
|
||||
errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
@ -986,7 +988,9 @@ static BOOL _get_modemstatus(WINPR_COMM* pComm, ULONG* pRegister)
|
||||
UINT32 lines = 0;
|
||||
if (ioctl(pComm->fd, TIOCMGET, &lines) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCMGET ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCMGET ioctl failed, errno=[%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1057,8 +1061,9 @@ static BOOL _set_wait_mask(WINPR_COMM* pComm, const ULONG* pWaitMask)
|
||||
|
||||
if (ioctl(pComm->fd, TIOCGICOUNT, &(pComm->counters)) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
|
||||
if (pComm->permissive)
|
||||
{
|
||||
@ -1150,8 +1155,9 @@ static BOOL _purge(WINPR_COMM* pComm, const ULONG* pPurgeMask)
|
||||
{
|
||||
if (errno != EAGAIN)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "eventfd_write failed, errno=[%d] %s", errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
}
|
||||
|
||||
WINPR_ASSERT(errno == EAGAIN); /* no reader <=> no pending IRP_MJ_WRITE */
|
||||
@ -1166,8 +1172,9 @@ static BOOL _purge(WINPR_COMM* pComm, const ULONG* pPurgeMask)
|
||||
{
|
||||
if (errno != EAGAIN)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "eventfd_write failed, errno=[%d] %s", errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
}
|
||||
|
||||
WINPR_ASSERT(errno == EAGAIN); /* no reader <=> no pending IRP_MJ_READ */
|
||||
@ -1180,8 +1187,9 @@ static BOOL _purge(WINPR_COMM* pComm, const ULONG* pPurgeMask)
|
||||
|
||||
if (tcflush(pComm->fd, TCOFLUSH) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "tcflush(TCOFLUSH) failure, errno=[%d] %s", errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_CANCELLED);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1193,8 +1201,9 @@ static BOOL _purge(WINPR_COMM* pComm, const ULONG* pPurgeMask)
|
||||
|
||||
if (tcflush(pComm->fd, TCIFLUSH) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "tcflush(TCIFLUSH) failure, errno=[%d] %s", errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_CANCELLED);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1221,8 +1230,9 @@ static BOOL _get_commstatus(WINPR_COMM* pComm, SERIAL_STATUS* pCommstatus)
|
||||
ZeroMemory(¤tCounters, sizeof(struct serial_icounter_struct));
|
||||
if (ioctl(pComm->fd, TIOCGICOUNT, ¤tCounters) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCGICOUNT ioctl failed, errno=[%d] %s.", errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
CommLog_Print(WLOG_WARN, " could not read counters.");
|
||||
|
||||
if (pComm->permissive)
|
||||
@ -1292,7 +1302,9 @@ static BOOL _get_commstatus(WINPR_COMM* pComm, SERIAL_STATUS* pCommstatus)
|
||||
|
||||
if (ioctl(pComm->fd, TIOCINQ, &(pCommstatus->AmountInInQueue)) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCINQ ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCINQ ioctl failed, errno=[%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
|
||||
LeaveCriticalSection(&pComm->EventsLock);
|
||||
@ -1303,7 +1315,9 @@ static BOOL _get_commstatus(WINPR_COMM* pComm, SERIAL_STATUS* pCommstatus)
|
||||
|
||||
if (ioctl(pComm->fd, TIOCOUTQ, &(pCommstatus->AmountInOutQueue)) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCOUTQ ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCOUTQ ioctl failed, errno=[%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
|
||||
LeaveCriticalSection(&pComm->EventsLock);
|
||||
@ -1476,7 +1490,9 @@ static BOOL _set_break_on(WINPR_COMM* pComm)
|
||||
{
|
||||
if (ioctl(pComm->fd, TIOCSBRK, NULL) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCSBRK ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCSBRK ioctl failed, errno=[%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1488,7 +1504,9 @@ static BOOL _set_break_off(WINPR_COMM* pComm)
|
||||
{
|
||||
if (ioctl(pComm->fd, TIOCCBRK, NULL) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCSBRK ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCSBRK ioctl failed, errno=[%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1500,7 +1518,9 @@ static BOOL _set_xoff(WINPR_COMM* pComm)
|
||||
{
|
||||
if (tcflow(pComm->fd, TCIOFF) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TCIOFF failure, errno=[%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TCIOFF failure, errno=[%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1512,7 +1532,9 @@ static BOOL _set_xon(WINPR_COMM* pComm)
|
||||
{
|
||||
if (tcflow(pComm->fd, TCION) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TCION failure, errno=[%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TCION failure, errno=[%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
@ -1525,7 +1547,9 @@ static BOOL _get_dtrrts(WINPR_COMM* pComm, ULONG* pMask)
|
||||
UINT32 lines = 0;
|
||||
if (ioctl(pComm->fd, TIOCMGET, &lines) < 0)
|
||||
{
|
||||
CommLog_Print(WLOG_WARN, "TIOCMGET ioctl failed, errno=[%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
CommLog_Print(WLOG_WARN, "TIOCMGET ioctl failed, errno=[%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_IO_DEVICE);
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <winpr/config.h>
|
||||
#include <winpr/debug.h>
|
||||
|
||||
#if defined(__FreeBSD_kernel__) && defined(__GLIBC__)
|
||||
#define _GNU_SOURCE
|
||||
@ -108,8 +109,9 @@ static BOOL FileSetEndOfFile(HANDLE hFile)
|
||||
|
||||
if (ftruncate(fileno(pFile->fp), size) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "ftruncate %s failed with %s [0x%08X]", pFile->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "ftruncate %s failed with %s [0x%08X]", pFile->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
SetLastError(map_posix_err(errno));
|
||||
return FALSE;
|
||||
}
|
||||
@ -153,8 +155,9 @@ static DWORD FileSetFilePointer(HANDLE hFile, LONG lDistanceToMove, PLONG lpDist
|
||||
|
||||
if (_fseeki64(pFile->fp, offset, whence))
|
||||
{
|
||||
WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", pFile->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", pFile->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return INVALID_SET_FILE_POINTER;
|
||||
}
|
||||
|
||||
@ -187,8 +190,9 @@ static BOOL FileSetFilePointerEx(HANDLE hFile, LARGE_INTEGER liDistanceToMove,
|
||||
|
||||
if (_fseeki64(pFile->fp, liDistanceToMove.QuadPart, whence))
|
||||
{
|
||||
WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", pFile->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", pFile->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -283,15 +287,17 @@ static DWORD FileGetFileSize(HANDLE Object, LPDWORD lpFileSizeHigh)
|
||||
|
||||
if (cur < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return INVALID_FILE_SIZE;
|
||||
}
|
||||
|
||||
if (_fseeki64(file->fp, 0, SEEK_END) != 0)
|
||||
{
|
||||
WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", file->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "_fseeki64(%s) failed with %s [0x%08X]", file->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return INVALID_FILE_SIZE;
|
||||
}
|
||||
|
||||
@ -299,15 +305,17 @@ static DWORD FileGetFileSize(HANDLE Object, LPDWORD lpFileSizeHigh)
|
||||
|
||||
if (size < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return INVALID_FILE_SIZE;
|
||||
}
|
||||
|
||||
if (_fseeki64(file->fp, cur, SEEK_SET) != 0)
|
||||
{
|
||||
WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "_ftelli64(%s) failed with %s [0x%08X]", file->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return INVALID_FILE_SIZE;
|
||||
}
|
||||
|
||||
@ -332,7 +340,9 @@ static BOOL FileGetFileInformationByHandle(HANDLE hFile,
|
||||
|
||||
if (fstat(fileno(pFile->fp), &st) == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "fstat failed with %s [%#08X]", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "fstat failed with %s [%#08X]", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@ -425,7 +435,9 @@ static BOOL FileLockFileEx(HANDLE hFile, DWORD dwFlags, DWORD dwReserved,
|
||||
|
||||
if (fcntl(fileno(pFile->fp), lckcmd, &lock) == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "F_SETLK failed with %s [0x%08X]", strerror(errno), errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "F_SETLK failed with %s [0x%08X]",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
@ -439,7 +451,9 @@ static BOOL FileLockFileEx(HANDLE hFile, DWORD dwFlags, DWORD dwReserved,
|
||||
|
||||
if (flock(fileno(pFile->fp), lock) < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "flock failed with %s [0x%08X]", strerror(errno), errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "flock failed with %s [0x%08X]",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
@ -473,16 +487,18 @@ static BOOL FileUnlockFile(HANDLE hFile, DWORD dwFileOffsetLow, DWORD dwFileOffs
|
||||
lock.l_type = F_UNLCK;
|
||||
if (fcntl(fileno(pFile->fp), F_GETLK, &lock) == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "F_UNLCK on %s failed with %s [0x%08X]", pFile->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "F_UNLCK on %s failed with %s [0x%08X]", pFile->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#else
|
||||
if (flock(fileno(pFile->fp), LOCK_UN) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "flock(LOCK_UN) %s failed with %s [0x%08X]", pFile->lpFileName,
|
||||
strerror(errno), errno);
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
@ -521,15 +537,17 @@ static BOOL FileUnlockFileEx(HANDLE hFile, DWORD dwReserved, DWORD nNumberOfByte
|
||||
lock.l_type = F_UNLCK;
|
||||
if (fcntl(fileno(pFile->fp), F_GETLK, &lock) == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "F_UNLCK on %s failed with %s [0x%08X]", pFile->lpFileName, strerror(errno),
|
||||
errno);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "F_UNLCK on %s failed with %s [0x%08X]", pFile->lpFileName,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return FALSE;
|
||||
}
|
||||
#else
|
||||
if (flock(fileno(pFile->fp), LOCK_UN) < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "flock(LOCK_UN) %s failed with %s [0x%08X]", pFile->lpFileName,
|
||||
strerror(errno), errno);
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
@ -766,8 +784,12 @@ UINT32 map_posix_err(int fs_errno)
|
||||
break;
|
||||
|
||||
default:
|
||||
WLog_ERR(TAG, "Missing ERRNO mapping %s [%d]", strerror(fs_errno), fs_errno);
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "Missing ERRNO mapping %s [%d]",
|
||||
winpr_strerror(fs_errno, ebuffer, sizeof(ebuffer)), fs_errno);
|
||||
rc = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -908,10 +930,13 @@ static HANDLE FileCreateFileA(LPCSTR lpFileName, DWORD dwDesiredAccess, DWORD dw
|
||||
if (flock(fileno(pFile->fp), lock) < 0)
|
||||
#endif
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
#ifdef __sun
|
||||
WLog_ERR(TAG, "F_SETLKW failed with %s [0x%08X]", strerror(errno), errno);
|
||||
WLog_ERR(TAG, "F_SETLKW failed with %s [0x%08X]",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
#else
|
||||
WLog_ERR(TAG, "flock failed with %s [0x%08X]", strerror(errno), errno);
|
||||
WLog_ERR(TAG, "flock failed with %s [0x%08X]",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)), errno);
|
||||
#endif
|
||||
|
||||
SetLastError(map_posix_err(errno));
|
||||
|
@ -649,7 +649,9 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
|
||||
|
||||
if ((serverfd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "CreateNamedPipeA: socket error, %s", strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "CreateNamedPipeA: socket error, %s",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@ -658,13 +660,17 @@ HANDLE CreateNamedPipeA(LPCSTR lpName, DWORD dwOpenMode, DWORD dwPipeMode, DWORD
|
||||
|
||||
if (bind(serverfd, (struct sockaddr*)&s, sizeof(struct sockaddr_un)) == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "CreateNamedPipeA: bind error, %s", strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "CreateNamedPipeA: bind error, %s",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (listen(serverfd, 2) == -1)
|
||||
{
|
||||
WLog_ERR(TAG, "CreateNamedPipeA: listen error, %s", strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "CreateNamedPipeA: listen error, %s",
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,9 @@ BOOL MutexCloseHandle(HANDLE handle)
|
||||
|
||||
if ((rc = pthread_mutex_destroy(&mutex->mutex)))
|
||||
{
|
||||
WLog_ERR(TAG, "pthread_mutex_destroy failed with %s [%d]", strerror(rc), rc);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "pthread_mutex_destroy failed with %s [%d]",
|
||||
winpr_strerror(rc, ebuffer, sizeof(ebuffer)), rc);
|
||||
#if defined(WITH_DEBUG_MUTEX)
|
||||
{
|
||||
size_t used = 0, i;
|
||||
@ -230,7 +232,9 @@ BOOL ReleaseMutex(HANDLE hMutex)
|
||||
|
||||
if (rc)
|
||||
{
|
||||
WLog_ERR(TAG, "pthread_mutex_unlock failed with %s [%d]", strerror(rc), rc);
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "pthread_mutex_unlock failed with %s [%d]",
|
||||
winpr_strerror(rc, ebuffer, sizeof(ebuffer)), rc);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@ -18,7 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <winpr/config.h>
|
||||
|
||||
#include <winpr/debug.h>
|
||||
#include <winpr/synch.h>
|
||||
|
||||
#include "synch.h"
|
||||
@ -63,7 +63,9 @@ static DWORD SemaphoreCleanupHandle(HANDLE handle)
|
||||
|
||||
if (length != 1)
|
||||
{
|
||||
WLog_ERR(TAG, "semaphore read() failure [%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "semaphore read() failure [%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return WAIT_FAILED;
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,7 @@ static DWORD TimerCleanupHandle(HANDLE handle)
|
||||
{
|
||||
if (length < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
switch (errno)
|
||||
{
|
||||
case ETIMEDOUT:
|
||||
@ -94,7 +95,8 @@ static DWORD TimerCleanupHandle(HANDLE handle)
|
||||
break;
|
||||
}
|
||||
|
||||
WLog_ERR(TAG, "timer read() failure [%d] %s", errno, strerror(errno));
|
||||
WLog_ERR(TAG, "timer read() failure [%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -209,7 +209,9 @@ DWORD WaitForSingleObjectEx(HANDLE hHandle, DWORD dwMilliseconds, BOOL bAlertabl
|
||||
}
|
||||
else if (ret < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "waitpid failure [%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "waitpid failure [%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
SetLastError(ERROR_INTERNAL_ERROR);
|
||||
return WAIT_FAILED;
|
||||
}
|
||||
@ -310,7 +312,9 @@ DWORD WaitForSingleObjectEx(HANDLE hHandle, DWORD dwMilliseconds, BOOL bAlertabl
|
||||
status = pollset_poll(&pollset, dwMilliseconds);
|
||||
if (status < 0)
|
||||
{
|
||||
WLog_ERR(TAG, "pollset_poll() failure [%d] %s", errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "pollset_poll() failure [%d] %s", errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
@ -464,12 +468,13 @@ DWORD WaitForMultipleObjectsEx(DWORD nCount, const HANDLE* lpHandles, BOOL bWait
|
||||
status = pollset_poll(&pollset, waitTime);
|
||||
if (status < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
#ifdef WINPR_HAVE_POLL_H
|
||||
WLog_ERR(TAG, "poll() handle %" PRIu32 " (%" PRIu32 ") failure [%d] %s", index,
|
||||
nCount, errno, strerror(errno));
|
||||
nCount, errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
#else
|
||||
WLog_ERR(TAG, "select() handle %" PRIu32 " (%" PRIu32 ") failure [%d] %s", index,
|
||||
nCount, errno, strerror(errno));
|
||||
nCount, errno, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
#endif
|
||||
winpr_log_backtrace(TAG, WLOG_ERROR, 20);
|
||||
SetLastError(ERROR_INTERNAL_ERROR);
|
||||
|
@ -144,7 +144,8 @@ static int get_file_size(const char* pathname)
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
D("Can't open %s: %s\n", pathname, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
D("Can't open %s: %s\n", pathname, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -154,10 +155,12 @@ static int get_file_size(const char* pathname)
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
D("Error while reading %s: %s\n", pathname, strerror(errno));
|
||||
D("Error while reading %s: %s\n", pathname,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -183,7 +186,8 @@ static int read_file(const char* pathname, char* buffer, size_t buffsize)
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
D("Could not open %s: %s\n", pathname, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
D("Could not open %s: %s\n", pathname, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -195,10 +199,12 @@ static int read_file(const char* pathname, char* buffer, size_t buffsize)
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
D("Error while reading from %s: %s\n", pathname, strerror(errno));
|
||||
D("Error while reading from %s: %s\n", pathname,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
|
||||
if (count == 0)
|
||||
count = -1;
|
||||
@ -476,7 +482,8 @@ static void cpulist_read_from(CpuList* list, const char* filename)
|
||||
|
||||
if (filelen < 0)
|
||||
{
|
||||
D("Could not read %s: %s\n", filename, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
D("Could not read %s: %s\n", filename, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -586,7 +593,8 @@ static uint32_t get_elf_hwcap_from_proc_self_auxv(void)
|
||||
|
||||
if (fd < 0)
|
||||
{
|
||||
D("Could not open %s: %s\n", filepath, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
D("Could not open %s: %s\n", filepath, winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -604,7 +612,9 @@ static uint32_t get_elf_hwcap_from_proc_self_auxv(void)
|
||||
|
||||
if (ret < 0)
|
||||
{
|
||||
D("Error while reading %s: %s\n", filepath, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
D("Error while reading %s: %s\n", filepath,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -132,7 +132,8 @@ static BOOL run_mutex_init_(int (*fkt)(pthread_mutex_t*, const pthread_mutexattr
|
||||
rc = fkt(mutex, mutexattr);
|
||||
if (rc != 0)
|
||||
{
|
||||
WLog_WARN(TAG, "[%s] failed with [%s]", name, strerror(rc));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_WARN(TAG, "[%s] failed with [%s]", name, winpr_strerror(rc, ebuffer, sizeof(ebuffer)));
|
||||
}
|
||||
return rc == 0;
|
||||
}
|
||||
@ -149,7 +150,8 @@ static BOOL run_mutex_fkt_(int (*fkt)(pthread_mutex_t* mux), const char* name,
|
||||
rc = fkt(mutex);
|
||||
if (rc != 0)
|
||||
{
|
||||
WLog_WARN(TAG, "[%s] failed with [%s]", name, strerror(rc));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_WARN(TAG, "[%s] failed with [%s]", name, winpr_strerror(rc, ebuffer, sizeof(ebuffer)));
|
||||
}
|
||||
return rc == 0;
|
||||
}
|
||||
@ -166,7 +168,8 @@ static BOOL run_cond_init_(int (*fkt)(pthread_cond_t*, const pthread_condattr_t*
|
||||
rc = fkt(condition, conditionattr);
|
||||
if (rc != 0)
|
||||
{
|
||||
WLog_WARN(TAG, "[%s] failed with [%s]", name, strerror(rc));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_WARN(TAG, "[%s] failed with [%s]", name, winpr_strerror(rc, ebuffer, sizeof(ebuffer)));
|
||||
}
|
||||
return rc == 0;
|
||||
}
|
||||
@ -183,7 +186,8 @@ static BOOL run_cond_fkt_(int (*fkt)(pthread_cond_t* mux), const char* name,
|
||||
rc = fkt(condition);
|
||||
if (rc != 0)
|
||||
{
|
||||
WLog_WARN(TAG, "[%s] failed with [%s]", name, strerror(rc));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_WARN(TAG, "[%s] failed with [%s]", name, winpr_strerror(rc, ebuffer, sizeof(ebuffer)));
|
||||
}
|
||||
return rc == 0;
|
||||
}
|
||||
@ -259,7 +263,9 @@ static BOOL mux_condition_bundle_wait(mux_condition_bundle* bundle, const char*
|
||||
int r = pthread_cond_wait(&bundle->cond, &bundle->mux);
|
||||
if (r != 0)
|
||||
{
|
||||
WLog_ERR(TAG, "failed to wait for %s [%s]", name, strerror(r));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "failed to wait for %s [%s]", name,
|
||||
winpr_strerror(r, ebuffer, sizeof(ebuffer)));
|
||||
switch (r)
|
||||
{
|
||||
case ENOTRECOVERABLE:
|
||||
@ -311,7 +317,9 @@ static DWORD ThreadCleanupHandle(HANDLE handle)
|
||||
|
||||
if (rc != 0)
|
||||
{
|
||||
WLog_ERR(TAG, "pthread_join failure: [%d] %s", rc, strerror(rc));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(TAG, "pthread_join failure: [%d] %s", rc,
|
||||
winpr_strerror(rc, ebuffer, sizeof(ebuffer)));
|
||||
goto fail;
|
||||
}
|
||||
else
|
||||
|
@ -18,6 +18,7 @@
|
||||
*/
|
||||
|
||||
#include <winpr/config.h>
|
||||
#include <winpr/debug.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@ -67,8 +68,9 @@ void winpr_HexLogDump(wLog* log, UINT32 lvl, const void* data, size_t length)
|
||||
|
||||
if (!buffer)
|
||||
{
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_Print(log, WLOG_ERROR, "malloc(%" PRIuz ") failed with [%" PRIuz "] %s", blen, errno,
|
||||
strerror(errno));
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -137,7 +139,9 @@ void winpr_CArrayDump(const char* tag, UINT32 level, const void* data, size_t le
|
||||
|
||||
if (!buffer)
|
||||
{
|
||||
WLog_ERR(tag, "malloc(%" PRIuz ") failed with [%d] %s", llen, errno, strerror(errno));
|
||||
char ebuffer[256] = { 0 };
|
||||
WLog_ERR(tag, "malloc(%" PRIuz ") failed with [%d] %s", llen, errno,
|
||||
winpr_strerror(errno, ebuffer, sizeof(ebuffer)));
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user