OpenCoverage

atomicio.c

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/openssh/src/atomicio.c
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6-
7-
8-
9-
10-
11-
12-
13-
14-
15-
16size_t-
17atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,-
18 int (*cb)(void *, size_t), void *cb_arg)-
19{-
20 char *s = _s;-
21 size_t pos = 0;-
22 ssize_t res;-
23 struct pollfd pfd;-
24-
25-
26 pfd.fd = fd;-
27 pfd.events = f == read
f == readDescription
TRUEevaluated 138 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
FALSEevaluated 7 times by 1 test
Evaluated by:
  • ssh-keygen
?
7-138
28 0x001 -
29 : -
30 0x004-
31 ;-
32-
33 while (n > pos
n > posDescription
TRUEevaluated 212 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
FALSEevaluated 11 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
) {
11-212
34 res = (f) (fd, s + pos, n - pos);-
35 switch (res) {-
36 case
never executed: case -1:
-1:
never executed: case -1:
0
37 if (-
38 (*
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
39 ==
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
40 4
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
41 )-
42 continue;
never executed: continue;
0
43 if (-
44 (*
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
45 ==
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
46 11
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
47 || -
48 (*
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
49 ==
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
50 11
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
51 ) {-
52-
53 (void)poll(&pfd, 1, -1);-
54-
55 continue;
never executed: continue;
0
56 }-
57 return
never executed: return 0;
0;
never executed: return 0;
0
58 case
executed 134 times by 3 tests: case 0:
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
0:
executed 134 times by 3 tests: case 0:
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
134
59 -
60 (*__errno_location ()) -
61 = -
62 32-
63 ;-
64 return
executed 134 times by 3 tests: return pos;
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
pos;
executed 134 times by 3 tests: return pos;
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
134
65 default
executed 78 times by 3 tests: default:
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
:
executed 78 times by 3 tests: default:
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
78
66 pos += (size_t)res;-
67 if (cb !=
cb != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 78 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-78
68 ((void *)0)
cb != ((void *)0)Description
TRUEnever evaluated
FALSEevaluated 78 times by 3 tests
Evaluated by:
  • ssh-keygen
  • sshd
  • test_sshkey
0-78
69 && cb(cb_arg, (size_t)res) == -1
cb(cb_arg, (size_t)res) == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
70 -
71 (*__errno_location ()) -
72 = -
73 4-
74 ;-
75 return
never executed: return pos;
pos;
never executed: return pos;
0
76 }-
77 }
executed 78 times by 3 tests: end of block
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
78
78 }-
79 return
executed 11 times by 3 tests: return pos;
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
pos;
executed 11 times by 3 tests: return pos;
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
11
80}-
81-
82size_t-
83atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n)-
84{-
85 return
executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
atomicio6(f, fd, _s, n,
executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
145
86 ((void *)0)
executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
145
87 ,
executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
145
88 ((void *)0)
executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
145
89 );
executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );
Executed by:
  • ssh-keygen
  • sshd
  • test_sshkey
145
90}-
91-
92-
93-
94-
95size_t-
96atomiciov6(ssize_t (*f) (int, const struct iovec *, int), int fd,-
97 const struct iovec *_iov, int iovcnt,-
98 int (*cb)(void *, size_t), void *cb_arg)-
99{-
100 size_t pos = 0, rem;-
101 ssize_t res;-
102 struct iovec iov_array[-
103 1024-
104 ], *iov = iov_array;-
105 struct pollfd pfd;-
106-
107 if (iovcnt < 0
iovcnt < 0Description
TRUEnever evaluated
FALSEnever evaluated
|| iovcnt >
iovcnt > 1024Description
TRUEnever evaluated
FALSEnever evaluated
0
108 1024
iovcnt > 1024Description
TRUEnever evaluated
FALSEnever evaluated
0
109 ) {-
110 -
111 (*__errno_location ()) -
112 = -
113 22-
114 ;-
115 return
never executed: return 0;
0;
never executed: return 0;
0
116 }-
117-
118 memcpy(iov, _iov, (size_t)iovcnt * sizeof(*_iov));-
119-
120-
121 pfd.fd = fd;-
122 pfd.events = f == readv
f == readvDescription
TRUEnever evaluated
FALSEnever evaluated
?
0
123 0x001 -
124 : -
125 0x004-
126 ;-
127-
128 for (; iovcnt > 0
iovcnt > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& iov[0].iov_len > 0
iov[0].iov_len > 0Description
TRUEnever evaluated
FALSEnever evaluated
;) {
0
129 res = (f) (fd, iov, iovcnt);-
130 switch (res) {-
131 case
never executed: case -1:
-1:
never executed: case -1:
0
132 if (-
133 (*
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
134 ==
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
135 4
(*__errno_location ()) == 4Description
TRUEnever evaluated
FALSEnever evaluated
0
136 )-
137 continue;
never executed: continue;
0
138 if (-
139 (*
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
140 ==
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
141 11
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
142 || -
143 (*
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
__errno_location ())
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
144 ==
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
145 11
(*__errno_location ()) == 11Description
TRUEnever evaluated
FALSEnever evaluated
0
146 ) {-
147-
148 (void)poll(&pfd, 1, -1);-
149-
150 continue;
never executed: continue;
0
151 }-
152 return
never executed: return 0;
0;
never executed: return 0;
0
153 case
never executed: case 0:
0:
never executed: case 0:
0
154 -
155 (*__errno_location ()) -
156 = -
157 32-
158 ;-
159 return
never executed: return pos;
pos;
never executed: return pos;
0
160 default
never executed: default:
:
never executed: default:
0
161 rem = (size_t)res;-
162 pos += rem;-
163-
164 while (iovcnt > 0
iovcnt > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& rem >= iov[0].iov_len
rem >= iov[0].iov_lenDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
165 rem -= iov[0].iov_len;-
166 iov++;-
167 iovcnt--;-
168 }
never executed: end of block
0
169-
170 if (rem > 0
rem > 0Description
TRUEnever evaluated
FALSEnever evaluated
&& (iovcnt <= 0
iovcnt <= 0Description
TRUEnever evaluated
FALSEnever evaluated
|| rem > iov[0].iov_len
rem > iov[0].iov_lenDescription
TRUEnever evaluated
FALSEnever evaluated
)) {
0
171 -
172 (*__errno_location ()) -
173 = -
174 14-
175 ;-
176 return
never executed: return 0;
0;
never executed: return 0;
0
177 }-
178 if (iovcnt == 0
iovcnt == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
179 break;
never executed: break;
0
180-
181 iov[0].iov_base = ((char *)iov[0].iov_base) + rem;-
182 iov[0].iov_len -= rem;-
183 }
never executed: end of block
0
184 if (cb !=
cb != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
185 ((void *)0)
cb != ((void *)0)Description
TRUEnever evaluated
FALSEnever evaluated
0
186 && cb(cb_arg, (size_t)res) == -1
cb(cb_arg, (size_t)res) == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
187 -
188 (*__errno_location ()) -
189 = -
190 4-
191 ;-
192 return
never executed: return pos;
pos;
never executed: return pos;
0
193 }-
194 }
never executed: end of block
0
195 return
never executed: return pos;
pos;
never executed: return pos;
0
196}-
197-
198size_t-
199atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd,-
200 const struct iovec *_iov, int iovcnt)-
201{-
202 return
never executed: return atomiciov6(f, fd, _iov, iovcnt, ((void *)0) , ((void *)0) );
atomiciov6(f, fd, _iov, iovcnt,
never executed: return atomiciov6(f, fd, _iov, iovcnt, ((void *)0) , ((void *)0) );
0
203 ((void *)0)
never executed: return atomiciov6(f, fd, _iov, iovcnt, ((void *)0) , ((void *)0) );
0
204 ,
never executed: return atomiciov6(f, fd, _iov, iovcnt, ((void *)0) , ((void *)0) );
0
205 ((void *)0)
never executed: return atomiciov6(f, fd, _iov, iovcnt, ((void *)0) , ((void *)0) );
0
206 );
never executed: return atomiciov6(f, fd, _iov, iovcnt, ((void *)0) , ((void *)0) );
0
207}-
Switch to Source codePreprocessed file

Generated by Squish Coco 4.2.2