| Line | Source Code | Coverage | 
|---|
| 1 | /****************************************************************************  | - | 
| 2 | **  | - | 
| 3 | ** Copyright (C) 2012 Intel Corporation  | - | 
| 4 | ** Contact: http://www.qt-project.org/legal  | - | 
| 5 | **  | - | 
| 6 | ** This file is part of the QtCore 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 | #include "qipaddress_p.h"  | - | 
| 43 | #include "private/qlocale_tools_p.h"  | - | 
| 44 | #include "qvarlengtharray.h"  | - | 
| 45 |   | - | 
| 46 | QT_BEGIN_NAMESPACE  | - | 
| 47 | namespace QIPAddressUtils {  | - | 
| 48 |   | - | 
| 49 | static QString number(quint8 val, int base = 10)  | - | 
| 50 | {  | - | 
| 51 |     QChar zero(0x30); executed (the execution status of this line is deduced):  QChar zero(0x30);  | - | 
| 52 |     return val ? qulltoa(val, base, zero) : zero; executed:  return val ? qulltoa(val, base, zero) : zero;Execution Count:3480   | 3480 | 
| 53 | }  | - | 
| 54 |   | - | 
| 55 | typedef QVarLengthArray<char, 64> Buffer;  | - | 
| 56 | static bool checkedToAscii(Buffer &buffer, const QChar *begin, const QChar *end)  | - | 
| 57 | {  | - | 
| 58 |     const ushort *const ubegin = reinterpret_cast<const ushort *>(begin); executed (the execution status of this line is deduced):  const ushort *const ubegin = reinterpret_cast<const ushort *>(begin);  | - | 
| 59 |     const ushort *const uend = reinterpret_cast<const ushort *>(end); executed (the execution status of this line is deduced):  const ushort *const uend = reinterpret_cast<const ushort *>(end);  | - | 
| 60 |     const ushort *src = ubegin; executed (the execution status of this line is deduced):  const ushort *src = ubegin;  | - | 
| 61 |   | - | 
| 62 |     buffer.resize(uend - ubegin + 1); executed (the execution status of this line is deduced):  buffer.resize(uend - ubegin + 1);  | - | 
| 63 |     char *dst = buffer.data(); executed (the execution status of this line is deduced):  char *dst = buffer.data();  | - | 
| 64 |   | - | 
| 65 |     while (src != uend) { evaluated:  src != uend| yes Evaluation Count:262201  | yes Evaluation Count:17475  |  
   | 17475-262201 | 
| 66 |         if (*src >= 0x7f) evaluated:  *src >= 0x7f| yes Evaluation Count:199  | yes Evaluation Count:262034  |  
   | 199-262034 | 
| 67 |             return false; executed:  return false;Execution Count:199   | 199 | 
| 68 |         *dst++ = *src++; executed (the execution status of this line is deduced):  *dst++ = *src++;  | - | 
| 69 |     } executed:  }Execution Count:262069   | 262069 | 
| 70 |     *dst = '\0'; executed (the execution status of this line is deduced):  *dst = '\0';  | - | 
| 71 |     return true; executed:  return true;Execution Count:17476   | 17476 | 
| 72 | }  | - | 
| 73 |   | - | 
| 74 | static bool parseIp4Internal(IPv4Address &address, const char *ptr, bool acceptLeadingZero);  | - | 
| 75 | bool parseIp4(IPv4Address &address, const QChar *begin, const QChar *end)  | - | 
| 76 | {  | - | 
| 77 |     Q_ASSERT(begin != end); executed (the execution status of this line is deduced):  qt_noop();  | - | 
| 78 |     Buffer buffer; executed (the execution status of this line is deduced):  Buffer buffer;  | - | 
| 79 |     if (!checkedToAscii(buffer, begin, end)) evaluated:  !checkedToAscii(buffer, begin, end)| yes Evaluation Count:199  | yes Evaluation Count:17140  |  
   | 199-17140 | 
| 80 |         return false; executed:  return false;Execution Count:199   | 199 | 
| 81 |   | - | 
| 82 |     const char *ptr = buffer.data(); executed (the execution status of this line is deduced):  const char *ptr = buffer.data();  | - | 
| 83 |     return parseIp4Internal(address, ptr, true); executed:  return parseIp4Internal(address, ptr, true);Execution Count:17140   | 17140 | 
| 84 | }  | - | 
| 85 |   | - | 
| 86 | static bool parseIp4Internal(IPv4Address &address, const char *ptr, bool acceptLeadingZero)  | - | 
| 87 | {  | - | 
| 88 |     address = 0; executed (the execution status of this line is deduced):  address = 0;  | - | 
| 89 |     int dotCount = 0; executed (the execution status of this line is deduced):  int dotCount = 0;  | - | 
| 90 |     while (dotCount < 4) { partially evaluated:  dotCount < 4| yes Evaluation Count:22535  | no Evaluation Count:0  |  
   | 0-22535 | 
| 91 |         if (!acceptLeadingZero && *ptr == '0' && evaluated:  !acceptLeadingZero| yes Evaluation Count:148  | yes Evaluation Count:22383  |  
  evaluated:  *ptr == '0'| yes Evaluation Count:32  | yes Evaluation Count:116  |  
   | 32-22383 | 
| 92 |                 ptr[1] != '.' && ptr[1] != '\0') evaluated:  ptr[1] != '.'| yes Evaluation Count:3  | yes Evaluation Count:29  |  
  partially evaluated:  ptr[1] != '\0'| no Evaluation Count:0  | yes Evaluation Count:3  |  
   | 0-29 | 
| 93 |             return false; never executed: return false;  | 0 | 
| 94 |   | - | 
| 95 |         const char *endptr; executed (the execution status of this line is deduced):  const char *endptr;  | - | 
| 96 |         bool ok; executed (the execution status of this line is deduced):  bool ok;  | - | 
| 97 |         quint64 ll = qstrtoull(ptr, &endptr, 0, &ok); executed (the execution status of this line is deduced):  quint64 ll = qstrtoull(ptr, &endptr, 0, &ok);  | - | 
| 98 |         quint32 x = ll; executed (the execution status of this line is deduced):  quint32 x = ll;  | - | 
| 99 |         if (!ok || endptr == ptr || ll != x) evaluated:  !ok| yes Evaluation Count:15311  | yes Evaluation Count:7137  |  
  partially evaluated:  endptr == ptr| no Evaluation Count:0  | yes Evaluation Count:7137  |  
  partially evaluated:  ll != x| no Evaluation Count:0  | yes Evaluation Count:7137  |  
   | 0-15311 | 
| 100 |             return false; executed:  return false;Execution Count:15298   | 15298 | 
| 101 |   | - | 
| 102 |         if (*endptr == '.' || dotCount == 3) { evaluated:  *endptr == '.'| yes Evaluation Count:5317  | yes Evaluation Count:1821  |  
  evaluated:  dotCount == 3| yes Evaluation Count:1770  | yes Evaluation Count:51  |  
   | 51-5317 | 
| 103 |             if (x & ~0xff) evaluated:  x & ~0xff| yes Evaluation Count:3  | yes Evaluation Count:7083  |  
   | 3-7083 | 
| 104 |                 return false; executed:  return false;Execution Count:3   | 3 | 
| 105 |             address <<= 8; executed (the execution status of this line is deduced):  address <<= 8;  | - | 
| 106 |         } else if (dotCount == 2) { executed:  }Execution Count:7083  evaluated:  dotCount == 2| yes Evaluation Count:12  | yes Evaluation Count:39  |  
   | 12-7083 | 
| 107 |             if (x & ~0xffff) partially evaluated:  x & ~0xffff| no Evaluation Count:0  | yes Evaluation Count:12  |  
   | 0-12 | 
| 108 |                 return false; never executed: return false;  | 0 | 
| 109 |             address <<= 16; executed (the execution status of this line is deduced):  address <<= 16;  | - | 
| 110 |         } else if (dotCount == 1) { executed:  }Execution Count:12  evaluated:  dotCount == 1| yes Evaluation Count:14  | yes Evaluation Count:25  |  
   | 12-25 | 
| 111 |             if (x & ~0xffffff) partially evaluated:  x & ~0xffffff| no Evaluation Count:0  | yes Evaluation Count:14  |  
   | 0-14 | 
| 112 |                 return false; never executed: return false;  | 0 | 
| 113 |             address <<= 24; executed (the execution status of this line is deduced):  address <<= 24;  | - | 
| 114 |         } executed:  }Execution Count:14   | 14 | 
| 115 |         address |= x; executed (the execution status of this line is deduced):  address |= x;  | - | 
| 116 |   | - | 
| 117 |         if (dotCount == 3 && *endptr != '\0') evaluated:  dotCount == 3| yes Evaluation Count:1776  | yes Evaluation Count:5359  |  
  evaluated:  *endptr != '\0'| yes Evaluation Count:19  | yes Evaluation Count:1757  |  
   | 19-5359 | 
| 118 |             return false; executed:  return false;Execution Count:19   | 19 | 
| 119 |         else if (dotCount == 3 || *endptr == '\0') evaluated:  dotCount == 3| yes Evaluation Count:1757  | yes Evaluation Count:5359  |  
  evaluated:  *endptr == '\0'| yes Evaluation Count:5  | yes Evaluation Count:5354  |  
   | 5-5359 | 
| 120 |             return true; executed:  return true;Execution Count:1762   | 1762 | 
| 121 |         ++dotCount; executed (the execution status of this line is deduced):  ++dotCount;  | - | 
| 122 |         ptr = endptr + 1; executed (the execution status of this line is deduced):  ptr = endptr + 1;  | - | 
| 123 |     } executed:  }Execution Count:5354   | 5354 | 
| 124 |     return false; never executed: return false;  | 0 | 
| 125 | }  | - | 
| 126 |   | - | 
| 127 | void toString(QString &appendTo, IPv4Address address)  | - | 
| 128 | {  | - | 
| 129 |     // reconstructing is easy  | - | 
| 130 |     // use the fast operator% that pre-calculates the size  | - | 
| 131 |     appendTo += number(address >> 24) executed (the execution status of this line is deduced):  appendTo += number(address >> 24)  | - | 
| 132 |                 % QLatin1Char('.') executed (the execution status of this line is deduced):  % QLatin1Char('.')  | - | 
| 133 |                 % number(address >> 16) executed (the execution status of this line is deduced):  % number(address >> 16)  | - | 
| 134 |                 % QLatin1Char('.') executed (the execution status of this line is deduced):  % QLatin1Char('.')  | - | 
| 135 |                 % number(address >> 8) executed (the execution status of this line is deduced):  % number(address >> 8)  | - | 
| 136 |                 % QLatin1Char('.') executed (the execution status of this line is deduced):  % QLatin1Char('.')  | - | 
| 137 |                 % number(address); executed (the execution status of this line is deduced):  % number(address);  | - | 
| 138 | } executed:  }Execution Count:870   | 870 | 
| 139 |   | - | 
| 140 | bool parseIp6(IPv6Address &address, const QChar *begin, const QChar *end)  | - | 
| 141 | {  | - | 
| 142 |     Q_ASSERT(begin != end); executed (the execution status of this line is deduced):  qt_noop();  | - | 
| 143 |     Buffer buffer; executed (the execution status of this line is deduced):  Buffer buffer;  | - | 
| 144 |     if (!checkedToAscii(buffer, begin, end)) partially evaluated:  !checkedToAscii(buffer, begin, end)| no Evaluation Count:0  | yes Evaluation Count:336  |  
   | 0-336 | 
| 145 |         return false; never executed: return false;  | 0 | 
| 146 |   | - | 
| 147 |     const char *ptr = buffer.data(); executed (the execution status of this line is deduced):  const char *ptr = buffer.data();  | - | 
| 148 |   | - | 
| 149 |     // count the colons  | - | 
| 150 |     int colonCount = 0; executed (the execution status of this line is deduced):  int colonCount = 0;  | - | 
| 151 |     int dotCount = 0; executed (the execution status of this line is deduced):  int dotCount = 0;  | - | 
| 152 |     while (*ptr) { evaluated:  *ptr| yes Evaluation Count:5194  | yes Evaluation Count:336  |  
   | 336-5194 | 
| 153 |         if (*ptr == ':') evaluated:  *ptr == ':'| yes Evaluation Count:1312  | yes Evaluation Count:3882  |  
   | 1312-3882 | 
| 154 |             ++colonCount; executed:  ++colonCount;Execution Count:1312   | 1312 | 
| 155 |         if (*ptr == '.') evaluated:  *ptr == '.'| yes Evaluation Count:165  | yes Evaluation Count:5029  |  
   | 165-5029 | 
| 156 |             ++dotCount; executed:  ++dotCount;Execution Count:165   | 165 | 
| 157 |         ++ptr; executed (the execution status of this line is deduced):  ++ptr;  | - | 
| 158 |     } executed:  }Execution Count:5194   | 5194 | 
| 159 |     // IPv4-in-IPv6 addresses are stricter in what they accept  | - | 
| 160 |     if (dotCount != 0 && dotCount != 3) evaluated:  dotCount != 0| yes Evaluation Count:55  | yes Evaluation Count:281  |  
  evaluated:  dotCount != 3| yes Evaluation Count:5  | yes Evaluation Count:50  |  
   | 5-281 | 
| 161 |         return false; executed:  return false;Execution Count:5   | 5 | 
| 162 |   | - | 
| 163 |     memset(address, 0, sizeof address); executed (the execution status of this line is deduced):  memset(address, 0, sizeof address);  | - | 
| 164 |     if (colonCount == 2 && end - begin == 2) // "::" evaluated:  colonCount == 2| yes Evaluation Count:123  | yes Evaluation Count:208  |  
  evaluated:  end - begin == 2| yes Evaluation Count:14  | yes Evaluation Count:109  |  
   | 14-208 | 
| 165 |         return true; executed:  return true;Execution Count:14   | 14 | 
| 166 |   | - | 
| 167 |     // if there's a double colon ("::"), this is how many zeroes it means  | - | 
| 168 |     int zeroWordsToFill; executed (the execution status of this line is deduced):  int zeroWordsToFill;  | - | 
| 169 |     ptr = buffer.data(); executed (the execution status of this line is deduced):  ptr = buffer.data();  | - | 
| 170 |   | - | 
| 171 |     // there are two cases where 8 colons are allowed: at the ends  | - | 
| 172 |     // so test that before the colon-count test  | - | 
| 173 |     if ((ptr[0] == ':' && ptr[1] == ':') || evaluated:  ptr[0] == ':'| yes Evaluation Count:115  | yes Evaluation Count:202  |  
  evaluated:  ptr[1] == ':'| yes Evaluation Count:110  | yes Evaluation Count:5  |  
   | 5-202 | 
| 174 |             (ptr[end - begin - 2] == ':' && ptr[end - begin - 1] == ':')) { evaluated:  ptr[end - begin - 2] == ':'| yes Evaluation Count:88  | yes Evaluation Count:119  |  
  evaluated:  ptr[end - begin - 1] == ':'| yes Evaluation Count:51  | yes Evaluation Count:37  |  
   | 37-119 | 
| 175 |         zeroWordsToFill = 9 - colonCount; executed (the execution status of this line is deduced):  zeroWordsToFill = 9 - colonCount;  | - | 
| 176 |     } else if (colonCount < 2 || colonCount > 7) { executed:  }Execution Count:161  evaluated:  colonCount < 2| yes Evaluation Count:12  | yes Evaluation Count:144  |  
  evaluated:  colonCount > 7| yes Evaluation Count:2  | yes Evaluation Count:142  |  
   | 2-161 | 
| 177 |         return false; executed:  return false;Execution Count:14   | 14 | 
| 178 |     } else {  | - | 
| 179 |         zeroWordsToFill = 8 - colonCount; executed (the execution status of this line is deduced):  zeroWordsToFill = 8 - colonCount;  | - | 
| 180 |     } executed:  }Execution Count:142   | 142 | 
| 181 |     if (dotCount) evaluated:  dotCount| yes Evaluation Count:47  | yes Evaluation Count:256  |  
   | 47-256 | 
| 182 |         --zeroWordsToFill; executed:  --zeroWordsToFill;Execution Count:47   | 47 | 
| 183 |   | - | 
| 184 |     int pos = 0; executed (the execution status of this line is deduced):  int pos = 0;  | - | 
| 185 |     while (pos < 15) { evaluated:  pos < 15| yes Evaluation Count:1349  | yes Evaluation Count:45  |  
   | 45-1349 | 
| 186 |         const char *endptr; executed (the execution status of this line is deduced):  const char *endptr;  | - | 
| 187 |         bool ok; executed (the execution status of this line is deduced):  bool ok;  | - | 
| 188 |         quint64 ll = qstrtoull(ptr, &endptr, 16, &ok); executed (the execution status of this line is deduced):  quint64 ll = qstrtoull(ptr, &endptr, 16, &ok);  | - | 
| 189 |         quint16 x = ll; executed (the execution status of this line is deduced):  quint16 x = ll;  | - | 
| 190 |   | - | 
| 191 |         if (ptr == endptr) { evaluated:  ptr == endptr| yes Evaluation Count:258  | yes Evaluation Count:1091  |  
   | 258-1091 | 
| 192 |             // empty field, we hope it's "::"  | - | 
| 193 |             if (zeroWordsToFill < 1) evaluated:  zeroWordsToFill < 1| yes Evaluation Count:23  | yes Evaluation Count:235  |  
   | 23-235 | 
| 194 |                 return false; executed:  return false;Execution Count:23   | 23 | 
| 195 |             if (pos == 0 || pos == colonCount * 2) { evaluated:  pos == 0| yes Evaluation Count:112  | yes Evaluation Count:123  |  
  partially evaluated:  pos == colonCount * 2| no Evaluation Count:0  | yes Evaluation Count:123  |  
   | 0-123 | 
| 196 |                 if (ptr[0] == '\0' || ptr[1] != ':') partially evaluated:  ptr[0] == '\0'| no Evaluation Count:0  | yes Evaluation Count:112  |  
  evaluated:  ptr[1] != ':'| yes Evaluation Count:2  | yes Evaluation Count:110  |  
   | 0-112 | 
| 197 |                     return false; executed:  return false;Execution Count:2   | 2 | 
| 198 |                 ++ptr; executed (the execution status of this line is deduced):  ++ptr;  | - | 
| 199 |             } executed:  }Execution Count:110   | 110 | 
| 200 |             pos += zeroWordsToFill * 2; executed (the execution status of this line is deduced):  pos += zeroWordsToFill * 2;  | - | 
| 201 |             zeroWordsToFill = 0; executed (the execution status of this line is deduced):  zeroWordsToFill = 0;  | - | 
| 202 |             ++ptr; executed (the execution status of this line is deduced):  ++ptr;  | - | 
| 203 |             continue; executed:  continue;Execution Count:233   | 233 | 
| 204 |         }  | - | 
| 205 |         if (!ok || ll != x) partially evaluated:  !ok| no Evaluation Count:0  | yes Evaluation Count:1091  |  
  evaluated:  ll != x| yes Evaluation Count:4  | yes Evaluation Count:1087  |  
   | 0-1091 | 
| 206 |             return false; executed:  return false;Execution Count:4   | 4 | 
| 207 |   | - | 
| 208 |         if (*endptr == '.') { evaluated:  *endptr == '.'| yes Evaluation Count:41  | yes Evaluation Count:1046  |  
   | 41-1046 | 
| 209 |             // this could be an IPv4 address  | - | 
| 210 |             // it's only valid in the last element  | - | 
| 211 |             if (pos != 12) evaluated:  pos != 12| yes Evaluation Count:4  | yes Evaluation Count:37  |  
   | 4-37 | 
| 212 |                 return false; executed:  return false;Execution Count:4   | 4 | 
| 213 |   | - | 
| 214 |             IPv4Address ip4; executed (the execution status of this line is deduced):  IPv4Address ip4;  | - | 
| 215 |             if (!parseIp4Internal(ip4, ptr, false)) partially evaluated:  !parseIp4Internal(ip4, ptr, false)| no Evaluation Count:0  | yes Evaluation Count:37  |  
   | 0-37 | 
| 216 |                 return false; never executed: return false;  | 0 | 
| 217 |   | - | 
| 218 |             address[12] = ip4 >> 24; executed (the execution status of this line is deduced):  address[12] = ip4 >> 24;  | - | 
| 219 |             address[13] = ip4 >> 16; executed (the execution status of this line is deduced):  address[13] = ip4 >> 16;  | - | 
| 220 |             address[14] = ip4 >> 8; executed (the execution status of this line is deduced):  address[14] = ip4 >> 8;  | - | 
| 221 |             address[15] = ip4; executed (the execution status of this line is deduced):  address[15] = ip4;  | - | 
| 222 |             return true; executed:  return true;Execution Count:37   | 37 | 
| 223 |         }  | - | 
| 224 |   | - | 
| 225 |         address[pos++] = x >> 8; executed (the execution status of this line is deduced):  address[pos++] = x >> 8;  | - | 
| 226 |         address[pos++] = x & 0xff; executed (the execution status of this line is deduced):  address[pos++] = x & 0xff;  | - | 
| 227 |   | - | 
| 228 |         if (*endptr == '\0') evaluated:  *endptr == '\0'| yes Evaluation Count:167  | yes Evaluation Count:879  |  
   | 167-879 | 
| 229 |             break; executed:  break;Execution Count:167   | 167 | 
| 230 |         if (*endptr != ':') evaluated:  *endptr != ':'| yes Evaluation Count:21  | yes Evaluation Count:858  |  
   | 21-858 | 
| 231 |             return false; executed:  return false;Execution Count:21   | 21 | 
| 232 |         ptr = endptr + 1; executed (the execution status of this line is deduced):  ptr = endptr + 1;  | - | 
| 233 |     } executed:  }Execution Count:858   | 858 | 
| 234 |     return pos == 16; executed:  return pos == 16;Execution Count:212   | 212 | 
| 235 | }  | - | 
| 236 |   | - | 
| 237 | static inline QChar toHex(uchar c)  | - | 
| 238 | {  | - | 
| 239 |     return ushort(c > 9 ? c + 'a' - 0xA : c + '0'); executed:  return ushort(c > 9 ? c + 'a' - 0xA : c + '0');Execution Count:2184   | 2184 | 
| 240 | }  | - | 
| 241 |   | - | 
| 242 | void toString(QString &appendTo, IPv6Address address)  | - | 
| 243 | {  | - | 
| 244 |     // the longest IPv6 address possible is:  | - | 
| 245 |     //   "1111:2222:3333:4444:5555:6666:255.255.255.255"  | - | 
| 246 |     // however, this function never generates that. The longest it does  | - | 
| 247 |     // generate without an IPv4 address is:  | - | 
| 248 |     //   "1111:2222:3333:4444:5555:6666:7777:8888"  | - | 
| 249 |     // and the longest with an IPv4 address is:  | - | 
| 250 |     //   "::ffff:255.255.255.255"  | - | 
| 251 |     static const int Ip6AddressMaxLen = sizeof "1111:2222:3333:4444:5555:6666:7777:8888";  | - | 
| 252 |     static const int Ip6WithIp4AddressMaxLen = sizeof "::ffff:255.255.255.255";  | - | 
| 253 |   | - | 
| 254 |     // check for the special cases  | - | 
| 255 |     const quint64 zeroes[] = { 0, 0 }; executed (the execution status of this line is deduced):  const quint64 zeroes[] = { 0, 0 };  | - | 
| 256 |     bool embeddedIp4 = false; executed (the execution status of this line is deduced):  bool embeddedIp4 = false;  | - | 
| 257 |   | - | 
| 258 |     // we consider embedded IPv4 for:  | - | 
| 259 |     //  ::ffff:x.x.x.x  | - | 
| 260 |     //  ::x.x.x.y  except if the x are 0 too  | - | 
| 261 |     if (memcmp(address, zeroes, 10) == 0) { evaluated:  memcmp(address, zeroes, 10) == 0| yes Evaluation Count:84  | yes Evaluation Count:133  |  
   | 84-133 | 
| 262 |         if (address[10] == 0xff && address[11] == 0xff) { evaluated:  address[10] == 0xff| yes Evaluation Count:17  | yes Evaluation Count:67  |  
  partially evaluated:  address[11] == 0xff| yes Evaluation Count:17  | no Evaluation Count:0  |  
   | 0-67 | 
| 263 |             embeddedIp4 = true; executed (the execution status of this line is deduced):  embeddedIp4 = true;  | - | 
| 264 |         } else if (address[10] == 0 && address[11] == 0) { executed:  }Execution Count:17  partially evaluated:  address[10] == 0| yes Evaluation Count:67  | no Evaluation Count:0  |  
  partially evaluated:  address[11] == 0| yes Evaluation Count:67  | no Evaluation Count:0  |  
   | 0-67 | 
| 265 |             if (address[12] != 0 || address[13] != 0 || address[14] != 0) { evaluated:  address[12] != 0| yes Evaluation Count:5  | yes Evaluation Count:62  |  
  partially evaluated:  address[13] != 0| no Evaluation Count:0  | yes Evaluation Count:62  |  
  partially evaluated:  address[14] != 0| no Evaluation Count:0  | yes Evaluation Count:62  |  
   | 0-62 | 
| 266 |                 embeddedIp4 = true; executed (the execution status of this line is deduced):  embeddedIp4 = true;  | - | 
| 267 |             } else if (address[15] == 0) { executed:  }Execution Count:5  evaluated:  address[15] == 0| yes Evaluation Count:31  | yes Evaluation Count:31  |  
   | 5-31 | 
| 268 |                 appendTo.append(QLatin1String("::")); executed (the execution status of this line is deduced):  appendTo.append(QLatin1String("::"));  | - | 
| 269 |                 return; executed:  return;Execution Count:31   | 31 | 
| 270 |             }  | - | 
| 271 |         }  | - | 
| 272 |     }  | - | 
| 273 |   | - | 
| 274 |     // QString::reserve doesn't shrink, so it's fine to us  | - | 
| 275 |     appendTo.reserve(appendTo.size() + executed (the execution status of this line is deduced):  appendTo.reserve(appendTo.size() +  | - | 
| 276 |                      (embeddedIp4 ? Ip6WithIp4AddressMaxLen : Ip6AddressMaxLen)); executed (the execution status of this line is deduced):  (embeddedIp4 ? Ip6WithIp4AddressMaxLen : Ip6AddressMaxLen));  | - | 
| 277 |   | - | 
| 278 |     // for finding where to place the "::"  | - | 
| 279 |     int zeroRunLength = 0; // in octets executed (the execution status of this line is deduced):  int zeroRunLength = 0;  | - | 
| 280 |     int zeroRunOffset = 0; // in octets executed (the execution status of this line is deduced):  int zeroRunOffset = 0;  | - | 
| 281 |     for (int i = 0; i < 16; i += 2) { evaluated:  i < 16| yes Evaluation Count:827  | yes Evaluation Count:186  |  
   | 186-827 | 
| 282 |         if (address[i] == 0 && address[i + 1] == 0) { evaluated:  address[i] == 0| yes Evaluation Count:438  | yes Evaluation Count:389  |  
  evaluated:  address[i + 1] == 0| yes Evaluation Count:196  | yes Evaluation Count:242  |  
   | 196-438 | 
| 283 |             // found a zero, scan forward to see how many more there are  | - | 
| 284 |             int j; executed (the execution status of this line is deduced):  int j;  | - | 
| 285 |             for (j = i; j < 16; j += 2) { evaluated:  j < 16| yes Evaluation Count:869  | yes Evaluation Count:43  |  
   | 43-869 | 
| 286 |                 if (address[j] != 0 || address[j+1] != 0) evaluated:  address[j] != 0| yes Evaluation Count:59  | yes Evaluation Count:810  |  
  evaluated:  address[j+1] != 0| yes Evaluation Count:94  | yes Evaluation Count:716  |  
   | 59-810 | 
| 287 |                     break; executed:  break;Execution Count:153   | 153 | 
| 288 |             } executed:  }Execution Count:716   | 716 | 
| 289 |   | - | 
| 290 |             if (j - i > zeroRunLength) { evaluated:  j - i > zeroRunLength| yes Evaluation Count:178  | yes Evaluation Count:18  |  
   | 18-178 | 
| 291 |                 zeroRunLength = j - i; executed (the execution status of this line is deduced):  zeroRunLength = j - i;  | - | 
| 292 |                 zeroRunOffset = i; executed (the execution status of this line is deduced):  zeroRunOffset = i;  | - | 
| 293 |                 i = j; executed (the execution status of this line is deduced):  i = j;  | - | 
| 294 |             } executed:  }Execution Count:178   | 178 | 
| 295 |         } executed:  }Execution Count:196   | 196 | 
| 296 |     } executed:  }Execution Count:827   | 827 | 
| 297 |   | - | 
| 298 |     const QChar colon = ushort(':'); executed (the execution status of this line is deduced):  const QChar colon = ushort(':');  | - | 
| 299 |     if (zeroRunLength < 4) evaluated:  zeroRunLength < 4| yes Evaluation Count:47  | yes Evaluation Count:139  |  
   | 47-139 | 
| 300 |         zeroRunOffset = -1; executed:  zeroRunOffset = -1;Execution Count:47   | 47 | 
| 301 |     else if (zeroRunOffset == 0) evaluated:  zeroRunOffset == 0| yes Evaluation Count:53  | yes Evaluation Count:86  |  
   | 53-86 | 
| 302 |         appendTo.append(colon); executed:  appendTo.append(colon);Execution Count:53   | 53 | 
| 303 |   | - | 
| 304 |     for (int i = 0; i < 16; i += 2) { evaluated:  i < 16| yes Evaluation Count:948  | yes Evaluation Count:164  |  
   | 164-948 | 
| 305 |         if (i == zeroRunOffset) { evaluated:  i == zeroRunOffset| yes Evaluation Count:139  | yes Evaluation Count:809  |  
   | 139-809 | 
| 306 |             appendTo.append(colon); executed (the execution status of this line is deduced):  appendTo.append(colon);  | - | 
| 307 |             i += zeroRunLength - 2; executed (the execution status of this line is deduced):  i += zeroRunLength - 2;  | - | 
| 308 |             continue; executed:  continue;Execution Count:139   | 139 | 
| 309 |         }  | - | 
| 310 |   | - | 
| 311 |         if (i == 12 && embeddedIp4) { evaluated:  i == 12| yes Evaluation Count:122  | yes Evaluation Count:687  |  
  evaluated:  embeddedIp4| yes Evaluation Count:22  | yes Evaluation Count:100  |  
   | 22-687 | 
| 312 |             IPv4Address ip4 = address[12] << 24 | executed (the execution status of this line is deduced):  IPv4Address ip4 = address[12] << 24 |  | - | 
| 313 |                               address[13] << 16 | executed (the execution status of this line is deduced):  address[13] << 16 |  | - | 
| 314 |                               address[14] << 8 | executed (the execution status of this line is deduced):  address[14] << 8 |  | - | 
| 315 |                               address[15]; executed (the execution status of this line is deduced):  address[15];  | - | 
| 316 |             toString(appendTo, ip4); executed (the execution status of this line is deduced):  toString(appendTo, ip4);  | - | 
| 317 |             return; executed:  return;Execution Count:22   | 22 | 
| 318 |         }  | - | 
| 319 |   | - | 
| 320 |         if (address[i]) { evaluated:  address[i]| yes Evaluation Count:408  | yes Evaluation Count:379  |  
   | 379-408 | 
| 321 |             if (address[i] >> 4) { evaluated:  address[i] >> 4| yes Evaluation Count:363  | yes Evaluation Count:45  |  
   | 45-363 | 
| 322 |                 appendTo.append(toHex(address[i] >> 4)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i] >> 4));  | - | 
| 323 |                 appendTo.append(toHex(address[i] & 0xf)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i] & 0xf));  | - | 
| 324 |                 appendTo.append(toHex(address[i + 1] >> 4)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i + 1] >> 4));  | - | 
| 325 |                 appendTo.append(toHex(address[i + 1] & 0xf)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i + 1] & 0xf));  | - | 
| 326 |             } else if (address[i] & 0xf) { executed:  }Execution Count:363  partially evaluated:  address[i] & 0xf| yes Evaluation Count:45  | no Evaluation Count:0  |  
   | 0-363 | 
| 327 |                 appendTo.append(toHex(address[i] & 0xf)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i] & 0xf));  | - | 
| 328 |                 appendTo.append(toHex(address[i + 1] >> 4)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i + 1] >> 4));  | - | 
| 329 |                 appendTo.append(toHex(address[i + 1] & 0xf)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i + 1] & 0xf));  | - | 
| 330 |             } executed:  }Execution Count:45   | 45 | 
| 331 |         } else if (address[i + 1] >> 4) { evaluated:  address[i + 1] >> 4| yes Evaluation Count:218  | yes Evaluation Count:161  |  
   | 161-218 | 
| 332 |             appendTo.append(toHex(address[i + 1] >> 4)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i + 1] >> 4));  | - | 
| 333 |             appendTo.append(toHex(address[i + 1] & 0xf)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i + 1] & 0xf));  | - | 
| 334 |         } else { executed:  }Execution Count:218   | 218 | 
| 335 |             appendTo.append(toHex(address[i + 1] & 0xf)); executed (the execution status of this line is deduced):  appendTo.append(toHex(address[i + 1] & 0xf));  | - | 
| 336 |         } executed:  }Execution Count:161   | 161 | 
| 337 |   | - | 
| 338 |         if (i != 14) evaluated:  i != 14| yes Evaluation Count:654  | yes Evaluation Count:133  |  
   | 133-654 | 
| 339 |             appendTo.append(colon); executed:  appendTo.append(colon);Execution Count:654   | 654 | 
| 340 |     } executed:  }Execution Count:787   | 787 | 
| 341 | } executed:  }Execution Count:164   | 164 | 
| 342 |   | - | 
| 343 | }  | - | 
| 344 | QT_END_NAMESPACE  | - | 
| 345 |   | - | 
 |  |  |