Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9b53d96

Browse files
committed
Suppress -Wshift-negative-value warnings.
Clean up four places that result in compiler warnings when using recentgcc with this warning class enabled (as seen on buildfarm memberscalliphoridae, skink, and others). In all these places, this is purelycosmetic, because the shift distance could not be large enough to riska change of sign, so there's no chance of implementation-dependentbehavior. Still, it's easy enough to avoid the warning by casting theshifted value to unsigned, so let's do that.Patch HEAD only, this isn't worth a back-patch.
1 parent514d4a1 commit9b53d96

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

‎src/backend/utils/adt/inet_cidr_ntop.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size)
202202
b=bits %8;
203203
if (b!=0)
204204
{
205-
m=~0 << (8-b);
205+
m=((u_int) ~0) << (8-b);
206206
inbuf[p-1] &=m;
207207
}
208208

‎src/backend/utils/adt/network.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1486,7 +1486,7 @@ inetmi(PG_FUNCTION_ARGS)
14861486
* have to do proper sign extension.
14871487
*/
14881488
if (carry==0&&byte<sizeof(int64))
1489-
res |= ((int64)-1) << (byte*8);
1489+
res |= ((uint64) (int64)-1) << (byte*8);
14901490
}
14911491

14921492
PG_RETURN_INT64(res);

‎src/backend/utils/adt/varbit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1539,11 +1539,11 @@ bitfromint4(PG_FUNCTION_ARGS)
15391539
/* store first fractional byte */
15401540
if (destbitsleft>srcbitsleft)
15411541
{
1542-
intval= (int) (a >> (destbitsleft-8));
1542+
unsignedintval= (unsignedint) (a >> (destbitsleft-8));
15431543

15441544
/* Force sign-fill in case the compiler implements >> as zero-fill */
15451545
if (a<0)
1546-
val |= (-1) << (srcbitsleft+8-destbitsleft);
1546+
val |= ((unsignedint)-1) << (srcbitsleft+8-destbitsleft);
15471547
*r++= (bits8) (val&BITMASK);
15481548
destbitsleft-=8;
15491549
}
@@ -1619,11 +1619,11 @@ bitfromint8(PG_FUNCTION_ARGS)
16191619
/* store first fractional byte */
16201620
if (destbitsleft>srcbitsleft)
16211621
{
1622-
intval= (int) (a >> (destbitsleft-8));
1622+
unsignedintval= (unsignedint) (a >> (destbitsleft-8));
16231623

16241624
/* Force sign-fill in case the compiler implements >> as zero-fill */
16251625
if (a<0)
1626-
val |= (-1) << (srcbitsleft+8-destbitsleft);
1626+
val |= ((unsignedint)-1) << (srcbitsleft+8-destbitsleft);
16271627
*r++= (bits8) (val&BITMASK);
16281628
destbitsleft-=8;
16291629
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp