diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2018-06-17 16:15:11 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2018-06-17 16:15:11 -0400 |
commit | 9b53d966847c55fbd2bff63b3e1a1c37fc694071 (patch) | |
tree | 0347b58db1ab9598307ddf3c9e207ce1aa90514e /src/backend/utils/adt/varbit.c | |
parent | 514d4a1338d5409431d644eaf453193ac362ef16 (diff) |
Suppress -Wshift-negative-value warnings.
Clean up four places that result in compiler warnings when using recent
gcc with this warning class enabled (as seen on buildfarm members
calliphoridae, skink, and others). In all these places, this is purely
cosmetic, because the shift distance could not be large enough to risk
a change of sign, so there's no chance of implementation-dependent
behavior. Still, it's easy enough to avoid the warning by casting the
shifted value to unsigned, so let's do that.
Patch HEAD only, this isn't worth a back-patch.
Diffstat (limited to 'src/backend/utils/adt/varbit.c')
-rw-r--r-- | src/backend/utils/adt/varbit.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 6ba400b699c..d8a58160f41 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -1539,11 +1539,11 @@ bitfromint4(PG_FUNCTION_ARGS) /* store first fractional byte */ if (destbitsleft > srcbitsleft) { - int val = (int) (a >> (destbitsleft - 8)); + unsigned int val = (unsigned int) (a >> (destbitsleft - 8)); /* Force sign-fill in case the compiler implements >> as zero-fill */ if (a < 0) - val |= (-1) << (srcbitsleft + 8 - destbitsleft); + val |= ((unsigned int) -1) << (srcbitsleft + 8 - destbitsleft); *r++ = (bits8) (val & BITMASK); destbitsleft -= 8; } @@ -1619,11 +1619,11 @@ bitfromint8(PG_FUNCTION_ARGS) /* store first fractional byte */ if (destbitsleft > srcbitsleft) { - int val = (int) (a >> (destbitsleft - 8)); + unsigned int val = (unsigned int) (a >> (destbitsleft - 8)); /* Force sign-fill in case the compiler implements >> as zero-fill */ if (a < 0) - val |= (-1) << (srcbitsleft + 8 - destbitsleft); + val |= ((unsigned int) -1) << (srcbitsleft + 8 - destbitsleft); *r++ = (bits8) (val & BITMASK); destbitsleft -= 8; } |