1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-03 15:22:11 +03:00

Add -Wimplicit-fallthrough to CFLAGS and CXXFLAGS

Use it at level 4, a bit more restrictive than the default level, and
tweak our commanding comments to FALLTHROUGH.

(However, leave zic.c alone, since it's external code; to avoid the
warnings that would appear there, change CFLAGS for that file in the
Makefile.)

Author: Julien Rouhaud <rjuju123@gmail.com>
Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/20200412081825.qyo5vwwco3fv4gdo@nol
Discussion: https://postgr.es/m/flat/E1fDenm-0000C8-IJ@gemulon.postgresql.org
This commit is contained in:
Alvaro Herrera
2020-05-12 16:01:52 -04:00
parent 6a918c3ac8
commit 3e9744465d
33 changed files with 269 additions and 171 deletions

View File

@@ -178,13 +178,13 @@ hash_bytes(const unsigned char *k, int keylen)
{
case 11:
c += ((uint32) k[10] << 8);
/* fall through */
/* FALLTHROUGH */
case 10:
c += ((uint32) k[9] << 16);
/* fall through */
/* FALLTHROUGH */
case 9:
c += ((uint32) k[8] << 24);
/* fall through */
/* FALLTHROUGH */
case 8:
/* the lowest byte of c is reserved for the length */
b += ka[1];
@@ -192,22 +192,22 @@ hash_bytes(const unsigned char *k, int keylen)
break;
case 7:
b += ((uint32) k[6] << 8);
/* fall through */
/* FALLTHROUGH */
case 6:
b += ((uint32) k[5] << 16);
/* fall through */
/* FALLTHROUGH */
case 5:
b += ((uint32) k[4] << 24);
/* fall through */
/* FALLTHROUGH */
case 4:
a += ka[0];
break;
case 3:
a += ((uint32) k[2] << 8);
/* fall through */
/* FALLTHROUGH */
case 2:
a += ((uint32) k[1] << 16);
/* fall through */
/* FALLTHROUGH */
case 1:
a += ((uint32) k[0] << 24);
/* case 0: nothing left to add */
@@ -217,13 +217,13 @@ hash_bytes(const unsigned char *k, int keylen)
{
case 11:
c += ((uint32) k[10] << 24);
/* fall through */
/* FALLTHROUGH */
case 10:
c += ((uint32) k[9] << 16);
/* fall through */
/* FALLTHROUGH */
case 9:
c += ((uint32) k[8] << 8);
/* fall through */
/* FALLTHROUGH */
case 8:
/* the lowest byte of c is reserved for the length */
b += ka[1];
@@ -231,22 +231,22 @@ hash_bytes(const unsigned char *k, int keylen)
break;
case 7:
b += ((uint32) k[6] << 16);
/* fall through */
/* FALLTHROUGH */
case 6:
b += ((uint32) k[5] << 8);
/* fall through */
/* FALLTHROUGH */
case 5:
b += k[4];
/* fall through */
/* FALLTHROUGH */
case 4:
a += ka[0];
break;
case 3:
a += ((uint32) k[2] << 16);
/* fall through */
/* FALLTHROUGH */
case 2:
a += ((uint32) k[1] << 8);
/* fall through */
/* FALLTHROUGH */
case 1:
a += k[0];
/* case 0: nothing left to add */
@@ -280,35 +280,35 @@ hash_bytes(const unsigned char *k, int keylen)
{
case 11:
c += ((uint32) k[10] << 8);
/* fall through */
/* FALLTHROUGH */
case 10:
c += ((uint32) k[9] << 16);
/* fall through */
/* FALLTHROUGH */
case 9:
c += ((uint32) k[8] << 24);
/* fall through */
/* FALLTHROUGH */
case 8:
/* the lowest byte of c is reserved for the length */
b += k[7];
/* fall through */
/* FALLTHROUGH */
case 7:
b += ((uint32) k[6] << 8);
/* fall through */
/* FALLTHROUGH */
case 6:
b += ((uint32) k[5] << 16);
/* fall through */
/* FALLTHROUGH */
case 5:
b += ((uint32) k[4] << 24);
/* fall through */
/* FALLTHROUGH */
case 4:
a += k[3];
/* fall through */
/* FALLTHROUGH */
case 3:
a += ((uint32) k[2] << 8);
/* fall through */
/* FALLTHROUGH */
case 2:
a += ((uint32) k[1] << 16);
/* fall through */
/* FALLTHROUGH */
case 1:
a += ((uint32) k[0] << 24);
/* case 0: nothing left to add */
@@ -318,35 +318,35 @@ hash_bytes(const unsigned char *k, int keylen)
{
case 11:
c += ((uint32) k[10] << 24);
/* fall through */
/* FALLTHROUGH */
case 10:
c += ((uint32) k[9] << 16);
/* fall through */
/* FALLTHROUGH */
case 9:
c += ((uint32) k[8] << 8);
/* fall through */
/* FALLTHROUGH */
case 8:
/* the lowest byte of c is reserved for the length */
b += ((uint32) k[7] << 24);
/* fall through */
/* FALLTHROUGH */
case 7:
b += ((uint32) k[6] << 16);
/* fall through */
/* FALLTHROUGH */
case 6:
b += ((uint32) k[5] << 8);
/* fall through */
/* FALLTHROUGH */
case 5:
b += k[4];
/* fall through */
/* FALLTHROUGH */
case 4:
a += ((uint32) k[3] << 24);
/* fall through */
/* FALLTHROUGH */
case 3:
a += ((uint32) k[2] << 16);
/* fall through */
/* FALLTHROUGH */
case 2:
a += ((uint32) k[1] << 8);
/* fall through */
/* FALLTHROUGH */
case 1:
a += k[0];
/* case 0: nothing left to add */
@@ -417,13 +417,13 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed)
{
case 11:
c += ((uint32) k[10] << 8);
/* fall through */
/* FALLTHROUGH */
case 10:
c += ((uint32) k[9] << 16);
/* fall through */
/* FALLTHROUGH */
case 9:
c += ((uint32) k[8] << 24);
/* fall through */
/* FALLTHROUGH */
case 8:
/* the lowest byte of c is reserved for the length */
b += ka[1];
@@ -431,22 +431,22 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed)
break;
case 7:
b += ((uint32) k[6] << 8);
/* fall through */
/* FALLTHROUGH */
case 6:
b += ((uint32) k[5] << 16);
/* fall through */
/* FALLTHROUGH */
case 5:
b += ((uint32) k[4] << 24);
/* fall through */
/* FALLTHROUGH */
case 4:
a += ka[0];
break;
case 3:
a += ((uint32) k[2] << 8);
/* fall through */
/* FALLTHROUGH */
case 2:
a += ((uint32) k[1] << 16);
/* fall through */
/* FALLTHROUGH */
case 1:
a += ((uint32) k[0] << 24);
/* case 0: nothing left to add */
@@ -456,13 +456,13 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed)
{
case 11:
c += ((uint32) k[10] << 24);
/* fall through */
/* FALLTHROUGH */
case 10:
c += ((uint32) k[9] << 16);
/* fall through */
/* FALLTHROUGH */
case 9:
c += ((uint32) k[8] << 8);
/* fall through */
/* FALLTHROUGH */
case 8:
/* the lowest byte of c is reserved for the length */
b += ka[1];
@@ -470,22 +470,22 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed)
break;
case 7:
b += ((uint32) k[6] << 16);
/* fall through */
/* FALLTHROUGH */
case 6:
b += ((uint32) k[5] << 8);
/* fall through */
/* FALLTHROUGH */
case 5:
b += k[4];
/* fall through */
/* FALLTHROUGH */
case 4:
a += ka[0];
break;
case 3:
a += ((uint32) k[2] << 16);
/* fall through */
/* FALLTHROUGH */
case 2:
a += ((uint32) k[1] << 8);
/* fall through */
/* FALLTHROUGH */
case 1:
a += k[0];
/* case 0: nothing left to add */
@@ -519,35 +519,35 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed)
{
case 11:
c += ((uint32) k[10] << 8);
/* fall through */
/* FALLTHROUGH */
case 10:
c += ((uint32) k[9] << 16);
/* fall through */
/* FALLTHROUGH */
case 9:
c += ((uint32) k[8] << 24);
/* fall through */
/* FALLTHROUGH */
case 8:
/* the lowest byte of c is reserved for the length */
b += k[7];
/* fall through */
/* FALLTHROUGH */
case 7:
b += ((uint32) k[6] << 8);
/* fall through */
/* FALLTHROUGH */
case 6:
b += ((uint32) k[5] << 16);
/* fall through */
/* FALLTHROUGH */
case 5:
b += ((uint32) k[4] << 24);
/* fall through */
/* FALLTHROUGH */
case 4:
a += k[3];
/* fall through */
/* FALLTHROUGH */
case 3:
a += ((uint32) k[2] << 8);
/* fall through */
/* FALLTHROUGH */
case 2:
a += ((uint32) k[1] << 16);
/* fall through */
/* FALLTHROUGH */
case 1:
a += ((uint32) k[0] << 24);
/* case 0: nothing left to add */
@@ -557,35 +557,35 @@ hash_bytes_extended(const unsigned char *k, int keylen, uint64 seed)
{
case 11:
c += ((uint32) k[10] << 24);
/* fall through */
/* FALLTHROUGH */
case 10:
c += ((uint32) k[9] << 16);
/* fall through */
/* FALLTHROUGH */
case 9:
c += ((uint32) k[8] << 8);
/* fall through */
/* FALLTHROUGH */
case 8:
/* the lowest byte of c is reserved for the length */
b += ((uint32) k[7] << 24);
/* fall through */
/* FALLTHROUGH */
case 7:
b += ((uint32) k[6] << 16);
/* fall through */
/* FALLTHROUGH */
case 6:
b += ((uint32) k[5] << 8);
/* fall through */
/* FALLTHROUGH */
case 5:
b += k[4];
/* fall through */
/* FALLTHROUGH */
case 4:
a += ((uint32) k[3] << 24);
/* fall through */
/* FALLTHROUGH */
case 3:
a += ((uint32) k[2] << 16);
/* fall through */
/* FALLTHROUGH */
case 2:
a += ((uint32) k[1] << 8);
/* fall through */
/* FALLTHROUGH */
case 1:
a += k[0];
/* case 0: nothing left to add */