Use qintptr for socket handles

Because the real handle is also the size of a pointer,
not int

Change-Id: Ic2efdd56a5deffe9bd130ce02e549efd68d6a337
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
Mårten Nordheim 2023-06-06 15:02:55 +02:00
parent a11c42359a
commit 394602a80a
2 changed files with 10 additions and 10 deletions

View File

@ -136,7 +136,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA
QSNDict *sn_vec[4] = { &d->sn_read, &d->sn_write, &d->sn_except, &d->sn_read }; QSNDict *sn_vec[4] = { &d->sn_read, &d->sn_write, &d->sn_except, &d->sn_read };
QSNDict *dict = sn_vec[type]; QSNDict *dict = sn_vec[type];
QSockNot *sn = dict ? dict->value(wp) : 0; QSockNot *sn = dict ? dict->value(qintptr(wp)) : 0;
if (sn == nullptr) { if (sn == nullptr) {
d->postActivateSocketNotifiers(); d->postActivateSocketNotifiers();
} else { } else {
@ -409,7 +409,7 @@ void QEventDispatcherWin32Private::sendTimerEvent(int timerId)
} }
} }
void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket, long event) void QEventDispatcherWin32Private::doWsaAsyncSelect(qintptr socket, long event)
{ {
Q_ASSERT(internalHwnd); Q_ASSERT(internalHwnd);
// BoundsChecker may emit a warning for WSAAsyncSelect when event == 0 // BoundsChecker may emit a warning for WSAAsyncSelect when event == 0
@ -558,7 +558,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier) void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier)
{ {
Q_ASSERT(notifier); Q_ASSERT(notifier);
int sockfd = notifier->socket(); qintptr sockfd = notifier->socket();
int type = notifier->type(); int type = notifier->type();
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
if (sockfd < 0) { if (sockfd < 0) {
@ -582,7 +582,7 @@ void QEventDispatcherWin32::registerSocketNotifier(QSocketNotifier *notifier)
const char *t[] = { "Read", "Write", "Exception" }; const char *t[] = { "Read", "Write", "Exception" };
/* Variable "socket" below is a function pointer. */ /* Variable "socket" below is a function pointer. */
qWarning("QSocketNotifier: Multiple socket notifiers for " qWarning("QSocketNotifier: Multiple socket notifiers for "
"same socket %d and type %s", sockfd, t[type]); "same socket %" PRIdQINTPTR " and type %s", sockfd, t[type]);
} }
QSockNot *sn = new QSockNot; QSockNot *sn = new QSockNot;
@ -626,7 +626,7 @@ void QEventDispatcherWin32::unregisterSocketNotifier(QSocketNotifier *notifier)
{ {
Q_ASSERT(notifier); Q_ASSERT(notifier);
#ifndef QT_NO_DEBUG #ifndef QT_NO_DEBUG
int sockfd = notifier->socket(); qintptr sockfd = notifier->socket();
if (sockfd < 0) { if (sockfd < 0) {
qWarning("QEventDispatcherWin32::unregisterSocketNotifier: invalid socket identifier"); qWarning("QEventDispatcherWin32::unregisterSocketNotifier: invalid socket identifier");
return; return;
@ -643,7 +643,7 @@ void QEventDispatcherWin32::doUnregisterSocketNotifier(QSocketNotifier *notifier
{ {
Q_D(QEventDispatcherWin32); Q_D(QEventDispatcherWin32);
int type = notifier->type(); int type = notifier->type();
int sockfd = notifier->socket(); qintptr sockfd = notifier->socket();
Q_ASSERT(sockfd >= 0); Q_ASSERT(sockfd >= 0);
QSFDict::iterator it = d->active_fd.find(sockfd); QSFDict::iterator it = d->active_fd.find(sockfd);

View File

@ -71,9 +71,9 @@ private:
struct QSockNot { struct QSockNot {
QSocketNotifier *obj; QSocketNotifier *obj;
int fd; qintptr fd;
}; };
typedef QHash<int, QSockNot *> QSNDict; typedef QHash<qintptr, QSockNot *> QSNDict;
struct QSockFd { struct QSockFd {
long event; long event;
@ -82,7 +82,7 @@ struct QSockFd {
explicit inline QSockFd(long ev = 0, long ma = 0) : event(ev), mask(ma), selected(false) { } explicit inline QSockFd(long ev = 0, long ma = 0) : event(ev), mask(ma), selected(false) { }
}; };
typedef QHash<int, QSockFd> QSFDict; typedef QHash<qintptr, QSockFd> QSFDict;
struct WinTimerInfo { // internal timer info struct WinTimerInfo { // internal timer info
QObject *dispatcher; QObject *dispatcher;
@ -135,7 +135,7 @@ public:
QSFDict active_fd; QSFDict active_fd;
bool activateNotifiersPosted; bool activateNotifiersPosted;
void postActivateSocketNotifiers(); void postActivateSocketNotifiers();
void doWsaAsyncSelect(int socket, long event); void doWsaAsyncSelect(qintptr socket, long event);
bool closingDown = false; bool closingDown = false;