Commit 50b2bb5
check-magic: Remember all explained magic constants
Previously, scripts/check-magic would remember only the last explained
magic constant, preventing, for example, the explanation of multiple
magic constants ahead of a comment block referring to all of them.
Moreover, check-magic would only lazily evaluate a provided explanation
when actually finding a magic value magic the LHS of the proposed
explanation. In particular, a _wrong_ explanation would only be caught
if, in the rest of the file under consideration, some matching magic
constant would be found. This led to an ambiguous and unused explanation
being overlooked in params.h.
This commit makes check-magic more general so that
- it always checks magic value explanations when they are provided,
regardless of whether they are needed or not; and,
- it remembers all magic values explained so far.
Moreover, the `round` function is instrumented to fail if it is
called on an odd multiple of 1/2 -- in this case, the rounding
is ambiguous (do we want round-half-down or round-half-up?);
this was the source of the mismatch in params.h previously.
We also add support for `intdiv(a,b)` to an integer division which we
want to assert to be without residue. This can be used instead of `//`
to additionally check that the division is indeed integral.
Signed-off-by: Hanno Becker <[email protected]>1 parent fba1a38 commit 50b2bb5
2 files changed
+39
-13
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | | - | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
24 | 36 | | |
25 | 37 | | |
26 | 38 | | |
| |||
62 | 74 | | |
63 | 75 | | |
64 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
65 | 87 | | |
66 | 88 | | |
67 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
68 | 92 | | |
69 | 93 | | |
70 | 94 | | |
| |||
80 | 104 | | |
81 | 105 | | |
82 | 106 | | |
| 107 | + | |
83 | 108 | | |
84 | 109 | | |
85 | 110 | | |
| |||
92 | 117 | | |
93 | 118 | | |
94 | 119 | | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
95 | 126 | | |
96 | 127 | | |
97 | 128 | | |
| |||
101 | 132 | | |
102 | 133 | | |
103 | 134 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
114 | 141 | | |
115 | 142 | | |
116 | 143 | | |
| |||
0 commit comments