Branch Coverage

picohttpparser-git/picohttpparser.c
Criterion Covered Total %
branch 129 288 44.7


line true false branch
148 5168 54 while (likely(buf_end - buf >= 8)) {
155 17 5151 DOIT();
156 478 4673 DOIT();
157 37 4636 DOIT();
158 22 4614 DOIT();
159 48 4566 DOIT();
160 452 4114 DOIT();
161 24 4090 DOIT();
162 549 3541 DOIT();
166 1627 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 1627 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
173 2 142 CHECK_EOF();
174 52 90 if (unlikely(!IS_PRINTABLE_ASCII(*buf))) {
175 52 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 52 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
181 1664 15 if (likely(*buf == '\015')) {
183 0 1664 EXPECT_CHAR('\012');
0 1664 EXPECT_CHAR('\012');
185 14 1 } else if (*buf == '\012') {
200 12 4 buf = last_len < 3 ? buf : buf + last_len - 3;
203 10 29102 CHECK_EOF();
204 21 29081 if (*buf == '\015') {
206 0 21 CHECK_EOF();
207 0 21 EXPECT_CHAR('\012');
0 21 EXPECT_CHAR('\012');
209 0 29081 } else if (*buf == '\012') {
216 6 29096 if (ret_cnt == 2) {
261 0 2316 if (!found) {
262 2316 0 CHECK_EOF();
265 2305 16859 if (*buf == next_char) {
267 9 16850 } else if (!token_char_map[(unsigned char)*buf]) {
272 2 16848 CHECK_EOF();
283 0 617 if (buf_end - buf < 9) {
287 2 615 EXPECT_CHAR_NO_CHECK('H');
288 0 615 EXPECT_CHAR_NO_CHECK('T');
289 0 615 EXPECT_CHAR_NO_CHECK('T');
290 0 615 EXPECT_CHAR_NO_CHECK('P');
291 0 615 EXPECT_CHAR_NO_CHECK('/');
292 0 615 EXPECT_CHAR_NO_CHECK('1');
293 0 615 EXPECT_CHAR_NO_CHECK('.');
294 615 0 PARSE_INT(minor_version, 1);
0 615 PARSE_INT(minor_version, 1);
302 3 2290 CHECK_EOF();
303 601 1689 if (*buf == '\015') {
305 0 601 EXPECT_CHAR('\012');
0 601 EXPECT_CHAR('\012');
307 5 1684 } else if (*buf == '\012') {
311 2 1682 if (*num_headers == max_headers) {
315 1070 612 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
1069 1 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
1069 0 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
318 0 1681 if ((buf = parse_token(buf, buf_end, &headers[*num_headers].name, &headers[*num_headers].name_len, ':', ret)) == NULL) {
321 0 1681 if (headers[*num_headers].name_len == 0) {
327 1 3365 CHECK_EOF();
328 1681 1684 if (!(*buf == ' ' || *buf == '\t')) {
1680 1 if (!(*buf == ' ' || *buf == '\t')) {
338 3 1678 if ((buf = get_token_to_eol(buf, buf_end, &value, &value_len, ret)) == NULL) {
343 1677 1 for (; value_end != value; --value_end) {
345 1677 0 if (!(c == ' ' || c == '\t')) {
1677 0 if (!(c == ' ' || c == '\t')) {
360 0 635 CHECK_EOF();
361 1 634 if (*buf == '\015') {
363 0 1 EXPECT_CHAR('\012');
0 1 EXPECT_CHAR('\012');
364 0 634 } else if (*buf == '\012') {
369 11 624 if ((buf = parse_token(buf, buf_end, method, method_len, ' ', ret)) == NULL) {
374 0 624 CHECK_EOF();
375 0 624 } while (*buf == ' ');
376 0 624 ADVANCE_TOKEN(*path, *path_len);
624 0 ADVANCE_TOKEN(*path, *path_len);
618 60910 ADVANCE_TOKEN(*path, *path_len);
2 60908 ADVANCE_TOKEN(*path, *path_len);
0 2 ADVANCE_TOKEN(*path, *path_len);
0 0 ADVANCE_TOKEN(*path, *path_len);
4 60904 ADVANCE_TOKEN(*path, *path_len);
379 0 618 CHECK_EOF();
380 0 618 } while (*buf == ' ');
381 617 1 if (*method_len == 0 || *path_len == 0) {
0 617 if (*method_len == 0 || *path_len == 0) {
385 2 615 if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
388 610 5 if (*buf == '\015') {
390 0 610 EXPECT_CHAR('\012');
0 610 EXPECT_CHAR('\012');
391 5 0 } else if (*buf == '\012') {
417 16 629 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
10 6 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
421 29 606 if ((buf = parse_request(buf, buf_end, method, method_len, path, path_len, minor_version, headers, num_headers, max_headers,
433 0 0 if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
437 0 0 if (*buf != ' ') {
443 0 0 CHECK_EOF();
444 0 0 } while (*buf == ' ');
446 0 0 if (buf_end - buf < 4) {
450 0 0 PARSE_INT_3(status);
0 0 PARSE_INT_3(status);
0 0 PARSE_INT_3(status);
0 0 PARSE_INT_3(status);
0 0 PARSE_INT_3(status);
0 0 PARSE_INT_3(status);
453 0 0 if ((buf = get_token_to_eol(buf, buf_end, msg, msg_len, ret)) == NULL) {
456 0 0 if (*msg_len == 0) {
458 0 0 } else if (**msg == ' ') {
464 0 0 } while (**msg == ' ');
489 0 0 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
0 0 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
493 0 0 if ((buf = parse_response(buf, buf_end, minor_version, status, msg, msg_len, headers, num_headers, max_headers, &r)) == NULL) {
510 0 0 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
0 0 if (last_len != 0 && is_complete(buf, buf_end, last_len, &r) == NULL) {
514 0 0 if ((buf = parse_headers(buf, buf_end, headers, num_headers, max_headers, &r)) == NULL) {
534 0 0 if ('0' <= ch && ch <= '9') {
0 0 if ('0' <= ch && ch <= '9') {
536 0 0 } else if ('A' <= ch && ch <= 'F') {
0 0 } else if ('A' <= ch && ch <= 'F') {
538 0 0 } else if ('a' <= ch && ch <= 'f') {
0 0 } else if ('a' <= ch && ch <= 'f') {
557 0 0 if (src == bufsz)
559 0 0 if ((v = decode_hex(buf[src])) == -1) {
560 0 0 if (decoder->_hex_count == 0) {
565 0 0 switch (buf[src]) {
578 0 0 if (decoder->_hex_count == sizeof(size_t) * 2) {
591 0 0 if (src == bufsz)
593 0 0 if (buf[src] == '\015') {
595 0 0 } else if (buf[src] == '\012') {
604 0 0 if (src == bufsz)
606 0 0 if (buf[src] != '\012') {
611 0 0 if (decoder->bytes_left_in_chunk == 0) {
612 0 0 if (decoder->consume_trailer) {
623 0 0 if (avail < decoder->bytes_left_in_chunk) {
624 0 0 if (dst != src)
631 0 0 if (dst != src)
640 0 0 if (src == bufsz)
642 0 0 if (buf[src] != '\015') {
650 0 0 if (src == bufsz)
652 0 0 if (buf[src] != '\012') {
661 0 0 if (src == bufsz)
663 0 0 if (buf[src] != '\015')
666 0 0 if (buf[src++] == '\012')
672 0 0 if (src == bufsz)
674 0 0 if (buf[src] == '\012')
688 0 0 if (dst != src)
692 0 0 if (ret == -2) {
694 0 0 if (decoder->_total_overhead >= 100 * 1024 && decoder->_total_read - decoder->_total_overhead < decoder->_total_read / 4)
0 0 if (decoder->_total_overhead >= 100 * 1024 && decoder->_total_read - decoder->_total_overhead < decoder->_total_read / 4)