Branch Coverage

libeio/eio.c
Criterion Covered Total %
branch 125 358 34.9


line true false branch
426 16 12 while (grp->size < grp->int2 && !EIO_CANCELLED (grp))
16 0 while (grp->size < grp->int2 && !EIO_CANCELLED (grp))
430 11 5 EIO_FEED (grp);
433 6 10 if (!(grp->flags & ETP_FLAG_GROUPADD))
450 4 12 if (!grp->size && grp->flags & ETP_FLAG_DELAYED)
3 1 if (!grp->size && grp->flags & ETP_FLAG_DELAYED)
459 4 41 if ((req)->flags & EIO_FLAG_PTR1_FREE) free (req->ptr1);
460 12 33 if ((req)->flags & EIO_FLAG_PTR2_FREE) free (req->ptr2);
470 16 29 if (req->grp)
476 10 6 if (req->grp_next) req->grp_next->grp_prev = req->grp_prev;
477 8 8 if (req->grp_prev) req->grp_prev->grp_next = req->grp_next;
479 8 8 if (grp->grp_first == req)
484 16 0 if (!res)
647 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)
672 0 0 if (!res || errno != ENOSYS)
0 0 if (!res || errno != ENOSYS)
726 0 0 if (!count)
800 0 0 if (res <= 128 * 1024 * 1024)
802 0 0 if (res > 0)
805 0 0 if (written)
817 0 0 if (!count)
822 0 0 if (res < 0
823 0 0 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
0 0 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
0 0 && (errno == ENOSYS || errno == EINVAL || errno == ENOTSOCK
826 0 0 || errno == ENOTSUP
829 0 0 || errno == EOPNOTSUPP /* BSDs */
838 0 0 dBUF;
842 0 0 while (count)
848 0 0 if (cnt <= 0)
850 0 0 if (cnt && !res) res = -1;
0 0 if (cnt && !res) res = -1;
856 0 0 if (cnt <= 0)
858 0 0 if (cnt && !res) res = -1;
0 0 if (cnt && !res) res = -1;
881 0 0 if (!page)
988 0 0 if (addr < end)
989 0 0 if (flags & EIO_MT_MODIFY) /* modify */
990 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));
992 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));
1012 0 0 req->result = req->offs == (off_t)-1 ? -1 : 0;
1029 0 1 if (!rel)
1033 0 1 if (!*rel)
1079 1 0 if (*rel != '/')
1084 0 1 if (wd == EIO_INVALID_WD)
1087 1 0 if (wd == EIO_CWD)
1089 0 1 if (!getcwd (res, EIO_PATH_MAX))
1097 1 0 if (res [1]) /* only use if not / */
1101 1 1 while (*rel)
1106 1 1 while (*rel && *rel != '/')
1 0 while (*rel && *rel != '/')
1111 0 1 if (!len) /* skip slashes */
1117 1 0 if (beg [0] == '.')
1119 1 0 if (len == 1)
1122 0 0 if (beg [1] == '.' && len == 2)
0 0 if (beg [1] == '.' && len == 2)
1126 0 0 while (res != tmpbuf->ptr)
1127 0 0 if (*--res == '/')
1135 0 0 if (res + 1 + len + 1 >= tmp1)
1148 0 0 if (linklen < 0)
1150 0 0 if (errno != EINVAL)
1162 0 0 if (linklen + 1 + rellen >= EIO_PATH_MAX) /* also catch linklen >= EIO_PATH_MAX */
1166 0 0 if (!--symlinks)
1169 0 0 if (*tmp1 == '/')
1182 0 1 if (res == tmpbuf->ptr)
1193 0 146 : a->inode < b->inode ? -1
74 72 : a->inode < b->inode ? -1
1214 3 0 if (size <= EIO_SORT_FAST)
1226 0 0 for (i = 0; i < sizeof (eio_ino_t); ++i)
1231 0 0 for (i = 0; i < sizeof (eio_ino_t); ++i)
1237 0 0 for (j = 0; j < 8; ++j)
1238 0 0 if (inode_bits & (((eio_ino_t)1) << (i * 8 + j)))
1242 0 0 for (j = 0; j < 8; ++j)
1243 0 0 if (score_bits & (1 << j))
1272 0 0 if (b - a < EIO_SORT_CUTOFF)
1279 0 0 if (!(((unsigned char *)a)[O] & M))
1281 0 0 else if (!(((unsigned char *)--b)[O] & M))
1286 0 0 while (b > a);
1289 0 0 if (!*--bit)
1300 0 0 while (stk_idx--);
1313 3 0 for (i = size > EIO_SORT_FAST ? EIO_SORT_CUTOFF + 1 : size; --i; )
70 3 for (i = size > EIO_SORT_FAST ? EIO_SORT_CUTOFF + 1 : size; --i; )
1314 2 68 if (EIO_DENT_CMP (dents [i], <, *min))
1327 70 3 for (i = dents + 1; i < dents + size; ++i)
1331 6 70 for (j = i - 1; EIO_DENT_CMP (*j, >, value); --j)
1342 0 3 if (size <= 1)
1376 1 3 if (!(flags & EIO_READDIR_DENTS))
1427 1 3 int fd = openat (WD2FD (req->wd), req->ptr1, O_CLOEXEC | O_RDONLY | O_DIRECTORY | O_NONBLOCK);
1429 0 4 if (fd < 0)
1434 0 4 if (!dirp)
1448 0 4 if (req->flags & EIO_FLAG_PTR1_FREE)
1452 3 1 req->ptr1 = dents = flags ? malloc (dentalloc * sizeof (eio_dirent)) : 0;
1455 4 0 if (!names || (flags && !dents))
1 3 if (!names || (flags && !dents))
3 0 if (!names || (flags && !dents))
1470 4 144 if (done)
1477 0 4 if (errno)
1485 2 2 if (flags & EIO_READDIR_STAT_ORDER)
1486 0 2 eio_dent_sort (dents, dentoffs, flags & EIO_READDIR_DIRS_FIRST ? 7 : 0, inode_bits);
1487 1 1 else if (flags & EIO_READDIR_DIRS_FIRST)
1488 0 1 if (flags & EIO_READDIR_FOUND_UNKNOWN)
1498 31 1 while (oth > dir)
1500 2 29 if (dir->type == EIO_DT_DIR)
1502 3 26 else if ((--oth)->type == EIO_DT_DIR)
1521 8 136 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])))
1525 0 136 while (ecb_expect_false (namesoffs + len > namesalloc))
1530 0 0 if (!names)
1536 102 34 if (dents)
1540 0 102 if (ecb_expect_false (dentoffs == dentalloc))
1545 0 0 if (!dents)
1610 34 68 if (flags & EIO_READDIR_DIRS_FIRST)
1612 0 34 if (ent->type == EIO_DT_UNKNOWN)
1614 0 0 if (*name == '.') /* leading dots are likely directories, and, in any case, rare */
1616 0 0 else if (!strchr (name, '.')) /* absence of dots indicate likely dirs */
1617 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 */
1619 5 29 else if (ent->type == EIO_DT_DIR)
1628 0 144 if (EIO_CANCELLED (req))
1686 0 1 if (len < 0)
1690 0 1 fd = openat (WD2FD (wd), path, EIO_O_PATH | O_DIRECTORY | O_NONBLOCK | O_CLOEXEC);
1698 0 1 if (ecb_expect_false (fd == 0))
1706 0 1 if (fd < 0)
1736 9 0 if (wd != EIO_INVALID_WD && wd != EIO_CWD)
1 8 if (wd != EIO_INVALID_WD && wd != EIO_CWD)
1768 0 0 if (fd < 0)
1782 0 0 if (fd < 0)
1816 0 0 if (fd < 0)
1819 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? */
1823 0 0 if (req->offs < 0)
1826 0 0 if (!req->size)
1830 0 0 ALLOC (req->size);
0 0 ALLOC (req->size);
1889 2 56 if (ecb_expect_false (EIO_CANCELLED (req)))
1896 8 48 if (ecb_expect_false (req->wd == EIO_INVALID_WD))
1903 15 33 if (req->type >= EIO_OPEN)
1906 1 14 dirfd = WD2FD (req->wd);
1915 0 1 req->result = req->wd == EIO_INVALID_WD ? -1 : 0;
1921 0 1 case EIO_READ: ALLOC (req->size);
0 0 case EIO_READ: ALLOC (req->size);
1924 1 0 : read (req->int1, req->ptr2, req->size); break;
1927 0 0 : write (req->int1, req->ptr2, req->size); break;
1937 6 0 case EIO_STAT: ALLOC (sizeof (EIO_STRUCT_STAT));
0 6 case EIO_STAT: ALLOC (sizeof (EIO_STRUCT_STAT));
1939 1 0 case EIO_LSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
0 1 case EIO_LSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
1949 0 0 req->result = req->wd && SINGLEDOT (req->ptr1)
0 0 req->result = req->wd && SINGLEDOT (req->ptr1)
1951 0 1 : unlinkat (dirfd, req->ptr1, AT_REMOVEDIR); break;
1956 0 0 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
0 0 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
0 0 req->wd && SINGLEDOT (req->ptr1) ? req->wd->str : req->ptr1,
1959 0 0 req->int2
1962 0 0 case EIO_LINK: req->result = linkat (dirfd, req->ptr1, WD2FD ((eio_wd)req->int3), req->ptr2, 0); break;
1965 0 0 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
0 0 case EIO_STATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
1967 0 0 case EIO_READLINK: ALLOC (EIO_PATH_MAX);
0 0 case EIO_READLINK: ALLOC (EIO_PATH_MAX);
1969 0 0 if (req->result == EIO_PATH_MAX)
1981 0 0 if (req->nv1 != -1. || req->nv2 != -1.)
0 0 if (req->nv1 != -1. || req->nv2 != -1.)
1995 0 0 : utimensat (dirfd, req->ptr1, times, 0);
2055 0 0 case EIO_REALPATH: if (0 <= (req->result = eio__realpath (&self->tmpbuf, req->wd, req->ptr1)))
2057 0 0 ALLOC (req->result);
0 0 ALLOC (req->result);
2062 1 0 case EIO_FSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
0 1 case EIO_FSTAT: ALLOC (sizeof (EIO_STRUCT_STAT));
2065 0 0 case EIO_FSTATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
0 0 case EIO_FSTATVFS: ALLOC (sizeof (EIO_STRUCT_STATVFS));
2399 0 0 REQ (EIO_GROUP); SEND;
2439 12 4 if (grp->grp_first)