forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commita2a8acd
committed
Produce compiler errors if errno is referenced inside elog/ereport calls.
It's often unsafe to reference errno within an elog/ereport call, becausethere are a lot of sub-functions involved and they might not all preserveerrno. (This is why we support the %m format spec: it works off a valueof errno captured before we execute any potentially-unsafe functions inthe arguments.) Therefore, we have a project policy not to use errnothere.This patch adds a hack to cause an (admittedly obscure) compiler errorfor such unsafe usages. With the current code, the error will only be seenon Linux, macOS, and FreeBSD, but that should certainly be enough to catchmistakes in the buildfarm if they somehow get missed earlier.In addition, fix some places in src/common/exec.c that trip the error.I think these places are actually all safe, but it's simple enough toavoid the error by capturing errno manually, and doing so is goodfuture-proofing in case these call sites get any more complicated.Thomas Munro (exec.c fixes by me)Discussion:https://postgr.es/m/2975.1526862605@sss.pgh.pa.us1 parent3a60c8f commita2a8acd
2 files changed
+42
-6
lines changedLines changed: 21 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
124 | 124 |
| |
125 | 125 |
| |
126 | 126 |
| |
| 127 | + | |
| 128 | + | |
127 | 129 |
| |
128 |
| - | |
| 130 | + | |
129 | 131 |
| |
130 | 132 |
| |
131 | 133 |
| |
| |||
238 | 240 |
| |
239 | 241 |
| |
240 | 242 |
| |
| 243 | + | |
| 244 | + | |
241 | 245 |
| |
242 |
| - | |
| 246 | + | |
243 | 247 |
| |
244 | 248 |
| |
245 | 249 |
| |
| |||
254 | 258 |
| |
255 | 259 |
| |
256 | 260 |
| |
257 |
| - | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
258 | 265 |
| |
259 | 266 |
| |
260 | 267 |
| |
| |||
281 | 288 |
| |
282 | 289 |
| |
283 | 290 |
| |
| 291 | + | |
| 292 | + | |
284 | 293 |
| |
285 |
| - | |
| 294 | + | |
286 | 295 |
| |
287 | 296 |
| |
288 | 297 |
| |
289 | 298 |
| |
290 | 299 |
| |
291 | 300 |
| |
292 | 301 |
| |
293 |
| - | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
294 | 306 |
| |
295 | 307 |
| |
296 | 308 |
| |
| |||
520 | 532 |
| |
521 | 533 |
| |
522 | 534 |
| |
523 |
| - | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
524 | 539 |
| |
525 | 540 |
| |
526 | 541 |
| |
|
Lines changed: 21 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
70 | 70 |
| |
71 | 71 |
| |
72 | 72 |
| |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
73 | 90 |
| |
74 | 91 |
| |
75 | 92 |
| |
| |||
103 | 120 |
| |
104 | 121 |
| |
105 | 122 |
| |
| 123 | + | |
106 | 124 |
| |
107 | 125 |
| |
108 | 126 |
| |
| |||
112 | 130 |
| |
113 | 131 |
| |
114 | 132 |
| |
| 133 | + | |
115 | 134 |
| |
116 | 135 |
| |
117 | 136 |
| |
| |||
198 | 217 |
| |
199 | 218 |
| |
200 | 219 |
| |
| 220 | + | |
201 | 221 |
| |
202 | 222 |
| |
203 | 223 |
| |
| |||
206 | 226 |
| |
207 | 227 |
| |
208 | 228 |
| |
| 229 | + | |
209 | 230 |
| |
210 | 231 |
| |
211 | 232 |
| |
|
0 commit comments
Comments
(0)