From 91caea0b81c9d852f0bb73ee451248a8ba0af5c0 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Fri, 7 Jun 2019 13:49:51 +0000 Subject: [PATCH] mark some cases as unlikely Signed-off-by: Ivailo Monev --- src/core/io/qiodevice.cpp | 6 +++--- src/gui/image/qimage.cpp | 2 +- src/gui/util/qsystemtrayicon_x11.cpp | 20 ++++++++++---------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/core/io/qiodevice.cpp b/src/core/io/qiodevice.cpp index b096a64af..aa06d6e25 100644 --- a/src/core/io/qiodevice.cpp +++ b/src/core/io/qiodevice.cpp @@ -90,7 +90,7 @@ inline void debugBinaryString(const char *data, qint64 maxlen) #define CHECK_MAXLEN(function, returnType) \ do { \ - if (maxSize < 0) { \ + if (Q_UNLIKELY(maxSize < 0)) { \ qWarning("QIODevice::"#function": Called with maxSize < 0"); \ return returnType; \ } \ @@ -98,7 +98,7 @@ inline void debugBinaryString(const char *data, qint64 maxlen) #define CHECK_WRITABLE(function, returnType) \ do { \ - if ((d->openMode & WriteOnly) == 0) { \ + if (Q_UNLIKELY((d->openMode & WriteOnly) == 0)) { \ if (d->openMode == NotOpen) { \ qWarning("QIODevice::"#function": device not open"); \ return returnType; \ @@ -110,7 +110,7 @@ inline void debugBinaryString(const char *data, qint64 maxlen) #define CHECK_READABLE(function, returnType) \ do { \ - if ((d->openMode & ReadOnly) == 0) { \ + if (Q_UNLIKELY((d->openMode & ReadOnly) == 0)) { \ if (d->openMode == NotOpen) { \ qWarning("QIODevice::"#function": device not open"); \ return returnType; \ diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index ec1e367dc..d927ebc79 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -93,7 +93,7 @@ static inline bool checkPixelSize(const QImage::Format format) #define QIMAGE_SANITYCHECK_MEMORY(image) \ - if ((image).isNull()) { \ + if (Q_UNLIKELY((image).isNull())) { \ qWarning("QImage: out of memory, returning null image"); \ return QImage(); \ } diff --git a/src/gui/util/qsystemtrayicon_x11.cpp b/src/gui/util/qsystemtrayicon_x11.cpp index 8eacebcef..2b84f35a4 100644 --- a/src/gui/util/qsystemtrayicon_x11.cpp +++ b/src/gui/util/qsystemtrayicon_x11.cpp @@ -127,15 +127,15 @@ bool QSystemTrayIconSys::sysTrayTracker(void *message, long *result) Display *display = QX11Info::display(); XEvent *ev = (XEvent *)message; if (ev->type == DestroyNotify && ev->xany.window == sysTrayWindow) { - sysTrayWindow = locateSystemTray(); + sysTrayWindow = locateSystemTray(); memset(&sysTrayVisual, 0, sizeof(sysTrayVisual)); for (int i = 0; i < trayIcons.count(); i++) { if (sysTrayWindow == XNone) { - QBalloonTip::hideBalloon(); + QBalloonTip::hideBalloon(); trayIcons[i]->hide(); // still no luck trayIcons[i]->destroy(); trayIcons[i]->create(); - } else + } else trayIcons[i]->addToTray(); // add it to the new tray } retval = true; @@ -143,9 +143,9 @@ bool QSystemTrayIconSys::sysTrayTracker(void *message, long *result) static Atom manager_atom = XInternAtom(display, "MANAGER", False); XClientMessageEvent *cm = (XClientMessageEvent *)message; if ((cm->message_type == manager_atom) && ((Atom)cm->data.l[1] == sysTraySelection)) { - sysTrayWindow = cm->data.l[2]; + sysTrayWindow = cm->data.l[2]; memset(&sysTrayVisual, 0, sizeof(sysTrayVisual)); - XSelectInput(display, sysTrayWindow, StructureNotifyMask); + XSelectInput(display, sysTrayWindow, StructureNotifyMask); for (int i = 0; i < trayIcons.count(); i++) { trayIcons[i]->addToTray(); } @@ -175,8 +175,8 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *q) Display *display = QX11Info::display(); if (!eventFilterAdded) { oldEventFilter = qApp->setEventFilter(sysTrayTracker); - eventFilterAdded = true; - Window root = QX11Info::appRootWindow(); + eventFilterAdded = true; + Window root = QX11Info::appRootWindow(); XWindowAttributes attr; XGetWindowAttributes(display, root, &attr); if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) { @@ -186,8 +186,8 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *q) } if (trayIcons.isEmpty()) { sysTrayWindow = locateSystemTray(); - if (sysTrayWindow != XNone) - XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events + if (sysTrayWindow != XNone) + XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events } trayIcons.append(this); setMouseTracking(true); @@ -341,7 +341,7 @@ void QSystemTrayIconPrivate::install_sys() QRect QSystemTrayIconPrivate::geometry_sys() const { if (!sys) - return QRect(); + return QRect(); return QRect(sys->mapToGlobal(QPoint(0, 0)), sys->size()); }