socket/qnativesocketengine_unix.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtNetwork module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42//#define QNATIVESOCKETENGINE_DEBUG -
43#include "qnativesocketengine_p.h" -
44#include "private/qnet_unix_p.h" -
45#include "qiodevice.h" -
46#include "qhostaddress.h" -
47#include "qelapsedtimer.h" -
48#include "qvarlengtharray.h" -
49#include "qnetworkinterface.h" -
50#include <time.h> -
51#include <errno.h> -
52#include <fcntl.h> -
53#ifndef QT_NO_IPV6IFNAME -
54#include <net/if.h> -
55#endif -
56#ifdef QT_LINUXBASE -
57#include <arpa/inet.h> -
58#endif -
59 -
60#if defined QNATIVESOCKETENGINE_DEBUG -
61#include <qstring.h> -
62#include <ctype.h> -
63#endif -
64 -
65#include <netinet/tcp.h> -
66 -
67QT_BEGIN_NAMESPACE -
68 -
69#if defined QNATIVESOCKETENGINE_DEBUG -
70 -
71/* -
72 Returns a human readable representation of the first \a len -
73 characters in \a data. -
74*/ -
75static QByteArray qt_prettyDebug(const char *data, int len, int maxSize) -
76{ -
77 if (!data) return "(null)"; -
78 QByteArray out; -
79 for (int i = 0; i < len; ++i) { -
80 char c = data[i]; -
81 if (isprint(c)) { -
82 out += c; -
83 } else switch (c) { -
84 case '\n': out += "\\n"; break; -
85 case '\r': out += "\\r"; break; -
86 case '\t': out += "\\t"; break; -
87 default: -
88 QString tmp; -
89 tmp.sprintf("\\%o", c); -
90 out += tmp.toLatin1(); -
91 } -
92 } -
93 -
94 if (len < maxSize) -
95 out += "..."; -
96 -
97 return out; -
98} -
99#endif -
100 -
101/* -
102 Extracts the port and address from a sockaddr, and stores them in -
103 \a port and \a addr if they are non-null. -
104*/ -
105static inline void qt_socket_getPortAndAddress(const qt_sockaddr *s, quint16 *port, QHostAddress *addr) -
106{ -
107 if (s->a.sa_family == AF_INET6) {
evaluated: s->a.sa_family == 10
TRUEFALSE
yes
Evaluation Count:12296
yes
Evaluation Count:3240
3240-12296
108 Q_IPV6ADDR tmp;
executed (the execution status of this line is deduced): Q_IPV6ADDR tmp;
-
109 memcpy(&tmp, &s->a6.sin6_addr, sizeof(tmp));
executed (the execution status of this line is deduced): memcpy(&tmp, &s->a6.sin6_addr, sizeof(tmp));
-
110 if (addr) {
partially evaluated: addr
TRUEFALSE
yes
Evaluation Count:12296
no
Evaluation Count:0
0-12296
111 QHostAddress tmpAddress;
executed (the execution status of this line is deduced): QHostAddress tmpAddress;
-
112 tmpAddress.setAddress(tmp);
executed (the execution status of this line is deduced): tmpAddress.setAddress(tmp);
-
113 *addr = tmpAddress;
executed (the execution status of this line is deduced): *addr = tmpAddress;
-
114#ifndef QT_NO_IPV6IFNAME -
115 char scopeid[IFNAMSIZ];
executed (the execution status of this line is deduced): char scopeid[16];
-
116 if (::if_indextoname(s->a6.sin6_scope_id, scopeid)) {
evaluated: ::if_indextoname(s->a6.sin6_scope_id, scopeid)
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:12257
39-12257
117 addr->setScopeId(QLatin1String(scopeid));
executed (the execution status of this line is deduced): addr->setScopeId(QLatin1String(scopeid));
-
118 } else
executed: }
Execution Count:39
39
119#endif -
120 addr->setScopeId(QString::number(s->a6.sin6_scope_id));
executed: addr->setScopeId(QString::number(s->a6.sin6_scope_id));
Execution Count:12257
12257
121 } -
122 if (port)
partially evaluated: port
TRUEFALSE
yes
Evaluation Count:12296
no
Evaluation Count:0
0-12296
123 *port = ntohs(s->a6.sin6_port);
executed: *port = (__extension__ ({ register unsigned short int __v, __x = (unsigned short int) (s->a6.sin6_port); if (__builtin_constant_p (__x)) __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8))); else __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc"); __v; }));
Execution Count:12296
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
Execution Count:12296
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12296
0-12296
124 return;
executed: return;
Execution Count:12296
12296
125 } -
126 -
127 if (port)
partially evaluated: port
TRUEFALSE
yes
Evaluation Count:3240
no
Evaluation Count:0
0-3240
128 *port = ntohs(s->a4.sin_port);
executed: *port = (__extension__ ({ register unsigned short int __v, __x = (unsigned short int) (s->a4.sin_port); if (__builtin_constant_p (__x)) __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8))); else __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc"); __v; }));
Execution Count:3240
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
Execution Count:3240
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3240
0-3240
129 if (addr) {
partially evaluated: addr
TRUEFALSE
yes
Evaluation Count:3240
no
Evaluation Count:0
0-3240
130 QHostAddress tmpAddress;
executed (the execution status of this line is deduced): QHostAddress tmpAddress;
-
131 tmpAddress.setAddress(ntohl(s->a4.sin_addr.s_addr));
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
Execution Count:3240
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3240
0-3240
132 *addr = tmpAddress;
executed (the execution status of this line is deduced): *addr = tmpAddress;
-
133 }
executed: }
Execution Count:3240
3240
134}
executed: }
Execution Count:3240
3240
135 -
136/*! \internal -
137 -
138 Creates and returns a new socket descriptor of type \a socketType -
139 and \a socketProtocol. Returns -1 on failure. -
140*/ -
141bool QNativeSocketEnginePrivate::createNewSocket(QAbstractSocket::SocketType socketType, -
142 QAbstractSocket::NetworkLayerProtocol &socketProtocol) -
143{ -
144 int protocol = (socketProtocol == QAbstractSocket::IPv6Protocol || socketProtocol == QAbstractSocket::AnyIPProtocol) ? AF_INET6 : AF_INET;
evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:95
yes
Evaluation Count:2666
evaluated: socketProtocol == QAbstractSocket::AnyIPProtocol
TRUEFALSE
yes
Evaluation Count:378
yes
Evaluation Count:2288
95-2666
145 int type = (socketType == QAbstractSocket::UdpSocket) ? SOCK_DGRAM : SOCK_STREAM;
evaluated: (socketType == QAbstractSocket::UdpSocket)
TRUEFALSE
yes
Evaluation Count:235
yes
Evaluation Count:2526
235-2526
146 -
147 int socket = qt_safe_socket(protocol, type, 0);
executed (the execution status of this line is deduced): int socket = qt_safe_socket(protocol, type, 0);
-
148 if (socket <= 0 && socketProtocol == QAbstractSocket::AnyIPProtocol && errno == EAFNOSUPPORT) {
partially evaluated: socket <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2761
never evaluated: socketProtocol == QAbstractSocket::AnyIPProtocol
never evaluated: (*__errno_location ()) == 97
0-2761
149 protocol = AF_INET;
never executed (the execution status of this line is deduced): protocol = 2;
-
150 socket = qt_safe_socket(protocol, type, 0);
never executed (the execution status of this line is deduced): socket = qt_safe_socket(protocol, type, 0);
-
151 socketProtocol = QAbstractSocket::IPv4Protocol;
never executed (the execution status of this line is deduced): socketProtocol = QAbstractSocket::IPv4Protocol;
-
152 }
never executed: }
0
153 -
154 if (socket <= 0) {
partially evaluated: socket <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2761
0-2761
155 switch (errno) { -
156 case EPROTONOSUPPORT: -
157 case EAFNOSUPPORT: -
158 case EINVAL: -
159 setError(QAbstractSocket::UnsupportedSocketOperationError, ProtocolUnsupportedErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, ProtocolUnsupportedErrorString);
-
160 break;
never executed: break;
0
161 case ENFILE: -
162 case EMFILE: -
163 case ENOBUFS: -
164 case ENOMEM: -
165 setError(QAbstractSocket::SocketResourceError, ResourceErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketResourceError, ResourceErrorString);
-
166 break;
never executed: break;
0
167 case EACCES: -
168 setError(QAbstractSocket::SocketAccessError, AccessErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketAccessError, AccessErrorString);
-
169 break;
never executed: break;
0
170 default: -
171 break;
never executed: break;
0
172 } -
173 -
174 return false;
never executed: return false;
0
175 } -
176 -
177 socketDescriptor = socket;
executed (the execution status of this line is deduced): socketDescriptor = socket;
-
178 return true;
executed: return true;
Execution Count:2761
2761
179} -
180 -
181/* -
182 Returns the value of the socket option \a opt. -
183*/ -
184int QNativeSocketEnginePrivate::option(QNativeSocketEngine::SocketOption opt) const -
185{ -
186 Q_Q(const QNativeSocketEngine);
executed (the execution status of this line is deduced): const QNativeSocketEngine * const q = q_func();
-
187 if (!q->isValid())
partially evaluated: !q->isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
188 return -1;
never executed: return -1;
0
189 -
190 int n = -1;
executed (the execution status of this line is deduced): int n = -1;
-
191 int level = SOL_SOCKET; // default
executed (the execution status of this line is deduced): int level = 1;
-
192 -
193 switch (opt) { -
194 case QNativeSocketEngine::ReceiveBufferSocketOption: -
195 n = SO_RCVBUF;
never executed (the execution status of this line is deduced): n = 8;
-
196 break;
never executed: break;
0
197 case QNativeSocketEngine::SendBufferSocketOption: -
198 n = SO_SNDBUF;
never executed (the execution status of this line is deduced): n = 7;
-
199 break;
never executed: break;
0
200 case QNativeSocketEngine::NonBlockingSocketOption: -
201 break;
never executed: break;
0
202 case QNativeSocketEngine::BroadcastSocketOption: -
203 break;
never executed: break;
0
204 case QNativeSocketEngine::AddressReusable: -
205 n = SO_REUSEADDR;
never executed (the execution status of this line is deduced): n = 2;
-
206 break;
never executed: break;
0
207 case QNativeSocketEngine::BindExclusively: -
208 return true;
never executed: return true;
0
209 case QNativeSocketEngine::ReceiveOutOfBandData: -
210 n = SO_OOBINLINE;
never executed (the execution status of this line is deduced): n = 10;
-
211 break;
never executed: break;
0
212 case QNativeSocketEngine::LowDelayOption: -
213 level = IPPROTO_TCP;
never executed (the execution status of this line is deduced): level = IPPROTO_TCP;
-
214 n = TCP_NODELAY;
never executed (the execution status of this line is deduced): n = 1;
-
215 break;
never executed: break;
0
216 case QNativeSocketEngine::KeepAliveOption: -
217 n = SO_KEEPALIVE;
never executed (the execution status of this line is deduced): n = 9;
-
218 break;
never executed: break;
0
219 case QNativeSocketEngine::MulticastTtlOption: -
220 if (socketProtocol == QAbstractSocket::IPv6Protocol) {
evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
221 level = IPPROTO_IPV6;
executed (the execution status of this line is deduced): level = IPPROTO_IPV6;
-
222 n = IPV6_MULTICAST_HOPS;
executed (the execution status of this line is deduced): n = 18;
-
223 } else
executed: }
Execution Count:6
6
224 { -
225 level = IPPROTO_IP;
executed (the execution status of this line is deduced): level = IPPROTO_IP;
-
226 n = IP_MULTICAST_TTL;
executed (the execution status of this line is deduced): n = 33;
-
227 }
executed: }
Execution Count:6
6
228 break;
executed: break;
Execution Count:12
12
229 case QNativeSocketEngine::MulticastLoopbackOption: -
230 if (socketProtocol == QAbstractSocket::IPv6Protocol) {
evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
231 level = IPPROTO_IPV6;
executed (the execution status of this line is deduced): level = IPPROTO_IPV6;
-
232 n = IPV6_MULTICAST_LOOP;
executed (the execution status of this line is deduced): n = 19;
-
233 } else
executed: }
Execution Count:7
7
234 { -
235 level = IPPROTO_IP;
executed (the execution status of this line is deduced): level = IPPROTO_IP;
-
236 n = IP_MULTICAST_LOOP;
executed (the execution status of this line is deduced): n = 34;
-
237 }
executed: }
Execution Count:7
7
238 break;
executed: break;
Execution Count:14
14
239 case QNativeSocketEngine::TypeOfServiceOption: -
240 if (socketProtocol == QAbstractSocket::IPv4Protocol) {
never evaluated: socketProtocol == QAbstractSocket::IPv4Protocol
0
241 level = IPPROTO_IP;
never executed (the execution status of this line is deduced): level = IPPROTO_IP;
-
242 n = IP_TOS;
never executed (the execution status of this line is deduced): n = 1;
-
243 }
never executed: }
0
244 break;
never executed: break;
0
245 } -
246 -
247 int v = -1;
executed (the execution status of this line is deduced): int v = -1;
-
248 QT_SOCKOPTLEN_T len = sizeof(v);
executed (the execution status of this line is deduced): socklen_t len = sizeof(v);
-
249 if (::getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1)
partially evaluated: ::getsockopt(socketDescriptor, level, n, (char *) &v, &len) != -1
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-26
250 return v;
executed: return v;
Execution Count:26
26
251 -
252 return -1;
never executed: return -1;
0
253} -
254 -
255 -
256/* -
257 Sets the socket option \a opt to \a v. -
258*/ -
259bool QNativeSocketEnginePrivate::setOption(QNativeSocketEngine::SocketOption opt, int v) -
260{ -
261 Q_Q(QNativeSocketEngine);
executed (the execution status of this line is deduced): QNativeSocketEngine * const q = q_func();
-
262 if (!q->isValid())
partially evaluated: !q->isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7277
0-7277
263 return false;
never executed: return false;
0
264 -
265 int n = 0;
executed (the execution status of this line is deduced): int n = 0;
-
266 int level = SOL_SOCKET; // default
executed (the execution status of this line is deduced): int level = 1;
-
267 -
268 switch (opt) { -
269 case QNativeSocketEngine::ReceiveBufferSocketOption: -
270 n = SO_RCVBUF;
never executed (the execution status of this line is deduced): n = 8;
-
271 break;
never executed: break;
0
272 case QNativeSocketEngine::SendBufferSocketOption: -
273 n = SO_SNDBUF;
never executed (the execution status of this line is deduced): n = 7;
-
274 break;
never executed: break;
0
275 case QNativeSocketEngine::BroadcastSocketOption: -
276 n = SO_BROADCAST;
executed (the execution status of this line is deduced): n = 6;
-
277 break;
executed: break;
Execution Count:235
235
278 case QNativeSocketEngine::NonBlockingSocketOption: { -
279 // Make the socket nonblocking. -
280#if !defined(Q_OS_VXWORKS) -
281 int flags = ::fcntl(socketDescriptor, F_GETFL, 0);
executed (the execution status of this line is deduced): int flags = ::fcntl(socketDescriptor, 3, 0);
-
282 if (flags == -1) {
partially evaluated: flags == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3373
0-3373
283#ifdef QNATIVESOCKETENGINE_DEBUG -
284 perror("QNativeSocketEnginePrivate::setOption(): fcntl(F_GETFL) failed"); -
285#endif -
286 return false;
never executed: return false;
0
287 } -
288 if (::fcntl(socketDescriptor, F_SETFL, flags | O_NONBLOCK) == -1) {
partially evaluated: ::fcntl(socketDescriptor, 4, flags | 04000) == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3373
0-3373
289#ifdef QNATIVESOCKETENGINE_DEBUG -
290 perror("QNativeSocketEnginePrivate::setOption(): fcntl(F_SETFL) failed"); -
291#endif -
292 return false;
never executed: return false;
0
293 } -
294#else // Q_OS_VXWORKS -
295 int onoff = 1; -
296 -
297 if (qt_safe_ioctl(socketDescriptor, FIONBIO, &onoff) < 0) { -
298 -
299#ifdef QNATIVESOCKETENGINE_DEBUG -
300 perror("QNativeSocketEnginePrivate::setOption(): ioctl(FIONBIO, 1) failed"); -
301#endif -
302 return false; -
303 } -
304#endif // Q_OS_VXWORKS -
305 return true;
executed: return true;
Execution Count:3373
3373
306 } -
307 case QNativeSocketEngine::AddressReusable: -
308#if defined(SO_REUSEPORT) -
309 // on OS X, SO_REUSEADDR isn't sufficient to allow multiple binds to the -
310 // same port (which is useful for multicast UDP). SO_REUSEPORT is, but -
311 // we most definitely do not want to use this for TCP. See QTBUG-6305. -
312 if (socketType == QAbstractSocket::UdpSocket) -
313 n = SO_REUSEPORT; -
314 else -
315 n = SO_REUSEADDR; -
316#else -
317 n = SO_REUSEADDR;
executed (the execution status of this line is deduced): n = 2;
-
318#endif -
319 break;
executed: break;
Execution Count:437
437
320 case QNativeSocketEngine::BindExclusively: -
321 return true;
never executed: return true;
0
322 case QNativeSocketEngine::ReceiveOutOfBandData: -
323 n = SO_OOBINLINE;
executed (the execution status of this line is deduced): n = 10;
-
324 break;
executed: break;
Execution Count:2526
2526
325 case QNativeSocketEngine::LowDelayOption: -
326 level = IPPROTO_TCP;
executed (the execution status of this line is deduced): level = IPPROTO_TCP;
-
327 n = TCP_NODELAY;
executed (the execution status of this line is deduced): n = 1;
-
328 break;
executed: break;
Execution Count:36
36
329 case QNativeSocketEngine::KeepAliveOption: -
330 n = SO_KEEPALIVE;
executed (the execution status of this line is deduced): n = 9;
-
331 break;
executed: break;
Execution Count:644
644
332 case QNativeSocketEngine::MulticastTtlOption: -
333 if (socketProtocol == QAbstractSocket::IPv6Protocol) {
evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
6
334 level = IPPROTO_IPV6;
executed (the execution status of this line is deduced): level = IPPROTO_IPV6;
-
335 n = IPV6_MULTICAST_HOPS;
executed (the execution status of this line is deduced): n = 18;
-
336 } else
executed: }
Execution Count:6
6
337 { -
338 level = IPPROTO_IP;
executed (the execution status of this line is deduced): level = IPPROTO_IP;
-
339 n = IP_MULTICAST_TTL;
executed (the execution status of this line is deduced): n = 33;
-
340 }
executed: }
Execution Count:6
6
341 break;
executed: break;
Execution Count:12
12
342 case QNativeSocketEngine::MulticastLoopbackOption: -
343 if (socketProtocol == QAbstractSocket::IPv6Protocol) {
evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
344 level = IPPROTO_IPV6;
executed (the execution status of this line is deduced): level = IPPROTO_IPV6;
-
345 n = IPV6_MULTICAST_LOOP;
executed (the execution status of this line is deduced): n = 19;
-
346 } else
executed: }
Execution Count:7
7
347 { -
348 level = IPPROTO_IP;
executed (the execution status of this line is deduced): level = IPPROTO_IP;
-
349 n = IP_MULTICAST_LOOP;
executed (the execution status of this line is deduced): n = 34;
-
350 }
executed: }
Execution Count:7
7
351 break;
executed: break;
Execution Count:14
14
352 case QNativeSocketEngine::TypeOfServiceOption: -
353 if (socketProtocol == QAbstractSocket::IPv4Protocol) {
never evaluated: socketProtocol == QAbstractSocket::IPv4Protocol
0
354 level = IPPROTO_IP;
never executed (the execution status of this line is deduced): level = IPPROTO_IP;
-
355 n = IP_TOS;
never executed (the execution status of this line is deduced): n = 1;
-
356 }
never executed: }
0
357 break;
never executed: break;
0
358 } -
359 -
360 return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0;
executed: return ::setsockopt(socketDescriptor, level, n, (char *) &v, sizeof(v)) == 0;
Execution Count:3904
3904
361} -
362 -
363bool QNativeSocketEnginePrivate::nativeConnect(const QHostAddress &addr, quint16 port) -
364{ -
365#ifdef QNATIVESOCKETENGINE_DEBUG -
366 qDebug("QNativeSocketEnginePrivate::nativeConnect() : %d ", socketDescriptor); -
367#endif -
368 -
369 struct sockaddr_in sockAddrIPv4;
executed (the execution status of this line is deduced): struct sockaddr_in sockAddrIPv4;
-
370 struct sockaddr *sockAddrPtr = 0;
executed (the execution status of this line is deduced): struct sockaddr *sockAddrPtr = 0;
-
371 QT_SOCKLEN_T sockAddrSize = 0;
executed (the execution status of this line is deduced): socklen_t sockAddrSize = 0;
-
372 -
373 struct sockaddr_in6 sockAddrIPv6;
executed (the execution status of this line is deduced): struct sockaddr_in6 sockAddrIPv6;
-
374 -
375 if (addr.protocol() == QAbstractSocket::IPv6Protocol) {
evaluated: addr.protocol() == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:3259
29-3259
376 memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
executed (the execution status of this line is deduced): memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
-
377 sockAddrIPv6.sin6_family = AF_INET6;
executed (the execution status of this line is deduced): sockAddrIPv6.sin6_family = 10;
-
378 sockAddrIPv6.sin6_port = htons(port);
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
Execution Count:29
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:29
0-29
379 -
380 QString scopeid = addr.scopeId();
executed (the execution status of this line is deduced): QString scopeid = addr.scopeId();
-
381 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
382 sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok);
executed (the execution status of this line is deduced): sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok);
-
383#ifndef QT_NO_IPV6IFNAME -
384 if (!ok)
partially evaluated: !ok
TRUEFALSE
yes
Evaluation Count:29
no
Evaluation Count:0
0-29
385 sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1());
executed: sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1());
Execution Count:29
29
386#endif -
387 Q_IPV6ADDR ip6 = addr.toIPv6Address();
executed (the execution status of this line is deduced): Q_IPV6ADDR ip6 = addr.toIPv6Address();
-
388 memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &ip6, sizeof(ip6));
executed (the execution status of this line is deduced): memcpy(&sockAddrIPv6.sin6_addr.__in6_u.__u6_addr8, &ip6, sizeof(ip6));
-
389 -
390 sockAddrSize = sizeof(sockAddrIPv6);
executed (the execution status of this line is deduced): sockAddrSize = sizeof(sockAddrIPv6);
-
391 sockAddrPtr = (struct sockaddr *) &sockAddrIPv6;
executed (the execution status of this line is deduced): sockAddrPtr = (struct sockaddr *) &sockAddrIPv6;
-
392 } else
executed: }
Execution Count:29
29
393 if (addr.protocol() == QAbstractSocket::IPv4Protocol) {
partially evaluated: addr.protocol() == QAbstractSocket::IPv4Protocol
TRUEFALSE
yes
Evaluation Count:3259
no
Evaluation Count:0
0-3259
394 memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
executed (the execution status of this line is deduced): memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
-
395 sockAddrIPv4.sin_family = AF_INET;
executed (the execution status of this line is deduced): sockAddrIPv4.sin_family = 2;
-
396 sockAddrIPv4.sin_port = htons(port);
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
Execution Count:3259
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3259
0-3259
397 sockAddrIPv4.sin_addr.s_addr = htonl(addr.toIPv4Address());
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
Execution Count:3259
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3259
0-3259
398 -
399 sockAddrSize = sizeof(sockAddrIPv4);
executed (the execution status of this line is deduced): sockAddrSize = sizeof(sockAddrIPv4);
-
400 sockAddrPtr = (struct sockaddr *) &sockAddrIPv4;
executed (the execution status of this line is deduced): sockAddrPtr = (struct sockaddr *) &sockAddrIPv4;
-
401 } else {
executed: }
Execution Count:3259
3259
402 // unreachable -
403 }
never executed: }
0
404 -
405 int connectResult = qt_safe_connect(socketDescriptor, sockAddrPtr, sockAddrSize);
executed (the execution status of this line is deduced): int connectResult = qt_safe_connect(socketDescriptor, sockAddrPtr, sockAddrSize);
-
406 if (connectResult == -1) {
evaluated: connectResult == -1
TRUEFALSE
yes
Evaluation Count:2097
yes
Evaluation Count:1191
1191-2097
407 switch (errno) { -
408 case EISCONN: -
409 socketState = QAbstractSocket::ConnectedState;
never executed (the execution status of this line is deduced): socketState = QAbstractSocket::ConnectedState;
-
410 break;
never executed: break;
0
411 case ECONNREFUSED: -
412 case EINVAL: -
413 setError(QAbstractSocket::ConnectionRefusedError, ConnectionRefusedErrorString);
executed (the execution status of this line is deduced): setError(QAbstractSocket::ConnectionRefusedError, ConnectionRefusedErrorString);
-
414 socketState = QAbstractSocket::UnconnectedState;
executed (the execution status of this line is deduced): socketState = QAbstractSocket::UnconnectedState;
-
415 break;
executed: break;
Execution Count:8
8
416 case ETIMEDOUT: -
417 setError(QAbstractSocket::NetworkError, ConnectionTimeOutErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::NetworkError, ConnectionTimeOutErrorString);
-
418 break;
never executed: break;
0
419 case EHOSTUNREACH: -
420 setError(QAbstractSocket::NetworkError, HostUnreachableErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::NetworkError, HostUnreachableErrorString);
-
421 socketState = QAbstractSocket::UnconnectedState;
never executed (the execution status of this line is deduced): socketState = QAbstractSocket::UnconnectedState;
-
422 break;
never executed: break;
0
423 case ENETUNREACH: -
424 setError(QAbstractSocket::NetworkError, NetworkUnreachableErrorString);
executed (the execution status of this line is deduced): setError(QAbstractSocket::NetworkError, NetworkUnreachableErrorString);
-
425 socketState = QAbstractSocket::UnconnectedState;
executed (the execution status of this line is deduced): socketState = QAbstractSocket::UnconnectedState;
-
426 break;
executed: break;
Execution Count:2
2
427 case EADDRINUSE: -
428 setError(QAbstractSocket::NetworkError, AddressInuseErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::NetworkError, AddressInuseErrorString);
-
429 break;
never executed: break;
0
430 case EINPROGRESS: -
431 case EALREADY: -
432 setError(QAbstractSocket::UnfinishedSocketOperationError, InvalidSocketErrorString);
executed (the execution status of this line is deduced): setError(QAbstractSocket::UnfinishedSocketOperationError, InvalidSocketErrorString);
-
433 socketState = QAbstractSocket::ConnectingState;
executed (the execution status of this line is deduced): socketState = QAbstractSocket::ConnectingState;
-
434 break;
executed: break;
Execution Count:2087
2087
435 case EAGAIN: -
436 setError(QAbstractSocket::UnfinishedSocketOperationError, InvalidSocketErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::UnfinishedSocketOperationError, InvalidSocketErrorString);
-
437 break;
never executed: break;
0
438 case EACCES: -
439 case EPERM: -
440 setError(QAbstractSocket::SocketAccessError, AccessErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketAccessError, AccessErrorString);
-
441 socketState = QAbstractSocket::UnconnectedState;
never executed (the execution status of this line is deduced): socketState = QAbstractSocket::UnconnectedState;
-
442 break;
never executed: break;
0
443 case EAFNOSUPPORT: -
444 case EBADF: -
445 case EFAULT: -
446 case ENOTSOCK: -
447 socketState = QAbstractSocket::UnconnectedState;
never executed (the execution status of this line is deduced): socketState = QAbstractSocket::UnconnectedState;
-
448 default: -
449 break;
never executed: break;
0
450 } -
451 -
452 if (socketState != QAbstractSocket::ConnectedState) {
partially evaluated: socketState != QAbstractSocket::ConnectedState
TRUEFALSE
yes
Evaluation Count:2097
no
Evaluation Count:0
0-2097
453#if defined (QNATIVESOCKETENGINE_DEBUG) -
454 qDebug("QNativeSocketEnginePrivate::nativeConnect(%s, %i) == false (%s)", -
455 addr.toString().toLatin1().constData(), port, -
456 socketState == QAbstractSocket::ConnectingState -
457 ? "Connection in progress" : socketErrorString.toLatin1().constData()); -
458#endif -
459 return false;
executed: return false;
Execution Count:2097
2097
460 } -
461 }
never executed: }
0
462 -
463#if defined (QNATIVESOCKETENGINE_DEBUG) -
464 qDebug("QNativeSocketEnginePrivate::nativeConnect(%s, %i) == true", -
465 addr.toString().toLatin1().constData(), port); -
466#endif -
467 -
468 socketState = QAbstractSocket::ConnectedState;
executed (the execution status of this line is deduced): socketState = QAbstractSocket::ConnectedState;
-
469 return true;
executed: return true;
Execution Count:1191
1191
470} -
471 -
472bool QNativeSocketEnginePrivate::nativeBind(const QHostAddress &address, quint16 port) -
473{ -
474 struct sockaddr_in sockAddrIPv4;
executed (the execution status of this line is deduced): struct sockaddr_in sockAddrIPv4;
-
475 struct sockaddr *sockAddrPtr = 0;
executed (the execution status of this line is deduced): struct sockaddr *sockAddrPtr = 0;
-
476 QT_SOCKLEN_T sockAddrSize = 0;
executed (the execution status of this line is deduced): socklen_t sockAddrSize = 0;
-
477 -
478 -
479 struct sockaddr_in6 sockAddrIPv6;
executed (the execution status of this line is deduced): struct sockaddr_in6 sockAddrIPv6;
-
480 -
481 if (address.protocol() == QAbstractSocket::IPv6Protocol || address.protocol() == QAbstractSocket::AnyIPProtocol) {
evaluated: address.protocol() == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:590
evaluated: address.protocol() == QAbstractSocket::AnyIPProtocol
TRUEFALSE
yes
Evaluation Count:379
yes
Evaluation Count:211
79-590
482#ifdef IPV6_V6ONLY -
483 int ipv6only = 0;
executed (the execution status of this line is deduced): int ipv6only = 0;
-
484 if (address.protocol() == QAbstractSocket::IPv6Protocol)
evaluated: address.protocol() == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:79
yes
Evaluation Count:379
79-379
485 ipv6only = 1;
executed: ipv6only = 1;
Execution Count:79
79
486 //default value of this socket option varies depending on unix variant (or system configuration on BSD), so always set it explicitly -
487 ::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, sizeof(ipv6only) );
executed (the execution status of this line is deduced): ::setsockopt(socketDescriptor, IPPROTO_IPV6, 26, (char*)&ipv6only, sizeof(ipv6only) );
-
488#endif -
489 memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
executed (the execution status of this line is deduced): memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
-
490 sockAddrIPv6.sin6_family = AF_INET6;
executed (the execution status of this line is deduced): sockAddrIPv6.sin6_family = 10;
-
491 sockAddrIPv6.sin6_port = htons(port);
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
Execution Count:458
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:458
0-458
492#ifndef QT_NO_IPV6IFNAME -
493 sockAddrIPv6.sin6_scope_id = ::if_nametoindex(address.scopeId().toLatin1().data());
executed (the execution status of this line is deduced): sockAddrIPv6.sin6_scope_id = ::if_nametoindex(address.scopeId().toLatin1().data());
-
494#else -
495 sockAddrIPv6.sin6_scope_id = address.scopeId().toInt(); -
496#endif -
497 Q_IPV6ADDR tmp = address.toIPv6Address();
executed (the execution status of this line is deduced): Q_IPV6ADDR tmp = address.toIPv6Address();
-
498 memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp));
executed (the execution status of this line is deduced): memcpy(&sockAddrIPv6.sin6_addr.__in6_u.__u6_addr8, &tmp, sizeof(tmp));
-
499 sockAddrSize = sizeof(sockAddrIPv6);
executed (the execution status of this line is deduced): sockAddrSize = sizeof(sockAddrIPv6);
-
500 sockAddrPtr = (struct sockaddr *) &sockAddrIPv6;
executed (the execution status of this line is deduced): sockAddrPtr = (struct sockaddr *) &sockAddrIPv6;
-
501 } else
executed: }
Execution Count:458
458
502 if (address.protocol() == QAbstractSocket::IPv4Protocol) {
partially evaluated: address.protocol() == QAbstractSocket::IPv4Protocol
TRUEFALSE
yes
Evaluation Count:211
no
Evaluation Count:0
0-211
503 memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
executed (the execution status of this line is deduced): memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
-
504 sockAddrIPv4.sin_family = AF_INET;
executed (the execution status of this line is deduced): sockAddrIPv4.sin_family = 2;
-
505 sockAddrIPv4.sin_port = htons(port);
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
Execution Count:211
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:211
0-211
506 sockAddrIPv4.sin_addr.s_addr = htonl(address.toIPv4Address());
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
Execution Count:211
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:211
0-211
507 sockAddrSize = sizeof(sockAddrIPv4);
executed (the execution status of this line is deduced): sockAddrSize = sizeof(sockAddrIPv4);
-
508 sockAddrPtr = (struct sockaddr *) &sockAddrIPv4;
executed (the execution status of this line is deduced): sockAddrPtr = (struct sockaddr *) &sockAddrIPv4;
-
509 } else {
executed: }
Execution Count:211
211
510 // unreachable -
511 }
never executed: }
0
512 -
513 int bindResult = QT_SOCKET_BIND(socketDescriptor, sockAddrPtr, sockAddrSize);
executed (the execution status of this line is deduced): int bindResult = ::bind(socketDescriptor, sockAddrPtr, sockAddrSize);
-
514 if (bindResult < 0 && errno == EAFNOSUPPORT && address.protocol() == QAbstractSocket::AnyIPProtocol) {
evaluated: bindResult < 0
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:658
partially evaluated: (*__errno_location ()) == 97
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
never evaluated: address.protocol() == QAbstractSocket::AnyIPProtocol
0-658
515 memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
never executed (the execution status of this line is deduced): memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
-
516 sockAddrIPv4.sin_family = AF_INET;
never executed (the execution status of this line is deduced): sockAddrIPv4.sin_family = 2;
-
517 sockAddrIPv4.sin_port = htons(port);
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
never executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
never evaluated: __builtin_constant_p (__x)
0
518 sockAddrIPv4.sin_addr.s_addr = htonl(address.toIPv4Address());
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
never executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
never evaluated: __builtin_constant_p (__x)
0
519 sockAddrSize = sizeof(sockAddrIPv4);
never executed (the execution status of this line is deduced): sockAddrSize = sizeof(sockAddrIPv4);
-
520 sockAddrPtr = (struct sockaddr *) &sockAddrIPv4;
never executed (the execution status of this line is deduced): sockAddrPtr = (struct sockaddr *) &sockAddrIPv4;
-
521 bindResult = QT_SOCKET_BIND(socketDescriptor, sockAddrPtr, sockAddrSize);
never executed (the execution status of this line is deduced): bindResult = ::bind(socketDescriptor, sockAddrPtr, sockAddrSize);
-
522 }
never executed: }
0
523 -
524 if (bindResult < 0) {
evaluated: bindResult < 0
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:658
11-658
525 switch(errno) { -
526 case EADDRINUSE: -
527 setError(QAbstractSocket::AddressInUseError, AddressInuseErrorString);
executed (the execution status of this line is deduced): setError(QAbstractSocket::AddressInUseError, AddressInuseErrorString);
-
528 break;
executed: break;
Execution Count:10
10
529 case EACCES: -
530 setError(QAbstractSocket::SocketAccessError, AddressProtectedErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketAccessError, AddressProtectedErrorString);
-
531 break;
never executed: break;
0
532 case EINVAL: -
533 setError(QAbstractSocket::UnsupportedSocketOperationError, OperationUnsupportedErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, OperationUnsupportedErrorString);
-
534 break;
never executed: break;
0
535 case EADDRNOTAVAIL: -
536 setError(QAbstractSocket::SocketAddressNotAvailableError, AddressNotAvailableErrorString);
executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketAddressNotAvailableError, AddressNotAvailableErrorString);
-
537 break;
executed: break;
Execution Count:1
1
538 default: -
539 break;
never executed: break;
0
540 } -
541 -
542#if defined (QNATIVESOCKETENGINE_DEBUG) -
543 qDebug("QNativeSocketEnginePrivate::nativeBind(%s, %i) == false (%s)", -
544 address.toString().toLatin1().constData(), port, socketErrorString.toLatin1().constData()); -
545#endif -
546 -
547 return false;
executed: return false;
Execution Count:11
11
548 } -
549 -
550 localPort = port;
executed (the execution status of this line is deduced): localPort = port;
-
551 localAddress = address;
executed (the execution status of this line is deduced): localAddress = address;
-
552 -
553#if defined (QNATIVESOCKETENGINE_DEBUG) -
554 qDebug("QNativeSocketEnginePrivate::nativeBind(%s, %i) == true", -
555 address.toString().toLatin1().constData(), port); -
556#endif -
557 socketState = QAbstractSocket::BoundState;
executed (the execution status of this line is deduced): socketState = QAbstractSocket::BoundState;
-
558 return true;
executed: return true;
Execution Count:658
658
559} -
560 -
561bool QNativeSocketEnginePrivate::nativeListen(int backlog) -
562{ -
563 if (qt_safe_listen(socketDescriptor, backlog) < 0) {
partially evaluated: qt_safe_listen(socketDescriptor, backlog) < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:425
0-425
564 switch (errno) { -
565 case EADDRINUSE: -
566 setError(QAbstractSocket::AddressInUseError,
never executed (the execution status of this line is deduced): setError(QAbstractSocket::AddressInUseError,
-
567 PortInuseErrorString);
never executed (the execution status of this line is deduced): PortInuseErrorString);
-
568 break;
never executed: break;
0
569 default: -
570 break;
never executed: break;
0
571 } -
572 -
573#if defined (QNATIVESOCKETENGINE_DEBUG) -
574 qDebug("QNativeSocketEnginePrivate::nativeListen(%i) == false (%s)", -
575 backlog, socketErrorString.toLatin1().constData()); -
576#endif -
577 return false;
never executed: return false;
0
578 } -
579 -
580#if defined (QNATIVESOCKETENGINE_DEBUG) -
581 qDebug("QNativeSocketEnginePrivate::nativeListen(%i) == true", backlog); -
582#endif -
583 -
584 socketState = QAbstractSocket::ListeningState;
executed (the execution status of this line is deduced): socketState = QAbstractSocket::ListeningState;
-
585 return true;
executed: return true;
Execution Count:425
425
586} -
587 -
588int QNativeSocketEnginePrivate::nativeAccept() -
589{ -
590 int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0);
executed (the execution status of this line is deduced): int acceptedDescriptor = qt_safe_accept(socketDescriptor, 0, 0);
-
591 if (acceptedDescriptor == -1) {
evaluated: acceptedDescriptor == -1
TRUEFALSE
yes
Evaluation Count:455
yes
Evaluation Count:465
455-465
592 switch (errno) { -
593 case EBADF: -
594 case EOPNOTSUPP: -
595 setError(QAbstractSocket::UnsupportedSocketOperationError, InvalidSocketErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, InvalidSocketErrorString);
-
596 break;
never executed: break;
0
597 case ECONNABORTED: -
598 setError(QAbstractSocket::NetworkError, RemoteHostClosedErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::NetworkError, RemoteHostClosedErrorString);
-
599 break;
never executed: break;
0
600 case EFAULT: -
601 case ENOTSOCK: -
602 setError(QAbstractSocket::SocketResourceError, NotSocketErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketResourceError, NotSocketErrorString);
-
603 break;
never executed: break;
0
604 case EPROTONOSUPPORT: -
605 case EPROTO: -
606 case EAFNOSUPPORT: -
607 case EINVAL: -
608 setError(QAbstractSocket::UnsupportedSocketOperationError, ProtocolUnsupportedErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, ProtocolUnsupportedErrorString);
-
609 break;
never executed: break;
0
610 case ENFILE: -
611 case EMFILE: -
612 case ENOBUFS: -
613 case ENOMEM: -
614 setError(QAbstractSocket::SocketResourceError, ResourceErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketResourceError, ResourceErrorString);
-
615 break;
never executed: break;
0
616 case EACCES: -
617 case EPERM: -
618 setError(QAbstractSocket::SocketAccessError, AccessErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::SocketAccessError, AccessErrorString);
-
619 break;
never executed: break;
0
620#if EAGAIN != EWOULDBLOCK -
621 case EWOULDBLOCK: -
622#endif -
623 case EAGAIN: -
624 setError(QAbstractSocket::TemporaryError, TemporaryErrorString);
executed (the execution status of this line is deduced): setError(QAbstractSocket::TemporaryError, TemporaryErrorString);
-
625 break;
executed: break;
Execution Count:455
455
626 default: -
627 setError(QAbstractSocket::UnknownSocketError, UnknownSocketErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::UnknownSocketError, UnknownSocketErrorString);
-
628 break;
never executed: break;
0
629 } -
630 }
executed: }
Execution Count:455
455
631 -
632 return acceptedDescriptor;
executed: return acceptedDescriptor;
Execution Count:920
920
633} -
634 -
635#ifndef QT_NO_NETWORKINTERFACE -
636 -
637static bool multicastMembershipHelper(QNativeSocketEnginePrivate *d, -
638 int how6, -
639 int how4, -
640 const QHostAddress &groupAddress, -
641 const QNetworkInterface &interface) -
642{ -
643 int level = 0;
executed (the execution status of this line is deduced): int level = 0;
-
644 int sockOpt = 0;
executed (the execution status of this line is deduced): int sockOpt = 0;
-
645 void *sockArg;
executed (the execution status of this line is deduced): void *sockArg;
-
646 int sockArgSize;
executed (the execution status of this line is deduced): int sockArgSize;
-
647 -
648 ip_mreq mreq4;
executed (the execution status of this line is deduced): ip_mreq mreq4;
-
649 ipv6_mreq mreq6;
executed (the execution status of this line is deduced): ipv6_mreq mreq6;
-
650 -
651 if (groupAddress.protocol() == QAbstractSocket::IPv6Protocol) {
evaluated: groupAddress.protocol() == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
652 level = IPPROTO_IPV6;
executed (the execution status of this line is deduced): level = IPPROTO_IPV6;
-
653 sockOpt = how6;
executed (the execution status of this line is deduced): sockOpt = how6;
-
654 sockArg = &mreq6;
executed (the execution status of this line is deduced): sockArg = &mreq6;
-
655 sockArgSize = sizeof(mreq6);
executed (the execution status of this line is deduced): sockArgSize = sizeof(mreq6);
-
656 memset(&mreq6, 0, sizeof(mreq6));
executed (the execution status of this line is deduced): memset(&mreq6, 0, sizeof(mreq6));
-
657 Q_IPV6ADDR ip6 = groupAddress.toIPv6Address();
executed (the execution status of this line is deduced): Q_IPV6ADDR ip6 = groupAddress.toIPv6Address();
-
658 memcpy(&mreq6.ipv6mr_multiaddr, &ip6, sizeof(ip6));
executed (the execution status of this line is deduced): memcpy(&mreq6.ipv6mr_multiaddr, &ip6, sizeof(ip6));
-
659 mreq6.ipv6mr_interface = interface.index();
executed (the execution status of this line is deduced): mreq6.ipv6mr_interface = interface.index();
-
660 } else
executed: }
Execution Count:1
1
661 if (groupAddress.protocol() == QAbstractSocket::IPv4Protocol) {
partially evaluated: groupAddress.protocol() == QAbstractSocket::IPv4Protocol
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
662 level = IPPROTO_IP;
executed (the execution status of this line is deduced): level = IPPROTO_IP;
-
663 sockOpt = how4;
executed (the execution status of this line is deduced): sockOpt = how4;
-
664 sockArg = &mreq4;
executed (the execution status of this line is deduced): sockArg = &mreq4;
-
665 sockArgSize = sizeof(mreq4);
executed (the execution status of this line is deduced): sockArgSize = sizeof(mreq4);
-
666 memset(&mreq4, 0, sizeof(mreq4));
executed (the execution status of this line is deduced): memset(&mreq4, 0, sizeof(mreq4));
-
667 mreq4.imr_multiaddr.s_addr = htonl(groupAddress.toIPv4Address());
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
Execution Count:6
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
668 -
669 if (interface.isValid()) {
partially evaluated: interface.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
670 QList<QNetworkAddressEntry> addressEntries = interface.addressEntries();
never executed (the execution status of this line is deduced): QList<QNetworkAddressEntry> addressEntries = interface.addressEntries();
-
671 if (!addressEntries.isEmpty()) {
never evaluated: !addressEntries.isEmpty()
0
672 QHostAddress firstIP = addressEntries.first().ip();
never executed (the execution status of this line is deduced): QHostAddress firstIP = addressEntries.first().ip();
-
673 mreq4.imr_interface.s_addr = htonl(firstIP.toIPv4Address());
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
never executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
never evaluated: __builtin_constant_p (__x)
0
674 } else {
never executed: }
0
675 d->setError(QAbstractSocket::NetworkError,
never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::NetworkError,
-
676 QNativeSocketEnginePrivate::NetworkUnreachableErrorString);
never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::NetworkUnreachableErrorString);
-
677 return false;
never executed: return false;
0
678 } -
679 } else { -
680 mreq4.imr_interface.s_addr = INADDR_ANY;
executed (the execution status of this line is deduced): mreq4.imr_interface.s_addr = ((in_addr_t) 0x00000000);
-
681 }
executed: }
Execution Count:6
6
682 } else { -
683 // unreachable -
684 d->setError(QAbstractSocket::UnsupportedSocketOperationError,
never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::UnsupportedSocketOperationError,
-
685 QNativeSocketEnginePrivate::ProtocolUnsupportedErrorString);
never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::ProtocolUnsupportedErrorString);
-
686 return false;
never executed: return false;
0
687 } -
688 -
689 int res = setsockopt(d->socketDescriptor, level, sockOpt, sockArg, sockArgSize);
executed (the execution status of this line is deduced): int res = setsockopt(d->socketDescriptor, level, sockOpt, sockArg, sockArgSize);
-
690 if (res == -1) {
evaluated: res == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
691 switch (errno) { -
692 case ENOPROTOOPT: -
693 d->setError(QAbstractSocket::UnsupportedSocketOperationError,
never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::UnsupportedSocketOperationError,
-
694 QNativeSocketEnginePrivate::OperationUnsupportedErrorString);
never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::OperationUnsupportedErrorString);
-
695 break;
never executed: break;
0
696 case EADDRNOTAVAIL: -
697 d->setError(QAbstractSocket::SocketAddressNotAvailableError,
never executed (the execution status of this line is deduced): d->setError(QAbstractSocket::SocketAddressNotAvailableError,
-
698 QNativeSocketEnginePrivate::AddressNotAvailableErrorString);
never executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::AddressNotAvailableErrorString);
-
699 break;
never executed: break;
0
700 default: -
701 d->setError(QAbstractSocket::UnknownSocketError,
executed (the execution status of this line is deduced): d->setError(QAbstractSocket::UnknownSocketError,
-
702 QNativeSocketEnginePrivate::UnknownSocketErrorString);
executed (the execution status of this line is deduced): QNativeSocketEnginePrivate::UnknownSocketErrorString);
-
703 break;
executed: break;
Execution Count:1
1
704 } -
705 return false;
executed: return false;
Execution Count:1
1
706 } -
707 return true;
executed: return true;
Execution Count:6
6
708} -
709 -
710bool QNativeSocketEnginePrivate::nativeJoinMulticastGroup(const QHostAddress &groupAddress, -
711 const QNetworkInterface &interface) -
712{ -
713 return multicastMembershipHelper(this,
executed: return multicastMembershipHelper(this, 20, 35, groupAddress, interface);
Execution Count:5
5
714 IPV6_JOIN_GROUP,
executed: return multicastMembershipHelper(this, 20, 35, groupAddress, interface);
Execution Count:5
5
715 IP_ADD_MEMBERSHIP,
executed: return multicastMembershipHelper(this, 20, 35, groupAddress, interface);
Execution Count:5
5
716 groupAddress,
executed: return multicastMembershipHelper(this, 20, 35, groupAddress, interface);
Execution Count:5
5
717 interface);
executed: return multicastMembershipHelper(this, 20, 35, groupAddress, interface);
Execution Count:5
5
718} -
719 -
720bool QNativeSocketEnginePrivate::nativeLeaveMulticastGroup(const QHostAddress &groupAddress, -
721 const QNetworkInterface &interface) -
722{ -
723 return multicastMembershipHelper(this,
executed: return multicastMembershipHelper(this, 21, 36, groupAddress, interface);
Execution Count:2
2
724 IPV6_LEAVE_GROUP,
executed: return multicastMembershipHelper(this, 21, 36, groupAddress, interface);
Execution Count:2
2
725 IP_DROP_MEMBERSHIP,
executed: return multicastMembershipHelper(this, 21, 36, groupAddress, interface);
Execution Count:2
2
726 groupAddress,
executed: return multicastMembershipHelper(this, 21, 36, groupAddress, interface);
Execution Count:2
2
727 interface);
executed: return multicastMembershipHelper(this, 21, 36, groupAddress, interface);
Execution Count:2
2
728} -
729 -
730QNetworkInterface QNativeSocketEnginePrivate::nativeMulticastInterface() const -
731{ -
732 if (socketProtocol == QAbstractSocket::IPv6Protocol) {
evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
733 uint v;
executed (the execution status of this line is deduced): uint v;
-
734 QT_SOCKOPTLEN_T sizeofv = sizeof(v);
executed (the execution status of this line is deduced): socklen_t sizeofv = sizeof(v);
-
735 if (::getsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, &v, &sizeofv) == -1)
partially evaluated: ::getsockopt(socketDescriptor, IPPROTO_IPV6, 17, &v, &sizeofv) == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
736 return QNetworkInterface();
never executed: return QNetworkInterface();
0
737 return QNetworkInterface::interfaceFromIndex(v);
executed: return QNetworkInterface::interfaceFromIndex(v);
Execution Count:4
4
738 } -
739 -
740 struct in_addr v = { 0 };
executed (the execution status of this line is deduced): struct in_addr v = { 0 };
-
741 QT_SOCKOPTLEN_T sizeofv = sizeof(v);
executed (the execution status of this line is deduced): socklen_t sizeofv = sizeof(v);
-
742 if (::getsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, &v, &sizeofv) == -1)
partially evaluated: ::getsockopt(socketDescriptor, IPPROTO_IP, 32, &v, &sizeofv) == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
743 return QNetworkInterface();
never executed: return QNetworkInterface();
0
744 if (v.s_addr != 0 && sizeofv >= sizeof(v)) {
partially evaluated: v.s_addr != 0
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: sizeofv >= sizeof(v)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
745 QHostAddress ipv4(ntohl(v.s_addr));
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
Execution Count:4
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
746 QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
executed (the execution status of this line is deduced): QList<QNetworkInterface> ifaces = QNetworkInterface::allInterfaces();
-
747 for (int i = 0; i < ifaces.count(); ++i) {
partially evaluated: i < ifaces.count()
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
748 const QNetworkInterface &iface = ifaces.at(i);
executed (the execution status of this line is deduced): const QNetworkInterface &iface = ifaces.at(i);
-
749 QList<QNetworkAddressEntry> entries = iface.addressEntries();
executed (the execution status of this line is deduced): QList<QNetworkAddressEntry> entries = iface.addressEntries();
-
750 for (int j = 0; j < entries.count(); ++j) {
evaluated: j < entries.count()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:8
8-16
751 const QNetworkAddressEntry &entry = entries.at(j);
executed (the execution status of this line is deduced): const QNetworkAddressEntry &entry = entries.at(j);
-
752 if (entry.ip() == ipv4)
evaluated: entry.ip() == ipv4
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:12
4-12
753 return iface;
executed: return iface;
Execution Count:4
4
754 }
executed: }
Execution Count:12
12
755 }
executed: }
Execution Count:8
8
756 }
never executed: }
0
757 return QNetworkInterface();
never executed: return QNetworkInterface();
0
758} -
759 -
760bool QNativeSocketEnginePrivate::nativeSetMulticastInterface(const QNetworkInterface &iface) -
761{ -
762 if (socketProtocol == QAbstractSocket::IPv6Protocol) {
evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
763 uint v = iface.index();
executed (the execution status of this line is deduced): uint v = iface.index();
-
764 return (::setsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_MULTICAST_IF, &v, sizeof(v)) != -1);
executed: return (::setsockopt(socketDescriptor, IPPROTO_IPV6, 17, &v, sizeof(v)) != -1);
Execution Count:4
4
765 } -
766 -
767 struct in_addr v;
executed (the execution status of this line is deduced): struct in_addr v;
-
768 if (iface.isValid()) {
partially evaluated: iface.isValid()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
769 QList<QNetworkAddressEntry> entries = iface.addressEntries();
executed (the execution status of this line is deduced): QList<QNetworkAddressEntry> entries = iface.addressEntries();
-
770 for (int i = 0; i < entries.count(); ++i) {
partially evaluated: i < entries.count()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
771 const QNetworkAddressEntry &entry = entries.at(i);
executed (the execution status of this line is deduced): const QNetworkAddressEntry &entry = entries.at(i);
-
772 const QHostAddress &ip = entry.ip();
executed (the execution status of this line is deduced): const QHostAddress &ip = entry.ip();
-
773 if (ip.protocol() == QAbstractSocket::IPv4Protocol) {
partially evaluated: ip.protocol() == QAbstractSocket::IPv4Protocol
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
774 v.s_addr = htonl(ip.toIPv4Address());
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
Execution Count:4
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
775 int r = ::setsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, &v, sizeof(v));
executed (the execution status of this line is deduced): int r = ::setsockopt(socketDescriptor, IPPROTO_IP, 32, &v, sizeof(v));
-
776 if (r != -1)
partially evaluated: r != -1
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
777 return true;
executed: return true;
Execution Count:4
4
778 }
never executed: }
0
779 }
never executed: }
0
780 return false;
never executed: return false;
0
781 } -
782 -
783 v.s_addr = INADDR_ANY;
never executed (the execution status of this line is deduced): v.s_addr = ((in_addr_t) 0x00000000);
-
784 return (::setsockopt(socketDescriptor, IPPROTO_IP, IP_MULTICAST_IF, &v, sizeof(v)) != -1);
never executed: return (::setsockopt(socketDescriptor, IPPROTO_IP, 32, &v, sizeof(v)) != -1);
0
785} -
786 -
787#endif // QT_NO_NETWORKINTERFACE -
788 -
789qint64 QNativeSocketEnginePrivate::nativeBytesAvailable() const -
790{ -
791 int nbytes = 0;
executed (the execution status of this line is deduced): int nbytes = 0;
-
792 // gives shorter than true amounts on Unix domain sockets. -
793 qint64 available = 0;
executed (the execution status of this line is deduced): qint64 available = 0;
-
794 if (qt_safe_ioctl(socketDescriptor, FIONREAD, (char *) &nbytes) >= 0)
partially evaluated: qt_safe_ioctl(socketDescriptor, 0x541B, (char *) &nbytes) >= 0
TRUEFALSE
yes
Evaluation Count:33407
no
Evaluation Count:0
0-33407
795 available = (qint64) nbytes;
executed: available = (qint64) nbytes;
Execution Count:33408
33408
796 -
797#if defined (QNATIVESOCKETENGINE_DEBUG) -
798 qDebug("QNativeSocketEnginePrivate::nativeBytesAvailable() == %lli", available); -
799#endif -
800 return available;
executed: return available;
Execution Count:33408
33408
801} -
802 -
803bool QNativeSocketEnginePrivate::nativeHasPendingDatagrams() const -
804{ -
805 // Create a sockaddr struct and reset its port number. -
806 qt_sockaddr storage;
executed (the execution status of this line is deduced): qt_sockaddr storage;
-
807 QT_SOCKLEN_T storageSize = sizeof(storage);
executed (the execution status of this line is deduced): socklen_t storageSize = sizeof(storage);
-
808 memset(&storage, 0, storageSize);
executed (the execution status of this line is deduced): memset(&storage, 0, storageSize);
-
809 -
810 // Peek 0 bytes into the next message. The size of the message may -
811 // well be 0, so we can't check recvfrom's return value. -
812 ssize_t readBytes;
executed (the execution status of this line is deduced): ssize_t readBytes;
-
813 do { -
814 char c;
executed (the execution status of this line is deduced): char c;
-
815 readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
executed (the execution status of this line is deduced): readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
-
816 } while (readBytes == -1 && errno == EINTR);
executed: }
Execution Count:1662511
evaluated: readBytes == -1
TRUEFALSE
yes
Evaluation Count:1605060
yes
Evaluation Count:57451
partially evaluated: (*__errno_location ()) == 4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1605060
0-1662511
817 -
818 // If there's no error, or if our buffer was too small, there must be a -
819 // pending datagram. -
820 bool result = (readBytes != -1) || errno == EMSGSIZE;
evaluated: (readBytes != -1)
TRUEFALSE
yes
Evaluation Count:57451
yes
Evaluation Count:1605060
partially evaluated: (*__errno_location ()) == 90
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1605060
0-1605060
821 -
822#if defined (QNATIVESOCKETENGINE_DEBUG) -
823 qDebug("QNativeSocketEnginePrivate::nativeHasPendingDatagrams() == %s", -
824 result ? "true" : "false"); -
825#endif -
826 return result;
executed: return result;
Execution Count:1662511
1662511
827} -
828 -
829qint64 QNativeSocketEnginePrivate::nativePendingDatagramSize() const -
830{ -
831 QVarLengthArray<char, 8192> udpMessagePeekBuffer(8192);
executed (the execution status of this line is deduced): QVarLengthArray<char, 8192> udpMessagePeekBuffer(8192);
-
832 ssize_t recvResult = -1;
executed (the execution status of this line is deduced): ssize_t recvResult = -1;
-
833 -
834 for (;;) {
executed (the execution status of this line is deduced): for (;;) {
-
835 // the data written to udpMessagePeekBuffer is discarded, so -
836 // this function is still reentrant although it might not look -
837 // so. -
838 recvResult = ::recv(socketDescriptor, udpMessagePeekBuffer.data(),
executed (the execution status of this line is deduced): recvResult = ::recv(socketDescriptor, udpMessagePeekBuffer.data(),
-
839 udpMessagePeekBuffer.size(), MSG_PEEK);
executed (the execution status of this line is deduced): udpMessagePeekBuffer.size(), MSG_PEEK);
-
840 if (recvResult == -1 && errno == EINTR)
partially evaluated: recvResult == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:52648
never evaluated: (*__errno_location ()) == 4
0-52648
841 continue;
never executed: continue;
0
842 -
843 if (recvResult != (ssize_t) udpMessagePeekBuffer.size())
evaluated: recvResult != (ssize_t) udpMessagePeekBuffer.size()
TRUEFALSE
yes
Evaluation Count:31926
yes
Evaluation Count:20722
20722-31926
844 break;
executed: break;
Execution Count:31926
31926
845 -
846 udpMessagePeekBuffer.resize(udpMessagePeekBuffer.size() * 2);
executed (the execution status of this line is deduced): udpMessagePeekBuffer.resize(udpMessagePeekBuffer.size() * 2);
-
847 }
executed: }
Execution Count:20722
20722
848 -
849#if defined (QNATIVESOCKETENGINE_DEBUG) -
850 qDebug("QNativeSocketEnginePrivate::nativePendingDatagramSize() == %i", recvResult); -
851#endif -
852 -
853 return qint64(recvResult);
executed: return qint64(recvResult);
Execution Count:31926
31926
854} -
855 -
856qint64 QNativeSocketEnginePrivate::nativeReceiveDatagram(char *data, qint64 maxSize, -
857 QHostAddress *address, quint16 *port) -
858{ -
859 qt_sockaddr aa;
executed (the execution status of this line is deduced): qt_sockaddr aa;
-
860 memset(&aa, 0, sizeof(aa));
executed (the execution status of this line is deduced): memset(&aa, 0, sizeof(aa));
-
861 QT_SOCKLEN_T sz;
executed (the execution status of this line is deduced): socklen_t sz;
-
862 sz = sizeof(aa);
executed (the execution status of this line is deduced): sz = sizeof(aa);
-
863 -
864 ssize_t recvFromResult = 0;
executed (the execution status of this line is deduced): ssize_t recvFromResult = 0;
-
865 do { -
866 char c;
executed (the execution status of this line is deduced): char c;
-
867 recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
executed (the execution status of this line is deduced): recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
-
868 0, &aa.a, &sz);
executed (the execution status of this line is deduced): 0, &aa.a, &sz);
-
869 } while (recvFromResult == -1 && errno == EINTR);
executed: }
Execution Count:990809
partially evaluated: recvFromResult == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:990809
never evaluated: (*__errno_location ()) == 4
0-990809
870 -
871 if (recvFromResult == -1) {
partially evaluated: recvFromResult == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:990809
0-990809
872 setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::NetworkError, ReceiveDatagramErrorString);
-
873 } else if (port || address) {
never executed: }
evaluated: port
TRUEFALSE
yes
Evaluation Count:11274
yes
Evaluation Count:979535
partially evaluated: address
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:979535
0-979535
874 qt_socket_getPortAndAddress(&aa, port, address);
executed (the execution status of this line is deduced): qt_socket_getPortAndAddress(&aa, port, address);
-
875 }
executed: }
Execution Count:11274
11274
876 -
877#if defined (QNATIVESOCKETENGINE_DEBUG) -
878 qDebug("QNativeSocketEnginePrivate::nativeReceiveDatagram(%p \"%s\", %lli, %s, %i) == %lli", -
879 data, qt_prettyDebug(data, qMin(recvFromResult, ssize_t(16)), recvFromResult).data(), maxSize, -
880 address ? address->toString().toLatin1().constData() : "(nil)", -
881 port ? *port : 0, (qint64) recvFromResult); -
882#endif -
883 -
884 return qint64(maxSize ? recvFromResult : recvFromResult == -1 ? -1 : 0);
executed: return qint64(maxSize ? recvFromResult : recvFromResult == -1 ? -1 : 0);
Execution Count:990809
990809
885} -
886 -
887qint64 QNativeSocketEnginePrivate::nativeSendDatagram(const char *data, qint64 len, -
888 const QHostAddress &host, quint16 port) -
889{ -
890 struct sockaddr_in sockAddrIPv4;
executed (the execution status of this line is deduced): struct sockaddr_in sockAddrIPv4;
-
891 struct sockaddr *sockAddrPtr = 0;
executed (the execution status of this line is deduced): struct sockaddr *sockAddrPtr = 0;
-
892 QT_SOCKLEN_T sockAddrSize = 0;
executed (the execution status of this line is deduced): socklen_t sockAddrSize = 0;
-
893 -
894 struct sockaddr_in6 sockAddrIPv6;
executed (the execution status of this line is deduced): struct sockaddr_in6 sockAddrIPv6;
-
895 if (host.protocol() == QAbstractSocket::IPv6Protocol
evaluated: host.protocol() == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:324622
24-324622
896 || socketProtocol == QAbstractSocket::IPv6Protocol
partially evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:324622
0-324622
897 || socketProtocol == QAbstractSocket::AnyIPProtocol) {
evaluated: socketProtocol == QAbstractSocket::AnyIPProtocol
TRUEFALSE
yes
Evaluation Count:11312
yes
Evaluation Count:313310
11312-313310
898 memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
executed (the execution status of this line is deduced): memset(&sockAddrIPv6, 0, sizeof(sockAddrIPv6));
-
899 sockAddrIPv6.sin6_family = AF_INET6;
executed (the execution status of this line is deduced): sockAddrIPv6.sin6_family = 10;
-
900 sockAddrIPv6.sin6_port = htons(port);
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
Execution Count:11336
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11336
0-11336
901 -
902 Q_IPV6ADDR tmp = host.toIPv6Address();
executed (the execution status of this line is deduced): Q_IPV6ADDR tmp = host.toIPv6Address();
-
903 memcpy(&sockAddrIPv6.sin6_addr.s6_addr, &tmp, sizeof(tmp));
executed (the execution status of this line is deduced): memcpy(&sockAddrIPv6.sin6_addr.__in6_u.__u6_addr8, &tmp, sizeof(tmp));
-
904 QString scopeid = host.scopeId();
executed (the execution status of this line is deduced): QString scopeid = host.scopeId();
-
905 bool ok;
executed (the execution status of this line is deduced): bool ok;
-
906 sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok);
executed (the execution status of this line is deduced): sockAddrIPv6.sin6_scope_id = scopeid.toInt(&ok);
-
907#ifndef QT_NO_IPV6IFNAME -
908 if (!ok)
partially evaluated: !ok
TRUEFALSE
yes
Evaluation Count:11336
no
Evaluation Count:0
0-11336
909 sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1());
executed: sockAddrIPv6.sin6_scope_id = ::if_nametoindex(scopeid.toLatin1());
Execution Count:11336
11336
910#endif -
911 sockAddrSize = sizeof(sockAddrIPv6);
executed (the execution status of this line is deduced): sockAddrSize = sizeof(sockAddrIPv6);
-
912 sockAddrPtr = (struct sockaddr *)&sockAddrIPv6;
executed (the execution status of this line is deduced): sockAddrPtr = (struct sockaddr *)&sockAddrIPv6;
-
913 } else if (host.protocol() == QAbstractSocket::IPv4Protocol) {
executed: }
Execution Count:11336
partially evaluated: host.protocol() == QAbstractSocket::IPv4Protocol
TRUEFALSE
yes
Evaluation Count:313310
no
Evaluation Count:0
0-313310
914 memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
executed (the execution status of this line is deduced): memset(&sockAddrIPv4, 0, sizeof(sockAddrIPv4));
-
915 sockAddrIPv4.sin_family = AF_INET;
executed (the execution status of this line is deduced): sockAddrIPv4.sin_family = 2;
-
916 sockAddrIPv4.sin_port = htons(port);
never executed: __v = ((unsigned short int) ((((__x) >> 8) & 0xff) | (((__x) & 0xff) << 8)));
executed: __asm__ ("rorw $8, %w0" : "=r" (__v) : "0" (__x) : "cc");
Execution Count:313310
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:313310
0-313310
917 sockAddrIPv4.sin_addr.s_addr = htonl(host.toIPv4Address());
never executed: __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24));
executed: __asm__ ("bswap %0" : "=r" (__v) : "0" (__x));
Execution Count:313310
partially evaluated: __builtin_constant_p (__x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:313310
0-313310
918 sockAddrSize = sizeof(sockAddrIPv4);
executed (the execution status of this line is deduced): sockAddrSize = sizeof(sockAddrIPv4);
-
919 sockAddrPtr = (struct sockaddr *)&sockAddrIPv4;
executed (the execution status of this line is deduced): sockAddrPtr = (struct sockaddr *)&sockAddrIPv4;
-
920 }
executed: }
Execution Count:313310
313310
921 -
922 ssize_t sentBytes = qt_safe_sendto(socketDescriptor, data, len,
executed (the execution status of this line is deduced): ssize_t sentBytes = qt_safe_sendto(socketDescriptor, data, len,
-
923 0, sockAddrPtr, sockAddrSize);
executed (the execution status of this line is deduced): 0, sockAddrPtr, sockAddrSize);
-
924 -
925 if (sentBytes < 0) {
evaluated: sentBytes < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:324645
1-324645
926 switch (errno) { -
927 case EMSGSIZE: -
928 setError(QAbstractSocket::DatagramTooLargeError, DatagramTooLargeErrorString);
executed (the execution status of this line is deduced): setError(QAbstractSocket::DatagramTooLargeError, DatagramTooLargeErrorString);
-
929 break;
executed: break;
Execution Count:1
1
930 default: -
931 setError(QAbstractSocket::NetworkError, SendDatagramErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::NetworkError, SendDatagramErrorString);
-
932 }
never executed: }
0
933 }
executed: }
Execution Count:1
1
934 -
935#if defined (QNATIVESOCKETENGINE_DEBUG) -
936 qDebug("QNativeSocketEngine::sendDatagram(%p \"%s\", %lli, \"%s\", %i) == %lli", data, -
937 qt_prettyDebug(data, qMin<int>(len, 16), len).data(), len, host.toString().toLatin1().constData(), -
938 port, (qint64) sentBytes); -
939#endif -
940 -
941 return qint64(sentBytes);
executed: return qint64(sentBytes);
Execution Count:324646
324646
942} -
943 -
944bool QNativeSocketEnginePrivate::fetchConnectionParameters() -
945{ -
946 localPort = 0;
executed (the execution status of this line is deduced): localPort = 0;
-
947 localAddress.clear();
executed (the execution status of this line is deduced): localAddress.clear();
-
948 peerPort = 0;
executed (the execution status of this line is deduced): peerPort = 0;
-
949 peerAddress.clear();
executed (the execution status of this line is deduced): peerAddress.clear();
-
950 -
951 if (socketDescriptor == -1)
evaluated: socketDescriptor == -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2463
1-2463
952 return false;
executed: return false;
Execution Count:1
1
953 -
954 qt_sockaddr sa;
executed (the execution status of this line is deduced): qt_sockaddr sa;
-
955 QT_SOCKLEN_T sockAddrSize = sizeof(sa);
executed (the execution status of this line is deduced): socklen_t sockAddrSize = sizeof(sa);
-
956 -
957 // Determine local address -
958 memset(&sa, 0, sizeof(sa));
executed (the execution status of this line is deduced): memset(&sa, 0, sizeof(sa));
-
959 if (::getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0) {
evaluated: ::getsockname(socketDescriptor, &sa.a, &sockAddrSize) == 0
TRUEFALSE
yes
Evaluation Count:2461
yes
Evaluation Count:2
2-2461
960 qt_socket_getPortAndAddress(&sa, &localPort, &localAddress);
executed (the execution status of this line is deduced): qt_socket_getPortAndAddress(&sa, &localPort, &localAddress);
-
961 -
962 // Determine protocol family -
963 switch (sa.a.sa_family) { -
964 case AF_INET: -
965 socketProtocol = QAbstractSocket::IPv4Protocol;
executed (the execution status of this line is deduced): socketProtocol = QAbstractSocket::IPv4Protocol;
-
966 break;
executed: break;
Execution Count:1576
1576
967 case AF_INET6: -
968 socketProtocol = QAbstractSocket::IPv6Protocol;
executed (the execution status of this line is deduced): socketProtocol = QAbstractSocket::IPv6Protocol;
-
969 break;
executed: break;
Execution Count:739
739
970 default: -
971 socketProtocol = QAbstractSocket::UnknownNetworkLayerProtocol;
executed (the execution status of this line is deduced): socketProtocol = QAbstractSocket::UnknownNetworkLayerProtocol;
-
972 break;
executed: break;
Execution Count:146
146
973 } -
974 -
975 } else if (errno == EBADF) {
executed: }
Execution Count:2461
partially evaluated: (*__errno_location ()) == 9
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2461
976 setError(QAbstractSocket::UnsupportedSocketOperationError, InvalidSocketErrorString);
executed (the execution status of this line is deduced): setError(QAbstractSocket::UnsupportedSocketOperationError, InvalidSocketErrorString);
-
977 return false;
executed: return false;
Execution Count:2
2
978 } -
979 -
980#if defined (IPV6_V6ONLY) -
981 // determine if local address is dual mode -
982 // On linux, these are returned as "::" (==AnyIPv6) -
983 // On OSX, these are returned as "::FFFF:0.0.0.0" (==AnyIPv4) -
984 // in either case, the IPV6_V6ONLY option is cleared -
985 int ipv6only = 0;
executed (the execution status of this line is deduced): int ipv6only = 0;
-
986 socklen_t optlen = sizeof(ipv6only);
executed (the execution status of this line is deduced): socklen_t optlen = sizeof(ipv6only);
-
987 if (socketProtocol == QAbstractSocket::IPv6Protocol
evaluated: socketProtocol == QAbstractSocket::IPv6Protocol
TRUEFALSE
yes
Evaluation Count:739
yes
Evaluation Count:1722
739-1722
988 && (localAddress == QHostAddress::AnyIPv4 || localAddress == QHostAddress::AnyIPv6)
partially evaluated: localAddress == QHostAddress::AnyIPv4
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:739
evaluated: localAddress == QHostAddress::AnyIPv6
TRUEFALSE
yes
Evaluation Count:418
yes
Evaluation Count:321
0-739
989 && !getsockopt(socketDescriptor, IPPROTO_IPV6, IPV6_V6ONLY, (char*)&ipv6only, &optlen )) {
partially evaluated: !getsockopt(socketDescriptor, IPPROTO_IPV6, 26, (char*)&ipv6only, &optlen )
TRUEFALSE
yes
Evaluation Count:418
no
Evaluation Count:0
0-418
990 if (optlen != sizeof(ipv6only))
partially evaluated: optlen != sizeof(ipv6only)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:418
0-418
991 qWarning("unexpected size of IPV6_V6ONLY socket option");
never executed: QMessageLogger("socket/qnativesocketengine_unix.cpp", 991, __PRETTY_FUNCTION__).warning("unexpected size of IPV6_V6ONLY socket option");
0
992 if (!ipv6only) {
evaluated: !ipv6only
TRUEFALSE
yes
Evaluation Count:376
yes
Evaluation Count:42
42-376
993 socketProtocol = QAbstractSocket::AnyIPProtocol;
executed (the execution status of this line is deduced): socketProtocol = QAbstractSocket::AnyIPProtocol;
-
994 localAddress = QHostAddress::Any;
executed (the execution status of this line is deduced): localAddress = QHostAddress::Any;
-
995 }
executed: }
Execution Count:376
376
996 }
executed: }
Execution Count:418
418
997#endif -
998 -
999 // Determine the remote address -
1000 if (!::getpeername(socketDescriptor, &sa.a, &sockAddrSize))
evaluated: !::getpeername(socketDescriptor, &sa.a, &sockAddrSize)
TRUEFALSE
yes
Evaluation Count:1801
yes
Evaluation Count:660
660-1801
1001 qt_socket_getPortAndAddress(&sa, &peerPort, &peerAddress);
executed: qt_socket_getPortAndAddress(&sa, &peerPort, &peerAddress);
Execution Count:1801
1801
1002 -
1003 // Determine the socket type (UDP/TCP) -
1004 int value = 0;
executed (the execution status of this line is deduced): int value = 0;
-
1005 QT_SOCKOPTLEN_T valueSize = sizeof(int);
executed (the execution status of this line is deduced): socklen_t valueSize = sizeof(int);
-
1006 if (::getsockopt(socketDescriptor, SOL_SOCKET, SO_TYPE, &value, &valueSize) == 0) {
partially evaluated: ::getsockopt(socketDescriptor, 1, 3, &value, &valueSize) == 0
TRUEFALSE
yes
Evaluation Count:2461
no
Evaluation Count:0
0-2461
1007 if (value == SOCK_STREAM)
evaluated: value == SOCK_STREAM
TRUEFALSE
yes
Evaluation Count:2227
yes
Evaluation Count:234
234-2227
1008 socketType = QAbstractSocket::TcpSocket;
executed: socketType = QAbstractSocket::TcpSocket;
Execution Count:2227
2227
1009 else if (value == SOCK_DGRAM)
partially evaluated: value == SOCK_DGRAM
TRUEFALSE
yes
Evaluation Count:234
no
Evaluation Count:0
0-234
1010 socketType = QAbstractSocket::UdpSocket;
executed: socketType = QAbstractSocket::UdpSocket;
Execution Count:234
234
1011 else -
1012 socketType = QAbstractSocket::UnknownSocketType;
never executed: socketType = QAbstractSocket::UnknownSocketType;
0
1013 } -
1014#if defined (QNATIVESOCKETENGINE_DEBUG) -
1015 QString socketProtocolStr = "UnknownProtocol"; -
1016 if (socketProtocol == QAbstractSocket::IPv4Protocol) socketProtocolStr = "IPv4Protocol"; -
1017 else if (socketProtocol == QAbstractSocket::IPv6Protocol) socketProtocolStr = "IPv6Protocol"; -
1018 -
1019 QString socketTypeStr = "UnknownSocketType"; -
1020 if (socketType == QAbstractSocket::TcpSocket) socketTypeStr = "TcpSocket"; -
1021 else if (socketType == QAbstractSocket::UdpSocket) socketTypeStr = "UdpSocket"; -
1022 -
1023 qDebug("QNativeSocketEnginePrivate::fetchConnectionParameters() local == %s:%i," -
1024 " peer == %s:%i, socket == %s - %s", -
1025 localAddress.toString().toLatin1().constData(), localPort, -
1026 peerAddress.toString().toLatin1().constData(), peerPort,socketTypeStr.toLatin1().constData(), -
1027 socketProtocolStr.toLatin1().constData()); -
1028#endif -
1029 return true;
executed: return true;
Execution Count:2461
2461
1030} -
1031 -
1032void QNativeSocketEnginePrivate::nativeClose() -
1033{ -
1034#if defined (QNATIVESOCKETENGINE_DEBUG) -
1035 qDebug("QNativeSocketEngine::nativeClose()"); -
1036#endif -
1037 -
1038 qt_safe_close(socketDescriptor);
executed (the execution status of this line is deduced): qt_safe_close(socketDescriptor);
-
1039}
executed: }
Execution Count:3371
3371
1040 -
1041qint64 QNativeSocketEnginePrivate::nativeWrite(const char *data, qint64 len) -
1042{ -
1043 Q_Q(QNativeSocketEngine);
executed (the execution status of this line is deduced): QNativeSocketEngine * const q = q_func();
-
1044 -
1045 ssize_t writtenBytes;
executed (the execution status of this line is deduced): ssize_t writtenBytes;
-
1046 writtenBytes = qt_safe_write_nosignal(socketDescriptor, data, len);
executed (the execution status of this line is deduced): writtenBytes = qt_safe_write_nosignal(socketDescriptor, data, len);
-
1047 -
1048 if (writtenBytes < 0) {
evaluated: writtenBytes < 0
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:983472
11-983472
1049 switch (errno) { -
1050 case EPIPE: -
1051 case ECONNRESET: -
1052 writtenBytes = -1;
never executed (the execution status of this line is deduced): writtenBytes = -1;
-
1053 setError(QAbstractSocket::RemoteHostClosedError, RemoteHostClosedErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::RemoteHostClosedError, RemoteHostClosedErrorString);
-
1054 q->close();
never executed (the execution status of this line is deduced): q->close();
-
1055 break;
never executed: break;
0
1056 case EAGAIN: -
1057 writtenBytes = 0;
executed (the execution status of this line is deduced): writtenBytes = 0;
-
1058 break;
executed: break;
Execution Count:11
11
1059 case EMSGSIZE: -
1060 setError(QAbstractSocket::DatagramTooLargeError, DatagramTooLargeErrorString);
never executed (the execution status of this line is deduced): setError(QAbstractSocket::DatagramTooLargeError, DatagramTooLargeErrorString);
-
1061 break;
never executed: break;
0
1062 default: -
1063 break;
never executed: break;
0
1064 } -
1065 }
executed: }
Execution Count:11
11
1066 -
1067#if defined (QNATIVESOCKETENGINE_DEBUG) -
1068 qDebug("QNativeSocketEnginePrivate::nativeWrite(%p \"%s\", %llu) == %i", -
1069 data, qt_prettyDebug(data, qMin((int) len, 16), -
1070 (int) len).data(), len, (int) writtenBytes); -
1071#endif -
1072 -
1073 return qint64(writtenBytes);
executed: return qint64(writtenBytes);
Execution Count:983483
983483
1074} -
1075/* -
1076*/ -
1077qint64 QNativeSocketEnginePrivate::nativeRead(char *data, qint64 maxSize) -
1078{ -
1079 Q_Q(QNativeSocketEngine);
executed (the execution status of this line is deduced): QNativeSocketEngine * const q = q_func();
-
1080 if (!q->isValid()) {
partially evaluated: !q->isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:154611
0-154611
1081 qWarning("QNativeSocketEngine::nativeRead: Invalid socket");
never executed (the execution status of this line is deduced): QMessageLogger("socket/qnativesocketengine_unix.cpp", 1081, __PRETTY_FUNCTION__).warning("QNativeSocketEngine::nativeRead: Invalid socket");
-
1082 return -1;
never executed: return -1;
0
1083 } -
1084 -
1085 ssize_t r = 0;
executed (the execution status of this line is deduced): ssize_t r = 0;
-
1086 r = qt_safe_read(socketDescriptor, data, maxSize);
executed (the execution status of this line is deduced): r = qt_safe_read(socketDescriptor, data, maxSize);
-
1087 -
1088 if (r < 0) {
evaluated: r < 0
TRUEFALSE
yes
Evaluation Count:5280
yes
Evaluation Count:149331
5280-149331
1089 r = -1;
executed (the execution status of this line is deduced): r = -1;
-
1090 switch (errno) { -
1091#if EWOULDBLOCK-0 && EWOULDBLOCK != EAGAIN -
1092 case EWOULDBLOCK: -
1093#endif -
1094 case EAGAIN: -
1095 // No data was available for reading -
1096 r = -2;
executed (the execution status of this line is deduced): r = -2;
-
1097 break;
executed: break;
Execution Count:5263
5263
1098 case EBADF: -
1099 case EINVAL: -
1100 case EIO: -
1101 //error string is now set in read(), not here in nativeRead() -
1102 break;
never executed: break;
0
1103 case ECONNRESET: -
1104#if defined(Q_OS_VXWORKS) -
1105 case ESHUTDOWN: -
1106#endif -
1107 r = 0;
executed (the execution status of this line is deduced): r = 0;
-
1108 break;
executed: break;
Execution Count:17
17
1109 default: -
1110 break;
never executed: break;
0
1111 } -
1112 }
executed: }
Execution Count:5280
5280
1113 -
1114#if defined (QNATIVESOCKETENGINE_DEBUG) -
1115 qDebug("QNativeSocketEnginePrivate::nativeRead(%p \"%s\", %llu) == %i", -
1116 data, qt_prettyDebug(data, qMin(r, ssize_t(16)), r).data(), -
1117 maxSize, r); -
1118#endif -
1119 -
1120 return qint64(r);
executed: return qint64(r);
Execution Count:154611
154611
1121} -
1122 -
1123int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool selectForRead) const -
1124{ -
1125 fd_set fds;
executed (the execution status of this line is deduced): fd_set fds;
-
1126 FD_ZERO(&fds);
executed: }
Execution Count:703
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:703
0-703
1127 FD_SET(socketDescriptor, &fds);
executed (the execution status of this line is deduced): (((&fds)->fds_bits)[((socketDescriptor) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((socketDescriptor) % (8 * (int) sizeof (__fd_mask)))));
-
1128 -
1129 struct timeval tv;
executed (the execution status of this line is deduced): struct timeval tv;
-
1130 tv.tv_sec = timeout / 1000;
executed (the execution status of this line is deduced): tv.tv_sec = timeout / 1000;
-
1131 tv.tv_usec = (timeout % 1000) * 1000;
executed (the execution status of this line is deduced): tv.tv_usec = (timeout % 1000) * 1000;
-
1132 -
1133 int retval;
executed (the execution status of this line is deduced): int retval;
-
1134 if (selectForRead)
evaluated: selectForRead
TRUEFALSE
yes
Evaluation Count:282
yes
Evaluation Count:421
282-421
1135 retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
executed: retval = qt_safe_select(socketDescriptor + 1, &fds, 0, 0, timeout < 0 ? 0 : &tv);
Execution Count:282
282
1136 else -
1137 retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
executed: retval = qt_safe_select(socketDescriptor + 1, 0, &fds, 0, timeout < 0 ? 0 : &tv);
Execution Count:421
421
1138 -
1139 return retval;
executed: return retval;
Execution Count:703
703
1140} -
1141 -
1142int QNativeSocketEnginePrivate::nativeSelect(int timeout, bool checkRead, bool checkWrite, -
1143 bool *selectForRead, bool *selectForWrite) const -
1144{ -
1145 fd_set fdread;
executed (the execution status of this line is deduced): fd_set fdread;
-
1146 FD_ZERO(&fdread);
executed: }
Execution Count:18314
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18314
0-18314
1147 if (checkRead)
partially evaluated: checkRead
TRUEFALSE
yes
Evaluation Count:18314
no
Evaluation Count:0
0-18314
1148 FD_SET(socketDescriptor, &fdread);
executed: (((&fdread)->fds_bits)[((socketDescriptor) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((socketDescriptor) % (8 * (int) sizeof (__fd_mask)))));
Execution Count:18314
18314
1149 -
1150 fd_set fdwrite;
executed (the execution status of this line is deduced): fd_set fdwrite;
-
1151 FD_ZERO(&fdwrite);
executed: }
Execution Count:18314
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18314
0-18314
1152 if (checkWrite)
evaluated: checkWrite
TRUEFALSE
yes
Evaluation Count:5141
yes
Evaluation Count:13173
5141-13173
1153 FD_SET(socketDescriptor, &fdwrite);
executed: (((&fdwrite)->fds_bits)[((socketDescriptor) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((socketDescriptor) % (8 * (int) sizeof (__fd_mask)))));
Execution Count:5141
5141
1154 -
1155 struct timeval tv;
executed (the execution status of this line is deduced): struct timeval tv;
-
1156 tv.tv_sec = timeout / 1000;
executed (the execution status of this line is deduced): tv.tv_sec = timeout / 1000;
-
1157 tv.tv_usec = (timeout % 1000) * 1000;
executed (the execution status of this line is deduced): tv.tv_usec = (timeout % 1000) * 1000;
-
1158 -
1159 int ret;
executed (the execution status of this line is deduced): int ret;
-
1160 ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
executed (the execution status of this line is deduced): ret = qt_safe_select(socketDescriptor + 1, &fdread, &fdwrite, 0, timeout < 0 ? 0 : &tv);
-
1161 -
1162 if (ret <= 0)
evaluated: ret <= 0
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:18284
31-18284
1163 return ret;
executed: return ret;
Execution Count:31
31
1164 *selectForRead = FD_ISSET(socketDescriptor, &fdread);
executed (the execution status of this line is deduced): *selectForRead = ((((&fdread)->fds_bits)[((socketDescriptor) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((socketDescriptor) % (8 * (int) sizeof (__fd_mask))))) != 0);
-
1165 *selectForWrite = FD_ISSET(socketDescriptor, &fdwrite);
executed (the execution status of this line is deduced): *selectForWrite = ((((&fdwrite)->fds_bits)[((socketDescriptor) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((socketDescriptor) % (8 * (int) sizeof (__fd_mask))))) != 0);
-
1166 -
1167 return ret;
executed: return ret;
Execution Count:18284
18284
1168} -
1169 -
1170QT_END_NAMESPACE -
1171 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial