Branch Coverage

picohttpparser-git/picohttpparser.c
Criterion Covered Total %
branch 128 288 44.4


line true false branch
148 5232 54 while (likely(buf_end - buf >= 8)) {
155 17 5215 DOIT();
156 498 4717 DOIT();
157 37 4680 DOIT();
158 22 4658 DOIT();
159 48 4610 DOIT();
160 472 4138 DOIT();
161 24 4114 DOIT();
162 553 3561 DOIT();
166 1671 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 1671 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 1708 15 if (likely(*buf == '\015')) {
183 0 1708 EXPECT_CHAR('\012');
0 1708 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 2378 if (!found) {
262 2378 0 CHECK_EOF();
265 2369 17273 if (*buf == next_char) {
267 7 17266 } else if (!token_char_map[(unsigned char)*buf]) {
272 2 17264 CHECK_EOF();
283 0 637 if (buf_end - buf < 9) {
287 2 635 EXPECT_CHAR_NO_CHECK('H');
288 0 635 EXPECT_CHAR_NO_CHECK('T');
289 0 635 EXPECT_CHAR_NO_CHECK('T');
290 0 635 EXPECT_CHAR_NO_CHECK('P');
291 0 635 EXPECT_CHAR_NO_CHECK('/');
292 0 635 EXPECT_CHAR_NO_CHECK('1');
293 0 635 EXPECT_CHAR_NO_CHECK('.');
294 635 0 PARSE_INT(minor_version, 1);
0 635 PARSE_INT(minor_version, 1);
302 3 2354 CHECK_EOF();
303 621 1733 if (*buf == '\015') {
305 0 621 EXPECT_CHAR('\012');
0 621 EXPECT_CHAR('\012');
307 5 1728 } else if (*buf == '\012') {
311 2 1726 if (*num_headers == max_headers) {
315 1094 632 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
1093 1 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
1093 0 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
318 0 1725 if ((buf = parse_token(buf, buf_end, &headers[*num_headers].name, &headers[*num_headers].name_len, ':', ret)) == NULL) {
321 0 1725 if (headers[*num_headers].name_len == 0) {
327 1 3453 CHECK_EOF();
328 1725 1728 if (!(*buf == ' ' || *buf == '\t')) {
1724 1 if (!(*buf == ' ' || *buf == '\t')) {
338 3 1722 if ((buf = get_token_to_eol(buf, buf_end, &value, &value_len, ret)) == NULL) {
343 1721 1 for (; value_end != value; --value_end) {
345 1721 0 if (!(c == ' ' || c == '\t')) {
1721 0 if (!(c == ' ' || c == '\t')) {
360 0 653 CHECK_EOF();
361 1 652 if (*buf == '\015') {
363 0 1 EXPECT_CHAR('\012');
0 1 EXPECT_CHAR('\012');
364 0 652 } else if (*buf == '\012') {
369 9 644 if ((buf = parse_token(buf, buf_end, method, method_len, ' ', ret)) == NULL) {
374 0 644 CHECK_EOF();
375 0 644 } while (*buf == ' ');
376 0 644 ADVANCE_TOKEN(*path, *path_len);
644 0 ADVANCE_TOKEN(*path, *path_len);
637 61033 ADVANCE_TOKEN(*path, *path_len);
3 61030 ADVANCE_TOKEN(*path, *path_len);
0 3 ADVANCE_TOKEN(*path, *path_len);
0 0 ADVANCE_TOKEN(*path, *path_len);
4 61026 ADVANCE_TOKEN(*path, *path_len);
379 0 637 CHECK_EOF();
380 0 637 } while (*buf == ' ');
381 637 0 if (*method_len == 0 || *path_len == 0) {
0 637 if (*method_len == 0 || *path_len == 0) {
385 2 635 if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
388 630 5 if (*buf == '\015') {
390 0 630 EXPECT_CHAR('\012');
0 630 EXPECT_CHAR('\012');
391 5 0 } else if (*buf == '\012') {
417 16 647 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 27 626 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)