Branch Coverage

OS.c
Criterion Covered Total %
branch 104 202 51.4


line true false branch
79 0 3 if((file_text = read_file("stat", NULL, &file_len, &mem_pool)) == NULL) {
88 51 0 for(file_off = file_text; file_off; file_off = strchr(file_off, '\n')) {
89 48 3 if(file_off != file_text) {
93 3 48 if(strncmp(file_off, "btime", 5) == 0) {
94 3 0 if(sscanf(file_off, "btime %lld", &boot_time) == 1) {
100 3 0 obstack_free(&mem_pool, file_text);
3 0 obstack_free(&mem_pool, file_text);
103 0 3 if(boot_time == -1) {
109 0 3 if((file_text = read_file("meminfo", NULL, &file_len, &mem_pool)) == NULL) {
114 3 0 for(file_off = file_text; file_off; file_off = strchr(file_off, '\n')) {
115 0 3 if(file_off != file_text) {
119 3 0 if(strncmp(file_off, "MemTotal:", 9) == 0) {
120 3 0 if(sscanf(file_off, "MemTotal: %llu", &system_memory) == 1) {
127 3 0 obstack_free(&mem_pool, file_text);
3 0 obstack_free(&mem_pool, file_text);
130 0 3 if(total_memory == -1) {
137 0 3 obstack_free(&mem_pool, NULL);
0 0 obstack_free(&mem_pool, NULL);
142 0 0 obstack_free(&mem_pool, NULL);
0 0 obstack_free(&mem_pool, NULL);
160 0 3 if(init_failed) {
166 0 3 if(statfs("/proc", &sfs) == -1) {
186 1344 192 for(i = field1; i <= field2; i++) {
205 336 54 if(file) {
209 0 390 obstack_1grow(mem_pool, '\0');
211 0 390 return (char *)obstack_finish(mem_pool);
0 390 return (char *)obstack_finish(mem_pool);
240 246 0 obstack_free(mem_pool, file);
246 0 obstack_free(mem_pool, file);
242 0 246 if(fd == -1) {
247 549 246 for(*len = 0; result; *len += result) {
248 147 402 obstack_blank(mem_pool, 1024);
251 0 549 if((result = read(fd, start, 1024)) == -1) {
252 0 0 obstack_free(mem_pool, obstack_finish(mem_pool));
0 0 obstack_free(mem_pool, obstack_finish(mem_pool));
0 0 obstack_free(mem_pool, obstack_finish(mem_pool));
0 0 obstack_free(mem_pool, obstack_finish(mem_pool));
262 0 246 text = obstack_finish(mem_pool);
0 246 text = obstack_finish(mem_pool);
291 48 0 obstack_free(mem_pool, path_pid);
48 0 obstack_free(mem_pool, path_pid);
293 0 48 if(result == -1) {
324 0 48 if((stat_text = read_file(pid, "stat", &stat_len, mem_pool)) == NULL) {
328 0 48 if(sscanf(stat_text, "%d (", &prs->pid) != 1) {
335 0 48 if((close_paren = strrchr(stat_text, ')')) == NULL) {
341 0 48 if((open_paren = strchr(stat_text, '(')) == NULL) {
350 0 48 if(comm_len > comm_esize) {
353 48 0 if(comm_len > 0) {
423 0 48 if(result != 33) {
432 48 0 obstack_free(mem_pool, stat_text);
48 0 obstack_free(mem_pool, stat_text);
452 96 0 obstack_free(mem_pool, link_file);
96 0 obstack_free(mem_pool, link_file);
454 0 96 if(link == NULL) {
461 0 96 obstack_1grow(mem_pool, '\0');
463 0 96 *ptr = (char *)obstack_finish(mem_pool);
0 96 *ptr = (char *)obstack_finish(mem_pool);
476 0 48 if((cmndline_text = read_file(pid, "cmdline", &cmndline_off, mem_pool)) == NULL) {
481 6970 48 for(cur = cmndline_text; cur < cmndline_text + cmndline_off - 1; cur++) {
482 288 6682 if(*cur == '\0') {
497 0 48 if((cmdline_text = read_file(pid, "cmdline", &cmdline_off, mem_pool)) == NULL) {
512 0 48 if((environ_text = read_file(pid, "environ", &environ_off, mem_pool)) == NULL) {
528 0 48 if((status_text = read_file(pid, "status", &status_len, mem_pool)) == NULL) {
542 480 0 for(loc = status_text; loc; loc = strchr(loc, '\n')) {
544 432 48 if(loc != status_text) {
548 48 432 if(strncmp(loc, "Uid:", 4) == 0) {
551 48 384 } else if(strncmp(loc, "Gid:", 4) == 0) {
554 48 336 } else if(strncmp(loc, "TracerPid:", 10) == 0) {
560 96 384 if(islower(format_str[F_EUID]) && islower(format_str[F_EGID]) && islower(format_str[F_TRACER])) {
48 48 if(islower(format_str[F_EUID]) && islower(format_str[F_EGID]) && islower(format_str[F_TRACER])) {
48 0 if(islower(format_str[F_EUID]) && islower(format_str[F_EGID]) && islower(format_str[F_TRACER])) {
566 48 0 obstack_free(mem_pool, status_text);
48 0 obstack_free(mem_pool, status_text);
673 0 48 if(len >= LENGTH_PCTCPU) {
681 48 0 if(system_memory > 0) {
694 482 48 for(; *str; str++) {
695 320 162 if(!isdigit(*str)) {
709 0 0 obstack_1grow(mem_pool, '\0');
710 0 0 pid_dir_path = obstack_finish(mem_pool);
0 0 pid_dir_path = obstack_finish(mem_pool);
715 0 0 obstack_free(mem_pool, pid_dir_path);
0 0 obstack_free(mem_pool, pid_dir_path);
740 0 5 dir_ent = obstack_alloc(&mem_pool, sizeof(struct dirent));
0 5 dir_ent = obstack_alloc(&mem_pool, sizeof(struct dirent));
0 5 dir_ent = obstack_alloc(&mem_pool, sizeof(struct dirent));
742 0 5 if((dir = opendir("/proc")) == NULL) {
747 373 0 while(readdir_r(dir, dir_ent, &dir_result) == 0 && dir_result) {
368 5 while(readdir_r(dir, dir_ent, &dir_result) == 0 && dir_result) {
749 320 48 if(!is_pid(dir_result->d_name)) {
754 0 48 prs = obstack_alloc(&mem_pool, sizeof(struct procstat));
0 48 prs = obstack_alloc(&mem_pool, sizeof(struct procstat));
0 48 prs = obstack_alloc(&mem_pool, sizeof(struct procstat));
759 0 48 obstack_1grow(&mem_pool, '\0');
760 0 48 format_str = (char *)obstack_finish(&mem_pool);
0 48 format_str = (char *)obstack_finish(&mem_pool);
766 0 48 if(get_proc_stat(dir_result->d_name, format_str, prs, &mem_pool) == false) {
768 0 0 if(pid_exists(dir_result->d_name, &mem_pool) == false) {
844 0 48 obstack_free(&mem_pool, prs);
0 0 obstack_free(&mem_pool, prs);
850 0 5 obstack_free(&mem_pool, NULL);
0 0 obstack_free(&mem_pool, NULL);