forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commite090466
committed
Fix latent problem with pg_jrand48().
POSIX specifies that jrand48() returns a signed 32-bit value (in therange [-2^31, 2^31)), but our code was returning an unsigned 32-bitvalue (in the range [0, 2^32)). This doesn't actually matter to anyexisting call site, because they all cast the "long" result to int32or uint32; but it will doubtless bite somebody in the future.To fix, cast the arithmetic result to int32 explicitly before thecompiler widens it to long (if widening is needed).While at it, upgrade this file's far-short-of-project-style comments.Had there been some peer pressure to document pg_jrand48() properly,maybe this thinko wouldn't have gotten committed to begin with.Backpatch to v10 where pg_jrand48() was added, just in case somebodyback-patches a fix that uses it and depends on the standard behavior.Discussion:https://postgr.es/m/17235.1545951602@sss.pgh.pa.us1 parent4ed6c07 commite090466
1 file changed
+36
-6
lines changedLines changed: 36 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
2 | 2 |
| |
3 | 3 |
| |
4 | 4 |
| |
5 |
| - | |
6 |
| - | |
7 |
| - | |
8 |
| - | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
9 | 12 |
| |
10 | 13 |
| |
11 | 14 |
| |
12 | 15 |
| |
13 | 16 |
| |
| 17 | + | |
14 | 18 |
| |
15 |
| - | |
| 19 | + | |
16 | 20 |
| |
17 | 21 |
| |
18 | 22 |
| |
| |||
54 | 58 |
| |
55 | 59 |
| |
56 | 60 |
| |
| 61 | + | |
| 62 | + | |
| 63 | + | |
57 | 64 |
| |
58 | 65 |
| |
59 | 66 |
| |
| |||
75 | 82 |
| |
76 | 83 |
| |
77 | 84 |
| |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
78 | 89 |
| |
79 | 90 |
| |
80 | 91 |
| |
| |||
84 | 95 |
| |
85 | 96 |
| |
86 | 97 |
| |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
87 | 102 |
| |
88 | 103 |
| |
89 | 104 |
| |
90 | 105 |
| |
91 | 106 |
| |
92 | 107 |
| |
93 | 108 |
| |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
94 | 113 |
| |
95 | 114 |
| |
96 | 115 |
| |
97 | 116 |
| |
98 |
| - | |
| 117 | + | |
99 | 118 |
| |
100 | 119 |
| |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
101 | 131 |
| |
102 | 132 |
| |
103 | 133 |
| |
|
0 commit comments
Comments
(0)