OpenCoverage

group-list.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/coreutils/src/src/group-list.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5extern -
6 _Bool-
7-
8print_group_list (const char *username,-
9 uid_t ruid, gid_t rgid, gid_t egid,-
10 -
11 _Bool -
12 use_names, char delim)-
13{-
14 -
15 _Bool -
16 ok = -
17 1-
18 ;-
19 struct passwd *pwd = -
20 ((void *)0)-
21 ;-
22-
23 if (username
usernameDescription
TRUEevaluated 35 times by 1 test
Evaluated by:
  • id
FALSEevaluated 15 times by 1 test
Evaluated by:
  • id
)
15-35
24 {-
25 pwd = getpwuid (ruid);-
26 if (pwd ==
pwd == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 35 times by 1 test
Evaluated by:
  • id
0-35
27 ((void *)0)
pwd == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 35 times by 1 test
Evaluated by:
  • id
0-35
28 )-
29 ok =
never executed: ok = 0 ;
0
30 0
never executed: ok = 0 ;
0
31 ;
never executed: ok = 0 ;
0
32 }
executed 35 times by 1 test: end of block
Executed by:
  • id
35
33-
34 if (!print_group (rgid, use_names)
!print_group (rgid, use_names)Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • id
)
0-50
35 ok =
never executed: ok = 0 ;
0
36 0
never executed: ok = 0 ;
0
37 ;
never executed: ok = 0 ;
0
38-
39 if (egid != rgid
egid != rgidDescription
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • id
)
0-50
40 {-
41 putchar_unlocked (delim);-
42 if (!print_group (egid, use_names)
!print_group (egid, use_names)Description
TRUEnever evaluated
FALSEnever evaluated
)
0
43 ok =
never executed: ok = 0 ;
0
44 0
never executed: ok = 0 ;
0
45 ;
never executed: ok = 0 ;
0
46 }
never executed: end of block
0
47-
48 {-
49 gid_t *groups;-
50-
51 int n_groups = xgetgroups (username, (pwd ? pwd->pw_gid : egid), &groups);-
52 if (n_groups < 0
n_groups < 0Description
TRUEnever evaluated
FALSEevaluated 50 times by 1 test
Evaluated by:
  • id
)
0-50
53 {-
54 if (username
usernameDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
55 {-
56 error (0, -
57 (*__errno_location ())-
58 , -
59 dcgettext (((void *)0), -
60 "failed to get groups for user %s"-
61 , 5)-
62 ,-
63 quote (username));-
64 }
never executed: end of block
0
65 else-
66 {-
67 error (0, -
68 (*__errno_location ())-
69 , -
70 dcgettext (((void *)0), -
71 "failed to get groups for the current process"-
72 , 5)-
73 );-
74 }
never executed: end of block
0
75 return
never executed: return 0 ;
never executed: return 0 ;
0
76 0
never executed: return 0 ;
0
77 ;
never executed: return 0 ;
0
78 }-
79-
80 for (int i = 0; i < n_groups
i < n_groupsDescription
TRUEevaluated 310 times by 1 test
Evaluated by:
  • id
FALSEevaluated 50 times by 1 test
Evaluated by:
  • id
; i++)
50-310
81 if (groups[i] != rgid
groups[i] != rgidDescription
TRUEevaluated 260 times by 1 test
Evaluated by:
  • id
FALSEevaluated 50 times by 1 test
Evaluated by:
  • id
&& groups[i] != egid
groups[i] != egidDescription
TRUEevaluated 260 times by 1 test
Evaluated by:
  • id
FALSEnever evaluated
)
0-260
82 {-
83 putchar_unlocked (delim);-
84 if (!print_group (groups[i], use_names)
!print_group (...i], use_names)Description
TRUEnever evaluated
FALSEevaluated 260 times by 1 test
Evaluated by:
  • id
)
0-260
85 ok =
never executed: ok = 0 ;
0
86 0
never executed: ok = 0 ;
0
87 ;
never executed: ok = 0 ;
0
88 }
executed 260 times by 1 test: end of block
Executed by:
  • id
260
89 free (groups);-
90 }-
91 return
executed 50 times by 1 test: return ok;
Executed by:
  • id
ok;
executed 50 times by 1 test: return ok;
Executed by:
  • id
50
92}-
93-
94-
95-
96-
97static char *-
98gidtostr_ptr (gid_t const *gid)-
99{-
100 static char buf[((((((sizeof (uintmax_t) * 8) - (! ((__typeof__ (uintmax_t)) 0 < (__typeof__ (uintmax_t)) -1))) * 146 + 484) / 485) + (! ((__typeof__ (uintmax_t)) 0 < (__typeof__ (uintmax_t)) -1))) + 1)];-
101 return
executed 237 times by 1 test: return umaxtostr (*gid, buf);
Executed by:
  • id
umaxtostr (*gid, buf);
executed 237 times by 1 test: return umaxtostr (*gid, buf);
Executed by:
  • id
237
102}-
103-
104-
105-
106extern -
107 _Bool-
108-
109print_group (gid_t gid, -
110 _Bool -
111 use_name)-
112{-
113 struct group *grp = -
114 ((void *)0)-
115 ;-
116 -
117 _Bool -
118 ok = -
119 1-
120 ;-
121-
122 if (use_name
use_nameDescription
TRUEevaluated 121 times by 1 test
Evaluated by:
  • id
FALSEevaluated 237 times by 1 test
Evaluated by:
  • id
)
121-237
123 {-
124 grp = getgrgid (gid);-
125 if (grp ==
grp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 121 times by 1 test
Evaluated by:
  • id
0-121
126 ((void *)0)
grp == ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 121 times by 1 test
Evaluated by:
  • id
0-121
127 )-
128 {-
129 error (0, 0, -
130 dcgettext (((void *)0), -
131 "cannot find name for group ID %lu"-
132 , 5)-
133 ,-
134 (unsigned long int) gid);-
135 ok = -
136 0-
137 ;-
138 }
never executed: end of block
0
139 }
executed 121 times by 1 test: end of block
Executed by:
  • id
121
140-
141 char *s = grp
grpDescription
TRUEevaluated 121 times by 1 test
Evaluated by:
  • id
FALSEevaluated 237 times by 1 test
Evaluated by:
  • id
? grp->gr_name : gidtostr_ptr (&(gid));
121-237
142 fputs_unlocked (s,-
143 stdout-
144 );-
145 return
executed 358 times by 1 test: return ok;
Executed by:
  • id
ok;
executed 358 times by 1 test: return ok;
Executed by:
  • id
358
146}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.1.2