Branch Coverage

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


line true false branch
148 5170 55 while (likely(buf_end - buf >= 8)) {
155 17 5153 DOIT();
156 479 4674 DOIT();
157 37 4637 DOIT();
158 22 4615 DOIT();
159 48 4567 DOIT();
160 452 4115 DOIT();
161 24 4091 DOIT();
162 549 3542 DOIT();
166 1628 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 1628 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 148 CHECK_EOF();
174 53 95 if (unlikely(!IS_PRINTABLE_ASCII(*buf))) {
175 53 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 53 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 17 if (likely(*buf == '\015')) {
183 0 1664 EXPECT_CHAR('\012');
0 1664 EXPECT_CHAR('\012');
185 16 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 2313 if (!found) {
262 2313 0 CHECK_EOF();
265 2307 16863 if (*buf == next_char) {
267 4 16859 } else if (!token_char_map[(unsigned char)*buf]) {
272 2 16857 CHECK_EOF();
283 0 618 if (buf_end - buf < 9) {
287 2 616 EXPECT_CHAR_NO_CHECK('H');
288 0 616 EXPECT_CHAR_NO_CHECK('T');
289 0 616 EXPECT_CHAR_NO_CHECK('T');
290 0 616 EXPECT_CHAR_NO_CHECK('P');
291 0 616 EXPECT_CHAR_NO_CHECK('/');
292 0 616 EXPECT_CHAR_NO_CHECK('1');
293 0 616 EXPECT_CHAR_NO_CHECK('.');
294 616 0 PARSE_INT(minor_version, 1);
0 616 PARSE_INT(minor_version, 1);
302 3 2293 CHECK_EOF();
303 601 1692 if (*buf == '\015') {
305 0 601 EXPECT_CHAR('\012');
0 601 EXPECT_CHAR('\012');
307 6 1686 } else if (*buf == '\012') {
311 2 1684 if (*num_headers == max_headers) {
315 1071 613 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
1070 1 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
1070 0 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
318 0 1683 if ((buf = parse_token(buf, buf_end, &headers[*num_headers].name, &headers[*num_headers].name_len, ':', ret)) == NULL) {
321 0 1683 if (headers[*num_headers].name_len == 0) {
327 1 3369 CHECK_EOF();
328 1683 1686 if (!(*buf == ' ' || *buf == '\t')) {
1682 1 if (!(*buf == ' ' || *buf == '\t')) {
338 3 1680 if ((buf = get_token_to_eol(buf, buf_end, &value, &value_len, ret)) == NULL) {
343 1679 1 for (; value_end != value; --value_end) {
345 1679 0 if (!(c == ' ' || c == '\t')) {
1679 0 if (!(c == ' ' || c == '\t')) {
360 0 630 CHECK_EOF();
361 1 629 if (*buf == '\015') {
363 0 1 EXPECT_CHAR('\012');
0 1 EXPECT_CHAR('\012');
364 0 629 } else if (*buf == '\012') {
369 6 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 618 0 if (*method_len == 0 || *path_len == 0) {
0 618 if (*method_len == 0 || *path_len == 0) {
385 2 616 if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
388 610 6 if (*buf == '\015') {
390 0 610 EXPECT_CHAR('\012');
0 610 EXPECT_CHAR('\012');
391 6 0 } else if (*buf == '\012') {
417 16 624 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 23 607 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)