Branch Coverage

libeio/eio.c
Criterion Covered Total %
branch 124 358 34.6


line true false branch
418 30 26 while (grp->size < grp->int2 && !EIO_CANCELLED (grp))
30 0 while (grp->size < grp->int2 && !EIO_CANCELLED (grp))
422 21 9 EIO_FEED (grp);
425 11 19 if (!(grp->flags & ETP_FLAG_GROUPADD))
442 5 27 if (!grp->size && grp->flags & ETP_FLAG_DELAYED)
5 0 if (!grp->size && grp->flags & ETP_FLAG_DELAYED)
451 4 57 if ((req)->flags & EIO_FLAG_PTR1_FREE) free (req->ptr1);
452 27 34 if ((req)->flags & EIO_FLAG_PTR2_FREE) free (req->ptr2);
462 32 29 if (req->grp)
468 14 18 if (req->grp_next) req->grp_next->grp_prev = req->grp_prev;
469 25 7 if (req->grp_prev) req->grp_prev->grp_next = req->grp_next;
471 7 25 if (grp->grp_first == req)
476 32 0 if (!res)
639 0 0 if (res < 0 && errno == ENOSYS && fd >= 0)
0 0 if (res < 0 && errno == ENOSYS && fd >= 0)
0 0 if (res < 0 && errno == ENOSYS && fd >= 0)
664 0 0 if (!res || errno != ENOSYS)
0 0 if (!res || errno != ENOSYS)
718 0 0 if (!count)
792 0 0 if (res <= 128 * 1024 * 1024)
794 0 0 if (res > 0)
797 0 0 if (written)
809 0 0 if (!count)
814 0 0 if (res < 0
815 0 0 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
0 0 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
0 0 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
818 0 0 || errno == ENOTSUP
821 0 0 || errno == EOPNOTSUPP /* BSDs */
830 0 0 dBUF;
834 0 0 while (count)
840 0 0 if (cnt <= 0)
842 0 0 if (cnt && !res) res = -1;
0 0 if (cnt && !res) res = -1;
848 0 0 if (cnt <= 0)
850 0 0 if (cnt && !res) res = -1;
0 0 if (cnt && !res) res = -1;
873 0 0 if (!page)
980 0 0 if (addr < end)
981 0 0 if (flags & EIO_MT_MODIFY) /* modify */
982 0 0 do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < end && !EIO_CANCELLED (req));
0 0 do { *((volatile sig_atomic_t *)addr) |= 0; } while ((addr += page) < end && !EIO_CANCELLED (req));
984 0 0 do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < end && !EIO_CANCELLED (req));
0 0 do { *((volatile sig_atomic_t *)addr) ; } while ((addr += page) < end && !EIO_CANCELLED (req));
1004 0 0 req->result = req->offs == (off_t)-1 ? -1 : 0;
1021 0 1 if (!rel)
1025 0 1 if (!*rel)
1071 1 0 if (*rel != '/')
1076 0 1 if (wd == EIO_INVALID_WD)
1079 1 0 if (wd == EIO_CWD)
1081 0 1 if (!getcwd (res, EIO_PATH_MAX))
1089 1 0 if (res [1]) /* only use if not / */
1093 1 1 while (*rel)
1098 1 1 while (*rel && *rel != '/')
1 0 while (*rel && *rel != '/')
1103 0 1 if (!len) /* skip slashes */
1109 1 0 if (beg [0] == '.')
1111 1 0 if (len == 1)
1114 0 0 if (beg [1] == '.' && len == 2)
0 0 if (beg [1] == '.' && len == 2)
1118 0 0 while (res != tmpbuf->ptr)
1119 0 0 if (*--res == '/')
1127 0 0 if (res + 1 + len + 1 >= tmp1)
1140 0 0 if (linklen < 0)
1142 0 0 if (errno != EINVAL)
1154 0 0 if (linklen + 1 + rellen >= EIO_PATH_MAX) /* also catch linklen >= EIO_PATH_MAX */
1158 0 0 if (!--symlinks)
1161 0 0 if (*tmp1 == '/')
1174 0 1 if (res == tmpbuf->ptr)
1184 0 725 return a->score - b->score ? a->score - b->score /* works because our signed char is always 0..100 */
647 78 return a->score - b->score ? a->score - b->score /* works because our signed char is always 0..100 */
1206 3 0 if (size <= EIO_SORT_FAST)
1218 0 0 for (i = 0; i < sizeof (eio_ino_t); ++i)
1223 0 0 for (i = 0; i < sizeof (eio_ino_t); ++i)
1229 0 0 for (j = 0; j < 8; ++j)
1230 0 0 if (inode_bits & (((eio_ino_t)1) << (i * 8 + j)))
1234 0 0 for (j = 0; j < 8; ++j)
1235 0 0 if (score_bits & (1 << j))
1264 0 0 if (b - a < EIO_SORT_CUTOFF)
1271 0 0 if (!(((unsigned char *)a)[O] & M))
1273 0 0 else if (!(((unsigned char *)--b)[O] & M))
1278 0 0 while (b > a);
1281 0 0 if (!*--bit)
1292 0 0 while (stk_idx--);
1305 3 0 for (i = size > EIO_SORT_FAST ? EIO_SORT_CUTOFF + 1 : size; --i; )
72 3 for (i = size > EIO_SORT_FAST ? EIO_SORT_CUTOFF + 1 : size; --i; )
1306 6 66 if (EIO_DENT_CMP (dents [i], <, *min))
1319 72 3 for (i = dents + 1; i < dents + size; ++i)
1323 581 72 for (j = i - 1; EIO_DENT_CMP (*j, >, value); --j)
1334 0 3 if (size <= 1)
1368 1 3 if (!(flags & EIO_READDIR_DENTS))
1419 1 3 int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK);
1421 0 4 if (fd < 0)
1426 0 4 if (!dirp)
1440 0 4 if (req->flags & EIO_FLAG_PTR1_FREE)
1444 3 1 req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0;
1447 4 0 if (!names || (flags && !dents))
3 1 if (!names || (flags && !dents))
0 3 if (!names || (flags && !dents))
1462 4 148 if (done)
1469 0 4 if (errno)
1477 2 2 if (flags & EIO_READDIR_STAT_ORDER)
1478 0 2 eio_dent_sort (dents, dentoffs, flags & EIO_READDIR_DIRS_FIRST ? 7 : 0, inode_bits);
1479 1 1 else if (flags & EIO_READDIR_DIRS_FIRST)
1480 0 1 if (flags & EIO_READDIR_FOUND_UNKNOWN)
1490 32 1 while (oth > dir)
1492 2 30 if (dir->type == EIO_DT_DIR)
1494 3 27 else if ((--oth)->type == EIO_DT_DIR)
1513 8 140 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2])))
4 4 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2])))
4 0 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2])))
0 4 if (name [0] != '.' || (name [1] && (name [1] != '.' || name [2])))
1517 0 140 while (ecb_expect_false (namesoffs + len > namesalloc))
1522 0 0 if (!names)
1528 105 35 if (dents)
1532 0 105 if (ecb_expect_false (dentoffs == dentalloc))
1537 0 0 if (!dents)
1602 35 70 if (flags & EIO_READDIR_DIRS_FIRST)
1604 0 35 if (ent->type == EIO_DT_UNKNOWN)
1606 0 0 if (*name == '.') /* leading dots are likely directories, and, in any case, rare */
1608 0 0 else if (!strchr (name, '.')) /* absence of dots indicate likely dirs */
1609 0 0 ent->score = len <= 2 ? 4 - len : len <= 4 ? 4 : len <= 7 ? 5 : 6; /* shorter == more likely dir, but avoid too many classes */
0 0 ent->score = len <= 2 ? 4 - len : len <= 4 ? 4 : len <= 7 ? 5 : 6; /* shorter == more likely dir, but avoid too many classes */
0 0 ent->score = len <= 2 ? 4 - len : len <= 4 ? 4 : len <= 7 ? 5 : 6; /* shorter == more likely dir, but avoid too many classes */
1611 5 30 else if (ent->type == EIO_DT_DIR)
1620 0 148 if (EIO_CANCELLED (req))
1678 0 1 if (len < 0)
1682 0 1 fd = openat (WD2FD (wd), path, O_CLOEXEC | O_SEARCH | O_DIRECTORY | O_NONBLOCK);
1690 0 1 if (ecb_expect_false (fd == 0))
1698 0 1 if (fd < 0)
1728 9 0 if (wd != EIO_INVALID_WD && wd != EIO_CWD)
1 8 if (wd != EIO_INVALID_WD && wd != EIO_CWD)
1760 0 0 if (fd < 0)
1774 0 0 if (fd < 0)
1808 0 0 if (fd < 0)
1811 0 0 if (req->offs < 0 || !req->size) /* do we need the size? */
0 0 if (req->offs < 0 || !req->size) /* do we need the size? */
1815 0 0 if (req->offs < 0)
1818 0 0 if (!req->size)
1822 0 0 ALLOC (req->size);
0 0 ALLOC (req->size);
1881 2 71 if (ecb_expect_false (EIO_CANCELLED (req)))
1888 8 63 if (ecb_expect_false (req->wd == EIO_INVALID_WD))
1895 30 33 if (req->type >= EIO_OPEN)
1898 16 14 dirfd = WD2FD (req->wd);
1907 0 1 req->result = req->wd == EIO_INVALID_WD ? -1 : 0;
1913 0 1 case EIO_READ: ALLOC (req->size);
0 0 case EIO_READ: ALLOC (req->size);
1916 1 0 : read (req->int1, req->ptr2, req->size); break;
1919 0 0 : write (req->int1, req->ptr2, req->size); break;
1929 16 0 case EIO_STAT: ALLOC (sizeof (EIO_STRUCT_STAT));
0 16 case EIO_STAT: ALLOC (sizeof (EIO_STRUCT_STAT));
1931 6 0 case EIO_LSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
0 6 case EIO_LSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
1941 0 1 req->result = req->wd && SINGLEDOT (req->ptr1)
0 0 req->result = req->wd && SINGLEDOT (req->ptr1)
0 0 req->result = req->wd && SINGLEDOT (req->ptr1)
1945 0 0 case EIO_RENAME: req->result = eio__renameat2 (
0 0 case EIO_RENAME: req->result = eio__renameat2 (
1948 0 0 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
0 0 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
1954 0 0 case EIO_LINK: req->result = linkat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2, 0); break;
1957 0 0 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
0 0 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1959 0 0 case EIO_READLINK: ALLOC (EIO_PATH_MAX);
0 0 case EIO_READLINK: ALLOC (EIO_PATH_MAX);
1961 0 0 if (req->result == EIO_PATH_MAX)
1973 0 0 if (req->nv1 != -1. || req->nv2 != -1.)
0 0 if (req->nv1 != -1. || req->nv2 != -1.)
1985 0 0 req->result = req->type == EIO_FUTIME
2047 0 0 case EIO_REALPATH: if (0 <= (req->result = eio__realpath (&self->tmpbuf, req->wd, req->ptr1)))
2049 0 0 ALLOC (req->result);
0 0 ALLOC (req->result);
2054 1 0 case EIO_FSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
0 1 case EIO_FSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
2057 0 0 case EIO_FSTATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
0 0 case EIO_FSTATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
2391 0 0 REQ (EIO_GROUP); SEND;
2431 27 5 if (grp->grp_first)