Absolute File Name: | /home/opencoverage/opencoverage/guest-scripts/bash/src/lib/sh/zread.c |
Switch to Source code | Preprocessed file |
Line | Source | Count | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | - | |||||||||||||
2 | - | |||||||||||||
3 | - | |||||||||||||
4 | - | |||||||||||||
5 | - | |||||||||||||
6 | - | |||||||||||||
7 | extern int executing_builtin; | - | ||||||||||||
8 | - | |||||||||||||
9 | extern void check_signals_and_traps (void); | - | ||||||||||||
10 | extern void check_signals (void); | - | ||||||||||||
11 | extern int signal_is_trapped (int); | - | ||||||||||||
12 | - | |||||||||||||
13 | - | |||||||||||||
14 | - | |||||||||||||
15 | ssize_t | - | ||||||||||||
16 | zread (fd, buf, len) | - | ||||||||||||
17 | int fd; | - | ||||||||||||
18 | char *buf; | - | ||||||||||||
19 | size_t len; | - | ||||||||||||
20 | { | - | ||||||||||||
21 | ssize_t r; | - | ||||||||||||
22 | - | |||||||||||||
23 | check_signals (); | - | ||||||||||||
24 | while ((
| 2-8538293 | ||||||||||||
25 | (*
| 1 | ||||||||||||
26 | ==
| 1 | ||||||||||||
27 | 4
| 1 | ||||||||||||
28 | ) | - | ||||||||||||
29 | - | |||||||||||||
30 | - | |||||||||||||
31 | if (executing_builtin
| 0-1 | ||||||||||||
32 | check_signals_and_traps (); executed 1 time by 1 test: check_signals_and_traps (); Executed by:
| 1 | ||||||||||||
33 | else | - | ||||||||||||
34 | check_signals (); never executed: check_signals (); | 0 | ||||||||||||
35 | - | |||||||||||||
36 | return executed 8538294 times by 1 test: r;return r; Executed by:
executed 8538294 times by 1 test: return r; Executed by:
| 8538294 | ||||||||||||
37 | } | - | ||||||||||||
38 | ssize_t | - | ||||||||||||
39 | zreadretry (fd, buf, len) | - | ||||||||||||
40 | int fd; | - | ||||||||||||
41 | char *buf; | - | ||||||||||||
42 | size_t len; | - | ||||||||||||
43 | { | - | ||||||||||||
44 | ssize_t r; | - | ||||||||||||
45 | int nintr; | - | ||||||||||||
46 | - | |||||||||||||
47 | for (nintr = 0; ; ) | - | ||||||||||||
48 | { | - | ||||||||||||
49 | r = read (fd, buf, len); | - | ||||||||||||
50 | if (r >= 0
| 0 | ||||||||||||
51 | return never executed: r;return r; never executed: return r; | 0 | ||||||||||||
52 | if (r == -1
| 0 | ||||||||||||
53 | (*
| 0 | ||||||||||||
54 | ==
| 0 | ||||||||||||
55 | 4
| 0 | ||||||||||||
56 | ) | - | ||||||||||||
57 | { | - | ||||||||||||
58 | if (++
| 0 | ||||||||||||
59 | return never executed: -1;return -1; never executed: return -1; | 0 | ||||||||||||
60 | continue; never executed: continue; | 0 | ||||||||||||
61 | } | - | ||||||||||||
62 | return never executed: r;return r; never executed: return r; | 0 | ||||||||||||
63 | } | - | ||||||||||||
64 | } never executed: end of block | 0 | ||||||||||||
65 | - | |||||||||||||
66 | - | |||||||||||||
67 | ssize_t | - | ||||||||||||
68 | zreadintr (fd, buf, len) | - | ||||||||||||
69 | int fd; | - | ||||||||||||
70 | char *buf; | - | ||||||||||||
71 | size_t len; | - | ||||||||||||
72 | { | - | ||||||||||||
73 | check_signals (); | - | ||||||||||||
74 | return never executed: (read (fd, buf, len));return (read (fd, buf, len)); never executed: return (read (fd, buf, len)); | 0 | ||||||||||||
75 | } | - | ||||||||||||
76 | - | |||||||||||||
77 | - | |||||||||||||
78 | - | |||||||||||||
79 | - | |||||||||||||
80 | - | |||||||||||||
81 | static char lbuf[128]; | - | ||||||||||||
82 | static size_t lind, lused; | - | ||||||||||||
83 | - | |||||||||||||
84 | ssize_t | - | ||||||||||||
85 | zreadc (fd, cp) | - | ||||||||||||
86 | int fd; | - | ||||||||||||
87 | char *cp; | - | ||||||||||||
88 | { | - | ||||||||||||
89 | ssize_t nr; | - | ||||||||||||
90 | - | |||||||||||||
91 | if (lind == lused
| 0-6514 | ||||||||||||
92 | { | - | ||||||||||||
93 | nr = zread (fd, lbuf, sizeof (lbuf)); | - | ||||||||||||
94 | lind = 0; | - | ||||||||||||
95 | if (nr <= 0
| 39-507 | ||||||||||||
96 | { | - | ||||||||||||
97 | lused = 0; | - | ||||||||||||
98 | return executed 39 times by 1 test: nr;return nr; Executed by:
executed 39 times by 1 test: return nr; Executed by:
| 39 | ||||||||||||
99 | } | - | ||||||||||||
100 | lused = nr; | - | ||||||||||||
101 | } executed 507 times by 1 test: end of block Executed by:
| 507 | ||||||||||||
102 | if (cp
| 0-7021 | ||||||||||||
103 | * executed 7021 times by 1 test: cp = lbuf[lind++];*cp = lbuf[lind++]; Executed by:
executed 7021 times by 1 test: *cp = lbuf[lind++]; Executed by:
| 7021 | ||||||||||||
104 | return executed 7021 times by 1 test: 1;return 1; Executed by:
executed 7021 times by 1 test: return 1; Executed by:
| 7021 | ||||||||||||
105 | } | - | ||||||||||||
106 | - | |||||||||||||
107 | - | |||||||||||||
108 | - | |||||||||||||
109 | ssize_t | - | ||||||||||||
110 | zreadcintr (fd, cp) | - | ||||||||||||
111 | int fd; | - | ||||||||||||
112 | char *cp; | - | ||||||||||||
113 | { | - | ||||||||||||
114 | ssize_t nr; | - | ||||||||||||
115 | - | |||||||||||||
116 | if (lind == lused
| 0 | ||||||||||||
117 | { | - | ||||||||||||
118 | nr = zreadintr (fd, lbuf, sizeof (lbuf)); | - | ||||||||||||
119 | lind = 0; | - | ||||||||||||
120 | if (nr <= 0
| 0 | ||||||||||||
121 | { | - | ||||||||||||
122 | lused = 0; | - | ||||||||||||
123 | return never executed: nr;return nr; never executed: return nr; | 0 | ||||||||||||
124 | } | - | ||||||||||||
125 | lused = nr; | - | ||||||||||||
126 | } never executed: end of block | 0 | ||||||||||||
127 | if (cp
| 0 | ||||||||||||
128 | * never executed: cp = lbuf[lind++];*cp = lbuf[lind++]; never executed: *cp = lbuf[lind++]; | 0 | ||||||||||||
129 | return never executed: 1;return 1; never executed: return 1; | 0 | ||||||||||||
130 | } | - | ||||||||||||
131 | - | |||||||||||||
132 | - | |||||||||||||
133 | - | |||||||||||||
134 | ssize_t | - | ||||||||||||
135 | zreadn (fd, cp, len) | - | ||||||||||||
136 | int fd; | - | ||||||||||||
137 | char *cp; | - | ||||||||||||
138 | size_t len; | - | ||||||||||||
139 | { | - | ||||||||||||
140 | ssize_t nr; | - | ||||||||||||
141 | - | |||||||||||||
142 | if (lind == lused
| 0-3 | ||||||||||||
143 | { | - | ||||||||||||
144 | if (len > sizeof (lbuf)
| 0-1 | ||||||||||||
145 | len = sizeof (lbuf); never executed: len = sizeof (lbuf); | 0 | ||||||||||||
146 | nr = zread (fd, lbuf, len); | - | ||||||||||||
147 | lind = 0; | - | ||||||||||||
148 | if (nr <= 0
| 0-1 | ||||||||||||
149 | { | - | ||||||||||||
150 | lused = 0; | - | ||||||||||||
151 | return never executed: nr;return nr; never executed: return nr; | 0 | ||||||||||||
152 | } | - | ||||||||||||
153 | lused = nr; | - | ||||||||||||
154 | } executed 1 time by 1 test: end of block Executed by:
| 1 | ||||||||||||
155 | if (cp
| 0-4 | ||||||||||||
156 | * executed 4 times by 1 test: cp = lbuf[lind++];*cp = lbuf[lind++]; Executed by:
executed 4 times by 1 test: *cp = lbuf[lind++]; Executed by:
| 4 | ||||||||||||
157 | return executed 4 times by 1 test: 1;return 1; Executed by:
executed 4 times by 1 test: return 1; Executed by:
| 4 | ||||||||||||
158 | } | - | ||||||||||||
159 | - | |||||||||||||
160 | void | - | ||||||||||||
161 | zreset () | - | ||||||||||||
162 | { | - | ||||||||||||
163 | lind = lused = 0; | - | ||||||||||||
164 | } executed 23 times by 1 test: end of block Executed by:
| 23 | ||||||||||||
165 | - | |||||||||||||
166 | - | |||||||||||||
167 | - | |||||||||||||
168 | void | - | ||||||||||||
169 | zsyncfd (fd) | - | ||||||||||||
170 | int fd; | - | ||||||||||||
171 | { | - | ||||||||||||
172 | off_t off, r; | - | ||||||||||||
173 | - | |||||||||||||
174 | off = lused - lind; | - | ||||||||||||
175 | r = 0; | - | ||||||||||||
176 | if (off > 0
| 171-352 | ||||||||||||
177 | r = lseek (fd, -off, executed 352 times by 1 test: r = lseek (fd, -off, 1 ); Executed by:
| 352 | ||||||||||||
178 | 1 executed 352 times by 1 test: r = lseek (fd, -off, 1 ); Executed by:
| 352 | ||||||||||||
179 | ); executed 352 times by 1 test: r = lseek (fd, -off, 1 ); Executed by:
| 352 | ||||||||||||
180 | - | |||||||||||||
181 | if (r != -1
| 0-523 | ||||||||||||
182 | lused = lind = 0; executed 523 times by 1 test: lused = lind = 0; Executed by:
| 523 | ||||||||||||
183 | } executed 523 times by 1 test: end of block Executed by:
| 523 | ||||||||||||
Switch to Source code | Preprocessed file |