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

Commitc126656

Browse files
committed
Work around spurious compiler warning in inet operators
gcc 12+ has complaints like the following:../../../../../pgsql/src/backend/utils/adt/network.c: In function 'inetnot':../../../../../pgsql/src/backend/utils/adt/network.c:1893:34: warning: writing 1 byte into a region of size 0 [-Wstringop-overflow=] 1893 | pdst[nb] = ~pip[nb]; | ~~~~~~~~~^~~~~~~~~~../../../../../pgsql/src/include/utils/inet.h:27:23: note: at offset -1 into destination object 'ipaddr' of size 16 27 | unsigned char ipaddr[16]; /* up to 128 bits of address */ | ^~~~~~../../../../../pgsql/src/include/utils/inet.h:27:23: note: at offset -1 into destination object 'ipaddr' of size 16This is due to a compiler bug:https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104986It has been a year since the bug has been reported without getting fixed. Asthe warnings are verbose and use of gcc 12 is becoming more common, it seemsworth working around the bug. Particularly because a simple reformulation ofthe loop condition fixes the issue and isn't any less readable.Author: Tom Lane <tgl@sss.pgh.pa.us>Author: Andres Freund <andres@anarazel.de>Discussion:https://postgr.es/m/144536.1648326206@sss.pgh.pa.usBackpatch: 11-
1 parent6f508b8 commitc126656

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1490,7 +1490,7 @@ inetnot(PG_FUNCTION_ARGS)
14901490
unsignedchar*pip=ip_addr(ip);
14911491
unsignedchar*pdst=ip_addr(dst);
14921492

1493-
while (nb-->0)
1493+
while (--nb >=0)
14941494
pdst[nb]= ~pip[nb];
14951495
}
14961496
ip_bits(dst)=ip_bits(ip);
@@ -1522,7 +1522,7 @@ inetand(PG_FUNCTION_ARGS)
15221522
unsignedchar*pip2=ip_addr(ip2);
15231523
unsignedchar*pdst=ip_addr(dst);
15241524

1525-
while (nb-->0)
1525+
while (--nb >=0)
15261526
pdst[nb]=pip[nb]&pip2[nb];
15271527
}
15281528
ip_bits(dst)=Max(ip_bits(ip),ip_bits(ip2));
@@ -1554,7 +1554,7 @@ inetor(PG_FUNCTION_ARGS)
15541554
unsignedchar*pip2=ip_addr(ip2);
15551555
unsignedchar*pdst=ip_addr(dst);
15561556

1557-
while (nb-->0)
1557+
while (--nb >=0)
15581558
pdst[nb]=pip[nb] |pip2[nb];
15591559
}
15601560
ip_bits(dst)=Max(ip_bits(ip),ip_bits(ip2));
@@ -1579,7 +1579,7 @@ internal_inetpl(inet *ip, int64 addend)
15791579
unsignedchar*pdst=ip_addr(dst);
15801580
intcarry=0;
15811581

1582-
while (nb-->0)
1582+
while (--nb >=0)
15831583
{
15841584
carry=pip[nb]+ (int) (addend&0xFF)+carry;
15851585
pdst[nb]= (unsignedchar) (carry&0xFF);
@@ -1663,7 +1663,7 @@ inetmi(PG_FUNCTION_ARGS)
16631663
unsignedchar*pip2=ip_addr(ip2);
16641664
intcarry=1;
16651665

1666-
while (nb-->0)
1666+
while (--nb >=0)
16671667
{
16681668
intlobyte;
16691669

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp