Annoying warning in SerializeClientConnectionInfo

Andres Freund <andres@anarazel.de>

From: Andres Freund <andres@anarazel.de>
To: pgsql-hackers@postgresql.org
Cc: Michael Paquier <michael@paquier.xyz>, Jacob Champion <jchampion@postgresql.org>
Date: 2025-08-11T22:52:23Z
Lists: pgsql-hackers
Hi,

When building without assertions with a rather recent gcc (trunk built in the
last weeks), I get this warning:

../../../../../home/andres/src/postgresql/src/backend/utils/init/miscinit.c: In function 'SerializeClientConnectionInfo':
../../../../../home/andres/src/postgresql/src/backend/utils/init/miscinit.c:1102:36: warning: parameter 'maxsize' set but not used [-Wunused-but-set-parameter=]
 1102 | SerializeClientConnectionInfo(Size maxsize, char *start_address)
      |                               ~~~~~^~~~~~~

And the warning is right. Not sure why a new compiler is needed, IIRC this
warning is present in other cases with older compilers too.

The most obvious fix is to slap on a PG_USED_FOR_ASSERTS_ONLY. However, we so
far don't seem to have used it for function parameters... But I don't see a
problem with starting to do so.

Greetings,

Andres Freund



Commits

  1. Fix compilation warning with SerializeClientConnectionInfo()