Branch Coverage

graph.h
Criterion Covered Total %
branch 54 128 42.1


line true false branch
102 0 0 if (pid == 0) return 1;
103 0 0 return !(kill((pid_t)pid, 0) == -1 && errno == ESRCH);
0 0 return !(kill((pid_t)pid, 0) == -1 && errno == ESRCH);
110 22 0 if (__atomic_compare_exchange_n(&hdr->mutex, &expected, mypid,
113 0 0 if (spin < 32) {
123 0 0 if (cur != 0) {
126 0 0 if (rc == -1 && errno == ETIMEDOUT && cur >= GRAPH_MUTEX_BIT) {
0 0 if (rc == -1 && errno == ETIMEDOUT && cur >= GRAPH_MUTEX_BIT) {
0 0 if (rc == -1 && errno == ETIMEDOUT && cur >= GRAPH_MUTEX_BIT) {
128 0 0 if (!graph_pid_alive(pid))
140 0 22 if (__atomic_load_n(&hdr->mutex_waiters, __ATOMIC_RELAXED) > 0)
154 10 0 for (uint32_t w = 0; w < bwords; w++) {
156 0 10 if (word == ~(uint64_t)0) continue;
159 0 10 if (idx >= max) return -1;
176 0 5 if (idx < 0) return -1;
184 6 0 if (src >= h->hdr->max_nodes || dst >= h->hdr->max_nodes) return 0;
0 6 if (src >= h->hdr->max_nodes || dst >= h->hdr->max_nodes) return 0;
185 5 1 if (!graph_bit_set(h->node_bitmap, src) || !graph_bit_set(h->node_bitmap, dst))
0 5 if (!graph_bit_set(h->node_bitmap, src) || !graph_bit_set(h->node_bitmap, dst))
188 0 5 if (eidx < 0) return 0;
198 0 1 if (node >= h->hdr->max_nodes) return 0;
199 0 1 if (!graph_bit_set(h->node_bitmap, node)) return 0;
202 1 1 while (eidx != GRAPH_NONE) {
243 1 12 if (node >= h->hdr->max_nodes) return 0;
264 3 3 while (eidx != GRAPH_NONE) {
265 0 3 if (out_dst && count < max_out) {
0 0 if (out_dst && count < max_out) {
283 3 0 if (errbuf) errbuf[0] = '\0';
284 0 3 if (max_nodes == 0) { GRAPH_ERR("max_nodes must be > 0"); return NULL; }
0 0 if (max_nodes == 0) { GRAPH_ERR("max_nodes must be > 0"); return NULL; }
285 0 3 if (max_edges == 0) { GRAPH_ERR("max_edges must be > 0"); return NULL; }
0 0 if (max_edges == 0) { GRAPH_ERR("max_edges must be > 0"); return NULL; }
286 0 3 if (max_nodes > UINT32_MAX - 63) { GRAPH_ERR("max_nodes too large"); return NULL; }
0 0 if (max_nodes > UINT32_MAX - 63) { GRAPH_ERR("max_nodes too large"); return NULL; }
287 0 3 if (max_edges > UINT32_MAX - 63) { GRAPH_ERR("max_edges too large"); return NULL; }
0 0 if (max_edges > UINT32_MAX - 63) { GRAPH_ERR("max_edges too large"); return NULL; }
304 1 2 if (anonymous) {
307 0 1 if (base == MAP_FAILED) { GRAPH_ERR("mmap: %s", strerror(errno)); return NULL; }
0 0 if (base == MAP_FAILED) { GRAPH_ERR("mmap: %s", strerror(errno)); return NULL; }
310 0 2 if (fd < 0) { GRAPH_ERR("open: %s", strerror(errno)); return NULL; }
0 0 if (fd < 0) { GRAPH_ERR("open: %s", strerror(errno)); return NULL; }
311 0 2 if (flock(fd, LOCK_EX) < 0) { GRAPH_ERR("flock: %s", strerror(errno)); close(fd); return NULL; }
0 0 if (flock(fd, LOCK_EX) < 0) { GRAPH_ERR("flock: %s", strerror(errno)); close(fd); return NULL; }
313 0 2 if (fstat(fd, &st) < 0) { GRAPH_ERR("fstat: %s", strerror(errno)); flock(fd, LOCK_UN); close(fd); return NULL; }
0 0 if (fstat(fd, &st) < 0) { GRAPH_ERR("fstat: %s", strerror(errno)); flock(fd, LOCK_UN); close(fd); return NULL; }
315 1 1 if (is_new && ftruncate(fd, (off_t)total) < 0) {
0 1 if (is_new && ftruncate(fd, (off_t)total) < 0) {
316 0 0 GRAPH_ERR("ftruncate: %s", strerror(errno)); flock(fd, LOCK_UN); close(fd); return NULL;
318 1 1 map_size = is_new ? (size_t)total : (size_t)st.st_size;
320 0 2 if (base == MAP_FAILED) { GRAPH_ERR("mmap: %s", strerror(errno)); flock(fd, LOCK_UN); close(fd); return NULL; }
0 0 if (base == MAP_FAILED) { GRAPH_ERR("mmap: %s", strerror(errno)); flock(fd, LOCK_UN); close(fd); return NULL; }
321 1 1 if (!is_new) {
323 1 0 if (hdr->magic != GRAPH_MAGIC || hdr->version != GRAPH_VERSION ||
1 0 if (hdr->magic != GRAPH_MAGIC || hdr->version != GRAPH_VERSION ||
324 0 1 hdr->total_size != (uint64_t)st.st_size) {
325 0 0 GRAPH_ERR("invalid graph file"); munmap(base, map_size); flock(fd, LOCK_UN); close(fd); return NULL;
347 20 2 for (uint32_t i = 0; i < max_nodes; i++) heads[i] = GRAPH_NONE;
350 1 1 if (fd >= 0) { flock(fd, LOCK_UN); close(fd); }
356 0 3 if (!h) { munmap(base, map_size); return NULL; }
366 2 1 h->path = path ? strdup(path) : NULL;
374 0 3 if (!h) return;
375 0 3 if (h->notify_fd >= 0) close(h->notify_fd);
376 0 3 if (h->backing_fd >= 0) close(h->backing_fd);
377 3 0 if (h->hdr) munmap(h->hdr, h->mmap_size);