Branch Coverage

picohttpparser-git/picohttpparser.c
Criterion Covered Total %
branch 90 280 32.1


line true false branch
148 467 9 while (likely(buf_end - buf >= 8)) {
155 0 467 DOIT();
156 30 437 DOIT();
157 16 421 DOIT();
158 13 408 DOIT();
159 14 394 DOIT();
160 65 329 DOIT();
161 2 327 DOIT();
162 121 206 DOIT();
166 261 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 261 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 0 18 CHECK_EOF();
174 9 9 if (unlikely(!IS_PRINTABLE_ASCII(*buf))) {
175 9 0 if ((likely((unsigned char)*buf < '\040') && likely(*buf != '\011')) || unlikely(*buf == '\177')) {
0 9 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 270 0 if (likely(*buf == '\015')) {
183 0 270 EXPECT_CHAR('\012');
0 270 EXPECT_CHAR('\012');
185 0 0 } else if (*buf == '\012') {
200 0 0 buf = last_len < 3 ? buf : buf + last_len - 3;
203 0 0 CHECK_EOF();
204 0 0 if (*buf == '\015') {
206 0 0 CHECK_EOF();
207 0 0 EXPECT_CHAR('\012');
0 0 EXPECT_CHAR('\012');
209 0 0 } else if (*buf == '\012') {
216 0 0 if (ret_cnt == 2) {
261 0 356 if (!found) {
262 356 0 CHECK_EOF();
265 356 2461 if (*buf == next_char) {
267 0 2461 } else if (!token_char_map[(unsigned char)*buf]) {
272 0 2461 CHECK_EOF();
283 0 86 if (buf_end - buf < 9) {
287 1 85 EXPECT_CHAR_NO_CHECK('H');
288 0 85 EXPECT_CHAR_NO_CHECK('T');
289 0 85 EXPECT_CHAR_NO_CHECK('T');
290 0 85 EXPECT_CHAR_NO_CHECK('P');
291 0 85 EXPECT_CHAR_NO_CHECK('/');
292 0 85 EXPECT_CHAR_NO_CHECK('1');
293 0 85 EXPECT_CHAR_NO_CHECK('.');
294 85 0 PARSE_INT(minor_version, 1);
0 85 PARSE_INT(minor_version, 1);
302 1 354 CHECK_EOF();
303 84 270 if (*buf == '\015') {
305 0 84 EXPECT_CHAR('\012');
0 84 EXPECT_CHAR('\012');
307 0 270 } else if (*buf == '\012') {
311 0 270 if (*num_headers == max_headers) {
315 186 84 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
186 0 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
186 0 if (!(*num_headers != 0 && (*buf == ' ' || *buf == '\t'))) {
318 0 270 if ((buf = parse_token(buf, buf_end, &headers[*num_headers].name, &headers[*num_headers].name_len, ':', ret)) == NULL) {
321 0 270 if (headers[*num_headers].name_len == 0) {
327 0 540 CHECK_EOF();
328 270 270 if (!(*buf == ' ' || *buf == '\t')) {
270 0 if (!(*buf == ' ' || *buf == '\t')) {
338 0 270 if ((buf = get_token_to_eol(buf, buf_end, &value, &value_len, ret)) == NULL) {
343 270 0 for (; value_end != value; --value_end) {
345 270 0 if (!(c == ' ' || c == '\t')) {
270 0 if (!(c == ' ' || c == '\t')) {
360 0 86 CHECK_EOF();
361 0 86 if (*buf == '\015') {
363 0 0 EXPECT_CHAR('\012');
0 0 EXPECT_CHAR('\012');
364 0 86 } else if (*buf == '\012') {
369 0 86 if ((buf = parse_token(buf, buf_end, method, method_len, ' ', ret)) == NULL) {
374 0 86 CHECK_EOF();
375 0 86 } while (*buf == ' ');
376 0 86 ADVANCE_TOKEN(*path, *path_len);
86 0 ADVANCE_TOKEN(*path, *path_len);
86 446 ADVANCE_TOKEN(*path, *path_len);
0 446 ADVANCE_TOKEN(*path, *path_len);
0 0 ADVANCE_TOKEN(*path, *path_len);
0 0 ADVANCE_TOKEN(*path, *path_len);
0 446 ADVANCE_TOKEN(*path, *path_len);
379 0 86 CHECK_EOF();
380 0 86 } while (*buf == ' ');
381 86 0 if (*method_len == 0 || *path_len == 0) {
0 86 if (*method_len == 0 || *path_len == 0) {
385 1 85 if ((buf = parse_http_version(buf, buf_end, minor_version, ret)) == NULL) {
388 85 0 if (*buf == '\015') {
390 0 85 EXPECT_CHAR('\012');
0 85 EXPECT_CHAR('\012');
391 0 0 } else if (*buf == '\012') {
417 0 86 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) {
421 2 84 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) {
532 0 0 if ('0' <= ch && ch <= '9') {
0 0 if ('0' <= ch && ch <= '9') {
534 0 0 } else if ('A' <= ch && ch <= 'F') {
0 0 } else if ('A' <= ch && ch <= 'F') {
536 0 0 } else if ('a' <= ch && ch <= 'f') {
0 0 } else if ('a' <= ch && ch <= 'f') {
555 0 0 if (src == bufsz)
557 0 0 if ((v = decode_hex(buf[src])) == -1) {
558 0 0 if (decoder->_hex_count == 0) {
563 0 0 switch (buf[src]) {
576 0 0 if (decoder->_hex_count == sizeof(size_t) * 2) {
589 0 0 if (src == bufsz)
591 0 0 if (buf[src] == '\012')
595 0 0 if (decoder->bytes_left_in_chunk == 0) {
596 0 0 if (decoder->consume_trailer) {
607 0 0 if (avail < decoder->bytes_left_in_chunk) {
608 0 0 if (dst != src)
615 0 0 if (dst != src)
625 0 0 if (src == bufsz)
627 0 0 if (buf[src] != '\015')
630 0 0 if (buf[src] != '\012') {
639 0 0 if (src == bufsz)
641 0 0 if (buf[src] != '\015')
644 0 0 if (buf[src++] == '\012')
650 0 0 if (src == bufsz)
652 0 0 if (buf[src] == '\012')
666 0 0 if (dst != src)
670 0 0 if (ret == -2) {
672 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)