Branch Coverage

functions.c
Criterion Covered Total %
branch 626 664 94.2


line true false branch
57 87 2727 if (!ref) {
78 20 1896 if (!ref) {
99 2 926 if (!ref) {
138 1 2 if (len > 511) {
184 208 52 for (i = 0; i < 4; i++) {
221 12164 15442 : ((c >= 'a') && (c <= 'f')) ? 10 + (c - 'a')
15439 0 : ((c >= 'a') && (c <= 'f')) ? 10 + (c - 'a')
222 15439 3 : -1;
234 53 5508 if (!n) {
239 104338 5508 for (c = 0; n; c++) {
261 2115970 66129 for (i = 0; i < len; i++) {
287 81 7 for (i = 0; i < len; i++) {
323 3 16005 if (len == 0) {
327 2047795 16005 for (i = 0; i < len; i++) {
328 380263 1667532 buf[len - 1 - i] = (n128_tstbit(num, i) ? '1' : '0');
350 1 12 if (!version) {
357 155 10 for (i = 0; i < len; i++) {
358 2 153 if (!isdigit(ip_int_str[i])) {
359 1 1 memset(buf, '0', (version == 4) ? 32 : 128);
360 1 1 buf[(version == 4) ? 32 : 128] = '\0';
367 1 9 if (!res) {
390 7 3 if (len <= 32) {
420 2 947 if (!len) {
427 10530 590 for (i = 0; i < len; i++) {
428 2017 8513 if (!isdigit(str[i]) && str[i] != '.') {
357 1660 if (!isdigit(str[i]) && str[i] != '.') {
436 1 589 if (str[0] == '.') {
441 1 588 if (str[len - 1] == '.') {
448 10153 587 for (i = 0; i < len; i++) {
449 1656 8497 if (str[i] == '.') {
450 1 1655 if (quads == 3) {
461 9554 586 for (i = 0; i < (len - 1); i++) {
462 1650 7904 if ((str[i] == '.') && (str[i + 1] == '.')) {
1 1649 if ((str[i] == '.') && (str[i + 1] == '.')) {
470 2235 577 for (cq_index = 0; cq_index <= quads; cq_index++) {
471 1649 586 i = (cq_index > 0) ? (quadspots[cq_index - 1]) : 0;
476 2232 3 if (STRTOL_FAILED(current_quad, str + i, endptr)
0 2232 if (STRTOL_FAILED(current_quad, str + i, endptr)
0 3 if (STRTOL_FAILED(current_quad, str + i, endptr)
295 1937 if (STRTOL_FAILED(current_quad, str + i, endptr)
295 0 if (STRTOL_FAILED(current_quad, str + i, endptr)
477 2232 0 || (!(current_quad >= 0 && current_quad < 256))) {
6 2226 || (!(current_quad >= 0 && current_quad < 256))) {
509 368 79 max_colons = (double_colon == NULL) ? 7 : 8;
514 16654 445 for (i = 0; i < len; i++) {
515 2646 14008 if (str[i] == ':') {
516 2 2644 if (octs == max_colons) {
523 12 433 if (!octs) {
527 3060 430 for (oct_index = 0; oct_index <= octs; oct_index++) {
528 2627 433 i = (oct_index > 0) ? (octspots[oct_index - 1]) : 0;
532 119 2941 if (str[i] == ':') {
535 68 2873 if (strlen(str + i) == 0) {
542 363 2510 if ((oct_index == octs) && NI_ip_is_ipv4(cc)) {
16 347 if ((oct_index == octs) && NI_ip_is_ipv4(cc)) {
549 347 2510 if (next_oct == NULL) {
556 11338 2855 while (cc != next_oct) {
557 2 11336 if (!isxdigit(*cc)) {
564 2855 2 if (is_hd && (count <= 4)) {
2854 1 if (is_hd && (count <= 4)) {
574 40 390 if ((str[0] == ':') && (str[1] != ':')) {
1 39 if ((str[0] == ':') && (str[1] != ':')) {
580 68 361 if ((str[len - 1] == ':') && (str[len - 2] != ':')) {
1 67 if ((str[len - 1] == ':') && (str[len - 2] != ':')) {
588 77 351 if ((double_colon != NULL) && (strstr(double_colon + 1, "::"))) {
1 76 if ((double_colon != NULL) && (strstr(double_colon + 1, "::"))) {
596 77 350 if ((octs != 7) && (double_colon == NULL)) {
1 76 if ((octs != 7) && (double_colon == NULL)) {
614 560 423 if ((!strchr(str, ':')) && NI_ip_is_ipv4(str)) {
549 11 if ((!strchr(str, ':')) && NI_ip_is_ipv4(str)) {
616 421 13 } else if (NI_ip_is_ipv6(str)) {
641 1 143 if (!version) {
648 1 142 if (len < 0) {
650 2 140 } else if (len > size) {
673 17 30 len = (len == 0) ? 128 : (128 - len);
675 4482 47 for (i = 0; i < len; i++) {
692 53 8 mask = (len == 0) ? 0xFFFFFFFF : ((1 << (32 - len)) - 1);
711 1 27 if (!version) {
718 26 1 if ((len < 0) || (len > size)) {
2 24 if ((len < 0) || (len > size)) {
754 949 5 : (!strcmp(op_str, "lt")) ? LT
755 939 10 : (!strcmp(op_str, "le")) ? LE
756 9 930 : (!strcmp(op_str, "ge")) ? GE
757 7 2 : 0;
759 2 952 if (!op) {
764 947 5 if ((op == GT) || (op == GE)) {
7 940 if ((op == GT) || (op == GE)) {
772 2 950 if (strlen(b) != (strlen(e))) {
780 18 2 (!res && ((op == GE) || (op == LE)))
5 13 (!res && ((op == GE) || (op == LE)))
782 20 930 : (res > 0);
921 14 : (res > 0);
801 5 10 if (!n128_cmp(begin_1, begin_2)) {
802 2 3 if (!n128_cmp(end_1, end_2)) {
808 2 1 : IP_B_IN_A_OVERLAP;
812 2 8 if (!n128_cmp(end_1, end_2)) {
815 1 1 : IP_A_IN_B_OVERLAP;
820 5 3 if (res < 0) {
822 2 3 if (res < 0) {
828 2 1 : IP_B_IN_A_OVERLAP;
833 1 2 if (res < 0) {
840 1 1 : IP_A_IN_B_OVERLAP;
858 4 9 if (begin_1 == begin_2) {
859 2 2 if (end_1 == end_2) {
866 1 1 : IP_B_IN_A_OVERLAP;
870 2 7 if (end_1 == end_2) {
874 1 1 : IP_A_IN_B_OVERLAP;
878 4 3 if (begin_1 < begin_2) {
879 2 2 if (end_1 < begin_2) {
886 1 1 : IP_B_IN_A_OVERLAP;
890 1 2 if (end_2 < begin_1) {
898 1 1 : IP_A_IN_B_OVERLAP;
939 22 1 if (!( (b1_len == (int) strlen(end_1))
1 20 if (!( (b1_len == (int) strlen(end_1))
940 21 1 && (b2_len == (int) strlen(end_2))
947 1 19 if (!res) {
953 1 18 if (!res) {
960 8 10 if (b1_len <= 32) {
995 49 1 if ((len < 0) || (len > 128)) {
1 48 if ((len < 0) || (len > 128)) {
1001 4609 48 for (i = 0; i < (128 - len); i++) {
1006 1 47 if (n128_cmp_ui(&mask, 0)) {
1026 63 1 if ((len < 0) || (len > 32)) {
1 62 if ((len < 0) || (len > 32)) {
1031 53 9 mask = (len == 0) ? 0xFFFFFFFF : ((1 << (32 - len)) - 1);
1033 1 61 if ((ip & mask) != 0) {
1055 1 159 if (len < 0) {
1062 1 158 if (len > iplen) {
1070 6062 156 while (*c != '\0') {
1071 2 6060 if (*c != '0') {
1078 1 155 if (iplen != NI_iplengths(version)) {
1100 110732 10 for (i = 0; i < bits; i++) {
1101 5551 105181 if ((begin & 1) == (end & 1)) {
1129 1316777 32 for (i = 0; i < bits; i++) {
1130 15963 1300814 if (n128_tstbit(num1, i) == n128_tstbit(num2, i)) {
1160 1 14 if (bin1_len != bin2_len) {
1167 243 2 for (i = (bin1_len - 1); i >= 0; i--) {
1168 12 231 if (bitstr_1[i] == bitstr_2[i]) {
1256 4 16033 if (size > iplen) {
1262 24 16009 if (version == 4) {
1268 64036 16009 for (i = 0; i < 4; i++) {
1275 64011 16009 for (i = (4 - longs), j = 0; i < 4; i++, j++) {
1277 3 16002 (i == (4 - longs) && excess)
1279 16005 48006 : 32;
1310 3 14 if (len1 != len2) {
1314 2 12 if (len1 > (maxlen - 1)) {
1360 5561 77 while (begin <= end) {
1364 53 5508 if (zeroes > 32) {
1369 106034 5561 for (i = 0; i < (int) zeroes; i++) {
1381 2549 5561 } while (current > end);
1390 0 5561 if (!new_prefix) {
1406 442 5119 if (current == 0xFFFFFFFF) {
1444 15995 35 while (n128_cmp(begin, end) <= 0) {
1445 0 15995 if (*pcount == 128) {
1453 51 15944 zeroes = ((zeroes == INT_MAX) ? (unsigned) iplen : zeroes) - 1;
1456 1303849 15995 for (i = 0; i < ((int) zeroes + 1); i++) {
1468 3035 15995 } while (n128_cmp(¤t, end) > 0);
1477 0 15995 if (!new_prefix) {
1496 376 15619 if (res == INT_MAX) {
1528 2 921 if (!version) {
1533 1 920 if (strlen(begin) != strlen(end)) {
1539 1 919 if (!iplen) {
1543 513 406 if (version == 4) {
1582 0 11 if (!res) {
1583 0 0 for (i = 0; i < pcount; i++) {
1589 1 10 if (pcount == 0) {
1593 1 9 if (pcount > 1) {
1594 32 1 for (i = 0; i < pcount; i++) {
1602 4 5 : MAX_IPV6_RANGE_STR_LEN - 1;
1603 0 9 if (len > max) {
1633 2 5 if (n128_cmp(e1, b2)) {
1662 1 6 if (e1 + 1 != b2) {
1706 1 13 if (!version) {
1710 7 6 } else if (version == 4) {
1711 25 6 for (i = 0; i < 4; i++) {
1712 1 24 if (strlen(addr_args[i]) != 32) {
1725 21 5 for (i = 0; i < 4; i++) {
1726 1 20 if (strlen(addr_args[i]) != 128) {
1740 1 10 if (res == 0) {
1743 2 8 if (res == 160) {
1747 1 7 if (res == 161) {
1778 1131 869 if (ipversion == 4) {
1780 4 1127 if (res == 0) {
1784 4508 1127 for (j = 0; j < 4; j++) {
1785 36064 4508 for (i = 0; i < 8; i++) {
1787 21708 14356 ((ipv4[j] & (1 << (8 - i - 1)))) ? '1' : '0';
1794 33749 869 while ((c = ip[j])) {
1795 27701 6048 if (c != ':') {
1800 4 865 if (ncount != 32) {
1806 33637 862 for (j = 0; ip[j] != '\0'; j++) {
1807 6031 27606 if (ip[j] == ':') {
1814 3 27603 if (y == -1) {
1818 110412 27603 for (k = 0; k < 4; k++) {
1820 67144 43268 ((y >> (3 - k)) & 1) ? '1' : '0';
1842 4 965 if (!res) {
1868 11 742 if (!res) {
1872 2968 742 for (i = 0; i < 4; i++) {
1900 969 753 : NI_ip_expand_address_ipv6(ip, buf);
1926 13 1 if ((len < 0) || (len > 32)) {
1 12 if ((len < 0) || (len > 32)) {
1932 1 11 if (!res) {
1936 28 11 for (i = (quads - 1); i >= 0; i--) {
1968 18 1 if ((len < 0) || (len > 128)) {
1 17 if ((len < 0) || (len > 128)) {
1974 1 16 if (!res) {
1978 110 16 for (i = (len - 1); i >= 0; i--) {
1980 58 52 shift = !(i % 2) * 4;
1999 1 34 if (!ipversion) {
2002 1 34 if (!ipversion) {
2008 14 20 if (ipversion == 4) {
2010 19 1 } else if (ipversion == 6) {
2041 54 70 if (c != '/') {
2048 70 0 if (STRTOL_FAILED(clen, slash, endptr)) {
0 70 if (STRTOL_FAILED(clen, slash, endptr)) {
0 0 if (STRTOL_FAILED(clen, slash, endptr)) {
12 58 if (STRTOL_FAILED(clen, slash, endptr)) {
3 9 if (STRTOL_FAILED(clen, slash, endptr)) {
2051 8 59 if (*endptr == ',') {
2053 3 56 } else if (endptr != (slash + strlen(slash))) {
2061 3 61 if (!res) {
2067 8 53 if (addcst) {
2103 42 53 if (c != '/') {
2110 53 0 if (STRTOL_FAILED(clen, slash, endptr)) {
0 53 if (STRTOL_FAILED(clen, slash, endptr)) {
0 0 if (STRTOL_FAILED(clen, slash, endptr)) {
31 22 if (STRTOL_FAILED(clen, slash, endptr)) {
1 30 if (STRTOL_FAILED(clen, slash, endptr)) {
2113 5 47 if (*endptr == ',') {
2115 2 45 } else if (endptr != (slash + strlen(slash))) {
2123 3 47 if (!res) {
2129 5 42 if (addcst) {
2169 23930 157 while ((c = *ip)) {
2170 821 23109 if (isspace(c)) {
2173 22131 978 if (i && (c == '/') && (!slash)) {
124 22007 if (i && (c == '/') && (!slash)) {
112 12 if (i && (c == '/') && (!slash)) {
2181 45 112 if (islash < 1) {
2188 63 49 if (ipversion == 4) {
2190 0 63 if (!res) {
2199 48 1 } else if (ipversion == 6) {
2201 0 48 if (!res) {
2242 26852 84 while ((c = *str)) {
2243 836 26016 if (c == separator) {
2245 17 819 if (!break_char) {
2246 3 14 if (!i) {
2253 856 25160 } else if (isspace(c)) {
2254 849 7 if (!break_char) {
2264 84 833 if (!hit_separator) {
2270 1 832 if (c == '\0') {
2274 1656 1 while ((c = *str) && (isspace(c))) {
825 831 while ((c = *str) && (isspace(c))) {
2278 1 831 if (c == '\0') {
2308 54 812 if (!res) {
2316 1 811 if (!ipversion) {
2324 1 810 if (!res) {
2329 0 810 if (!res) {
2356 0 15 if (!res) {
2365 14 1 if (STRTOUL_FAILED(addnum, num, endptr)) {
1 13 if (STRTOUL_FAILED(addnum, num, endptr)) {
0 2 if (STRTOUL_FAILED(addnum, num, endptr)) {
0 13 if (STRTOUL_FAILED(addnum, num, endptr)) {
0 0 if (STRTOUL_FAILED(addnum, num, endptr)) {
2368 1 12 if (addnum > 0xFFFFFFFF) {
2398 0 4 if (!res) {
2405 2 2 if (!res) {
2436 35 19 if (!res) {
2474 9 26 if (!ipversion) {
2479 0 26 if (!res) {
2504 112 866 if (res >= 0) {
2509 812 54 if (res >= 0) {
2514 19 35 if (res >= 0) {
2519 35 0 if (res >= 0) {
2546 3 6 if (!res) {
2550 1 5 sprintf(buf, "%s - %s", ip1buf,
2570 50 2 if ((len < 0) || (len > 32)) {
1 49 if ((len < 0) || (len > 32)) {
2573 2 47 if (strlen(ip) > (MAX_IPV4_RANGE_STR_LEN - 1)) {
2578 42 5 dotcount = (len == 0) ? 1 : ((len / 8) + (!(len % 8) ? 0 : 1));
2579 108 33 while (dotcount--) {
2581 14 94 if (c == NULL) {
2585 94 0 if (*(c + 1) != '\0') {
2591 0 47 if (buflen > maxlen) {
2626 1 18 if (!version) {
2632 1 17 if (version == 4) {
2638 1 16 if (!res) {
2642 128 16 for (i = 0; i < 16; i += 2) {
2643 94 34 if ((ipv6[i] == 0) && (ipv6[i + 1] == 0)) {
72 22 if ((ipv6[i] == 0) && (ipv6[i + 1] == 0)) {
2644 26 46 if (!in_ws) {
2657 64 16 for (i = 0; i < 4; i++) {
2663 20 44 if (ws_count[i] > largest && ws_count[i] > 1) {
14 6 if (ws_count[i] > largest && ws_count[i] > 1) {
2669 85 16 for (i = 0; i < 16; i += 2) {
2670 53 32 if ((largest_index != -1) && (i == ws_start[largest_index])) {
12 41 if ((largest_index != -1) && (i == ws_start[largest_index])) {
2671 2 10 if (i == 0) {
2680 59 14 if (i < 14) {
2705 2 145 if (!slash) {
2710 144 1 if ((len == 0) || (len > (MAX_IPV6_STR_LEN - 1))) {
2 142 if ((len == 0) || (len > (MAX_IPV6_STR_LEN - 1))) {
2715 1 141 if (*c == '\0') {
2722 141 0 if (STRTOL_FAILED(num, c, endptr)) {
1 140 if (STRTOL_FAILED(num, c, endptr)) {
0 1 if (STRTOL_FAILED(num, c, endptr)) {
37 103 if (STRTOL_FAILED(num, c, endptr)) {
1 36 if (STRTOL_FAILED(num, c, endptr)) {
2725 1 138 if (num < 0) {
2757 8 8 hash = get_hv(
2761 0 16 if (!hash) {
2768 268 16 while ((entry = hv_iternext(hash))) {
2770 178 90 if (keylen > current_keylen) {
2771 13 165 if (!strncmp(key, ip, keylen)) {
2775 1 12 if (len > (MAX_TYPE_STR_LEN - 1)) {
2784 10 6 if (current_keylen) {
2788 3 3 if (version == 4) {
2812 1 8 if (!version) {
2821 2 6 if (mask_len != iplen) {
2829 99 4 while (*c != '\0') {
2830 34 65 if ((*c == '1') && (state == 0)) {
33 1 if ((*c == '1') && (state == 0)) {
2834 64 2 if (*c == '0') {
2835 3 61 if (state == 0) {
2861 1 21 if (!version) {
2866 1 20 if (!NI_ip_expand_address(ip, version, buf)) {
2870 0 20 if (!NI_ip_iptobin(ip, version, bitstr1)) {
2874 18 2 bitstr1[(version == 4) ? 32 : 128] = '\0';
2876 1 19 if (!NI_ip_check_prefix(bitstr1, len, version)) {
2882 17 2 bitstr2[(version == 4) ? 32 : 128] = '\0';
2884 0 19 if (!NI_ip_bintoip(bitstr2, version, buf)) {
2903 3 5 if (c == NULL) {
2910 1 7 if (len > (MAX_IPV4_STR_LEN - 1)) {
2913 5 3 if ((len > 0) && NI_ip_is_ipv4(c)) {
4 1 if ((len > 0) && NI_ip_is_ipv4(c)) {