summaryrefslogtreecommitdiff
path: root/src/gui/embedded
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@nokia.com>2009-04-23 11:55:02 +0200
committerThiago Macieira <thiago.macieira@nokia.com>2009-07-02 13:29:36 +0200
commitcad1bf4c902899ec1a8277d46272afa23fc2b34b (patch)
treebc4c4f318893d2d8723b4898fc4edcf544eb4b83 /src/gui/embedded
parent27fc6ef5dfb7d58af778de162298fdc4da34459f (diff)
downloadqt4-tools-cad1bf4c902899ec1a8277d46272afa23fc2b34b.tar.gz
Port gui/embedded to the EINTR-safe functions.
I think I found two file descriptor that aren't closed. One seems like a genuine leak, the other seems intentional. Reviewed-By: ossi
Diffstat (limited to 'src/gui/embedded')
-rw-r--r--src/gui/embedded/qkbdlinuxinput_qws.cpp1
-rw-r--r--src/gui/embedded/qkbdsl5000_qws.cpp6
-rw-r--r--src/gui/embedded/qkbdtty_qws.cpp4
-rw-r--r--src/gui/embedded/qkbdvfb_qws.cpp9
-rw-r--r--src/gui/embedded/qkbdvr41xx_qws.cpp7
-rw-r--r--src/gui/embedded/qkbdyopy_qws.cpp10
-rw-r--r--src/gui/embedded/qlock.cpp6
-rw-r--r--src/gui/embedded/qmousebus_qws.cpp11
-rw-r--r--src/gui/embedded/qmouselinuxtp_qws.cpp7
-rw-r--r--src/gui/embedded/qmousepc_qws.cpp39
-rw-r--r--src/gui/embedded/qmousevfb_qws.cpp9
-rw-r--r--src/gui/embedded/qmousevr41xx_qws.cpp11
-rw-r--r--src/gui/embedded/qmouseyopy_qws.cpp7
-rw-r--r--src/gui/embedded/qscreenlinuxfb_qws.cpp20
-rw-r--r--src/gui/embedded/qsoundqss_qws.cpp9
-rw-r--r--src/gui/embedded/qtransportauth_qws.cpp7
-rw-r--r--src/gui/embedded/qunixsocket.cpp18
17 files changed, 106 insertions, 75 deletions
diff --git a/src/gui/embedded/qkbdlinuxinput_qws.cpp b/src/gui/embedded/qkbdlinuxinput_qws.cpp
index d5720f7d1b..e552731290 100644
--- a/src/gui/embedded/qkbdlinuxinput_qws.cpp
+++ b/src/gui/embedded/qkbdlinuxinput_qws.cpp
@@ -47,6 +47,7 @@
#include <QStringList>
#include <qplatformdefs.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <errno.h>
#include <termios.h>
diff --git a/src/gui/embedded/qkbdsl5000_qws.cpp b/src/gui/embedded/qkbdsl5000_qws.cpp
index 36cb9030c9..cf82c104e8 100644
--- a/src/gui/embedded/qkbdsl5000_qws.cpp
+++ b/src/gui/embedded/qkbdsl5000_qws.cpp
@@ -51,6 +51,8 @@
#include "qnamespace.h"
#include "qtimer.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/types.h>
@@ -207,14 +209,14 @@ QWSSL5000KeyboardHandler::QWSSL5000KeyboardHandler(const QString &device)
numLock = false;
sharp_kbdctl_modifstat st;
- int dev = ::open(device.isEmpty()?"/dev/sharp_kbdctl":device.toLocal8Bit().constData(), O_RDWR);
+ int dev = QT_OPEN(device.isEmpty()?"/dev/sharp_kbdctl":device.toLocal8Bit().constData(), O_RDWR);
if (dev >= 0) {
memset(&st, 0, sizeof(st));
st.which = 3;
int ret = ioctl(dev, SHARP_KBDCTL_GETMODIFSTAT, (char*)&st);
if(!ret)
numLock = (bool)st.stat;
- ::close(dev);
+ QT_CLOSE(dev);
}
}
diff --git a/src/gui/embedded/qkbdtty_qws.cpp b/src/gui/embedded/qkbdtty_qws.cpp
index 33777eb91b..8c1e79b45a 100644
--- a/src/gui/embedded/qkbdtty_qws.cpp
+++ b/src/gui/embedded/qkbdtty_qws.cpp
@@ -47,6 +47,7 @@
#include <QStringList>
#include <qplatformdefs.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <errno.h>
#include <termios.h>
@@ -213,6 +214,9 @@ QWSTtyKbPrivate::~QWSTtyKbPrivate()
::ioctl(m_tty_fd, KDSKBMODE, m_originalKbdMode);
#endif
tcsetattr(m_tty_fd, TCSANOW, &m_tty_attr);
+
+ // we're leaking m_tty_fd here?
+ //QT_CLOSE(m_tty_fd);
}
}
diff --git a/src/gui/embedded/qkbdvfb_qws.cpp b/src/gui/embedded/qkbdvfb_qws.cpp
index 082aac1d09..a44183ba44 100644
--- a/src/gui/embedded/qkbdvfb_qws.cpp
+++ b/src/gui/embedded/qkbdvfb_qws.cpp
@@ -55,6 +55,7 @@
#include <qwindowsystem_qws.h>
#include <qsocketnotifier.h>
#include <qapplication.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
QT_BEGIN_NAMESPACE
@@ -69,13 +70,13 @@ QVFbKeyboardHandler::QVFbKeyboardHandler(const QString &device)
kbdBufferLen = sizeof(QVFbKeyData) * 5;
kbdBuffer = new unsigned char [kbdBufferLen];
- if ((kbdFD = open(terminalName.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
+ if ((kbdFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
qWarning("Cannot open %s (%s)", terminalName.toLatin1().constData(),
strerror(errno));
} else {
// Clear pending input
char buf[2];
- while (read(kbdFD, buf, 1) > 0) { }
+ while (QT_READ(kbdFD, buf, 1) > 0) { }
notifier = new QSocketNotifier(kbdFD, QSocketNotifier::Read, this);
connect(notifier, SIGNAL(activated(int)),this, SLOT(readKeyboardData()));
@@ -85,7 +86,7 @@ QVFbKeyboardHandler::QVFbKeyboardHandler(const QString &device)
QVFbKeyboardHandler::~QVFbKeyboardHandler()
{
if (kbdFD >= 0)
- close(kbdFD);
+ QT_CLOSE(kbdFD);
delete [] kbdBuffer;
}
@@ -94,7 +95,7 @@ void QVFbKeyboardHandler::readKeyboardData()
{
int n;
do {
- n = read(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
+ n = QT_READ(kbdFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
if (n > 0)
kbdIdx += n;
} while (n > 0);
diff --git a/src/gui/embedded/qkbdvr41xx_qws.cpp b/src/gui/embedded/qkbdvr41xx_qws.cpp
index 03c2a6718e..6d8299b008 100644
--- a/src/gui/embedded/qkbdvr41xx_qws.cpp
+++ b/src/gui/embedded/qkbdvr41xx_qws.cpp
@@ -52,6 +52,7 @@
#include <errno.h>
#include <qsocketnotifier.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
QT_BEGIN_NAMESPACE
@@ -95,7 +96,7 @@ QWSVr41xxKbPrivate::QWSVr41xxKbPrivate(QWSVr41xxKeyboardHandler *h, const QStrin
buttonFD = -1;
notifier = 0;
- buttonFD = open(terminalName.toLatin1().constData(), O_RDWR | O_NDELAY, 0);;
+ buttonFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDWR | O_NDELAY, 0);;
if (buttonFD < 0) {
qWarning("Cannot open %s\n", qPrintable(terminalName));
return;
@@ -115,7 +116,7 @@ QWSVr41xxKbPrivate::QWSVr41xxKbPrivate(QWSVr41xxKeyboardHandler *h, const QStrin
QWSVr41xxKbPrivate::~QWSVr41xxKbPrivate()
{
if (buttonFD > 0) {
- ::close(buttonFD);
+ QT_CLOSE(buttonFD);
buttonFD = -1;
}
delete notifier;
@@ -127,7 +128,7 @@ void QWSVr41xxKbPrivate::readKeyboardData()
{
int n = 0;
do {
- n = read(buttonFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
+ n = QT_READ(buttonFD, kbdBuffer+kbdIdx, kbdBufferLen - kbdIdx);
if (n > 0)
kbdIdx += n;
} while (n > 0);
diff --git a/src/gui/embedded/qkbdyopy_qws.cpp b/src/gui/embedded/qkbdyopy_qws.cpp
index 5c9d28ddc6..edb732ccab 100644
--- a/src/gui/embedded/qkbdyopy_qws.cpp
+++ b/src/gui/embedded/qkbdyopy_qws.cpp
@@ -60,6 +60,8 @@
#include <linux/fb.h>
#include <linux/yopy_button.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+
extern "C" {
int getpgid(int);
}
@@ -105,7 +107,7 @@ QWSYopyKbPrivate::QWSYopyKbPrivate(QWSYopyKeyboardHandler *h, const QString &dev
buttonFD = -1;
notifier = 0;
- buttonFD = ::open(terminalName.toLatin1().constData(), O_RDWR | O_NDELAY, 0);
+ buttonFD = QT_OPEN(terminalName.toLatin1().constData(), O_RDWR | O_NDELAY, 0);
if (buttonFD < 0) {
qWarning("Cannot open %s\n", qPrintable(terminalName));
return;
@@ -177,10 +179,10 @@ void QWSYopyKbPrivate::readKeyboardData()
case 40: k=Qt::Key_Up; break; // prev
case 45: k=Qt::Key_Down; break; // next
case 35: if(!press) {
- fd = open("/proc/sys/pm/sleep",O_RDWR,0);
+ fd = QT_OPEN("/proc/sys/pm/sleep",O_RDWR,0);
if(fd >= 0) {
- write(fd,&c,sizeof(c));
- close(fd);
+ QT_WRITE(fd,&c,sizeof(c));
+ QT_CLOSE(fd);
//
// Updates all widgets.
//
diff --git a/src/gui/embedded/qlock.cpp b/src/gui/embedded/qlock.cpp
index c23608fa86..305832cf5d 100644
--- a/src/gui/embedded/qlock.cpp
+++ b/src/gui/embedded/qlock.cpp
@@ -73,6 +73,8 @@ union semun {
#endif // QT_NO_QWS_MULTIPROCESS
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
+
#define MAX_LOCKS 200 // maximum simultaneous read locks
QT_BEGIN_NAMESPACE
@@ -134,7 +136,7 @@ QLock::QLock(const QString &filename, char id, bool create)
#ifdef Q_NO_SEMAPHORE
data->file = QString(filename+id).toLocal8Bit().constData();
for(int x = 0; x < 2; x++) {
- data->id = open(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU);
+ data->id = QT_OPEN(data->file, O_RDWR | (x ? O_CREAT : 0), S_IRWXU);
if(data->id != -1 || !create) {
data->owned = x;
break;
@@ -177,7 +179,7 @@ QLock::~QLock()
unlock();
#ifdef Q_NO_SEMAPHORE
if(isValid()) {
- close(data->id);
+ QT_CLOSE(data->id);
if(data->owned)
unlink(data->file);
}
diff --git a/src/gui/embedded/qmousebus_qws.cpp b/src/gui/embedded/qmousebus_qws.cpp
index a88ca5be3e..0b674b6969 100644
--- a/src/gui/embedded/qmousebus_qws.cpp
+++ b/src/gui/embedded/qmousebus_qws.cpp
@@ -47,6 +47,7 @@
#include "qsocketnotifier.h"
#include "qapplication.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -119,9 +120,9 @@ QWSBusMouseHandlerPrivate::QWSBusMouseHandlerPrivate(QWSBusMouseHandler *h,
mouseDev = QLatin1String("/dev/mouse");
obstate = -1;
mouseFD = -1;
- mouseFD = open(mouseDev.toLocal8Bit(), O_RDWR | O_NDELAY);
+ mouseFD = QT_OPEN(mouseDev.toLocal8Bit(), O_RDWR | O_NDELAY);
if (mouseFD < 0)
- mouseFD = open(mouseDev.toLocal8Bit(), O_RDONLY | O_NDELAY);
+ mouseFD = QT_OPEN(mouseDev.toLocal8Bit(), O_RDONLY | O_NDELAY);
if (mouseFD < 0)
qDebug("Cannot open %s (%s)", qPrintable(mouseDev), strerror(errno));
@@ -130,7 +131,7 @@ QWSBusMouseHandlerPrivate::QWSBusMouseHandlerPrivate(QWSBusMouseHandler *h,
usleep(50000);
char buf[100]; // busmouse driver will not read if bufsize < 3, YYD
- while (read(mouseFD, buf, 100) > 0) { } // eat unwanted replies
+ while (QT_READ(mouseFD, buf, 100) > 0) { } // eat unwanted replies
mouseIdx = 0;
@@ -142,7 +143,7 @@ QWSBusMouseHandlerPrivate::~QWSBusMouseHandlerPrivate()
{
if (mouseFD >= 0) {
tcflush(mouseFD,TCIFLUSH); // yyd.
- close(mouseFD);
+ QT_CLOSE(mouseFD);
}
}
@@ -167,7 +168,7 @@ void QWSBusMouseHandlerPrivate::readMouseData()
for (;;) {
if (mouseBufSize - mouseIdx < 3)
break;
- n = read(mouseFD, mouseBuf+mouseIdx, 3);
+ n = QT_READ(mouseFD, mouseBuf+mouseIdx, 3);
if (n != 3)
break;
mouseIdx += 3;
diff --git a/src/gui/embedded/qmouselinuxtp_qws.cpp b/src/gui/embedded/qmouselinuxtp_qws.cpp
index 1b4d96e55d..e64407e078 100644
--- a/src/gui/embedded/qmouselinuxtp_qws.cpp
+++ b/src/gui/embedded/qmouselinuxtp_qws.cpp
@@ -47,6 +47,7 @@
#include "qtimer.h"
#include "qapplication.h"
#include "qscreen_qws.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -190,7 +191,7 @@ QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate(QWSLinuxTPMouseHand
} else {
mousedev = device;
}
- if ((mouseFD = open(mousedev.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
+ if ((mouseFD = QT_OPEN(mousedev.toLatin1().constData(), O_RDONLY | O_NDELAY)) < 0) {
qWarning("Cannot open %s (%s)", qPrintable(mousedev), strerror(errno));
return;
}
@@ -205,7 +206,7 @@ QWSLinuxTPMouseHandlerPrivate::QWSLinuxTPMouseHandlerPrivate(QWSLinuxTPMouseHand
QWSLinuxTPMouseHandlerPrivate::~QWSLinuxTPMouseHandlerPrivate()
{
if (mouseFD >= 0)
- close(mouseFD);
+ QT_CLOSE(mouseFD);
}
void QWSLinuxTPMouseHandlerPrivate::suspend()
@@ -233,7 +234,7 @@ void QWSLinuxTPMouseHandlerPrivate::readMouseData()
int n;
do {
- n = read(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
+ n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
if (n > 0)
mouseIdx += n;
} while (n > 0 && mouseIdx < mouseBufSize);
diff --git a/src/gui/embedded/qmousepc_qws.cpp b/src/gui/embedded/qmousepc_qws.cpp
index a9f2bc8340..317bb8af04 100644
--- a/src/gui/embedded/qmousepc_qws.cpp
+++ b/src/gui/embedded/qmousepc_qws.cpp
@@ -55,6 +55,7 @@
#include "qfile.h"
#include "qtextstream.h"
#include "qstringlist.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -107,7 +108,7 @@ public:
{
if (fd != f) {
f = fd;
- close(fd);
+ QT_CLOSE(fd);
}
}
@@ -170,7 +171,7 @@ public:
}
static const uchar initseq[] = { 243, 200, 243, 100, 243, 80 };
static const uchar query[] = { 0xf2 };
- if (write(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
+ if (QT_WRITE(fd, initseq, sizeof(initseq))!=sizeof(initseq)) {
badness = 100;
return;
}
@@ -180,12 +181,12 @@ public:
perror("QWSPcMouseSubHandler_intellimouse: post-init tcflush");
#endif
}
- if (write(fd, query, sizeof(query))!=sizeof(query)) {
+ if (QT_WRITE(fd, query, sizeof(query))!=sizeof(query)) {
badness = 100;
return;
}
usleep(10000);
- n = read(fd, reply, 20);
+ n = QT_READ(fd, reply, 20);
if (n > 0) {
goodness = 10;
switch (reply[n-1]) {
@@ -256,13 +257,13 @@ public:
perror("QWSPcMouseSubHandler_mouseman: initial tcflush");
#endif
}
- write(fd,"",1);
+ QT_WRITE(fd,"",1);
usleep(50000);
- write(fd,"@EeI!",5);
+ QT_WRITE(fd,"@EeI!",5);
usleep(10000);
static const char ibuf[] = { 246, 244 };
- write(fd,ibuf,1);
- write(fd,ibuf+1,1);
+ QT_WRITE(fd,ibuf,1);
+ QT_WRITE(fd,ibuf+1,1);
if (tcflush(fd,TCIOFLUSH) == -1) {
#ifdef QWS_MOUSE_DEBUG
perror("QWSPcMouseSubHandler_mouseman: tcflush");
@@ -271,7 +272,7 @@ public:
usleep(10000);
char buf[100];
- while (read(fd, buf, 100) > 0) { } // eat unwanted replies
+ while (QT_READ(fd, buf, 100) > 0) { } // eat unwanted replies
}
int tryData()
@@ -350,7 +351,7 @@ private:
for (int n = 0; n < 4; n++) {
setflags(CSTOPB | speed[n]);
- write(fd, "*q", 2);
+ QT_WRITE(fd, "*q", 2);
usleep(10000);
}
}
@@ -369,7 +370,7 @@ public:
{
setflags(B1200|CS8|CSTOPB);
// 60Hz
- if (write(fd, "R", 1)!=1) {
+ if (QT_WRITE(fd, "R", 1)!=1) {
badness = 100;
return;
}
@@ -418,7 +419,7 @@ public:
{
setflags(B1200|CS7);
// 60Hz
- if (write(fd, "R", 1)!=1) {
+ if (QT_WRITE(fd, "R", 1)!=1) {
badness = 100;
return;
}
@@ -648,25 +649,25 @@ void QWSPcMouseHandlerPrivate::openDevices()
if (drv == QLatin1String("intellimouse")) {
if (dev.isEmpty())
dev = "/dev/psaux";
- fd = open(dev, O_RDWR | O_NDELAY);
+ fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
if (fd >= 0)
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
} else if (drv == QLatin1String("microsoft")) {
if (dev.isEmpty())
dev = "/dev/ttyS0";
- fd = open(dev, O_RDWR | O_NDELAY);
+ fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
if (fd >= 0)
sub[nsub++] = new QWSPcMouseSubHandler_ms(fd);
} else if (drv == QLatin1String("mousesystems")) {
if (dev.isEmpty())
dev = "/dev/ttyS0";
- fd = open(dev, O_RDWR | O_NDELAY);
+ fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
if (fd >= 0)
sub[nsub++] = new QWSPcMouseSubHandler_mousesystems(fd);
} else if (drv == QLatin1String("mouseman")) {
if (dev.isEmpty())
dev = "/dev/psaux";
- fd = open(dev, O_RDWR | O_NDELAY);
+ fd = QT_OPEN(dev, O_RDWR | O_NDELAY);
if (fd >= 0)
sub[nsub++] = new QWSPcMouseSubHandler_mouseman(fd);
}
@@ -677,12 +678,12 @@ void QWSPcMouseHandlerPrivate::openDevices()
dev.constData(), strerror(errno));
} else {
// Try automatically
- fd = open("/dev/psaux", O_RDWR | O_NDELAY);
+ fd = QT_OPEN("/dev/psaux", O_RDWR | O_NDELAY);
if (fd >= 0) {
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
notify(fd);
}
- fd = open("/dev/input/mice", O_RDWR | O_NDELAY);
+ fd = QT_OPEN("/dev/input/mice", O_RDWR | O_NDELAY);
if (fd >= 0) {
sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
notify(fd);
@@ -694,7 +695,7 @@ void QWSPcMouseHandlerPrivate::openDevices()
#if 0
const char fn[4][11] = { "/dev/ttyS0", "/dev/ttyS1", "/dev/ttyS2", "/dev/ttyS3" };
for (int ch = 0; ch < 4; ++ch) {
- fd = open(fn[ch], O_RDWR | O_NDELAY);
+ fd = QT_OPEN(fn[ch], O_RDWR | O_NDELAY);
if (fd >= 0) {
//sub[nsub++] = new QWSPcMouseSubHandler_intellimouse(fd);
sub[nsub++] = new QWSPcMouseSubHandler_mousesystems(fd);
diff --git a/src/gui/embedded/qmousevfb_qws.cpp b/src/gui/embedded/qmousevfb_qws.cpp
index 17d051f7a6..dd553bc26b 100644
--- a/src/gui/embedded/qmousevfb_qws.cpp
+++ b/src/gui/embedded/qmousevfb_qws.cpp
@@ -54,6 +54,7 @@
#include <qsocketnotifier.h>
#include <qapplication.h>
#include <qtimer.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
QT_BEGIN_NAMESPACE
@@ -64,7 +65,7 @@ QVFbMouseHandler::QVFbMouseHandler(const QString &driver, const QString &device)
if (device.isEmpty())
mouseDev = QLatin1String("/dev/vmouse");
- mouseFD = open(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY);
+ mouseFD = QT_OPEN(mouseDev.toLatin1().constData(), O_RDWR | O_NDELAY);
if (mouseFD == -1) {
perror("QVFbMouseHandler::QVFbMouseHandler");
qWarning("QVFbMouseHander: Unable to open device %s",
@@ -74,7 +75,7 @@ QVFbMouseHandler::QVFbMouseHandler(const QString &driver, const QString &device)
// Clear pending input
char buf[2];
- while (read(mouseFD, buf, 1) > 0) { }
+ while (QT_READ(mouseFD, buf, 1) > 0) { }
mouseIdx = 0;
@@ -85,7 +86,7 @@ QVFbMouseHandler::QVFbMouseHandler(const QString &driver, const QString &device)
QVFbMouseHandler::~QVFbMouseHandler()
{
if (mouseFD >= 0)
- close(mouseFD);
+ QT_CLOSE(mouseFD);
}
void QVFbMouseHandler::resume()
@@ -102,7 +103,7 @@ void QVFbMouseHandler::readMouseData()
{
int n;
do {
- n = read(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
+ n = QT_READ(mouseFD, mouseBuf+mouseIdx, mouseBufSize-mouseIdx);
if (n > 0)
mouseIdx += n;
} while (n > 0);
diff --git a/src/gui/embedded/qmousevr41xx_qws.cpp b/src/gui/embedded/qmousevr41xx_qws.cpp
index 8748055d5d..b7491d9175 100644
--- a/src/gui/embedded/qmousevr41xx_qws.cpp
+++ b/src/gui/embedded/qmousevr41xx_qws.cpp
@@ -49,6 +49,7 @@
#include "qscreen_qws.h"
#include <qstringlist.h>
#include <qvarlengtharray.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -144,7 +145,7 @@ QWSVr41xxMouseHandlerPrivate::QWSVr41xxMouseHandlerPrivate(QWSVr41xxMouseHandler
else
dev = options.first();
- if ((mouseFD = open(dev.toLocal8Bit().constData(), O_RDONLY)) < 0) {
+ if ((mouseFD = QT_OPEN(dev.toLocal8Bit().constData(), O_RDONLY)) < 0) {
qWarning("Cannot open %s (%s)", qPrintable(dev), strerror(errno));
return;
}
@@ -167,7 +168,7 @@ QWSVr41xxMouseHandlerPrivate::QWSVr41xxMouseHandlerPrivate(QWSVr41xxMouseHandler
QWSVr41xxMouseHandlerPrivate::~QWSVr41xxMouseHandlerPrivate()
{
if (mouseFD >= 0)
- close(mouseFD);
+ QT_CLOSE(mouseFD);
}
void QWSVr41xxMouseHandlerPrivate::suspend()
@@ -190,9 +191,9 @@ void QWSVr41xxMouseHandlerPrivate::sendRelease()
bool QWSVr41xxMouseHandlerPrivate::getSample()
{
- const int n = read(mouseFD,
- reinterpret_cast<uchar*>(currSample) + currLength,
- sizeof(currSample) - currLength);
+ const int n = QT_READ(mouseFD,
+ reinterpret_cast<uchar*>(currSample) + currLength,
+ sizeof(currSample) - currLength);
if (n > 0)
currLength += n;
diff --git a/src/gui/embedded/qmouseyopy_qws.cpp b/src/gui/embedded/qmouseyopy_qws.cpp
index 7b1141a384..3a541d370c 100644
--- a/src/gui/embedded/qmouseyopy_qws.cpp
+++ b/src/gui/embedded/qmouseyopy_qws.cpp
@@ -46,6 +46,7 @@
#include "qsocketnotifier.h"
#include "qapplication.h"
#include "qscreen_qws.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -103,7 +104,7 @@ void QWSYopyMouseHandler::suspend()
QWSYopyMouseHandlerPrivate::QWSYopyMouseHandlerPrivate(QWSYopyMouseHandler *h)
: handler(h)
{
- if ((mouseFD = open("/dev/ts", O_RDONLY)) < 0) {
+ if ((mouseFD = QT_OPEN("/dev/ts", O_RDONLY)) < 0) {
qWarning("Cannot open /dev/ts (%s)", strerror(errno));
return;
} else {
@@ -118,7 +119,7 @@ QWSYopyMouseHandlerPrivate::QWSYopyMouseHandlerPrivate(QWSYopyMouseHandler *h)
QWSYopyMouseHandlerPrivate::~QWSYopyMouseHandlerPrivate()
{
if (mouseFD >= 0)
- close(mouseFD);
+ QT_CLOSE(mouseFD);
}
#define YOPY_XPOS(d) (d[1]&0x3FF)
@@ -156,7 +157,7 @@ void QWSYopyMouseHandlerPrivate::readMouseData()
int ret;
- ret=read(mouseFD,&yopDat,sizeof(yopDat));
+ ret=QT_READ(mouseFD,&yopDat,sizeof(yopDat));
if(ret) {
data.status= (YOPY_PRES(yopDat)) ? 1 : 0;
diff --git a/src/gui/embedded/qscreenlinuxfb_qws.cpp b/src/gui/embedded/qscreenlinuxfb_qws.cpp
index 42c4fcd4b6..28458422a3 100644
--- a/src/gui/embedded/qscreenlinuxfb_qws.cpp
+++ b/src/gui/embedded/qscreenlinuxfb_qws.cpp
@@ -46,6 +46,7 @@
#include "qwsdisplay_qws.h"
#include "qpixmap.h"
#include <private/qwssignalhandler_p.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -122,12 +123,12 @@ void QLinuxFbScreenPrivate::openTty()
if (ttyDevice.isEmpty()) {
for (const char * const *dev = devs; *dev; ++dev) {
- ttyfd = ::open(*dev, O_RDWR);
+ ttyfd = QT_OPEN(*dev, O_RDWR);
if (ttyfd != -1)
break;
}
} else {
- ttyfd = ::open(ttyDevice.toAscii().constData(), O_RDWR);
+ ttyfd = QT_OPEN(ttyDevice.toAscii().constData(), O_RDWR);
}
if (ttyfd == -1)
@@ -144,7 +145,7 @@ void QLinuxFbScreenPrivate::openTty()
// No blankin' screen, no blinkin' cursor!, no cursor!
const char termctl[] = "\033[9;0]\033[?33l\033[?25l\033[?1c";
- ::write(ttyfd, termctl, sizeof(termctl));
+ QT_WRITE(ttyfd, termctl, sizeof(termctl));
}
void QLinuxFbScreenPrivate::closeTty()
@@ -157,9 +158,9 @@ void QLinuxFbScreenPrivate::closeTty()
// Blankin' screen, blinkin' cursor!
const char termctl[] = "\033[9;15]\033[?33h\033[?25h\033[?0c";
- ::write(ttyfd, termctl, sizeof(termctl));
+ QT_WRITE(ttyfd, termctl, sizeof(termctl));
- ::close(ttyfd);
+ QT_CLOSE(ttyfd);
ttyfd = -1;
}
@@ -281,7 +282,7 @@ bool QLinuxFbScreen::connect(const QString &displaySpec)
dev = QLatin1String("/dev/fb0");
if (access(dev.toLatin1().constData(), R_OK|W_OK) == 0)
- d_ptr->fd = open(dev.toLatin1().constData(), O_RDWR);
+ d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDWR);
if (d_ptr->fd == -1) {
if (QApplication::type() == QApplication::GuiServer) {
perror("QScreenLinuxFb::connect");
@@ -289,7 +290,7 @@ bool QLinuxFbScreen::connect(const QString &displaySpec)
return false;
}
if (access(dev.toLatin1().constData(), R_OK) == 0)
- d_ptr->fd = open(dev.toLatin1().constData(), O_RDONLY);
+ d_ptr->fd = QT_OPEN(dev.toLatin1().constData(), O_RDONLY);
}
fb_fix_screeninfo finfo;
@@ -681,7 +682,7 @@ bool QLinuxFbScreen::initDevice()
#ifdef __i386__
// Now init mtrr
if(!::getenv("QWS_NOMTRR")) {
- int mfd=open("/proc/mtrr",O_WRONLY,0);
+ int mfd=QT_OPEN("/proc/mtrr",O_WRONLY,0);
// MTRR entry goes away when file is closed - i.e.
// hopefully when QWS is killed
if(mfd != -1) {
@@ -702,6 +703,9 @@ bool QLinuxFbScreen::initDevice()
//sentry.base,sentry.size,strerror(errno));
}
}
+
+ // Should we close mfd here?
+ //QT_CLOSE(mfd);
}
#endif
if ((vinfo.bits_per_pixel==8) || (vinfo.bits_per_pixel==4) || (finfo.visual==FB_VISUAL_DIRECTCOLOR))
diff --git a/src/gui/embedded/qsoundqss_qws.cpp b/src/gui/embedded/qsoundqss_qws.cpp
index ac0ac9dc27..a45d0fecbe 100644
--- a/src/gui/embedded/qsoundqss_qws.cpp
+++ b/src/gui/embedded/qsoundqss_qws.cpp
@@ -53,6 +53,7 @@
#include <qtimer.h>
#include <qpointer.h>
#include <qendian.h>
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <unistd.h>
#include <stdlib.h>
@@ -1137,7 +1138,7 @@ void QWSSoundServerPrivate::sendCompletedSignals()
int QWSSoundServerPrivate::openFile(int wid, int sid, const QString& filename)
{
stopFile(wid, sid); // close and re-open.
- int f = ::open(QFile::encodeName(filename), O_RDONLY|O_NONBLOCK);
+ int f = QT_OPEN(QFile::encodeName(filename), O_RDONLY|O_NONBLOCK);
if (f == -1) {
// XXX check ferror, check reason.
qDebug("Failed opening \"%s\"",filename.toLatin1().data());
@@ -1157,7 +1158,7 @@ bool QWSSoundServerPrivate::openDevice()
{
if (fd < 0) {
if( silent ) {
- fd = ::open( "/dev/null", O_WRONLY );
+ fd = QT_OPEN( "/dev/null", O_WRONLY );
// Emulate write to audio device
int delay = 1000*(sound_buffer_size>>(sound_stereo+sound_16bit))/sound_speed/2;
timerId = startTimer(delay);
@@ -1168,7 +1169,7 @@ bool QWSSoundServerPrivate::openDevice()
// Don't block open right away.
//
bool openOkay = false;
- if ((fd = ::open("/dev/dsp", O_WRONLY|O_NONBLOCK)) != -1) {
+ if ((fd = QT_OPEN("/dev/dsp", O_WRONLY|O_NONBLOCK)) != -1) {
int flags = fcntl(fd, F_GETFL);
flags &= ~O_NONBLOCK;
openOkay = (fcntl(fd, F_SETFL, flags) == 0);
@@ -1222,7 +1223,7 @@ bool QWSSoundServerPrivate::openDevice()
//
// Check system volume
//
- int mixerHandle = ::open( "/dev/mixer", O_RDWR|O_NONBLOCK );
+ int mixerHandle = QT_OPEN( "/dev/mixer", O_RDWR|O_NONBLOCK );
if ( mixerHandle >= 0 ) {
int volume;
ioctl( mixerHandle, MIXER_READ(0), &volume );
diff --git a/src/gui/embedded/qtransportauth_qws.cpp b/src/gui/embedded/qtransportauth_qws.cpp
index 05dce117c9..8523e272aa 100644
--- a/src/gui/embedded/qtransportauth_qws.cpp
+++ b/src/gui/embedded/qtransportauth_qws.cpp
@@ -56,6 +56,7 @@
#include "qlibraryinfo.h"
#include "qfile.h"
#include "qdebug.h"
+#include <private/qcore_unix_p.h> // overrides QT_OPEN
#include <syslog.h>
#include <unistd.h>
@@ -572,7 +573,7 @@ bool QTransportAuth::authorizeRequest( QTransportAuth::Data &d, const QString &r
//get cmdline from proc/pid/cmdline
snprintf( cmdlinePath, BUF_SIZE, "/proc/%d/cmdline", d.processId );
- int cmdlineFd = open( cmdlinePath, O_RDONLY );
+ int cmdlineFd = QT_OPEN( cmdlinePath, O_RDONLY );
if ( cmdlineFd == -1 )
{
qWarning( "SXE:- Error encountered in opening /proc/%u/cmdline: %s",
@@ -581,13 +582,13 @@ bool QTransportAuth::authorizeRequest( QTransportAuth::Data &d, const QString &r
}
else
{
- if ( -1 == ::read(cmdlineFd, cmdline, BUF_SIZE - 1 ) )
+ if ( -1 == QT_READ(cmdlineFd, cmdline, BUF_SIZE - 1 ) )
{
qWarning( "SXE:- Error encountered in reading /proc/%u/cmdline : %s",
d.processId, strerror(errno) );
snprintf( cmdline, BUF_SIZE, "%s", "Unknown" );
}
- close( cmdlineFd );
+ QT_CLOSE( cmdlineFd );
}
syslog( LOG_ERR | LOG_LOCAL6, "%s // PID:%u // ProgId:%u // Exe:%s // Request:%s // Cmdline:%s",
diff --git a/src/gui/embedded/qunixsocket.cpp b/src/gui/embedded/qunixsocket.cpp
index 070d3cf7bd..57a4a115d9 100644
--- a/src/gui/embedded/qunixsocket.cpp
+++ b/src/gui/embedded/qunixsocket.cpp
@@ -46,6 +46,7 @@
#include <QtCore/qsocketnotifier.h>
#include <QtCore/qqueue.h>
#include <QtCore/qdatetime.h>
+#include "private/qcore_unix_p.h" // overrides QT_OPEN
#ifdef QUNIXSOCKET_DEBUG
#include <QtCore/qdebug.h>
@@ -131,7 +132,7 @@ struct QUnixSocketRightsPrivate : public QSharedData
#ifdef QUNIXSOCKET_DEBUG
int closerv =
#endif
- ::close(fd);
+ QT_CLOSE(fd);
#ifdef QUNIXSOCKET_DEBUG
if(0 != closerv) {
qDebug() << "QUnixSocketRightsPrivate: Unable to close managed"
@@ -162,7 +163,7 @@ QUnixSocketRights::QUnixSocketRights(int fd)
if(-1 == fd) {
d->fd = -1;
} else {
- d->fd = ::dup(fd);
+ d->fd = qt_safe_dup(fd);
#ifdef QUNIXSOCKET_DEBUG
if(-1 == d->fd) {
qDebug() << "QUnixSocketRights: Unable to duplicate fd "
@@ -232,7 +233,7 @@ int QUnixSocketRights::dupFd() const
{
if(-1 == d->fd) return -1;
- int rv = ::dup(d->fd);
+ int rv = qt_safe_dup(d->fd);
#ifdef QUNIXSOCKET_DEBUG
if(-1 == rv)
@@ -825,7 +826,7 @@ public:
int numFds = (h->cmsg_len - CMSG_LEN(0)) / sizeof(int);
for(int ii = 0; ii < numFds; ++ii)
- ::close(fds[ii]);
+ QT_CLOSE(fds[ii]);
}
h = (::cmsghdr *)CMSG_NXTHDR(&(message), h);
@@ -1017,7 +1018,7 @@ connect_error: // Cleanup failed connection
#ifdef QUNIXSOCKET_DEBUG
int closerv =
#endif
- ::close(d->fd);
+ QT_CLOSE(d->fd);
#ifdef QUNIXSOCKET_DEBUG
if(0 != closerv) {
qDebug() << "QUnixSocket: Unable to close file descriptor after "
@@ -1762,7 +1763,12 @@ void QUnixSocketPrivate::readActivated()
message.msg_controllen = ancillaryBufferCapacity();
message.msg_control = ancillaryBuffer;
- int recvrv = ::recvmsg(fd, &message, 0);
+ int flags = 0;
+#ifdef MSG_CMSG_CLOEXEC
+ flags = MSG_CMSG_CLOEXEC;
+#endif
+
+ int recvrv = ::recvmsg(fd, &message, flags);
#ifdef QUNIXSOCKET_DEBUG
qDebug() << "QUnixSocket: Received message (" << recvrv << ')';
#endif