Branch Coverage

picohttpparser-git/picohttpparser.c
Criterion Covered Total %
branch 125 288 43.4


line true false branch
148 4997 54 while (likely(buf_end - buf >= 8)) {
155 16 4981 DOIT();
156 426 4555 DOIT();
157 37 4518 DOIT();
158 21 4497 DOIT();
159 44 4453 DOIT();
160 413 4040 DOIT();
161 23 4017 DOIT();
162 528 3489 DOIT();
166 1508 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 1508 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 165 CHECK_EOF();
174 52 113 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 1533 27 if (likely(*buf == '\015')) {
183 0 1533 EXPECT_CHAR('\012');
0 1533 EXPECT_CHAR('\012');
185 26 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 2146 if (!found) {
262 2146 0 CHECK_EOF();
265 2136 15768 if (*buf == next_char) {
267 8 15760 } else if (!token_char_map[(unsigned char)*buf]) {
272 2 15758 CHECK_EOF();
283 0 566 if (buf_end - buf < 9) {
287 1 565 EXPECT_CHAR_NO_CHECK('H');
288 0 565 EXPECT_CHAR_NO_CHECK('T');
289 0 565 EXPECT_CHAR_NO_CHECK('T');
290 0 565 EXPECT_CHAR_NO_CHECK('P');
291 0 565 EXPECT_CHAR_NO_CHECK('/');
292 0 565 EXPECT_CHAR_NO_CHECK('1');
293 0 565 EXPECT_CHAR_NO_CHECK('.');
294 565 0 PARSE_INT(minor_version, 1);
0 565 PARSE_INT(minor_version, 1);
302 3 2121 CHECK_EOF();
303 545 1576 if (*buf == '\015') {
305 0 545 EXPECT_CHAR('\012');
0 545 EXPECT_CHAR('\012');
307 11 1565 } else if (*buf == '\012') {
311 2 1563 if (*num_headers == max_headers) {
315 1001 562 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
1000 1 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
1000 0 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
318 0 1562 if ((buf = parse_token(buf, buf_end, &headers[*num_headers].name, &headers[*num_headers].name_len, ':', ret)) == NULL) {
321 0 1562 if (headers[*num_headers].name_len == 0) {
327 1 3127 CHECK_EOF();
328 1562 1565 if (!(*buf == ' ' || *buf == '\t')) {
1561 1 if (!(*buf == ' ' || *buf == '\t')) {
338 3 1559 if ((buf = get_token_to_eol(buf, buf_end, &value, &value_len, ret)) == NULL) {
343 1558 1 for (; value_end != value; --value_end) {
345 1558 0 if (!(c == ' ' || c == '\t')) {
1558 0 if (!(c == ' ' || c == '\t')) {
360 0 584 CHECK_EOF();
361 0 584 if (*buf == '\015') {
363 0 0 EXPECT_CHAR('\012');
0 0 EXPECT_CHAR('\012');
364 0 584 } else if (*buf == '\012') {
369 10 574 if ((buf = parse_token(buf, buf_end, method, method_len, ' ', ret)) == NULL) {
374 0 574 CHECK_EOF();
375 0 574 } while (*buf == ' ');
376 0 574 ADVANCE_TOKEN(*path, *path_len);
574 0 ADVANCE_TOKEN(*path, *path_len);
566 60585 ADVANCE_TOKEN(*path, *path_len);
4 60581 ADVANCE_TOKEN(*path, *path_len);
0 4 ADVANCE_TOKEN(*path, *path_len);
0 0 ADVANCE_TOKEN(*path, *path_len);
4 60577 ADVANCE_TOKEN(*path, *path_len);
379 0 566 CHECK_EOF();
380 0 566 } while (*buf == ' ');
381 566 0 if (*method_len == 0 || *path_len == 0) {
0 566 if (*method_len == 0 || *path_len == 0) {
385 1 565 if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
388 554 11 if (*buf == '\015') {
390 0 554 EXPECT_CHAR('\012');
0 554 EXPECT_CHAR('\012');
391 11 0 } else if (*buf == '\012') {
417 16 578 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 28 556 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)