13
0

Explicitly prevent unsigned int wrap-around

This is a NOOP (0 - 1) + 2 == (0 + 2) - 1 but avoids
a unsigned int wrap-wrap around for good measure.
This commit is contained in:
Robin Gareus 2021-06-14 00:43:08 +02:00
parent c8205cc6d9
commit 95f8a3aace
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -90,7 +90,7 @@ public:
guint rv;
if (w > r) {
rv = (r - w + size) & size_mask;
rv = ((r + size) - w) & size_mask;
} else if (w < r) {
rv = (r - w);
} else {
@ -119,7 +119,7 @@ public:
if (w > r) {
return w - r;
} else {
return (w - r + size) & size_mask;
return ((w + size) - r) & size_mask;
}
}