| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/plugin/quuid.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | template <class Char, class Integral> | - | ||||||||||||||||||
| 8 | void _q_toHex(Char *&dst, Integral value) | - | ||||||||||||||||||
| 9 | { | - | ||||||||||||||||||
| 10 | value = qToBigEndian(value); | - | ||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | const char* p = reinterpret_cast<const char*>(&value); | - | ||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | for (uint i = 0; i < sizeof(Integral)
| 14146-20576 | ||||||||||||||||||
| 15 | dst[0] = Char(QtMiscUtils::toHexLower((p[i] >> 4) & 0xf)); | - | ||||||||||||||||||
| 16 | dst[1] = Char(QtMiscUtils::toHexLower(p[i] & 0xf)); | - | ||||||||||||||||||
| 17 | } executed 20576 times by 4 tests: end of blockExecuted by:
| 20576 | ||||||||||||||||||
| 18 | } executed 14146 times by 4 tests: end of blockExecuted by:
| 14146 | ||||||||||||||||||
| 19 | - | |||||||||||||||||||
| 20 | template <class Char, class Integral> | - | ||||||||||||||||||
| 21 | bool _q_fromHex(const Char *&src, Integral &value) | - | ||||||||||||||||||
| 22 | { | - | ||||||||||||||||||
| 23 | value = 0; | - | ||||||||||||||||||
| 24 | - | |||||||||||||||||||
| 25 | for (uint i = 0; i < sizeof(Integral) * 2
| 269-810 | ||||||||||||||||||
| 26 | uint ch = *src++; | - | ||||||||||||||||||
| 27 | int tmp = QtMiscUtils::fromHex(ch); | - | ||||||||||||||||||
| 28 | if (tmp == -1
| 3-807 | ||||||||||||||||||
| 29 | return executed 3 times by 1 test: false;return false;Executed by:
executed 3 times by 1 test: return false;Executed by:
| 3 | ||||||||||||||||||
| 30 | - | |||||||||||||||||||
| 31 | value = value * 16 + tmp; | - | ||||||||||||||||||
| 32 | } executed 807 times by 2 tests: end of blockExecuted by:
| 807 | ||||||||||||||||||
| 33 | - | |||||||||||||||||||
| 34 | return executed 269 times by 2 tests: true;return true;Executed by:
executed 269 times by 2 tests: return true;Executed by:
| 269 | ||||||||||||||||||
| 35 | } | - | ||||||||||||||||||
| 36 | - | |||||||||||||||||||
| 37 | template <class Char> | - | ||||||||||||||||||
| 38 | void _q_uuidToHex(Char *&dst, const uint &d1, const ushort &d2, const ushort &d3, const uchar (&d4)[8]) | - | ||||||||||||||||||
| 39 | { | - | ||||||||||||||||||
| 40 | *dst++ = Char('{'); | - | ||||||||||||||||||
| 41 | _q_toHex(dst, d1); | - | ||||||||||||||||||
| 42 | *dst++ = Char('-'); | - | ||||||||||||||||||
| 43 | _q_toHex(dst, d2); | - | ||||||||||||||||||
| 44 | *dst++ = Char('-'); | - | ||||||||||||||||||
| 45 | _q_toHex(dst, d3); | - | ||||||||||||||||||
| 46 | *dst++ = Char('-'); | - | ||||||||||||||||||
| 47 | for (int i = 0; i < 2
| 1286-2572 | ||||||||||||||||||
| 48 | _q_toHex(dst, d4[i]); executed 2572 times by 4 tests: _q_toHex(dst, d4[i]);Executed by:
| 2572 | ||||||||||||||||||
| 49 | *dst++ = Char('-'); | - | ||||||||||||||||||
| 50 | for (int i = 2; i < 8
| 1286-7716 | ||||||||||||||||||
| 51 | _q_toHex(dst, d4[i]); executed 7716 times by 4 tests: _q_toHex(dst, d4[i]);Executed by:
| 7716 | ||||||||||||||||||
| 52 | *dst = Char('}'); | - | ||||||||||||||||||
| 53 | } executed 1286 times by 4 tests: end of blockExecuted by:
| 1286 | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | template <class Char> | - | ||||||||||||||||||
| 56 | bool _q_uuidFromHex(const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar (&d4)[8]) | - | ||||||||||||||||||
| 57 | { | - | ||||||||||||||||||
| 58 | if (*
| 9-19 | ||||||||||||||||||
| 59 | src++; executed 19 times by 2 tests: src++;Executed by:
| 19 | ||||||||||||||||||
| 60 | if (!_q_fromHex(src, d1)
| 1-27 | ||||||||||||||||||
| 61 | || *
| 0-27 | ||||||||||||||||||
| 62 | || !_q_fromHex(src, d2)
| 0-27 | ||||||||||||||||||
| 63 | || *
| 2-25 | ||||||||||||||||||
| 64 | || !_q_fromHex(src, d3)
| 1-24 | ||||||||||||||||||
| 65 | || *
| 0-24 | ||||||||||||||||||
| 66 | || !_q_fromHex(src, d4[0])
| 0-24 | ||||||||||||||||||
| 67 | || !_q_fromHex(src, d4[1])
| 0-24 | ||||||||||||||||||
| 68 | || *
| 0-24 | ||||||||||||||||||
| 69 | || !_q_fromHex(src, d4[2])
| 0-24 | ||||||||||||||||||
| 70 | || !_q_fromHex(src, d4[3])
| 0-24 | ||||||||||||||||||
| 71 | || !_q_fromHex(src, d4[4])
| 0-24 | ||||||||||||||||||
| 72 | || !_q_fromHex(src, d4[5])
| 0-24 | ||||||||||||||||||
| 73 | || !_q_fromHex(src, d4[6])
| 0-24 | ||||||||||||||||||
| 74 | || !_q_fromHex(src, d4[7])
| 1-23 | ||||||||||||||||||
| 75 | return executed 5 times by 1 test: false;return false;Executed by:
executed 5 times by 1 test: return false;Executed by:
| 5 | ||||||||||||||||||
| 76 | } | - | ||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | return executed 23 times by 2 tests: true;return true;Executed by:
executed 23 times by 2 tests: return true;Executed by:
| 23 | ||||||||||||||||||
| 79 | } | - | ||||||||||||||||||
| 80 | - | |||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | static QUuid createFromName(const QUuid &ns, const QByteArray &baseData, QCryptographicHash::Algorithm algorithm, int version) | - | ||||||||||||||||||
| 83 | { | - | ||||||||||||||||||
| 84 | QByteArray hashResult; | - | ||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | { | - | ||||||||||||||||||
| 88 | QCryptographicHash hash(algorithm); | - | ||||||||||||||||||
| 89 | hash.addData(ns.toRfc4122()); | - | ||||||||||||||||||
| 90 | hash.addData(baseData); | - | ||||||||||||||||||
| 91 | hashResult = hash.result(); | - | ||||||||||||||||||
| 92 | } | - | ||||||||||||||||||
| 93 | hashResult.resize(16); | - | ||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | QUuid result = QUuid::fromRfc4122(hashResult); | - | ||||||||||||||||||
| 96 | - | |||||||||||||||||||
| 97 | result.data3 &= 0x0FFF; | - | ||||||||||||||||||
| 98 | result.data3 |= (version << 12); | - | ||||||||||||||||||
| 99 | result.data4[0] &= 0x3F; | - | ||||||||||||||||||
| 100 | result.data4[0] |= 0x80; | - | ||||||||||||||||||
| 101 | - | |||||||||||||||||||
| 102 | return executed 4 times by 1 test: result;return result;Executed by:
executed 4 times by 1 test: return result;Executed by:
| 4 | ||||||||||||||||||
| 103 | } | - | ||||||||||||||||||
| 104 | QUuid::QUuid(const QString &text) | - | ||||||||||||||||||
| 105 | { | - | ||||||||||||||||||
| 106 | if (text.length() < 36
| 0-10 | ||||||||||||||||||
| 107 | *this = QUuid(); | - | ||||||||||||||||||
| 108 | return; never executed: return; | 0 | ||||||||||||||||||
| 109 | } | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | const ushort *data = reinterpret_cast<const ushort *>(text.unicode()); | - | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | if (*
| 1-8 | ||||||||||||||||||
| 114 | *this = QUuid(); | - | ||||||||||||||||||
| 115 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||
| 116 | } | - | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | if (!_q_uuidFromHex(data, data1, data2, data3, data4)
| 0-9 | ||||||||||||||||||
| 119 | *this = QUuid(); | - | ||||||||||||||||||
| 120 | return; never executed: return; | 0 | ||||||||||||||||||
| 121 | } | - | ||||||||||||||||||
| 122 | } executed 9 times by 2 tests: end of blockExecuted by:
| 9 | ||||||||||||||||||
| 123 | - | |||||||||||||||||||
| 124 | - | |||||||||||||||||||
| 125 | - | |||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | QUuid::QUuid(const char *text) | - | ||||||||||||||||||
| 128 | { | - | ||||||||||||||||||
| 129 | if (!text
| 1-14 | ||||||||||||||||||
| 130 | *this = QUuid(); | - | ||||||||||||||||||
| 131 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||
| 132 | } | - | ||||||||||||||||||
| 133 | - | |||||||||||||||||||
| 134 | if (!_q_uuidFromHex(text, data1, data2, data3, data4)
| 5-9 | ||||||||||||||||||
| 135 | *this = QUuid(); | - | ||||||||||||||||||
| 136 | return; executed 5 times by 1 test: return;Executed by:
| 5 | ||||||||||||||||||
| 137 | } | - | ||||||||||||||||||
| 138 | } executed 9 times by 2 tests: end of blockExecuted by:
| 9 | ||||||||||||||||||
| 139 | QUuid::QUuid(const QByteArray &text) | - | ||||||||||||||||||
| 140 | { | - | ||||||||||||||||||
| 141 | if (text.length() < 36
| 0-6 | ||||||||||||||||||
| 142 | *this = QUuid(); | - | ||||||||||||||||||
| 143 | return; never executed: return; | 0 | ||||||||||||||||||
| 144 | } | - | ||||||||||||||||||
| 145 | - | |||||||||||||||||||
| 146 | const char *data = text.constData(); | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | if (*
| 1-4 | ||||||||||||||||||
| 149 | *this = QUuid(); | - | ||||||||||||||||||
| 150 | return; executed 1 time by 1 test: return;Executed by:
| 1 | ||||||||||||||||||
| 151 | } | - | ||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | if (!_q_uuidFromHex(data, data1, data2, data3, data4)
| 0-5 | ||||||||||||||||||
| 154 | *this = QUuid(); | - | ||||||||||||||||||
| 155 | return; never executed: return; | 0 | ||||||||||||||||||
| 156 | } | - | ||||||||||||||||||
| 157 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||
| 158 | QUuid QUuid::createUuidV3(const QUuid &ns, const QByteArray &baseData) | - | ||||||||||||||||||
| 159 | { | - | ||||||||||||||||||
| 160 | return executed 2 times by 1 test: createFromName(ns, baseData, QCryptographicHash::Md5, 3);return createFromName(ns, baseData, QCryptographicHash::Md5, 3);Executed by:
executed 2 times by 1 test: return createFromName(ns, baseData, QCryptographicHash::Md5, 3);Executed by:
| 2 | ||||||||||||||||||
| 161 | } | - | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | QUuid QUuid::createUuidV5(const QUuid &ns, const QByteArray &baseData) | - | ||||||||||||||||||
| 164 | { | - | ||||||||||||||||||
| 165 | return executed 2 times by 1 test: createFromName(ns, baseData, QCryptographicHash::Sha1, 5);return createFromName(ns, baseData, QCryptographicHash::Sha1, 5);Executed by:
executed 2 times by 1 test: return createFromName(ns, baseData, QCryptographicHash::Sha1, 5);Executed by:
| 2 | ||||||||||||||||||
| 166 | } | - | ||||||||||||||||||
| 167 | QUuid QUuid::fromRfc4122(const QByteArray &bytes) | - | ||||||||||||||||||
| 168 | { | - | ||||||||||||||||||
| 169 | if (bytes.isEmpty()
| 0-10 | ||||||||||||||||||
| 170 | return never executed: QUuid();return QUuid();never executed: return QUuid(); | 0 | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | uint d1; | - | ||||||||||||||||||
| 173 | ushort d2, d3; | - | ||||||||||||||||||
| 174 | uchar d4[8]; | - | ||||||||||||||||||
| 175 | - | |||||||||||||||||||
| 176 | const uchar *data = reinterpret_cast<const uchar *>(bytes.constData()); | - | ||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | d1 = qFromBigEndian<quint32>(data); | - | ||||||||||||||||||
| 179 | data += sizeof(quint32); | - | ||||||||||||||||||
| 180 | d2 = qFromBigEndian<quint16>(data); | - | ||||||||||||||||||
| 181 | data += sizeof(quint16); | - | ||||||||||||||||||
| 182 | d3 = qFromBigEndian<quint16>(data); | - | ||||||||||||||||||
| 183 | data += sizeof(quint16); | - | ||||||||||||||||||
| 184 | - | |||||||||||||||||||
| 185 | for (int i = 0; i < 8
| 10-80 | ||||||||||||||||||
| 186 | d4[i] = *(data); | - | ||||||||||||||||||
| 187 | data++; | - | ||||||||||||||||||
| 188 | } executed 80 times by 3 tests: end of blockExecuted by:
| 80 | ||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | return executed 10 times by 3 tests: QUuid(d1, d2, d3, d4[0], d4[1], d4[2], d4[3], d4[4], d4[5], d4[6], d4[7]);return QUuid(d1, d2, d3, d4[0], d4[1], d4[2], d4[3], d4[4], d4[5], d4[6], d4[7]);Executed by:
executed 10 times by 3 tests: return QUuid(d1, d2, d3, d4[0], d4[1], d4[2], d4[3], d4[4], d4[5], d4[6], d4[7]);Executed by:
| 10 | ||||||||||||||||||
| 191 | } | - | ||||||||||||||||||
| 192 | QString QUuid::toString() const | - | ||||||||||||||||||
| 193 | { | - | ||||||||||||||||||
| 194 | QString result(38, Qt::Uninitialized); | - | ||||||||||||||||||
| 195 | ushort *data = (ushort *)result.data(); | - | ||||||||||||||||||
| 196 | - | |||||||||||||||||||
| 197 | _q_uuidToHex(data, data1, data2, data3, data4); | - | ||||||||||||||||||
| 198 | - | |||||||||||||||||||
| 199 | return executed 34 times by 3 tests: result;return result;Executed by:
executed 34 times by 3 tests: return result;Executed by:
| 34 | ||||||||||||||||||
| 200 | } | - | ||||||||||||||||||
| 201 | QByteArray QUuid::toByteArray() const | - | ||||||||||||||||||
| 202 | { | - | ||||||||||||||||||
| 203 | QByteArray result(38, Qt::Uninitialized); | - | ||||||||||||||||||
| 204 | char *data = result.data(); | - | ||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | _q_uuidToHex(data, data1, data2, data3, data4); | - | ||||||||||||||||||
| 207 | - | |||||||||||||||||||
| 208 | return executed 1252 times by 2 tests: result;return result;Executed by:
executed 1252 times by 2 tests: return result;Executed by:
| 1252 | ||||||||||||||||||
| 209 | } | - | ||||||||||||||||||
| 210 | QByteArray QUuid::toRfc4122() const | - | ||||||||||||||||||
| 211 | { | - | ||||||||||||||||||
| 212 | - | |||||||||||||||||||
| 213 | QByteArray bytes(16, Qt::Uninitialized); | - | ||||||||||||||||||
| 214 | uchar *data = reinterpret_cast<uchar*>(bytes.data()); | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | qToBigEndian(data1, data); | - | ||||||||||||||||||
| 217 | data += sizeof(quint32); | - | ||||||||||||||||||
| 218 | qToBigEndian(data2, data); | - | ||||||||||||||||||
| 219 | data += sizeof(quint16); | - | ||||||||||||||||||
| 220 | qToBigEndian(data3, data); | - | ||||||||||||||||||
| 221 | data += sizeof(quint16); | - | ||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | for (int i = 0; i < 8
| 9-72 | ||||||||||||||||||
| 224 | *(data) = data4[i]; | - | ||||||||||||||||||
| 225 | data++; | - | ||||||||||||||||||
| 226 | } executed 72 times by 3 tests: end of blockExecuted by:
| 72 | ||||||||||||||||||
| 227 | - | |||||||||||||||||||
| 228 | return executed 9 times by 3 tests: bytes;return bytes;Executed by:
executed 9 times by 3 tests: return bytes;Executed by:
| 9 | ||||||||||||||||||
| 229 | } | - | ||||||||||||||||||
| 230 | - | |||||||||||||||||||
| 231 | - | |||||||||||||||||||
| 232 | - | |||||||||||||||||||
| 233 | - | |||||||||||||||||||
| 234 | - | |||||||||||||||||||
| 235 | - | |||||||||||||||||||
| 236 | QDataStream &operator<<(QDataStream &s, const QUuid &id) | - | ||||||||||||||||||
| 237 | { | - | ||||||||||||||||||
| 238 | QByteArray bytes; | - | ||||||||||||||||||
| 239 | if (s.byteOrder() == QDataStream::BigEndian
| 1-3 | ||||||||||||||||||
| 240 | bytes = id.toRfc4122(); | - | ||||||||||||||||||
| 241 | } executed 3 times by 3 tests: else {end of blockExecuted by:
| 3 | ||||||||||||||||||
| 242 | - | |||||||||||||||||||
| 243 | bytes = QByteArray(16, Qt::Uninitialized); | - | ||||||||||||||||||
| 244 | uchar *data = reinterpret_cast<uchar*>(bytes.data()); | - | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | qToLittleEndian(id.data1, data); | - | ||||||||||||||||||
| 247 | data += sizeof(quint32); | - | ||||||||||||||||||
| 248 | qToLittleEndian(id.data2, data); | - | ||||||||||||||||||
| 249 | data += sizeof(quint16); | - | ||||||||||||||||||
| 250 | qToLittleEndian(id.data3, data); | - | ||||||||||||||||||
| 251 | data += sizeof(quint16); | - | ||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | for (int i = 0; i < 8
| 1-8 | ||||||||||||||||||
| 254 | *(data) = id.data4[i]; | - | ||||||||||||||||||
| 255 | data++; | - | ||||||||||||||||||
| 256 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 257 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 258 | - | |||||||||||||||||||
| 259 | if (s.writeRawData(bytes.data(), 16) != 16
| 0-4 | ||||||||||||||||||
| 260 | s.setStatus(QDataStream::WriteFailed); | - | ||||||||||||||||||
| 261 | } never executed: end of block | 0 | ||||||||||||||||||
| 262 | return executed 4 times by 3 tests: s;return s;Executed by:
executed 4 times by 3 tests: return s;Executed by:
| 4 | ||||||||||||||||||
| 263 | } | - | ||||||||||||||||||
| 264 | - | |||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | - | |||||||||||||||||||
| 267 | - | |||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | QDataStream &operator>>(QDataStream &s, QUuid &id) | - | ||||||||||||||||||
| 270 | { | - | ||||||||||||||||||
| 271 | QByteArray bytes(16, Qt::Uninitialized); | - | ||||||||||||||||||
| 272 | if (s.readRawData(bytes.data(), 16) != 16
| 2-5 | ||||||||||||||||||
| 273 | s.setStatus(QDataStream::ReadPastEnd); | - | ||||||||||||||||||
| 274 | return executed 2 times by 1 test: s;return s;Executed by:
executed 2 times by 1 test: return s;Executed by:
| 2 | ||||||||||||||||||
| 275 | } | - | ||||||||||||||||||
| 276 | - | |||||||||||||||||||
| 277 | if (s.byteOrder() == QDataStream::BigEndian
| 1-4 | ||||||||||||||||||
| 278 | id = QUuid::fromRfc4122(bytes); | - | ||||||||||||||||||
| 279 | } executed 4 times by 3 tests: else {end of blockExecuted by:
| 4 | ||||||||||||||||||
| 280 | const uchar *data = reinterpret_cast<const uchar *>(bytes.constData()); | - | ||||||||||||||||||
| 281 | - | |||||||||||||||||||
| 282 | id.data1 = qFromLittleEndian<quint32>(data); | - | ||||||||||||||||||
| 283 | data += sizeof(quint32); | - | ||||||||||||||||||
| 284 | id.data2 = qFromLittleEndian<quint16>(data); | - | ||||||||||||||||||
| 285 | data += sizeof(quint16); | - | ||||||||||||||||||
| 286 | id.data3 = qFromLittleEndian<quint16>(data); | - | ||||||||||||||||||
| 287 | data += sizeof(quint16); | - | ||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | for (int i = 0; i < 8
| 1-8 | ||||||||||||||||||
| 290 | id.data4[i] = *(data); | - | ||||||||||||||||||
| 291 | data++; | - | ||||||||||||||||||
| 292 | } executed 8 times by 1 test: end of blockExecuted by:
| 8 | ||||||||||||||||||
| 293 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | return executed 5 times by 3 tests: s;return s;Executed by:
executed 5 times by 3 tests: return s;Executed by:
| 5 | ||||||||||||||||||
| 296 | } | - | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | bool QUuid::isNull() const noexcept | - | ||||||||||||||||||
| 304 | { | - | ||||||||||||||||||
| 305 | return executed 58 times by 2 tests: data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 &&return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 && data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && data1 == 0 && data2 == 0 && data3 == 0;Executed by:
executed 58 times by 2 tests: return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 && data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && data1 == 0 && data2 == 0 && data3 == 0;Executed by:
| 58 | ||||||||||||||||||
| 306 | data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && executed 58 times by 2 tests: return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 && data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && data1 == 0 && data2 == 0 && data3 == 0;Executed by:
| 58 | ||||||||||||||||||
| 307 | data1 == 0 && data2 == 0 && data3 == 0; executed 58 times by 2 tests: return data4[0] == 0 && data4[1] == 0 && data4[2] == 0 && data4[3] == 0 && data4[4] == 0 && data4[5] == 0 && data4[6] == 0 && data4[7] == 0 && data1 == 0 && data2 == 0 && data3 == 0;Executed by:
| 58 | ||||||||||||||||||
| 308 | } | - | ||||||||||||||||||
| 309 | QUuid::Variant QUuid::variant() const noexcept | - | ||||||||||||||||||
| 310 | { | - | ||||||||||||||||||
| 311 | if (isNull()
| 12-35 | ||||||||||||||||||
| 312 | return executed 12 times by 1 test: VarUnknown;return VarUnknown;Executed by:
executed 12 times by 1 test: return VarUnknown;Executed by:
| 12 | ||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | if ((
executed 2 times by 1 test: NCS;return NCS;Executed by:
executed 2 times by 1 test: return NCS;Executed by:
| 2-33 | ||||||||||||||||||
| 315 | else if ((
executed 33 times by 1 test: DCE;return DCE;Executed by:
executed 33 times by 1 test: return DCE;Executed by:
| 0-33 | ||||||||||||||||||
| 316 | else if ((
never executed: Microsoft;return Microsoft;never executed: return Microsoft; | 0 | ||||||||||||||||||
| 317 | else if ((
never executed: Reserved;return Reserved;never executed: return Reserved; | 0 | ||||||||||||||||||
| 318 | return never executed: VarUnknown;return VarUnknown;never executed: return VarUnknown; | 0 | ||||||||||||||||||
| 319 | } | - | ||||||||||||||||||
| 320 | QUuid::Version QUuid::version() const noexcept | - | ||||||||||||||||||
| 321 | { | - | ||||||||||||||||||
| 322 | - | |||||||||||||||||||
| 323 | Version ver = (Version)(data3>>12); | - | ||||||||||||||||||
| 324 | if (isNull()
| 0-4 | ||||||||||||||||||
| 325 | || (
| 1-3 | ||||||||||||||||||
| 326 | || ver < Time
| 0-3 | ||||||||||||||||||
| 327 | || ver > Sha1
| 0-3 | ||||||||||||||||||
| 328 | return executed 1 time by 1 test: VerUnknown;return VerUnknown;Executed by:
executed 1 time by 1 test: return VerUnknown;Executed by:
| 1 | ||||||||||||||||||
| 329 | return executed 3 times by 1 test: ver;return ver;Executed by:
executed 3 times by 1 test: return ver;Executed by:
| 3 | ||||||||||||||||||
| 330 | } | - | ||||||||||||||||||
| 331 | bool QUuid::operator<(const QUuid &other) const noexcept | - | ||||||||||||||||||
| 332 | { | - | ||||||||||||||||||
| 333 | if (variant() != other.variant()
| 4-12 | ||||||||||||||||||
| 334 | return executed 4 times by 1 test: variant() < other.variant();return variant() < other.variant();Executed by:
executed 4 times by 1 test: return variant() < other.variant();Executed by:
| 4 | ||||||||||||||||||
| 335 | - | |||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | if (data1!=other.data1
executed 8 times by 1 test: (data1<other.data1);return (data1<other.data1);Executed by:
executed 8 times by 1 test: ;return (data1<other.data1);Executed by:
| 4-8 | ||||||||||||||||||
| 338 | if (data2!=other.data2
never executed: (data2<other.data2);return (data2<other.data2);never executed: ;return (data2<other.data2); | 0-4 | ||||||||||||||||||
| 339 | if (data3!=other.data3
never executed: (data3<other.data3);return (data3<other.data3);never executed: ;return (data3<other.data3); | 0-4 | ||||||||||||||||||
| 340 | for (int n = 0; n < 8
| 4-32 | ||||||||||||||||||
| 341 | if (data4[n]!=other.data4[n]
never executed: (data4[n]<other.data4[n]);return (data4[n]<other.data4[n]);never executed: ;return (data4[n]<other.data4[n]); | 0-32 | ||||||||||||||||||
| 342 | } executed 32 times by 1 test: end of blockExecuted by:
| 32 | ||||||||||||||||||
| 343 | - | |||||||||||||||||||
| 344 | return executed 4 times by 1 test: false;return false;Executed by:
executed 4 times by 1 test: return false;Executed by:
| 4 | ||||||||||||||||||
| 345 | } | - | ||||||||||||||||||
| 346 | bool QUuid::operator>(const QUuid &other) const noexcept | - | ||||||||||||||||||
| 347 | { | - | ||||||||||||||||||
| 348 | return executed 3 times by 1 test: other < *this;return other < *this;Executed by:
executed 3 times by 1 test: return other < *this;Executed by:
| 3 | ||||||||||||||||||
| 349 | } | - | ||||||||||||||||||
| 350 | - | |||||||||||||||||||
| 351 | - | |||||||||||||||||||
| 352 | - | |||||||||||||||||||
| 353 | - | |||||||||||||||||||
| 354 | - | |||||||||||||||||||
| 355 | namespace { namespace Q_QGS_devUrandomStorage { typedef QThreadStorage<QFile *> Type; QBasicAtomicInt guard = { QtGlobalStatic::Uninitialized }; __attribute__((visibility("hidden"))) inline Type *innerFunction() { struct HolderBase { ~HolderBase() noexcept { if (guard.load() == QtGlobalStatic::Initialized
executed 4 times by 2 tests: }guard.store(QtGlobalStatic::Destroyed);Executed by:
executed 4 times by 2 tests: }; static struct Holder : public HolderBase { Type value; Holder() noexcept(noexcept(Type ())) : value () { guard.store(QtGlobalStatic::Initialized); } } holder; returnend of blockExecuted by:
executed 1268 times by 3 tests: &holder.value;return &holder.value;Executed by:
executed 1268 times by 3 tests: } } } static QGlobalStatic<QThreadStorage<QFile *>, Q_QGS_devUrandomStorage::innerFunction, Q_QGS_devUrandomStorage::guard> devUrandomStorage;;return &holder.value;Executed by:
| 0-1268 | ||||||||||||||||||
| 356 | - | |||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | QUuid QUuid::createUuid() | - | ||||||||||||||||||
| 359 | { | - | ||||||||||||||||||
| 360 | QUuid result; | - | ||||||||||||||||||
| 361 | uint *data = &(result.data1); | - | ||||||||||||||||||
| 362 | - | |||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | QFile *devUrandom; | - | ||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | devUrandom = devUrandomStorage()->localData(); | - | ||||||||||||||||||
| 367 | if (!devUrandom
| 6-1256 | ||||||||||||||||||
| 368 | devUrandom = new QFile(QLatin1String("/dev/urandom")); | - | ||||||||||||||||||
| 369 | devUrandom->open(QIODevice::ReadOnly | QIODevice::Unbuffered); | - | ||||||||||||||||||
| 370 | devUrandomStorage()->setLocalData(devUrandom); | - | ||||||||||||||||||
| 371 | } executed 6 times by 3 tests: end of blockExecuted by:
| 6 | ||||||||||||||||||
| 372 | - | |||||||||||||||||||
| 373 | - | |||||||||||||||||||
| 374 | - | |||||||||||||||||||
| 375 | - | |||||||||||||||||||
| 376 | - | |||||||||||||||||||
| 377 | enum { AmountToRead = 4 * sizeof(uint) }; | - | ||||||||||||||||||
| 378 | if (devUrandom->isOpen()
| 0-1262 | ||||||||||||||||||
| 379 | && devUrandom->read((char *) data, AmountToRead) == AmountToRead
| 0-1262 | ||||||||||||||||||
| 380 | - | |||||||||||||||||||
| 381 | ; | - | ||||||||||||||||||
| 382 | } executed 1262 times by 3 tests: elseend of blockExecuted by:
| 1262 | ||||||||||||||||||
| 383 | - | |||||||||||||||||||
| 384 | { | - | ||||||||||||||||||
| 385 | static const int intbits = sizeof(int)*8; | - | ||||||||||||||||||
| 386 | static int randbits = 0; | - | ||||||||||||||||||
| 387 | if (!randbits
| 0 | ||||||||||||||||||
| 388 | int r = 0; | - | ||||||||||||||||||
| 389 | int max = 2147483647; | - | ||||||||||||||||||
| 390 | do { ++r; } never executed: while ((end of block
| 0 | ||||||||||||||||||
| 391 | randbits = r; | - | ||||||||||||||||||
| 392 | } never executed: end of block | 0 | ||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | - | |||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | static QThreadStorage<int *> uuidseed; | - | ||||||||||||||||||
| 399 | if (!uuidseed.hasLocalData()
| 0 | ||||||||||||||||||
| 400 | { | - | ||||||||||||||||||
| 401 | int *pseed = new int; | - | ||||||||||||||||||
| 402 | static QBasicAtomicInt serial = { 2 }; | - | ||||||||||||||||||
| 403 | qsrand(*pseed = QDateTime::currentDateTimeUtc().toTime_t() | - | ||||||||||||||||||
| 404 | + quintptr(&pseed) | - | ||||||||||||||||||
| 405 | + serial.fetchAndAddRelaxed(1)); | - | ||||||||||||||||||
| 406 | uuidseed.setLocalData(pseed); | - | ||||||||||||||||||
| 407 | } never executed: end of block | 0 | ||||||||||||||||||
| 408 | - | |||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | - | |||||||||||||||||||
| 413 | - | |||||||||||||||||||
| 414 | - | |||||||||||||||||||
| 415 | int chunks = 16 / sizeof(uint); | - | ||||||||||||||||||
| 416 | while (chunks--
| 0 | ||||||||||||||||||
| 417 | uint randNumber = 0; | - | ||||||||||||||||||
| 418 | for (int filled = 0; filled < intbits
| 0 | ||||||||||||||||||
| 419 | randNumber |= qrand()<<filled; never executed: randNumber |= qrand()<<filled; | 0 | ||||||||||||||||||
| 420 | *(data+chunks) = randNumber; | - | ||||||||||||||||||
| 421 | } never executed: end of block | 0 | ||||||||||||||||||
| 422 | } never executed: end of block | 0 | ||||||||||||||||||
| 423 | - | |||||||||||||||||||
| 424 | result.data4[0] = (result.data4[0] & 0x3F) | 0x80; | - | ||||||||||||||||||
| 425 | result.data3 = (result.data3 & 0x0FFF) | 0x4000; | - | ||||||||||||||||||
| 426 | - | |||||||||||||||||||
| 427 | return executed 1262 times by 3 tests: result;return result;Executed by:
executed 1262 times by 3 tests: return result;Executed by:
| 1262 | ||||||||||||||||||
| 428 | } | - | ||||||||||||||||||
| 429 | QDebug operator<<(QDebug dbg, const QUuid &id) | - | ||||||||||||||||||
| 430 | { | - | ||||||||||||||||||
| 431 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||
| 432 | dbg.nospace() << "QUuid(" << id.toString() << ')'; | - | ||||||||||||||||||
| 433 | return executed 1 time by 1 test: dbg;return dbg;Executed by:
executed 1 time by 1 test: return dbg;Executed by:
| 1 | ||||||||||||||||||
| 434 | } | - | ||||||||||||||||||
| 435 | - | |||||||||||||||||||
| 436 | - | |||||||||||||||||||
| 437 | - | |||||||||||||||||||
| 438 | - | |||||||||||||||||||
| 439 | - | |||||||||||||||||||
| 440 | - | |||||||||||||||||||
| 441 | - | |||||||||||||||||||
| 442 | uint qHash(const QUuid &uuid, uint seed) noexcept | - | ||||||||||||||||||
| 443 | { | - | ||||||||||||||||||
| 444 | return executed 3 times by 1 test: uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16)return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) ^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]) ^ seed;Executed by:
executed 3 times by 1 test: return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) ^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]) ^ seed;Executed by:
| 3 | ||||||||||||||||||
| 445 | ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) executed 3 times by 1 test: return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) ^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]) ^ seed;Executed by:
| 3 | ||||||||||||||||||
| 446 | ^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]) executed 3 times by 1 test: return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) ^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]) ^ seed;Executed by:
| 3 | ||||||||||||||||||
| 447 | ^ seed; executed 3 times by 1 test: return uuid.data1 ^ uuid.data2 ^ (uuid.data3 << 16) ^ ((uuid.data4[0] << 24) | (uuid.data4[1] << 16) | (uuid.data4[2] << 8) | uuid.data4[3]) ^ ((uuid.data4[4] << 24) | (uuid.data4[5] << 16) | (uuid.data4[6] << 8) | uuid.data4[7]) ^ seed;Executed by:
| 3 | ||||||||||||||||||
| 448 | } | - | ||||||||||||||||||
| 449 | - | |||||||||||||||||||
| 450 | - | |||||||||||||||||||
| 451 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |