| Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/openssh/src/atomicio.c |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | size_t | - | ||||||||||||||||||
| 17 | atomicio6(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
| 7-138 | ||||||||||||||||||
| 28 | 0x001 | - | ||||||||||||||||||
| 29 | : | - | ||||||||||||||||||
| 30 | 0x004 | - | ||||||||||||||||||
| 31 | ; | - | ||||||||||||||||||
| 32 | - | |||||||||||||||||||
| 33 | while (n > pos
| 11-212 | ||||||||||||||||||
| 34 | res = (f) (fd, s + pos, n - pos); | - | ||||||||||||||||||
| 35 | switch (res) { | - | ||||||||||||||||||
| 36 | case never executed: -1:case -1:never executed: case -1: | 0 | ||||||||||||||||||
| 37 | if ( | - | ||||||||||||||||||
| 38 | (*
| 0 | ||||||||||||||||||
| 39 | ==
| 0 | ||||||||||||||||||
| 40 | 4
| 0 | ||||||||||||||||||
| 41 | ) | - | ||||||||||||||||||
| 42 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 43 | if ( | - | ||||||||||||||||||
| 44 | (*
| 0 | ||||||||||||||||||
| 45 | ==
| 0 | ||||||||||||||||||
| 46 | 11
| 0 | ||||||||||||||||||
| 47 | || | - | ||||||||||||||||||
| 48 | (*
| 0 | ||||||||||||||||||
| 49 | ==
| 0 | ||||||||||||||||||
| 50 | 11
| 0 | ||||||||||||||||||
| 51 | ) { | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | (void)poll(&pfd, 1, -1); | - | ||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 56 | } | - | ||||||||||||||||||
| 57 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 58 | case executed 134 times by 3 tests: 0:case 0:Executed by:
executed 134 times by 3 tests: case 0:Executed by:
| 134 | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | (*__errno_location ()) | - | ||||||||||||||||||
| 61 | = | - | ||||||||||||||||||
| 62 | 32 | - | ||||||||||||||||||
| 63 | ; | - | ||||||||||||||||||
| 64 | return executed 134 times by 3 tests: pos;return pos;Executed by:
executed 134 times by 3 tests: return pos;Executed by:
| 134 | ||||||||||||||||||
| 65 | default executed 78 times by 3 tests: :default:Executed by:
executed 78 times by 3 tests: default:Executed by:
| 78 | ||||||||||||||||||
| 66 | pos += (size_t)res; | - | ||||||||||||||||||
| 67 | if (cb !=
| 0-78 | ||||||||||||||||||
| 68 | ((void *)0)
| 0-78 | ||||||||||||||||||
| 69 | && cb(cb_arg, (size_t)res) == -1
| 0 | ||||||||||||||||||
| 70 | - | |||||||||||||||||||
| 71 | (*__errno_location ()) | - | ||||||||||||||||||
| 72 | = | - | ||||||||||||||||||
| 73 | 4 | - | ||||||||||||||||||
| 74 | ; | - | ||||||||||||||||||
| 75 | return never executed: pos;return pos;never executed: return pos; | 0 | ||||||||||||||||||
| 76 | } | - | ||||||||||||||||||
| 77 | } executed 78 times by 3 tests: end of blockExecuted by:
| 78 | ||||||||||||||||||
| 78 | } | - | ||||||||||||||||||
| 79 | return executed 11 times by 3 tests: pos;return pos;Executed by:
executed 11 times by 3 tests: return pos;Executed by:
| 11 | ||||||||||||||||||
| 80 | } | - | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | size_t | - | ||||||||||||||||||
| 83 | atomicio(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n) | - | ||||||||||||||||||
| 84 | { | - | ||||||||||||||||||
| 85 | return executed 145 times by 3 tests: atomicio6(f, fd, _s, n, return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );Executed by:
executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );Executed by:
| 145 | ||||||||||||||||||
| 86 | ((void *)0) executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );Executed by:
| 145 | ||||||||||||||||||
| 87 | , executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );Executed by:
| 145 | ||||||||||||||||||
| 88 | ((void *)0) executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );Executed by:
| 145 | ||||||||||||||||||
| 89 | ); executed 145 times by 3 tests: return atomicio6(f, fd, _s, n, ((void *)0) , ((void *)0) );Executed by:
| 145 | ||||||||||||||||||
| 90 | } | - | ||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | - | |||||||||||||||||||
| 93 | - | |||||||||||||||||||
| 94 | - | |||||||||||||||||||
| 95 | size_t | - | ||||||||||||||||||
| 96 | atomiciov6(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
| 0 | ||||||||||||||||||
| 108 | 1024
| 0 | ||||||||||||||||||
| 109 | ) { | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | (*__errno_location ()) | - | ||||||||||||||||||
| 112 | = | - | ||||||||||||||||||
| 113 | 22 | - | ||||||||||||||||||
| 114 | ; | - | ||||||||||||||||||
| 115 | return never executed: 0;return 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
| 0 | ||||||||||||||||||
| 123 | 0x001 | - | ||||||||||||||||||
| 124 | : | - | ||||||||||||||||||
| 125 | 0x004 | - | ||||||||||||||||||
| 126 | ; | - | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | for (; iovcnt > 0
| 0 | ||||||||||||||||||
| 129 | res = (f) (fd, iov, iovcnt); | - | ||||||||||||||||||
| 130 | switch (res) { | - | ||||||||||||||||||
| 131 | case never executed: -1:case -1:never executed: case -1: | 0 | ||||||||||||||||||
| 132 | if ( | - | ||||||||||||||||||
| 133 | (*
| 0 | ||||||||||||||||||
| 134 | ==
| 0 | ||||||||||||||||||
| 135 | 4
| 0 | ||||||||||||||||||
| 136 | ) | - | ||||||||||||||||||
| 137 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 138 | if ( | - | ||||||||||||||||||
| 139 | (*
| 0 | ||||||||||||||||||
| 140 | ==
| 0 | ||||||||||||||||||
| 141 | 11
| 0 | ||||||||||||||||||
| 142 | || | - | ||||||||||||||||||
| 143 | (*
| 0 | ||||||||||||||||||
| 144 | ==
| 0 | ||||||||||||||||||
| 145 | 11
| 0 | ||||||||||||||||||
| 146 | ) { | - | ||||||||||||||||||
| 147 | - | |||||||||||||||||||
| 148 | (void)poll(&pfd, 1, -1); | - | ||||||||||||||||||
| 149 | - | |||||||||||||||||||
| 150 | continue; never executed: continue; | 0 | ||||||||||||||||||
| 151 | } | - | ||||||||||||||||||
| 152 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 153 | case never executed: 0:case 0:never executed: case 0: | 0 | ||||||||||||||||||
| 154 | - | |||||||||||||||||||
| 155 | (*__errno_location ()) | - | ||||||||||||||||||
| 156 | = | - | ||||||||||||||||||
| 157 | 32 | - | ||||||||||||||||||
| 158 | ; | - | ||||||||||||||||||
| 159 | return never executed: pos;return 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
| 0 | ||||||||||||||||||
| 165 | rem -= iov[0].iov_len; | - | ||||||||||||||||||
| 166 | iov++; | - | ||||||||||||||||||
| 167 | iovcnt--; | - | ||||||||||||||||||
| 168 | } never executed: end of block | 0 | ||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | if (rem > 0
| 0 | ||||||||||||||||||
| 171 | - | |||||||||||||||||||
| 172 | (*__errno_location ()) | - | ||||||||||||||||||
| 173 | = | - | ||||||||||||||||||
| 174 | 14 | - | ||||||||||||||||||
| 175 | ; | - | ||||||||||||||||||
| 176 | return never executed: 0;return 0;never executed: return 0; | 0 | ||||||||||||||||||
| 177 | } | - | ||||||||||||||||||
| 178 | if (iovcnt == 0
| 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 !=
| 0 | ||||||||||||||||||
| 185 | ((void *)0)
| 0 | ||||||||||||||||||
| 186 | && cb(cb_arg, (size_t)res) == -1
| 0 | ||||||||||||||||||
| 187 | - | |||||||||||||||||||
| 188 | (*__errno_location ()) | - | ||||||||||||||||||
| 189 | = | - | ||||||||||||||||||
| 190 | 4 | - | ||||||||||||||||||
| 191 | ; | - | ||||||||||||||||||
| 192 | return never executed: pos;return pos;never executed: return pos; | 0 | ||||||||||||||||||
| 193 | } | - | ||||||||||||||||||
| 194 | } never executed: end of block | 0 | ||||||||||||||||||
| 195 | return never executed: pos;return pos;never executed: return pos; | 0 | ||||||||||||||||||
| 196 | } | - | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | size_t | - | ||||||||||||||||||
| 199 | atomiciov(ssize_t (*f) (int, const struct iovec *, int), int fd, | - | ||||||||||||||||||
| 200 | const struct iovec *_iov, int iovcnt) | - | ||||||||||||||||||
| 201 | { | - | ||||||||||||||||||
| 202 | return never executed: atomiciov6(f, fd, _iov, iovcnt, return atomiciov6(f, fd, _iov, iovcnt, ((void *)0) , ((void *)0) );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 code | Preprocessed file |