diff options
| author | Thomas Weißschuh <thomas@t-8ch.de> | 2023-01-14 22:16:28 +0000 |
|---|---|---|
| committer | Thomas Weißschuh <thomas@t-8ch.de> | 2023-01-14 22:24:39 +0000 |
| commit | e53463ea40c58a6f84a597966ac69be9be72cd7d (patch) | |
| tree | f5082f29e9a55c8e5b7a99441eeb476b91540629 /sys-utils/swapon-common.c | |
| parent | dbf77f7a19e50686324e4fd5bb922411c2ada24e (diff) | |
| download | util-linux-e53463ea40c58a6f84a597966ac69be9be72cd7d.tar.gz | |
c.h: really avoid undefined behavior in SINT_MAX
The previous fix in #2013 still invoked undefined behavior by shifting
into the sign-bit.
Now we have a correct, albeit unwieldy solution that avoids undefined
behavior.
Instead of bit fiddling it uses plain addition and substraction.
We are looking for (in LaTeX notation):
2^(n - 1) - 1
= 2 * 2^(n - 2) - 1
= 2^(n - 2) + 2^(n - 2) - 1
= 2^(n - 2) - 1 + 2^(n - 2)
Diffstat (limited to 'sys-utils/swapon-common.c')
0 files changed, 0 insertions, 0 deletions
