| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/coreutils/src/gnulib/lib/readutmp.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | char * | - | ||||||||||||||||||
| 13 | extract_trimmed_name (const STRUCT_UTMP *ut) | - | ||||||||||||||||||
| 14 | { | - | ||||||||||||||||||
| 15 | char *p, *trimmed_name; | - | ||||||||||||||||||
| 16 | - | |||||||||||||||||||
| 17 | trimmed_name = xmalloc (sizeof (((ut)-> | - | ||||||||||||||||||
| 18 | ut_user | - | ||||||||||||||||||
| 19 | )) + 1); | - | ||||||||||||||||||
| 20 | strncpy (trimmed_name, ((ut)-> | - | ||||||||||||||||||
| 21 | ut_user | - | ||||||||||||||||||
| 22 | ), sizeof (((ut)-> | - | ||||||||||||||||||
| 23 | ut_user | - | ||||||||||||||||||
| 24 | ))); | - | ||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | - | |||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | trimmed_name[sizeof (((ut)-> | - | ||||||||||||||||||
| 29 | ut_user | - | ||||||||||||||||||
| 30 | ))] = '\0'; | - | ||||||||||||||||||
| 31 | for (p = trimmed_name + strlen (trimmed_name); | - | ||||||||||||||||||
| 32 | trimmed_name < p
| 0-1 | ||||||||||||||||||
| 33 | *--p = '\0') | - | ||||||||||||||||||
| 34 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 35 | return executed 1 time by 1 test: trimmed_name;return trimmed_name;Executed by:
executed 1 time by 1 test: return trimmed_name;Executed by:
| 1 | ||||||||||||||||||
| 36 | } | - | ||||||||||||||||||
| 37 | - | |||||||||||||||||||
| 38 | - | |||||||||||||||||||
| 39 | - | |||||||||||||||||||
| 40 | static | - | ||||||||||||||||||
| 41 | _Bool | - | ||||||||||||||||||
| 42 | - | |||||||||||||||||||
| 43 | desirable_utmp_entry (STRUCT_UTMP const *u, int options) | - | ||||||||||||||||||
| 44 | { | - | ||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | _Bool | - | ||||||||||||||||||
| 47 | user_proc = (((
| 0-12 | ||||||||||||||||||
| 48 | ut_user
| 0-12 | ||||||||||||||||||
| 49 | )[0]
| 0-12 | ||||||||||||||||||
| 50 | 7
| 3-9 | ||||||||||||||||||
| 51 | ))
dead code: u)->ut_tv.tv_sec) != 0((u)->ut_tv.tv_sec) != 0dead code: )));((u)->ut_tv.tv_sec) != 0 | - | ||||||||||||||||||
| 52 | if ((
| 0-12 | ||||||||||||||||||
| 53 | return never executed: return 0 ;never executed: return 0 ; | 0 | ||||||||||||||||||
| 54 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||
| 55 | ; never executed: return 0 ; | 0 | ||||||||||||||||||
| 56 | if ((
| 4-8 | ||||||||||||||||||
| 57 | && user_proc
| 2-6 | ||||||||||||||||||
| 58 | && 0 < ((u)->ut_pid)
| 0-2 | ||||||||||||||||||
| 59 | && (kill (((u)->ut_pid), 0) < 0
| 0-2 | ||||||||||||||||||
| 60 | (*
| 0 | ||||||||||||||||||
| 61 | ==
| 0 | ||||||||||||||||||
| 62 | 3
| 0 | ||||||||||||||||||
| 63 | )) | - | ||||||||||||||||||
| 64 | return never executed: return 0 ;never executed: return 0 ; | 0 | ||||||||||||||||||
| 65 | 0 never executed: return 0 ; | 0 | ||||||||||||||||||
| 66 | ; never executed: return 0 ; | 0 | ||||||||||||||||||
| 67 | return executed 12 times by 3 tests: return 1 ;Executed by:
executed 12 times by 3 tests: return 1 ;Executed by:
| 12 | ||||||||||||||||||
| 68 | 1 executed 12 times by 3 tests: return 1 ;Executed by:
| 12 | ||||||||||||||||||
| 69 | ; executed 12 times by 3 tests: return 1 ;Executed by:
| 12 | ||||||||||||||||||
| 70 | } | - | ||||||||||||||||||
| 71 | int | - | ||||||||||||||||||
| 72 | read_utmp (char const *file, size_t *n_entries, STRUCT_UTMP **utmp_buf, | - | ||||||||||||||||||
| 73 | int options) | - | ||||||||||||||||||
| 74 | { | - | ||||||||||||||||||
| 75 | size_t n_read = 0; | - | ||||||||||||||||||
| 76 | size_t n_alloc = 0; | - | ||||||||||||||||||
| 77 | STRUCT_UTMP *utmp = | - | ||||||||||||||||||
| 78 | ((void *)0) | - | ||||||||||||||||||
| 79 | ; | - | ||||||||||||||||||
| 80 | STRUCT_UTMP *u; | - | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | - | |||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | utmpxname ((char *) file); | - | ||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | setutxent (); | - | ||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | while ((
| 3-12 | ||||||||||||||||||
| 91 | ((void *)0)
| 3-12 | ||||||||||||||||||
| 92 | ) | - | ||||||||||||||||||
| 93 | if (desirable_utmp_entry (u, options)
| 0-12 | ||||||||||||||||||
| 94 | { | - | ||||||||||||||||||
| 95 | if (n_read == n_alloc
| 3-9 | ||||||||||||||||||
| 96 | utmp = x2nrealloc (utmp, &n_alloc, sizeof *utmp); executed 9 times by 3 tests: utmp = x2nrealloc (utmp, &n_alloc, sizeof *utmp);Executed by:
| 9 | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | utmp[n_read++] = *u; | - | ||||||||||||||||||
| 99 | } executed 12 times by 3 tests: end of blockExecuted by:
| 12 | ||||||||||||||||||
| 100 | - | |||||||||||||||||||
| 101 | endutxent (); | - | ||||||||||||||||||
| 102 | - | |||||||||||||||||||
| 103 | *n_entries = n_read; | - | ||||||||||||||||||
| 104 | *utmp_buf = utmp; | - | ||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | return executed 3 times by 3 tests: 0;return 0;Executed by:
executed 3 times by 3 tests: return 0;Executed by:
| 3 | ||||||||||||||||||
| 107 | } | - | ||||||||||||||||||
| Switch to Source code | Preprocessed file |