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:
parent
c8205cc6d9
commit
95f8a3aace
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user