mark some cases as unlikely

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2019-06-07 13:49:51 +00:00
parent b6fde31421
commit 91caea0b81
3 changed files with 14 additions and 14 deletions

View file

@ -90,7 +90,7 @@ inline void debugBinaryString(const char *data, qint64 maxlen)
#define CHECK_MAXLEN(function, returnType) \ #define CHECK_MAXLEN(function, returnType) \
do { \ do { \
if (maxSize < 0) { \ if (Q_UNLIKELY(maxSize < 0)) { \
qWarning("QIODevice::"#function": Called with maxSize < 0"); \ qWarning("QIODevice::"#function": Called with maxSize < 0"); \
return returnType; \ return returnType; \
} \ } \
@ -98,7 +98,7 @@ inline void debugBinaryString(const char *data, qint64 maxlen)
#define CHECK_WRITABLE(function, returnType) \ #define CHECK_WRITABLE(function, returnType) \
do { \ do { \
if ((d->openMode & WriteOnly) == 0) { \ if (Q_UNLIKELY((d->openMode & WriteOnly) == 0)) { \
if (d->openMode == NotOpen) { \ if (d->openMode == NotOpen) { \
qWarning("QIODevice::"#function": device not open"); \ qWarning("QIODevice::"#function": device not open"); \
return returnType; \ return returnType; \
@ -110,7 +110,7 @@ inline void debugBinaryString(const char *data, qint64 maxlen)
#define CHECK_READABLE(function, returnType) \ #define CHECK_READABLE(function, returnType) \
do { \ do { \
if ((d->openMode & ReadOnly) == 0) { \ if (Q_UNLIKELY((d->openMode & ReadOnly) == 0)) { \
if (d->openMode == NotOpen) { \ if (d->openMode == NotOpen) { \
qWarning("QIODevice::"#function": device not open"); \ qWarning("QIODevice::"#function": device not open"); \
return returnType; \ return returnType; \

View file

@ -93,7 +93,7 @@ static inline bool checkPixelSize(const QImage::Format format)
#define QIMAGE_SANITYCHECK_MEMORY(image) \ #define QIMAGE_SANITYCHECK_MEMORY(image) \
if ((image).isNull()) { \ if (Q_UNLIKELY((image).isNull())) { \
qWarning("QImage: out of memory, returning null image"); \ qWarning("QImage: out of memory, returning null image"); \
return QImage(); \ return QImage(); \
} }

View file

@ -127,15 +127,15 @@ bool QSystemTrayIconSys::sysTrayTracker(void *message, long *result)
Display *display = QX11Info::display(); Display *display = QX11Info::display();
XEvent *ev = (XEvent *)message; XEvent *ev = (XEvent *)message;
if (ev->type == DestroyNotify && ev->xany.window == sysTrayWindow) { if (ev->type == DestroyNotify && ev->xany.window == sysTrayWindow) {
sysTrayWindow = locateSystemTray(); sysTrayWindow = locateSystemTray();
memset(&sysTrayVisual, 0, sizeof(sysTrayVisual)); memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
for (int i = 0; i < trayIcons.count(); i++) { for (int i = 0; i < trayIcons.count(); i++) {
if (sysTrayWindow == XNone) { if (sysTrayWindow == XNone) {
QBalloonTip::hideBalloon(); QBalloonTip::hideBalloon();
trayIcons[i]->hide(); // still no luck trayIcons[i]->hide(); // still no luck
trayIcons[i]->destroy(); trayIcons[i]->destroy();
trayIcons[i]->create(); trayIcons[i]->create();
} else } else
trayIcons[i]->addToTray(); // add it to the new tray trayIcons[i]->addToTray(); // add it to the new tray
} }
retval = true; retval = true;
@ -143,9 +143,9 @@ bool QSystemTrayIconSys::sysTrayTracker(void *message, long *result)
static Atom manager_atom = XInternAtom(display, "MANAGER", False); static Atom manager_atom = XInternAtom(display, "MANAGER", False);
XClientMessageEvent *cm = (XClientMessageEvent *)message; XClientMessageEvent *cm = (XClientMessageEvent *)message;
if ((cm->message_type == manager_atom) && ((Atom)cm->data.l[1] == sysTraySelection)) { 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)); memset(&sysTrayVisual, 0, sizeof(sysTrayVisual));
XSelectInput(display, sysTrayWindow, StructureNotifyMask); XSelectInput(display, sysTrayWindow, StructureNotifyMask);
for (int i = 0; i < trayIcons.count(); i++) { for (int i = 0; i < trayIcons.count(); i++) {
trayIcons[i]->addToTray(); trayIcons[i]->addToTray();
} }
@ -175,8 +175,8 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *q)
Display *display = QX11Info::display(); Display *display = QX11Info::display();
if (!eventFilterAdded) { if (!eventFilterAdded) {
oldEventFilter = qApp->setEventFilter(sysTrayTracker); oldEventFilter = qApp->setEventFilter(sysTrayTracker);
eventFilterAdded = true; eventFilterAdded = true;
Window root = QX11Info::appRootWindow(); Window root = QX11Info::appRootWindow();
XWindowAttributes attr; XWindowAttributes attr;
XGetWindowAttributes(display, root, &attr); XGetWindowAttributes(display, root, &attr);
if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) { if ((attr.your_event_mask & StructureNotifyMask) != StructureNotifyMask) {
@ -186,8 +186,8 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *q)
} }
if (trayIcons.isEmpty()) { if (trayIcons.isEmpty()) {
sysTrayWindow = locateSystemTray(); sysTrayWindow = locateSystemTray();
if (sysTrayWindow != XNone) if (sysTrayWindow != XNone)
XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events XSelectInput(display, sysTrayWindow, StructureNotifyMask); // track tray events
} }
trayIcons.append(this); trayIcons.append(this);
setMouseTracking(true); setMouseTracking(true);
@ -341,7 +341,7 @@ void QSystemTrayIconPrivate::install_sys()
QRect QSystemTrayIconPrivate::geometry_sys() const QRect QSystemTrayIconPrivate::geometry_sys() const
{ {
if (!sys) if (!sys)
return QRect(); return QRect();
return QRect(sys->mapToGlobal(QPoint(0, 0)), sys->size()); return QRect(sys->mapToGlobal(QPoint(0, 0)), sys->size());
} }