Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | class 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); | - |
9 | public: | - |
10 | inline bool ensureInitialized(const QHostAddress &bindAddress, quint16 bindPort) | - |
11 | { return doEnsureInitialized(bindAddress, bindPort, QHostAddress()); } never executed: return doEnsureInitialized(bindAddress, bindPort, QHostAddress()); | 0 |
12 | | - |
13 | inline bool ensureInitialized(const QHostAddress &remoteAddress) | - |
14 | { return doEnsureInitialized(QHostAddress(), 0, remoteAddress); } never executed: return doEnsureInitialized(QHostAddress(), 0, remoteAddress); | 0 |
15 | }; | - |
16 | | - |
17 | bool 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) { partially evaluated: proto == QUdpSocket::UnknownNetworkLayerProtocol no Evaluation Count:0 | yes Evaluation Count:324697 |
| 0-324697 |
23 | address = &remoteAddress; | - |
24 | proto = address->protocol(); | - |
25 | } | 0 |
26 | | - |
27 | | - |
28 | if (!socketEngine || !socketEngine->isValid()) { evaluated: !socketEngine yes Evaluation Count:17 | yes Evaluation Count:324680 |
partially evaluated: !socketEngine->isValid() no Evaluation Count:0 | yes Evaluation Count:324680 |
| 0-324680 |
29 | resolveProxy(remoteAddress.toString(), bindPort); | - |
30 | if (!initSocketLayer(address->protocol())) partially evaluated: !initSocketLayer(address->protocol()) no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
31 | return false; never executed: return false; | 0 |
32 | } executed: } Execution Count:17 | 17 |
33 | | - |
34 | return true; executed: return true; Execution Count:324697 | 324697 |
35 | } | - |
36 | QUdpSocket::QUdpSocket(QObject *parent) | - |
37 | : QAbstractSocket(UdpSocket, *new QUdpSocketPrivate, parent) | - |
38 | { | - |
39 | d_func()->isBuffered = false; | - |
40 | } executed: } Execution Count:321 | 321 |
41 | | - |
42 | | - |
43 | | - |
44 | | - |
45 | | - |
46 | | - |
47 | QUdpSocket::~QUdpSocket() | - |
48 | { | - |
49 | } | - |
50 | bool QUdpSocket::joinMulticastGroup(const QHostAddress &groupAddress) | - |
51 | { | - |
52 | return joinMulticastGroup(groupAddress, QNetworkInterface()); executed: return joinMulticastGroup(groupAddress, QNetworkInterface()); Execution Count:14 | 14 |
53 | } | - |
54 | bool QUdpSocket::joinMulticastGroup(const QHostAddress &groupAddress, | - |
55 | const QNetworkInterface &iface) | - |
56 | { | - |
57 | QUdpSocketPrivate * const d = d_func(); | - |
58 | do { if (!isValid()) { QMessageLogger("socket/qudpsocket.cpp", 208, __PRETTY_FUNCTION__).warning("QUdpSocket::joinMulticastGroup()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return (false); } } while (0); evaluated: !isValid() yes Evaluation Count:8 | yes Evaluation Count:6 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:6 |
executed: return (false); Execution Count:8 executed: } Execution Count:6 | 0-8 |
59 | return d->socketEngine->joinMulticastGroup(groupAddress, iface); executed: return d->socketEngine->joinMulticastGroup(groupAddress, iface); Execution Count:6 | 6 |
60 | } | - |
61 | bool QUdpSocket::leaveMulticastGroup(const QHostAddress &groupAddress) | - |
62 | { | - |
63 | return leaveMulticastGroup(groupAddress, QNetworkInterface()); executed: return leaveMulticastGroup(groupAddress, QNetworkInterface()); Execution Count:4 | 4 |
64 | } | - |
65 | bool QUdpSocket::leaveMulticastGroup(const QHostAddress &groupAddress, | - |
66 | const QNetworkInterface &iface) | - |
67 | { | - |
68 | do { if (!isValid()) { QMessageLogger("socket/qudpsocket.cpp", 241, __PRETTY_FUNCTION__).warning("QUdpSocket::leaveMulticastGroup()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return (false); } } while (0); executed: return (false); Execution Count:2 executed: } Execution Count:2 evaluated: !isValid() yes Evaluation Count:2 | yes Evaluation Count:2 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
69 | return d_func()->socketEngine->leaveMulticastGroup(groupAddress, iface); executed: return d_func()->socketEngine->leaveMulticastGroup(groupAddress, iface); Execution Count:2 | 2 |
70 | } | - |
71 | QNetworkInterface QUdpSocket::multicastInterface() const | - |
72 | { | - |
73 | const QUdpSocketPrivate * const d = d_func(); | - |
74 | do { if (!isValid()) { QMessageLogger("socket/qudpsocket.cpp", 260, __PRETTY_FUNCTION__).warning("QUdpSocket::multicastInterface()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return (QNetworkInterface()); } } while (0); executed: return (QNetworkInterface()); Execution Count:8 executed: } Execution Count:8 evaluated: !isValid() yes Evaluation Count:8 | yes Evaluation Count:8 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
75 | return d->socketEngine->multicastInterface(); executed: return d->socketEngine->multicastInterface(); Execution Count:8 | 8 |
76 | } | - |
77 | void QUdpSocket::setMulticastInterface(const QNetworkInterface &iface) | - |
78 | { | - |
79 | QUdpSocketPrivate * const d = d_func(); | - |
80 | if (!isValid()) { evaluated: !isValid() yes Evaluation Count:4 | yes Evaluation Count:12 |
| 4-12 |
81 | QMessageLogger("socket/qudpsocket.cpp", 278, __PRETTY_FUNCTION__).warning("QUdpSocket::setMulticastInterface() called on a QUdpSocket when not in QUdpSocket::BoundState"); | - |
82 | return; executed: return; Execution Count:4 | 4 |
83 | } | - |
84 | d->socketEngine->setMulticastInterface(iface); | - |
85 | } executed: } Execution Count:12 | 12 |
86 | bool QUdpSocket::hasPendingDatagrams() const | - |
87 | { | - |
88 | do { if (!isValid()) { QMessageLogger("socket/qudpsocket.cpp", 294, __PRETTY_FUNCTION__).warning("QUdpSocket::hasPendingDatagrams()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return (false); } } while (0); never executed: return (false); executed: } Execution Count:1984704 partially evaluated: !isValid() no Evaluation Count:0 | yes Evaluation Count:1984704 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1984704 |
| 0-1984704 |
89 | return d_func()->socketEngine->hasPendingDatagrams(); executed: return d_func()->socketEngine->hasPendingDatagrams(); Execution Count:1984704 | 1984704 |
90 | } | - |
91 | | - |
92 | | - |
93 | | - |
94 | | - |
95 | | - |
96 | | - |
97 | | - |
98 | qint64 QUdpSocket::pendingDatagramSize() const | - |
99 | { | - |
100 | do { if (!isValid()) { QMessageLogger("socket/qudpsocket.cpp", 306, __PRETTY_FUNCTION__).warning("QUdpSocket::pendingDatagramSize()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return (-1); } } while (0); never executed: return (-1); executed: } Execution Count:31964 partially evaluated: !isValid() no Evaluation Count:0 | yes Evaluation Count:31964 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:31964 |
| 0-31964 |
101 | return d_func()->socketEngine->pendingDatagramSize(); executed: return d_func()->socketEngine->pendingDatagramSize(); Execution Count:31964 | 31964 |
102 | } | - |
103 | qint64 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)) partially evaluated: !d->doEnsureInitialized(QHostAddress::Any, 0, address) no Evaluation Count:0 | yes Evaluation Count:324697 |
| 0-324697 |
112 | return -1; never executed: return -1; | 0 |
113 | if (state() == UnconnectedState) evaluated: state() == UnconnectedState yes Evaluation Count:17 | yes Evaluation Count:324680 |
| 17-324680 |
114 | bind(); executed: bind(); Execution Count:17 | 17 |
115 | | - |
116 | qint64 sent = d->socketEngine->writeDatagram(data, size, address, port); | - |
117 | d->cachedSocketDescriptor = d->socketEngine->socketDescriptor(); | - |
118 | | - |
119 | if (sent >= 0) { evaluated: sent >= 0 yes Evaluation Count:324696 | yes Evaluation Count:1 |
| 1-324696 |
120 | bytesWritten(sent); | - |
121 | } else { executed: } Execution Count:324696 | 324696 |
122 | d->socketError = d->socketEngine->error(); | - |
123 | setErrorString(d->socketEngine->errorString()); | - |
124 | error(d->socketError); | - |
125 | } executed: } Execution Count:1 | 1 |
126 | return sent; executed: return sent; Execution Count:324697 | 324697 |
127 | } | - |
128 | qint64 QUdpSocket::readDatagram(char *data, qint64 maxSize, QHostAddress *address, | - |
129 | quint16 *port) | - |
130 | { | - |
131 | QUdpSocketPrivate * const d = d_func(); | - |
132 | | - |
133 | | - |
134 | | - |
135 | | - |
136 | do { if (!isValid()) { QMessageLogger("socket/qudpsocket.cpp", 389, __PRETTY_FUNCTION__).warning("QUdpSocket::readDatagram()"" called on a QUdpSocket when not in QUdpSocket::BoundState"); return (-1); } } while (0); never executed: return (-1); executed: } Execution Count:1313640 partially evaluated: !isValid() no Evaluation Count:0 | yes Evaluation Count:1313640 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:1313640 |
| 0-1313640 |
137 | qint64 readBytes = d->socketEngine->readDatagram(data, maxSize, address, port); | - |
138 | d_func()->socketEngine->setReadNotificationEnabled(true); | - |
139 | if (readBytes < 0) { partially evaluated: readBytes < 0 no Evaluation Count:0 | yes Evaluation Count:1313640 |
| 0-1313640 |
140 | d->socketError = d->socketEngine->error(); | - |
141 | setErrorString(d->socketEngine->errorString()); | - |
142 | error(d->socketError); | - |
143 | } | 0 |
144 | return readBytes; executed: return readBytes; Execution Count:1313640 | 1313640 |
145 | } | - |
146 | | - |
147 | | - |
148 | | - |
149 | | - |
| | |