OpenCoverage

qudpsocket.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/network/socket/qudpsocket.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3class QUdpSocketPrivate : public QAbstractSocketPrivate-
4{-
5 inline QUdpSocket* q_func() { return static_cast<QUdpSocket *>(q_ptr); } inline const QUdpSocket* q_func() const { return static_cast<const QUdpSocket *>(q_ptr); } friend class QUdpSocket;-
6-
7 bool doEnsureInitialized(const QHostAddress &bindAddress, quint16 bindPort,-
8 const QHostAddress &remoteAddress);-
9public:-
10 inline bool ensureInitialized(const QHostAddress &bindAddress, quint16 bindPort)-
11 { return
never executed: return doEnsureInitialized(bindAddress, bindPort, QHostAddress());
doEnsureInitialized(bindAddress, bindPort, QHostAddress());
never executed: return doEnsureInitialized(bindAddress, bindPort, QHostAddress());
}
0
12-
13 inline bool ensureInitialized(const QHostAddress &remoteAddress)-
14 { return
never executed: return doEnsureInitialized(QHostAddress(), 0, remoteAddress);
doEnsureInitialized(QHostAddress(), 0, remoteAddress);
never executed: return doEnsureInitialized(QHostAddress(), 0, remoteAddress);
}
0
15};-
16-
17bool QUdpSocketPrivate::doEnsureInitialized(const QHostAddress &bindAddress, quint16 bindPort,-
18 const QHostAddress &remoteAddress)-
19{-
20 const QHostAddress *address = &bindAddress;-
21 QAbstractSocket::NetworkLayerProtocol proto = address->protocol();-
22 if (proto == QUdpSocket::UnknownNetworkLayerProtocol
proto == QUdpS...kLayerProtocolDescription
TRUEnever evaluated
FALSEevaluated 635 times by 3 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
) {
0-635
23 address = &remoteAddress;-
24 proto = address->protocol();-
25 }
never executed: end of block
0
26-
27-
28 if (!socketEngine
!socketEngineDescription
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
FALSEevaluated 621 times by 3 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
|| !socketEngine->isValid()
!socketEngine->isValid()Description
TRUEnever evaluated
FALSEevaluated 621 times by 3 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
) {
0-621
29 resolveProxy(remoteAddress.toString(), bindPort);-
30 if (!initSocketLayer(address->protocol())
!initSocketLay...s->protocol())Description
TRUEnever evaluated
FALSEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
)
0-14
31 return
never executed: return false;
false;
never executed: return false;
0
32 }
executed 14 times by 2 tests: end of block
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
14
33-
34 return
executed 635 times by 3 tests: return true;
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
true;
executed 635 times by 3 tests: return true;
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
635
35}-
36QUdpSocket::QUdpSocket(QObject *parent)-
37 : QAbstractSocket(UdpSocket, *new QUdpSocketPrivate, parent)-
38{-
39 d_func()->isBuffered = false;-
40}
executed 137 times by 3 tests: end of block
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
137
41-
42-
43-
44-
45-
46-
47QUdpSocket::~QUdpSocket()-
48{-
49}-
50bool QUdpSocket::joinMulticastGroup(const QHostAddress &groupAddress)-
51{-
52 return
executed 13 times by 1 test: return joinMulticastGroup(groupAddress, QNetworkInterface());
Executed by:
  • tst_QUdpSocket
joinMulticastGroup(groupAddress, QNetworkInterface());
executed 13 times by 1 test: return joinMulticastGroup(groupAddress, QNetworkInterface());
Executed by:
  • tst_QUdpSocket
13
53}-
54bool QUdpSocket::joinMulticastGroup(const QHostAddress &groupAddress,-
55 const QNetworkInterface &iface)-
56{-
57 QUdpSocketPrivate * const d = d_func();-
58 do { if (!isValid()
!isValid()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUdpSocket
FALSEevaluated 9 times by 1 test
Evaluated by:
  • tst_QUdpSocket
) { QMessageLogger(__FILE__, 207, __PRETTY_FUNCTION__).warning("QUdpSocket::joinMulticastGroup()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return
executed 4 times by 1 test: return (false);
Executed by:
  • tst_QUdpSocket
(false);
executed 4 times by 1 test: return (false);
Executed by:
  • tst_QUdpSocket
} } while (0);
4-9
59 return
executed 9 times by 1 test: return d->socketEngine->joinMulticastGroup(groupAddress, iface);
Executed by:
  • tst_QUdpSocket
d->socketEngine->joinMulticastGroup(groupAddress, iface);
executed 9 times by 1 test: return d->socketEngine->joinMulticastGroup(groupAddress, iface);
Executed by:
  • tst_QUdpSocket
9
60}-
61bool QUdpSocket::leaveMulticastGroup(const QHostAddress &groupAddress)-
62{-
63 return
executed 6 times by 1 test: return leaveMulticastGroup(groupAddress, QNetworkInterface());
Executed by:
  • tst_QUdpSocket
leaveMulticastGroup(groupAddress, QNetworkInterface());
executed 6 times by 1 test: return leaveMulticastGroup(groupAddress, QNetworkInterface());
Executed by:
  • tst_QUdpSocket
6
64}-
65bool QUdpSocket::leaveMulticastGroup(const QHostAddress &groupAddress,-
66 const QNetworkInterface &iface)-
67{-
68 do { if (!isValid()
!isValid()Description
TRUEevaluated 2 times by 1 test
Evaluated by:
  • tst_QUdpSocket
FALSEevaluated 4 times by 1 test
Evaluated by:
  • tst_QUdpSocket
) { QMessageLogger(__FILE__, 240, __PRETTY_FUNCTION__).warning("QUdpSocket::leaveMulticastGroup()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return
executed 2 times by 1 test: return (false);
Executed by:
  • tst_QUdpSocket
(false);
executed 2 times by 1 test: return (false);
Executed by:
  • tst_QUdpSocket
} } while (0);
2-4
69 return
executed 4 times by 1 test: return d_func()->socketEngine->leaveMulticastGroup(groupAddress, iface);
Executed by:
  • tst_QUdpSocket
d_func()->socketEngine->leaveMulticastGroup(groupAddress, iface);
executed 4 times by 1 test: return d_func()->socketEngine->leaveMulticastGroup(groupAddress, iface);
Executed by:
  • tst_QUdpSocket
4
70}-
71QNetworkInterface QUdpSocket::multicastInterface() const-
72{-
73 const QUdpSocketPrivate * const d = d_func();-
74 do { if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QUdpSocket
) { QMessageLogger(__FILE__, 259, __PRETTY_FUNCTION__).warning("QUdpSocket::multicastInterface()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return
never executed: return (QNetworkInterface());
(QNetworkInterface());
never executed: return (QNetworkInterface());
} } while (0);
0-6
75 return
executed 6 times by 1 test: return d->socketEngine->multicastInterface();
Executed by:
  • tst_QUdpSocket
d->socketEngine->multicastInterface();
executed 6 times by 1 test: return d->socketEngine->multicastInterface();
Executed by:
  • tst_QUdpSocket
6
76}-
77void QUdpSocket::setMulticastInterface(const QNetworkInterface &iface)-
78{-
79 QUdpSocketPrivate * const d = d_func();-
80 if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEevaluated 6 times by 1 test
Evaluated by:
  • tst_QUdpSocket
) {
0-6
81 QMessageLogger(__FILE__, 277, __PRETTY_FUNCTION__).warning("QUdpSocket::setMulticastInterface() called on a QUdpSocket when not in QUdpSocket::BoundState");-
82 return;
never executed: return;
0
83 }-
84 d->socketEngine->setMulticastInterface(iface);-
85}
executed 6 times by 1 test: end of block
Executed by:
  • tst_QUdpSocket
6
86bool QUdpSocket::hasPendingDatagrams() const-
87{-
88 do { if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEevaluated 629303 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
) { QMessageLogger(__FILE__, 293, __PRETTY_FUNCTION__).warning("QUdpSocket::hasPendingDatagrams()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return
never executed: return (false);
(false);
never executed: return (false);
} } while (0);
0-629303
89 return
executed 629303 times by 2 tests: return d_func()->socketEngine->hasPendingDatagrams();
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
d_func()->socketEngine->hasPendingDatagrams();
executed 629303 times by 2 tests: return d_func()->socketEngine->hasPendingDatagrams();
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
629303
90}-
91-
92-
93-
94-
95-
96-
97-
98qint64 QUdpSocket::pendingDatagramSize() const-
99{-
100 do { if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEevaluated 592 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
) { QMessageLogger(__FILE__, 305, __PRETTY_FUNCTION__).warning("QUdpSocket::pendingDatagramSize()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return
never executed: return (-1);
(-1);
never executed: return (-1);
} } while (0);
0-592
101 return
executed 592 times by 2 tests: return d_func()->socketEngine->pendingDatagramSize();
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
d_func()->socketEngine->pendingDatagramSize();
executed 592 times by 2 tests: return d_func()->socketEngine->pendingDatagramSize();
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
592
102}-
103qint64 QUdpSocket::writeDatagram(const char *data, qint64 size, const QHostAddress &address,-
104 quint16 port)-
105{-
106 QUdpSocketPrivate * const d = d_func();-
107-
108-
109-
110-
111 if (!d->doEnsureInitialized(QHostAddress::Any, 0, address)
!d->doEnsureIn...y, 0, address)Description
TRUEnever evaluated
FALSEevaluated 635 times by 3 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
)
0-635
112 return
never executed: return -1;
-1;
never executed: return -1;
0
113 if (state() == UnconnectedState
state() == UnconnectedStateDescription
TRUEevaluated 14 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
FALSEevaluated 621 times by 3 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
)
14-621
114 bind();
executed 14 times by 2 tests: bind();
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
14
115-
116 qint64 sent = d->socketEngine->writeDatagram(data, size, QIpPacketHeader(address, port));-
117 d->cachedSocketDescriptor = d->socketEngine->socketDescriptor();-
118-
119 if (sent >= 0
sent >= 0Description
TRUEevaluated 634 times by 3 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
FALSEevaluated 1 time by 1 test
Evaluated by:
  • tst_QUdpSocket
) {
1-634
120 bytesWritten(sent);-
121 }
executed 634 times by 3 tests: end of block
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
else {
634
122 d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());-
123 }
executed 1 time by 1 test: end of block
Executed by:
  • tst_QUdpSocket
1
124 return
executed 635 times by 3 tests: return sent;
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
sent;
executed 635 times by 3 tests: return sent;
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
635
125}-
126qint64 QUdpSocket::readDatagram(char *data, qint64 maxSize, QHostAddress *address,-
127 quint16 *port)-
128{-
129 QUdpSocketPrivate * const d = d_func();-
130-
131-
132-
133-
134 do { if (!isValid()
!isValid()Description
TRUEnever evaluated
FALSEevaluated 629327 times by 3 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
) { QMessageLogger(__FILE__, 386, __PRETTY_FUNCTION__).warning("QUdpSocket::readDatagram()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return
never executed: return (-1);
(-1);
never executed: return (-1);
} } while (0);
0-629327
135-
136 qint64 readBytes;-
137 if (address
addressDescription
TRUEevaluated 507 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocks5socketengine - unknown status
FALSEevaluated 628820 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
|| port
portDescription
TRUEnever evaluated
FALSEevaluated 628820 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
) {
0-628820
138 QIpPacketHeader header;-
139 readBytes = d->socketEngine->readDatagram(data, maxSize, &header,-
140 QAbstractSocketEngine::WantDatagramSender);-
141 if (address
addressDescription
TRUEevaluated 507 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocks5socketengine - unknown status
FALSEnever evaluated
)
0-507
142 *
executed 507 times by 2 tests: *address = header.senderAddress;
Executed by:
  • tst_QUdpSocket
  • tst_qsocks5socketengine - unknown status
address = header.senderAddress;
executed 507 times by 2 tests: *address = header.senderAddress;
Executed by:
  • tst_QUdpSocket
  • tst_qsocks5socketengine - unknown status
507
143 if (port
portDescription
TRUEevaluated 507 times by 2 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocks5socketengine - unknown status
FALSEnever evaluated
)
0-507
144 *
executed 507 times by 2 tests: *port = header.senderPort;
Executed by:
  • tst_QUdpSocket
  • tst_qsocks5socketengine - unknown status
port = header.senderPort;
executed 507 times by 2 tests: *port = header.senderPort;
Executed by:
  • tst_QUdpSocket
  • tst_qsocks5socketengine - unknown status
507
145 }
executed 507 times by 2 tests: end of block
Executed by:
  • tst_QUdpSocket
  • tst_qsocks5socketengine - unknown status
else {
507
146 readBytes = d->socketEngine->readDatagram(data, maxSize);-
147 }
executed 628820 times by 2 tests: end of block
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
628820
148-
149 d_func()->socketEngine->setReadNotificationEnabled(true);-
150 if (readBytes < 0
readBytes < 0Description
TRUEnever evaluated
FALSEevaluated 629327 times by 3 tests
Evaluated by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
)
0-629327
151 d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
never executed: d->setErrorAndEmit(d->socketEngine->error(), d->socketEngine->errorString());
0
152 return
executed 629327 times by 3 tests: return readBytes;
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
readBytes;
executed 629327 times by 3 tests: return readBytes;
Executed by:
  • tst_QUdpSocket
  • tst_qsocketnotifier - unknown status
  • tst_qsocks5socketengine - unknown status
629327
153}-
154-
155-
156-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9