Hi, On Tue, Mar 11, 2025 at 11:14:24PM -0400, Tom Lane wrote: > Michael Paquier <mich...@paquier.xyz> writes: > > And I guess that we're OK here, so applied. That should be the last > > one. > > Quite a few buildfarm members are not happy about the initialization > that 9a8dd2c5a added to PendingBackendStats. For instance [1]: > > gcc -std=gnu99 -Wall -Wmissing-prototypes -Wpointer-arith > -Wdeclaration-after-statement -Werror=vla -Wendif-labels > -Wmissing-format-attribute -Wformat-security -fno-strict-aliasing -fwrapv > -fexcess-precision=standard -g -O2 -I. -I. -I../../../../src/include > -D_GNU_SOURCE -I/usr/include/libxml2 -c -o pgstat_backend.o pgstat_backend.c > pgstat_backend.c:39:1: warning: missing braces around initializer > [-Wmissing-braces] > static PgStat_BackendPending PendingBackendStats = {0}; > ^ > pgstat_backend.c:39:1: warning: (near initialization for > \342\200\230PendingBackendStats.pending_io\342\200\231) [-Wmissing-braces] > > I guess that more than one level of braces is needed for this to > be fully correct?
Thanks for the report! I think that it's better to remove the PendingBackendStats initializer (instead of adding extra braces). The reason is that I'm concerned about padding bytes (that could be added to the struct in the future) not being zeroed (see [1]). Done that way in the attached. [1]: https://www.postgresql.org/message-id/Z8/W73%2BHVo%2B/pKHZ%40ip-10-97-1-34.eu-west-3.compute.internal Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
>From d1178e65b5070f539677b1134224d6ca81fd0bbf Mon Sep 17 00:00:00 2001 From: Bertrand Drouvot <bertranddrouvot...@gmail.com> Date: Wed, 12 Mar 2025 05:14:21 +0000 Subject: [PATCH v1] Remove the PendingBackendStats initializer 9a8dd2c5a6d added an initializer to PendingBackendStats, but on some GCC versions -Werror=missing-braces would report a warning. Instead of adding extra braces, let's remove the initialization that would prevent padding bytes from being zeroed. Per buildfarm members ayu, batfish, boa, buri, demoiselle, dhole, rhinoceros, shelduck and siskin. --- src/backend/utils/activity/pgstat_backend.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 100.0% src/backend/utils/activity/ diff --git a/src/backend/utils/activity/pgstat_backend.c b/src/backend/utils/activity/pgstat_backend.c index da4c7edd772..a8cb54a7732 100644 --- a/src/backend/utils/activity/pgstat_backend.c +++ b/src/backend/utils/activity/pgstat_backend.c @@ -36,7 +36,7 @@ * reported within critical sections so we use static memory in order to avoid * memory allocation. */ -static PgStat_BackendPending PendingBackendStats = {0}; +static PgStat_BackendPending PendingBackendStats; /* * WAL usage counters saved from pgWalUsage at the previous call to -- 2.34.1