LLVMFuzzerTestOneInput: 23| 1.36k|{ 24| 1.36k| char *buf = (char *)malloc(size); 25| 1.36k| if (buf == NULL) { ------------------ | Branch (25:6): [True: 0, False: 1.36k] ------------------ 26| 0| return 0; 27| 0| } 28| 1.36k| memcpy(buf, data, size); 29| 1.36k| ssize_t rc = spdk_json_parse(buf, size, NULL, 0, NULL, 0); 30| | 31| 1.36k| free(buf); 32| 1.36k| return 0; 33| 1.36k|} json_parse.c:utf16_valid_surrogate_low: 220| 1.95k|{ 221| 1.95k| return val >= 0xDC00 && val <= 0xDFFF; ------------------ | Branch (221:9): [True: 852, False: 1.10k] | Branch (221:26): [True: 434, False: 418] ------------------ 222| 1.95k|} json_parse.c:utf16_decode_surrogate_pair: 269| 422|{ 270| 422| uint32_t codepoint; 271| | 272| 422| assert(utf16_valid_surrogate_high(high)); 273| 422| assert(utf16_valid_surrogate_low(low)); 274| | 275| 422| codepoint = low; 276| 422| codepoint &= 0x3FF; 277| 422| codepoint |= ((high & 0x3FF) << 10); 278| 422| codepoint += 0x10000; 279| | 280| 422| return codepoint; 281| 422|} json_parse.c:utf16_valid_surrogate_high: 214| 1.97k|{ 215| 1.97k| return val >= 0xD800 && val <= 0xDBFF; ------------------ | Branch (215:9): [True: 894, False: 1.08k] | Branch (215:26): [True: 470, False: 424] ------------------ 216| 1.97k|} json_parse.c:utf8_codepoint_len: 196| 1.91k|{ 197| 1.91k| if (c <= 0x7F) { ------------------ | Branch (197:6): [True: 290, False: 1.62k] ------------------ 198| 290| return 1; 199| 1.62k| } else if (c <= 0x7FF) { ------------------ | Branch (199:13): [True: 315, False: 1.31k] ------------------ 200| 315| return 2; 201| 1.31k| } else if (c >= 0xD800 && c <= 0xDFFF) { ------------------ | Branch (201:13): [True: 834, False: 479] | Branch (201:28): [True: 0, False: 834] ------------------ 202| | /* UTF-16 surrogate pairs - invalid in UTF-8 */ 203| 0| return -1; 204| 1.31k| } else if (c <= 0xFFFF) { ------------------ | Branch (204:13): [True: 891, False: 422] ------------------ 205| 891| return 3; 206| 891| } else if (c <= 0x10FFFF) { ------------------ | Branch (206:13): [True: 422, False: 0] ------------------ 207| 422| return 4; 208| 422| } 209| 0| return -1; 210| 1.91k|} json_parse.c:utf8_valid: 29| 1.04M|{ 30| 1.04M| const uint8_t *p = start; 31| 1.04M| uint8_t b0, b1, b2, b3; 32| | 33| 1.04M| if (p == end) { ------------------ | Branch (33:6): [True: 0, False: 1.04M] ------------------ 34| 0| return 0; 35| 0| } 36| | 37| 1.04M| b0 = *p; 38| | 39| 1.04M| if (b0 <= 0x7F) { ------------------ | Branch (39:6): [True: 1.04M, False: 5.32k] ------------------ 40| 1.04M| return 1; 41| 1.04M| } 42| | 43| 5.32k| if (b0 <= 0xC1) { ------------------ | Branch (43:6): [True: 22, False: 5.30k] ------------------ 44| | /* Invalid start byte */ 45| 22| return -1; 46| 22| } 47| | 48| 5.30k| if (++p == end) { ------------------ | Branch (48:6): [True: 28, False: 5.27k] ------------------ 49| | /* Not enough bytes left */ 50| 28| return -1; 51| 28| } 52| 5.27k| b1 = *p; 53| | 54| 5.27k| if (b0 <= 0xDF) { ------------------ | Branch (54:6): [True: 288, False: 4.98k] ------------------ 55| | /* C2..DF 80..BF */ 56| 288| if (!utf8_tail(b1)) { ------------------ | Branch (56:7): [True: 5, False: 283] ------------------ 57| 5| return -1; 58| 5| } 59| 283| return 2; 60| 288| } 61| | 62| 4.98k| if (++p == end) { ------------------ | Branch (62:6): [True: 3, False: 4.98k] ------------------ 63| | /* Not enough bytes left */ 64| 3| return -1; 65| 3| } 66| 4.98k| b2 = *p; 67| | 68| 4.98k| if (b0 == 0xE0) { ------------------ | Branch (68:6): [True: 214, False: 4.77k] ------------------ 69| | /* E0 A0..BF 80..BF */ 70| 214| if (b1 < 0xA0 || b1 > 0xBF || !utf8_tail(b2)) { ------------------ | Branch (70:7): [True: 11, False: 203] | Branch (70:20): [True: 3, False: 200] | Branch (70:33): [True: 4, False: 196] ------------------ 71| 18| return -1; 72| 18| } 73| 196| return 3; 74| 4.77k| } else if (b0 == 0xED && b1 >= 0xA0) { ------------------ | Branch (74:13): [True: 207, False: 4.56k] | Branch (74:27): [True: 4, False: 203] ------------------ 75| | /* 76| | * UTF-16 surrogate pairs use U+D800..U+DFFF, which would be encoded as 77| | * ED A0..BF 80..BF in UTF-8; however, surrogate pairs are not allowed in UTF-8. 78| | */ 79| 4| return -1; 80| 4.76k| } else if (b0 <= 0xEF) { ------------------ | Branch (80:13): [True: 3.92k, False: 840] ------------------ 81| | /* E1..EF 80..BF 80..BF */ 82| 3.92k| if (!utf8_tail(b1) || !utf8_tail(b2)) { ------------------ | Branch (82:7): [True: 10, False: 3.91k] | Branch (82:25): [True: 5, False: 3.91k] ------------------ 83| 15| return -1; 84| 15| } 85| 3.91k| return 3; 86| 3.92k| } 87| | 88| 840| if (++p == end) { ------------------ | Branch (88:6): [True: 3, False: 837] ------------------ 89| | /* Not enough bytes left */ 90| 3| return -1; 91| 3| } 92| 837| b3 = *p; 93| | 94| 837| if (b0 == 0xF0) { ------------------ | Branch (94:6): [True: 217, False: 620] ------------------ 95| | /* F0 90..BF 80..BF 80..BF */ 96| 217| if (b1 < 0x90 || b1 > 0xBF || !utf8_tail(b2) || !utf8_tail(b3)) { ------------------ | Branch (96:7): [True: 9, False: 208] | Branch (96:20): [True: 4, False: 204] | Branch (96:33): [True: 4, False: 200] | Branch (96:51): [True: 3, False: 197] ------------------ 97| 20| return -1; 98| 20| } 99| 197| return 4; 100| 620| } else if (b0 <= 0xF3) { ------------------ | Branch (100:13): [True: 402, False: 218] ------------------ 101| | /* F1..F3 80..BF 80..BF 80..BF */ 102| 402| if (!utf8_tail(b1) || !utf8_tail(b2) || !utf8_tail(b3)) { ------------------ | Branch (102:7): [True: 3, False: 399] | Branch (102:25): [True: 3, False: 396] | Branch (102:43): [True: 3, False: 393] ------------------ 103| 9| return -1; 104| 9| } 105| 393| return 4; 106| 402| } else if (b0 == 0xF4) { ------------------ | Branch (106:13): [True: 213, False: 5] ------------------ 107| | /* F4 80..8F 80..BF 80..BF */ 108| 213| if (b1 < 0x80 || b1 > 0x8F || !utf8_tail(b2) || !utf8_tail(b3)) { ------------------ | Branch (108:7): [True: 3, False: 210] | Branch (108:20): [True: 7, False: 203] | Branch (108:33): [True: 3, False: 200] | Branch (108:51): [True: 5, False: 195] ------------------ 109| 18| return -1; 110| 18| } 111| 195| return 4; 112| 213| } 113| | 114| 5| return -1; 115| 837|} json_parse.c:utf8_tail: 17| 10.3k|{ 18| | /* c >= 0x80 && c <= 0xBF, or binary 01xxxxxx */ 19| 10.3k| return (c & 0xC0) == 0x80; 20| 10.3k|} spdk_json_parse: 417| 1.36k|{ 418| 1.36k| uint8_t *json_end = json + size; 419| 1.36k| enum spdk_json_val_type containers[SPDK_JSON_MAX_NESTING_DEPTH]; 420| 1.36k| size_t con_value[SPDK_JSON_MAX_NESTING_DEPTH]; 421| 1.36k| enum spdk_json_val_type con_type = SPDK_JSON_VAL_INVALID; 422| 1.36k| bool trailing_comma = false; 423| 1.36k| size_t depth = 0; /* index into containers */ 424| 1.36k| size_t cur_value = 0; /* index into values */ 425| 1.36k| size_t con_start_value; 426| 1.36k| uint8_t *data = json; 427| 1.36k| uint8_t *new_data; 428| 1.36k| int rc = 0; 429| 1.36k| const struct json_literal *lit; 430| 1.36k| enum { 431| 1.36k| STATE_VALUE, /* initial state */ 432| 1.36k| STATE_VALUE_SEPARATOR, /* value separator (comma) */ 433| 1.36k| STATE_NAME, /* "name": value */ 434| 1.36k| STATE_NAME_SEPARATOR, /* colon */ 435| 1.36k| STATE_END, /* parsed the complete value, so only whitespace is valid */ 436| 1.36k| } state = STATE_VALUE; 437| | 438| 1.36k|#define ADD_VALUE(t, val_start_ptr, val_end_ptr) \ 439| 1.36k| if (values && cur_value < num_values) { \ 440| 1.36k| values[cur_value].type = t; \ 441| 1.36k| values[cur_value].start = val_start_ptr; \ 442| 1.36k| values[cur_value].len = val_end_ptr - val_start_ptr; \ 443| 1.36k| } \ 444| 1.36k| cur_value++ 445| | 446| 27.1k| while (data < json_end) { ------------------ | Branch (446:9): [True: 26.8k, False: 218] ------------------ 447| 26.8k| uint8_t c = *data; 448| | 449| 26.8k| switch (c) { 450| 333| case ' ': ------------------ | Branch (450:3): [True: 333, False: 26.5k] ------------------ 451| 537| case '\t': ------------------ | Branch (451:3): [True: 204, False: 26.6k] ------------------ 452| 742| case '\r': ------------------ | Branch (452:3): [True: 205, False: 26.6k] ------------------ 453| 949| case '\n': ------------------ | Branch (453:3): [True: 207, False: 26.6k] ------------------ 454| | /* Whitespace is allowed between any tokens. */ 455| 949| data++; 456| 949| break; 457| | 458| 327| case 't': ------------------ | Branch (458:3): [True: 327, False: 26.5k] ------------------ 459| 551| case 'f': ------------------ | Branch (459:3): [True: 224, False: 26.6k] ------------------ 460| 856| case 'n': ------------------ | Branch (460:3): [True: 305, False: 26.5k] ------------------ 461| | /* true, false, or null */ 462| 856| if (state != STATE_VALUE) { goto done_invalid; } ------------------ | Branch (462:8): [True: 23, False: 833] ------------------ 463| 833| lit = &g_json_literals[(c >> 3) & 3]; /* See comment above g_json_literals[] */ 464| 833| assert(lit->str[0] == c); 465| 833| rc = match_literal(data, json_end, lit->str, lit->len); 466| 833| if (rc < 0) { goto done_rc; } ------------------ | Branch (466:8): [True: 73, False: 760] ------------------ 467| 760| ADD_VALUE(lit->type, data, data + rc); ------------------ | | 439| 760| if (values && cur_value < num_values) { \ | | ------------------ | | | Branch (439:6): [True: 0, False: 760] | | | Branch (439:16): [True: 0, False: 0] | | ------------------ | | 440| 0| values[cur_value].type = t; \ | | 441| 0| values[cur_value].start = val_start_ptr; \ | | 442| 0| values[cur_value].len = val_end_ptr - val_start_ptr; \ | | 443| 0| } \ | | 444| 760| cur_value++ ------------------ 468| 760| data += rc; 469| 760| state = depth ? STATE_VALUE_SEPARATOR : STATE_END; ------------------ | Branch (469:12): [True: 757, False: 3] ------------------ 470| 760| trailing_comma = false; 471| 760| break; 472| | 473| 1.75k| case '"': ------------------ | Branch (473:3): [True: 1.75k, False: 25.1k] ------------------ 474| 1.75k| if (state != STATE_VALUE && state != STATE_NAME) { goto done_invalid; } ------------------ | Branch (474:8): [True: 803, False: 952] | Branch (474:32): [True: 3, False: 800] ------------------ 475| 1.75k| rc = json_decode_string(data, json_end, &new_data, flags); 476| 1.75k| if (rc < 0) { ------------------ | Branch (476:8): [True: 517, False: 1.23k] ------------------ 477| 517| data = new_data; 478| 517| goto done_rc; 479| 517| } 480| | /* 481| | * Start is data + 1 to skip initial quote. 482| | * Length is data + rc - 1 to skip both quotes. 483| | */ 484| 1.23k| ADD_VALUE(state == STATE_VALUE ? SPDK_JSON_VAL_STRING : SPDK_JSON_VAL_NAME, ------------------ | | 439| 1.23k| if (values && cur_value < num_values) { \ | | ------------------ | | | Branch (439:6): [True: 0, False: 1.23k] | | | Branch (439:16): [True: 0, False: 0] | | ------------------ | | 440| 0| values[cur_value].type = t; \ | | ------------------ | | | Branch (440:28): [True: 0, False: 0] | | ------------------ | | 441| 0| values[cur_value].start = val_start_ptr; \ | | 442| 0| values[cur_value].len = val_end_ptr - val_start_ptr; \ | | 443| 0| } \ | | 444| 1.23k| cur_value++ ------------------ 485| 1.23k| data + 1, data + rc - 1); 486| 1.23k| data = new_data; 487| 1.23k| if (state == STATE_NAME) { ------------------ | Branch (487:8): [True: 792, False: 443] ------------------ 488| 792| state = STATE_NAME_SEPARATOR; 489| 792| } else { 490| 443| state = depth ? STATE_VALUE_SEPARATOR : STATE_END; ------------------ | Branch (490:13): [True: 423, False: 20] ------------------ 491| 443| } 492| 1.23k| trailing_comma = false; 493| 1.23k| break; 494| | 495| 607| case '-': ------------------ | Branch (495:3): [True: 607, False: 26.2k] ------------------ 496| 2.67k| case '0': ------------------ | Branch (496:3): [True: 2.06k, False: 24.8k] ------------------ 497| 3.34k| case '1': ------------------ | Branch (497:3): [True: 676, False: 26.2k] ------------------ 498| 3.77k| case '2': ------------------ | Branch (498:3): [True: 430, False: 26.4k] ------------------ 499| 4.16k| case '3': ------------------ | Branch (499:3): [True: 383, False: 26.4k] ------------------ 500| 4.70k| case '4': ------------------ | Branch (500:3): [True: 546, False: 26.3k] ------------------ 501| 5.11k| case '5': ------------------ | Branch (501:3): [True: 409, False: 26.4k] ------------------ 502| 5.52k| case '6': ------------------ | Branch (502:3): [True: 407, False: 26.4k] ------------------ 503| 6.01k| case '7': ------------------ | Branch (503:3): [True: 497, False: 26.3k] ------------------ 504| 6.60k| case '8': ------------------ | Branch (504:3): [True: 590, False: 26.2k] ------------------ 505| 7.21k| case '9': ------------------ | Branch (505:3): [True: 601, False: 26.2k] ------------------ 506| 7.21k| if (state != STATE_VALUE) { goto done_invalid; } ------------------ | Branch (506:8): [True: 55, False: 7.15k] ------------------ 507| 7.15k| rc = json_valid_number(data, json_end); 508| 7.15k| if (rc < 0) { goto done_rc; } ------------------ | Branch (508:8): [True: 149, False: 7.00k] ------------------ 509| 7.00k| ADD_VALUE(SPDK_JSON_VAL_NUMBER, data, data + rc); ------------------ | | 439| 7.00k| if (values && cur_value < num_values) { \ | | ------------------ | | | Branch (439:6): [True: 0, False: 7.00k] | | | Branch (439:16): [True: 0, False: 0] | | ------------------ | | 440| 0| values[cur_value].type = t; \ | | 441| 0| values[cur_value].start = val_start_ptr; \ | | 442| 0| values[cur_value].len = val_end_ptr - val_start_ptr; \ | | 443| 0| } \ | | 444| 7.00k| cur_value++ ------------------ 510| 7.00k| data += rc; 511| 7.00k| state = depth ? STATE_VALUE_SEPARATOR : STATE_END; ------------------ | Branch (511:12): [True: 6.79k, False: 207] ------------------ 512| 7.00k| trailing_comma = false; 513| 7.00k| break; 514| | 515| 1.37k| case '{': ------------------ | Branch (515:3): [True: 1.37k, False: 25.5k] ------------------ 516| 4.19k| case '[': ------------------ | Branch (516:3): [True: 2.81k, False: 24.0k] ------------------ 517| 4.19k| if (state != STATE_VALUE) { goto done_invalid; } ------------------ | Branch (517:8): [True: 16, False: 4.17k] ------------------ 518| 4.17k| if (depth == SPDK_JSON_MAX_NESTING_DEPTH) { ------------------ | | 10| 4.17k|#define SPDK_JSON_MAX_NESTING_DEPTH 64 ------------------ | Branch (518:8): [True: 2, False: 4.17k] ------------------ 519| 2| rc = SPDK_JSON_PARSE_MAX_DEPTH_EXCEEDED; ------------------ | | 80| 2|#define SPDK_JSON_PARSE_MAX_DEPTH_EXCEEDED -3 ------------------ 520| 2| goto done_rc; 521| 2| } 522| 4.17k| if (c == '{') { ------------------ | Branch (522:8): [True: 1.36k, False: 2.80k] ------------------ 523| 1.36k| con_type = SPDK_JSON_VAL_OBJECT_BEGIN; 524| 1.36k| state = STATE_NAME; 525| 2.80k| } else { 526| 2.80k| con_type = SPDK_JSON_VAL_ARRAY_BEGIN; 527| 2.80k| state = STATE_VALUE; 528| 2.80k| } 529| 4.17k| con_value[depth] = cur_value; 530| 4.17k| containers[depth++] = con_type; 531| 4.17k| ADD_VALUE(con_type, data, data + 1); ------------------ | | 439| 4.17k| if (values && cur_value < num_values) { \ | | ------------------ | | | Branch (439:6): [True: 0, False: 4.17k] | | | Branch (439:16): [True: 0, False: 0] | | ------------------ | | 440| 0| values[cur_value].type = t; \ | | 441| 0| values[cur_value].start = val_start_ptr; \ | | 442| 0| values[cur_value].len = val_end_ptr - val_start_ptr; \ | | 443| 0| } \ | | 444| 4.17k| cur_value++ ------------------ 532| 4.17k| data++; 533| 4.17k| trailing_comma = false; 534| 4.17k| break; 535| | 536| 960| case '}': ------------------ | Branch (536:3): [True: 960, False: 25.9k] ------------------ 537| 2.43k| case ']': ------------------ | Branch (537:3): [True: 1.47k, False: 25.4k] ------------------ 538| 2.43k| if (trailing_comma) { goto done_invalid; } ------------------ | Branch (538:8): [True: 1, False: 2.43k] ------------------ 539| 2.43k| if (depth == 0) { goto done_invalid; } ------------------ | Branch (539:8): [True: 2, False: 2.43k] ------------------ 540| 2.43k| con_type = containers[--depth]; 541| 2.43k| con_start_value = con_value[depth]; 542| 2.43k| if (values && con_start_value < num_values) { ------------------ | Branch (542:8): [True: 0, False: 2.43k] | Branch (542:18): [True: 0, False: 0] ------------------ 543| 0| values[con_start_value].len = cur_value - con_start_value - 1; 544| 0| } 545| 2.43k| if (c == '}') { ------------------ | Branch (545:8): [True: 959, False: 1.47k] ------------------ 546| 959| if (state != STATE_NAME && state != STATE_VALUE_SEPARATOR) { ------------------ | Branch (546:9): [True: 208, False: 751] | Branch (546:32): [True: 3, False: 205] ------------------ 547| 3| goto done_invalid; 548| 3| } 549| 956| if (con_type != SPDK_JSON_VAL_OBJECT_BEGIN) { ------------------ | Branch (549:9): [True: 17, False: 939] ------------------ 550| 17| goto done_invalid; 551| 17| } 552| 939| ADD_VALUE(SPDK_JSON_VAL_OBJECT_END, data, data + 1); ------------------ | | 439| 939| if (values && cur_value < num_values) { \ | | ------------------ | | | Branch (439:6): [True: 0, False: 939] | | | Branch (439:16): [True: 0, False: 0] | | ------------------ | | 440| 0| values[cur_value].type = t; \ | | 441| 0| values[cur_value].start = val_start_ptr; \ | | 442| 0| values[cur_value].len = val_end_ptr - val_start_ptr; \ | | 443| 0| } \ | | 444| 939| cur_value++ ------------------ 553| 1.47k| } else { 554| 1.47k| if (state != STATE_VALUE && state != STATE_VALUE_SEPARATOR) { ------------------ | Branch (554:9): [True: 1.25k, False: 220] | Branch (554:33): [True: 3, False: 1.25k] ------------------ 555| 3| goto done_invalid; 556| 3| } 557| 1.47k| if (con_type != SPDK_JSON_VAL_ARRAY_BEGIN) { ------------------ | Branch (557:9): [True: 1, False: 1.47k] ------------------ 558| 1| goto done_invalid; 559| 1| } 560| 1.47k| ADD_VALUE(SPDK_JSON_VAL_ARRAY_END, data, data + 1); ------------------ | | 439| 1.47k| if (values && cur_value < num_values) { \ | | ------------------ | | | Branch (439:6): [True: 0, False: 1.47k] | | | Branch (439:16): [True: 0, False: 0] | | ------------------ | | 440| 0| values[cur_value].type = t; \ | | 441| 0| values[cur_value].start = val_start_ptr; \ | | 442| 0| values[cur_value].len = val_end_ptr - val_start_ptr; \ | | 443| 0| } \ | | 444| 1.47k| cur_value++ ------------------ 561| 1.47k| } 562| 2.41k| con_type = depth == 0 ? SPDK_JSON_VAL_INVALID : containers[depth - 1]; ------------------ | Branch (562:15): [True: 24, False: 2.38k] ------------------ 563| 2.41k| data++; 564| 2.41k| state = depth ? STATE_VALUE_SEPARATOR : STATE_END; ------------------ | Branch (564:12): [True: 2.38k, False: 24] ------------------ 565| 2.41k| trailing_comma = false; 566| 2.41k| break; 567| | 568| 8.68k| case ',': ------------------ | Branch (568:3): [True: 8.68k, False: 18.2k] ------------------ 569| 8.68k| if (state != STATE_VALUE_SEPARATOR) { goto done_invalid; } ------------------ | Branch (569:8): [True: 4, False: 8.67k] ------------------ 570| 8.67k| data++; 571| 8.67k| assert(con_type == SPDK_JSON_VAL_ARRAY_BEGIN || 572| 8.67k| con_type == SPDK_JSON_VAL_OBJECT_BEGIN); 573| 8.67k| state = con_type == SPDK_JSON_VAL_ARRAY_BEGIN ? STATE_VALUE : STATE_NAME; ------------------ | Branch (573:12): [True: 8.46k, False: 210] ------------------ 574| 8.67k| trailing_comma = true; 575| 8.67k| break; 576| | 577| 779| case ':': ------------------ | Branch (577:3): [True: 779, False: 26.1k] ------------------ 578| 779| if (state != STATE_NAME_SEPARATOR) { goto done_invalid; } ------------------ | Branch (578:8): [True: 2, False: 777] ------------------ 579| 777| data++; 580| 777| state = STATE_VALUE; 581| 777| break; 582| | 583| 2| case '/': ------------------ | Branch (583:3): [True: 2, False: 26.8k] ------------------ 584| 2| if (!(flags & SPDK_JSON_PARSE_FLAG_ALLOW_COMMENTS)) { ------------------ | | 92| 2|#define SPDK_JSON_PARSE_FLAG_ALLOW_COMMENTS 0x000000002 ------------------ | Branch (584:8): [True: 2, False: 0] ------------------ 585| 2| goto done_invalid; 586| 2| } 587| 0| rc = json_valid_comment(data, json_end); 588| 0| if (rc < 0) { goto done_rc; } ------------------ | Branch (588:8): [True: 0, False: 0] ------------------ 589| | /* Skip over comment */ 590| 0| data += rc; 591| 0| break; 592| | 593| 20| default: ------------------ | Branch (593:3): [True: 20, False: 26.8k] ------------------ 594| 20| goto done_invalid; 595| 26.8k| } 596| | 597| 25.9k| if (state == STATE_END) { ------------------ | Branch (597:7): [True: 254, False: 25.7k] ------------------ 598| 254| break; 599| 254| } 600| 25.9k| } 601| | 602| 472| if (state == STATE_END) { ------------------ | Branch (602:6): [True: 254, False: 218] ------------------ 603| | /* Skip trailing whitespace */ 604| 1.03k| while (data < json_end) { ------------------ | Branch (604:10): [True: 890, False: 143] ------------------ 605| 890| uint8_t c = *data; 606| | 607| 890| if (c == ' ' || c == '\t' || c == '\r' || c == '\n') { ------------------ | Branch (607:8): [True: 198, False: 692] | Branch (607:20): [True: 346, False: 346] | Branch (607:33): [True: 36, False: 310] | Branch (607:46): [True: 199, False: 111] ------------------ 608| 779| data++; 609| 779| } else { 610| 111| break; 611| 111| } 612| 890| } 613| | 614| | /* 615| | * These asserts are just for sanity checking - they are guaranteed by the allowed 616| | * state transitions. 617| | */ 618| 254| assert(depth == 0); 619| 254| assert(trailing_comma == false); 620| 254| assert(data <= json_end); 621| 254| if (end) { ------------------ | Branch (621:7): [True: 0, False: 254] ------------------ 622| 0| *end = data; 623| 0| } 624| 254| return cur_value; 625| 254| } 626| | 627| | /* Invalid end state - ran out of data */ 628| 218| rc = SPDK_JSON_PARSE_INCOMPLETE; ------------------ | | 78| 218|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ 629| | 630| 1.11k|done_rc: 631| 1.11k| assert(rc < 0); 632| 1.11k| if (end) { ------------------ | Branch (632:6): [True: 0, False: 1.11k] ------------------ 633| 0| *end = data; 634| 0| } 635| 1.11k| return rc; 636| | 637| 152|done_invalid: 638| 152| rc = SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 152|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 639| 152| goto done_rc; 640| 218|} json_parse.c:match_literal: 401| 833|{ 402| 833| assert(end >= start); 403| 833| if ((size_t)(end - start) < len) { ------------------ | Branch (403:6): [True: 4, False: 829] ------------------ 404| 4| return SPDK_JSON_PARSE_INCOMPLETE; ------------------ | | 78| 4|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ 405| 4| } 406| | 407| 829| if (memcmp(start, literal, len) != 0) { ------------------ | Branch (407:6): [True: 69, False: 760] ------------------ 408| 69| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 69|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 409| 69| } 410| | 411| 760| return len; 412| 829|} json_parse.c:json_decode_string: 171| 1.75k|{ 172| 1.75k| uint8_t *str = str_start; 173| 1.75k| uint8_t *out = str_start + 1; /* Decode string in place (skip the initial quote) */ 174| 1.75k| int rc; 175| | 176| 1.75k| if (buf_end - str_start < 2) { ------------------ | Branch (176:6): [True: 16, False: 1.73k] ------------------ 177| | /* 178| | * Shortest valid string (the empty string) is two bytes (""), 179| | * so this can't possibly be valid 180| | */ 181| 16| *str_end = str; 182| 16| return SPDK_JSON_PARSE_INCOMPLETE; ------------------ | | 78| 16|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ 183| 16| } 184| | 185| 1.73k| if (*str++ != '"') { ------------------ | Branch (185:6): [True: 0, False: 1.73k] ------------------ 186| 0| *str_end = str; 187| 0| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 0|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 188| 0| } 189| | 190| 1.05M| while (str < buf_end) { ------------------ | Branch (190:9): [True: 1.05M, False: 186] ------------------ 191| 1.05M| if (str[0] == '"') { ------------------ | Branch (191:7): [True: 1.23k, False: 1.05M] ------------------ 192| | /* 193| | * End of string. 194| | * Update str_end to point at next input byte and return output length. 195| | */ 196| 1.23k| *str_end = str + 1; 197| 1.23k| return out - str_start - 1; 198| 1.05M| } else if (str[0] == '\\') { ------------------ | Branch (198:14): [True: 5.75k, False: 1.04M] ------------------ 199| 5.75k| rc = json_decode_string_escape(&str, buf_end, 200| 5.75k| flags & SPDK_JSON_PARSE_FLAG_DECODE_IN_PLACE ? out : NULL); ------------------ | | 85| 5.75k|#define SPDK_JSON_PARSE_FLAG_DECODE_IN_PLACE 0x000000001 ------------------ | Branch (200:14): [True: 0, False: 5.75k] ------------------ 201| 5.75k| assert(rc != 0); 202| 5.75k| if (rc < 0) { ------------------ | Branch (202:8): [True: 139, False: 5.61k] ------------------ 203| 139| *str_end = str; 204| 139| return rc; 205| 139| } 206| 5.61k| out += rc; 207| 1.04M| } else if (str[0] <= 0x1f) { ------------------ | Branch (207:14): [True: 26, False: 1.04M] ------------------ 208| | /* control characters must be escaped */ 209| 26| *str_end = str; 210| 26| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 26|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 211| 1.04M| } else { 212| 1.04M| rc = utf8_valid(str, buf_end); 213| 1.04M| if (rc == 0) { ------------------ | Branch (213:8): [True: 0, False: 1.04M] ------------------ 214| 0| *str_end = str; 215| 0| return SPDK_JSON_PARSE_INCOMPLETE; ------------------ | | 78| 0|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ 216| 1.04M| } else if (rc < 0) { ------------------ | Branch (216:15): [True: 150, False: 1.04M] ------------------ 217| 150| *str_end = str; 218| 150| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 150|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 219| 150| } 220| | 221| 1.04M| if (out && out != str && (flags & SPDK_JSON_PARSE_FLAG_DECODE_IN_PLACE)) { ------------------ | | 85| 2.34k|#define SPDK_JSON_PARSE_FLAG_DECODE_IN_PLACE 0x000000001 ------------------ | Branch (221:8): [True: 1.04M, False: 0] | Branch (221:15): [True: 2.34k, False: 1.04M] | Branch (221:29): [True: 0, False: 2.34k] ------------------ 222| 0| memmove(out, str, rc); 223| 0| } 224| 1.04M| out += rc; 225| 1.04M| str += rc; 226| 1.04M| } 227| 1.05M| } 228| | 229| | /* If execution gets here, we ran out of buffer. */ 230| 186| *str_end = str; 231| 186| return SPDK_JSON_PARSE_INCOMPLETE; ------------------ | | 78| 186|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ 232| 1.73k|} json_parse.c:json_decode_string_escape: 151| 5.75k|{ 152| 5.75k| int rc; 153| | 154| 5.75k| rc = json_decode_string_escape_twochar(strp, buf_end, out); 155| 5.75k| if (rc > 0) { ------------------ | Branch (155:6): [True: 3.69k, False: 2.05k] ------------------ 156| 3.69k| return rc; 157| 3.69k| } 158| | 159| 2.05k| return json_decode_string_escape_unicode(strp, buf_end, out); 160| 5.75k|} json_parse.c:json_decode_string_escape_twochar: 109| 5.75k|{ 110| 5.75k| static const uint8_t escapes[256] = { 111| 5.75k| ['b'] = '\b', 112| 5.75k| ['f'] = '\f', 113| 5.75k| ['n'] = '\n', 114| 5.75k| ['r'] = '\r', 115| 5.75k| ['t'] = '\t', 116| 5.75k| ['/'] = '/', 117| 5.75k| ['"'] = '"', 118| 5.75k| ['\\'] = '\\', 119| 5.75k| }; 120| 5.75k| uint8_t *str = *strp; 121| 5.75k| uint8_t c; 122| | 123| 5.75k| assert(buf_end > str); 124| 5.75k| if (buf_end - str < 2) { ------------------ | Branch (124:6): [True: 24, False: 5.73k] ------------------ 125| 24| return SPDK_JSON_PARSE_INCOMPLETE; ------------------ | | 78| 24|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ 126| 24| } 127| | 128| 5.73k| assert(str[0] == '\\'); 129| | 130| 5.73k| c = escapes[str[1]]; 131| 5.73k| if (c) { ------------------ | Branch (131:6): [True: 3.69k, False: 2.03k] ------------------ 132| 3.69k| if (out) { ------------------ | Branch (132:7): [True: 0, False: 3.69k] ------------------ 133| 0| *out = c; 134| 0| } 135| 3.69k| *strp += 2; /* consumed two bytes */ 136| 3.69k| return 1; /* produced one byte */ 137| 3.69k| } 138| | 139| 2.03k| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 2.03k|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 140| 5.73k|} json_parse.c:json_decode_string_escape_unicode: 29| 2.05k|{ 30| 2.05k| uint8_t *str = *strp; 31| 2.05k| int v0, v1, v2, v3; 32| 2.05k| uint32_t val; 33| 2.05k| uint32_t surrogate_high = 0; 34| 2.05k| int rc; 35| 2.52k|decode: 36| | /* \uXXXX */ 37| 2.52k| assert(buf_end > str); 38| | 39| 2.52k| if (*str++ != '\\') { return SPDK_JSON_PARSE_INVALID; } ------------------ | | 73| 20|#define SPDK_JSON_PARSE_INVALID -1 ------------------ | Branch (39:6): [True: 20, False: 2.50k] ------------------ 40| 2.50k| if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; } ------------------ | | 78| 24|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ | Branch (40:6): [True: 24, False: 2.48k] ------------------ 41| | 42| 2.48k| if (*str++ != 'u') { return SPDK_JSON_PARSE_INVALID; } ------------------ | | 73| 25|#define SPDK_JSON_PARSE_INVALID -1 ------------------ | Branch (42:6): [True: 25, False: 2.45k] ------------------ 43| 2.45k| if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; } ------------------ | | 78| 3|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ | Branch (43:6): [True: 3, False: 2.45k] ------------------ 44| | 45| 2.45k| if ((v3 = hex_value(*str++)) < 0) { return SPDK_JSON_PARSE_INVALID; } ------------------ | | 73| 5|#define SPDK_JSON_PARSE_INVALID -1 ------------------ | Branch (45:6): [True: 5, False: 2.45k] ------------------ 46| 2.45k| if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; } ------------------ | | 78| 1|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ | Branch (46:6): [True: 1, False: 2.44k] ------------------ 47| | 48| 2.44k| if ((v2 = hex_value(*str++)) < 0) { return SPDK_JSON_PARSE_INVALID; } ------------------ | | 73| 1|#define SPDK_JSON_PARSE_INVALID -1 ------------------ | Branch (48:6): [True: 1, False: 2.44k] ------------------ 49| 2.44k| if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; } ------------------ | | 78| 3|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ | Branch (49:6): [True: 3, False: 2.44k] ------------------ 50| | 51| 2.44k| if ((v1 = hex_value(*str++)) < 0) { return SPDK_JSON_PARSE_INVALID; } ------------------ | | 73| 3|#define SPDK_JSON_PARSE_INVALID -1 ------------------ | Branch (51:6): [True: 3, False: 2.44k] ------------------ 52| 2.44k| if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; } ------------------ | | 78| 4|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ | Branch (52:6): [True: 4, False: 2.43k] ------------------ 53| | 54| 2.43k| if ((v0 = hex_value(*str++)) < 0) { return SPDK_JSON_PARSE_INVALID; } ------------------ | | 73| 8|#define SPDK_JSON_PARSE_INVALID -1 ------------------ | Branch (54:6): [True: 8, False: 2.43k] ------------------ 55| 2.43k| if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; } ------------------ | | 78| 5|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ | Branch (55:6): [True: 5, False: 2.42k] ------------------ 56| | 57| 2.42k| val = v0 | (v1 << 4) | (v2 << 8) | (v3 << 12); 58| | 59| 2.42k| if (surrogate_high) { ------------------ | Branch (59:6): [True: 447, False: 1.97k] ------------------ 60| | /* We already parsed the high surrogate, so this should be the low part. */ 61| 447| if (!utf16_valid_surrogate_low(val)) { ------------------ | Branch (61:7): [True: 25, False: 422] ------------------ 62| 25| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 25|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 63| 25| } 64| | 65| | /* Convert UTF-16 surrogate pair into codepoint and fall through to utf8_encode. */ 66| 422| val = utf16_decode_surrogate_pair(surrogate_high, val); 67| 1.97k| } else if (utf16_valid_surrogate_high(val)) { ------------------ | Branch (67:13): [True: 470, False: 1.50k] ------------------ 68| 470| surrogate_high = val; 69| | 70| | /* 71| | * We parsed a \uXXXX sequence that decoded to the first half of a 72| | * UTF-16 surrogate pair, so it must be immediately followed by another 73| | * \uXXXX escape. 74| | * 75| | * Loop around to get the low half of the surrogate pair. 76| | */ 77| 470| if (buf_end == str) { return SPDK_JSON_PARSE_INCOMPLETE; } ------------------ | | 78| 0|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ | Branch (77:7): [True: 0, False: 470] ------------------ 78| 470| goto decode; 79| 1.50k| } else if (utf16_valid_surrogate_low(val)) { ------------------ | Branch (79:13): [True: 12, False: 1.49k] ------------------ 80| | /* 81| | * We found the second half of surrogate pair without the first half; 82| | * this is an invalid encoding. 83| | */ 84| 12| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 12|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 85| 12| } 86| | 87| | /* 88| | * Convert Unicode escape (or surrogate pair) to UTF-8 in place. 89| | * 90| | * This is safe (will not write beyond the buffer) because the \uXXXX sequence is 6 bytes 91| | * (or 12 bytes for surrogate pairs), and the longest possible UTF-8 encoding of a 92| | * single codepoint is 4 bytes. 93| | */ 94| 1.91k| if (out) { ------------------ | Branch (94:6): [True: 0, False: 1.91k] ------------------ 95| 0| rc = utf8_encode_unsafe(out, val); 96| 1.91k| } else { 97| 1.91k| rc = utf8_codepoint_len(val); 98| 1.91k| } 99| 1.91k| if (rc < 0) { ------------------ | Branch (99:6): [True: 0, False: 1.91k] ------------------ 100| 0| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 0|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 101| 0| } 102| | 103| 1.91k| *strp = str; /* update input pointer */ 104| 1.91k| return rc; /* return number of bytes decoded */ 105| 1.91k|} json_parse.c:hex_value: 14| 9.78k|{ 15| 9.78k|#define V(x, y) [x] = y + 1 16| 9.78k| static const int8_t val[256] = { 17| 9.78k| V('0', 0), V('1', 1), V('2', 2), V('3', 3), V('4', 4), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('0', 0), V('1', 1), V('2', 2), V('3', 3), V('4', 4), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('0', 0), V('1', 1), V('2', 2), V('3', 3), V('4', 4), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('0', 0), V('1', 1), V('2', 2), V('3', 3), V('4', 4), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('0', 0), V('1', 1), V('2', 2), V('3', 3), V('4', 4), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ 18| 9.78k| V('5', 5), V('6', 6), V('7', 7), V('8', 8), V('9', 9), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('5', 5), V('6', 6), V('7', 7), V('8', 8), V('9', 9), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('5', 5), V('6', 6), V('7', 7), V('8', 8), V('9', 9), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('5', 5), V('6', 6), V('7', 7), V('8', 8), V('9', 9), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('5', 5), V('6', 6), V('7', 7), V('8', 8), V('9', 9), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ 19| 9.78k| V('A', 0xA), V('B', 0xB), V('C', 0xC), V('D', 0xD), V('E', 0xE), V('F', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('A', 0xA), V('B', 0xB), V('C', 0xC), V('D', 0xD), V('E', 0xE), V('F', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('A', 0xA), V('B', 0xB), V('C', 0xC), V('D', 0xD), V('E', 0xE), V('F', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('A', 0xA), V('B', 0xB), V('C', 0xC), V('D', 0xD), V('E', 0xE), V('F', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('A', 0xA), V('B', 0xB), V('C', 0xC), V('D', 0xD), V('E', 0xE), V('F', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('A', 0xA), V('B', 0xB), V('C', 0xC), V('D', 0xD), V('E', 0xE), V('F', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ 20| 9.78k| V('a', 0xA), V('b', 0xB), V('c', 0xC), V('d', 0xD), V('e', 0xE), V('f', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('a', 0xA), V('b', 0xB), V('c', 0xC), V('d', 0xD), V('e', 0xE), V('f', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('a', 0xA), V('b', 0xB), V('c', 0xC), V('d', 0xD), V('e', 0xE), V('f', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('a', 0xA), V('b', 0xB), V('c', 0xC), V('d', 0xD), V('e', 0xE), V('f', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('a', 0xA), V('b', 0xB), V('c', 0xC), V('d', 0xD), V('e', 0xE), V('f', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ V('a', 0xA), V('b', 0xB), V('c', 0xC), V('d', 0xD), V('e', 0xE), V('f', 0xF), ------------------ | | 15| 9.78k|#define V(x, y) [x] = y + 1 ------------------ 21| 9.78k| }; 22| 9.78k|#undef V 23| | 24| 9.78k| return val[c] - 1; 25| 9.78k|} json_parse.c:json_valid_number: 236| 7.15k|{ 237| 7.15k| uint8_t *p = start; 238| 7.15k| uint8_t c; 239| | 240| 7.15k| if (p >= buf_end) { return -1; } ------------------ | Branch (240:6): [True: 0, False: 7.15k] ------------------ 241| | 242| 7.15k| c = *p++; 243| 7.15k| if (c >= '1' && c <= '9') { goto num_int_digits; } ------------------ | Branch (243:6): [True: 4.49k, False: 2.65k] | Branch (243:18): [True: 4.49k, False: 0] ------------------ 244| 2.65k| if (c == '0') { goto num_frac_or_exp; } ------------------ | Branch (244:6): [True: 2.05k, False: 599] ------------------ 245| 599| if (c == '-') { goto num_int_first_digit; } ------------------ | Branch (245:6): [True: 599, False: 0] ------------------ 246| 0| p--; 247| 0| goto done_invalid; 248| | 249| 599|num_int_first_digit: 250| 599| if (spdk_likely(p != buf_end)) { ------------------ | | 20| 599|#define spdk_likely(cond) __builtin_expect(!!(cond), 1) | | ------------------ | | | Branch (20:27): [True: 598, False: 1] | | ------------------ ------------------ 251| 598| c = *p++; 252| 598| if (c == '0') { goto num_frac_or_exp; } ------------------ | Branch (252:7): [True: 275, False: 323] ------------------ 253| 323| if (c >= '1' && c <= '9') { goto num_int_digits; } ------------------ | Branch (253:7): [True: 316, False: 7] | Branch (253:19): [True: 303, False: 13] ------------------ 254| 20| p--; 255| 20| } 256| 21| goto done_invalid; 257| | 258| 26.1k|num_int_digits: 259| 26.1k| if (spdk_likely(p != buf_end)) { ------------------ | | 20| 26.1k|#define spdk_likely(cond) __builtin_expect(!!(cond), 1) | | ------------------ | | | Branch (20:27): [True: 26.0k, False: 71] | | ------------------ ------------------ 260| 26.0k| c = *p++; 261| 26.0k| if (c >= '0' && c <= '9') { goto num_int_digits; } ------------------ | Branch (261:7): [True: 22.6k, False: 3.47k] | Branch (261:19): [True: 21.3k, False: 1.25k] ------------------ 262| 4.73k| if (c == '.') { goto num_frac_first_digit; } ------------------ | Branch (262:7): [True: 833, False: 3.89k] ------------------ 263| 3.89k| if (c == 'e' || c == 'E') { goto num_exp_sign; } ------------------ | Branch (263:7): [True: 410, False: 3.48k] | Branch (263:19): [True: 614, False: 2.87k] ------------------ 264| 2.87k| p--; 265| 2.87k| } 266| 2.94k| goto done_valid; 267| | 268| 2.94k|num_frac_or_exp: 269| 2.33k| if (spdk_likely(p != buf_end)) { ------------------ | | 20| 2.33k|#define spdk_likely(cond) __builtin_expect(!!(cond), 1) | | ------------------ | | | Branch (20:27): [True: 2.31k, False: 18] | | ------------------ ------------------ 270| 2.31k| c = *p++; 271| 2.31k| if (c == '.') { goto num_frac_first_digit; } ------------------ | Branch (271:7): [True: 403, False: 1.91k] ------------------ 272| 1.91k| if (c == 'e' || c == 'E') { goto num_exp_sign; } ------------------ | Branch (272:7): [True: 600, False: 1.31k] | Branch (272:19): [True: 376, False: 935] ------------------ 273| 935| p--; 274| 935| } 275| 953| goto done_valid; 276| | 277| 1.23k|num_frac_first_digit: 278| 1.23k| if (spdk_likely(p != buf_end)) { ------------------ | | 20| 1.23k|#define spdk_likely(cond) __builtin_expect(!!(cond), 1) | | ------------------ | | | Branch (20:27): [True: 1.22k, False: 16] | | ------------------ ------------------ 279| 1.22k| c = *p++; 280| 1.22k| if (c >= '0' && c <= '9') { goto num_frac_digits; } ------------------ | Branch (280:7): [True: 1.21k, False: 7] | Branch (280:19): [True: 1.20k, False: 9] ------------------ 281| 16| p--; 282| 16| } 283| 32| goto done_invalid; 284| | 285| 12.7k|num_frac_digits: 286| 12.7k| if (spdk_likely(p != buf_end)) { ------------------ | | 20| 12.7k|#define spdk_likely(cond) __builtin_expect(!!(cond), 1) | | ------------------ | | | Branch (20:27): [True: 12.7k, False: 17] | | ------------------ ------------------ 287| 12.7k| c = *p++; 288| 12.7k| if (c >= '0' && c <= '9') { goto num_frac_digits; } ------------------ | Branch (288:7): [True: 12.1k, False: 573] | Branch (288:19): [True: 11.5k, False: 614] ------------------ 289| 1.18k| if (c == 'e' || c == 'E') { goto num_exp_sign; } ------------------ | Branch (289:7): [True: 200, False: 987] | Branch (289:19): [True: 204, False: 783] ------------------ 290| 783| p--; 291| 783| } 292| 800| goto done_valid; 293| | 294| 2.40k|num_exp_sign: 295| 2.40k| if (spdk_likely(p != buf_end)) { ------------------ | | 20| 2.40k|#define spdk_likely(cond) __builtin_expect(!!(cond), 1) | | ------------------ | | | Branch (20:27): [True: 2.35k, False: 48] | | ------------------ ------------------ 296| 2.35k| c = *p++; 297| 2.35k| if (c >= '0' && c <= '9') { goto num_exp_digits; } ------------------ | Branch (297:7): [True: 1.74k, False: 609] | Branch (297:19): [True: 1.73k, False: 8] ------------------ 298| 617| if (c == '-' || c == '+') { goto num_exp_first_digit; } ------------------ | Branch (298:7): [True: 349, False: 268] | Branch (298:19): [True: 248, False: 20] ------------------ 299| 20| p--; 300| 20| } 301| 68| goto done_invalid; 302| | 303| 597|num_exp_first_digit: 304| 597| if (spdk_likely(p != buf_end)) { ------------------ | | 20| 597|#define spdk_likely(cond) __builtin_expect(!!(cond), 1) | | ------------------ | | | Branch (20:27): [True: 581, False: 16] | | ------------------ ------------------ 305| 581| c = *p++; 306| 581| if (c >= '0' && c <= '9') { goto num_exp_digits; } ------------------ | Branch (306:7): [True: 574, False: 7] | Branch (306:19): [True: 569, False: 5] ------------------ 307| 12| p--; 308| 12| } 309| 28| goto done_invalid; 310| | 311| 1.01M|num_exp_digits: 312| 1.01M| if (spdk_likely(p != buf_end)) { ------------------ | | 20| 1.01M|#define spdk_likely(cond) __builtin_expect(!!(cond), 1) | | ------------------ | | | Branch (20:27): [True: 1.01M, False: 39] | | ------------------ ------------------ 313| 1.01M| c = *p++; 314| 1.01M| if (c >= '0' && c <= '9') { goto num_exp_digits; } ------------------ | Branch (314:7): [True: 1.01M, False: 2.07k] | Branch (314:19): [True: 1.01M, False: 197] ------------------ 315| 2.26k| p--; 316| 2.26k| } 317| 2.30k| goto done_valid; 318| | 319| 7.00k|done_valid: 320| | /* Valid end state */ 321| 7.00k| return p - start; 322| | 323| 149|done_invalid: 324| | /* Invalid end state */ 325| 149| if (p == buf_end) { ------------------ | Branch (325:6): [True: 81, False: 68] ------------------ 326| | /* Hit the end of the buffer - the stream is incomplete. */ 327| 81| return SPDK_JSON_PARSE_INCOMPLETE; ------------------ | | 78| 81|#define SPDK_JSON_PARSE_INCOMPLETE -2 ------------------ 328| 81| } 329| | 330| | /* Found an invalid character in an invalid end state */ 331| 68| return SPDK_JSON_PARSE_INVALID; ------------------ | | 73| 68|#define SPDK_JSON_PARSE_INVALID -1 ------------------ 332| 149|}