Fix gcc warning in sync.c (usr/src/backend/storage/sync/sync.c)

From: Ranier Vilela <ranier(dot)vf(at)gmail(dot)com>
To: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Fix gcc warning in sync.c (usr/src/backend/storage/sync/sync.c)
Date: 2022-07-10 00:53:31
Message-ID: CAEudQArDrFyQ15Am3rgWBunGBVZFDb90onTS8SRiFAWHeiLiFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

In one of my compilations of Postgres, I noted this warning from gcc.

gcc -Wall -Wmissing-prototypes -Wpointer-arith
-Wdeclaration-after-statement -Werror=vla -Wendif-labels
-Wmissing-format-attribute -Wimplicit-fallthrough=3 -Wcast-function-type
-Wformat-security -fno-strict-aliasing -fwrapv -fexcess-precision=standard
-Wno-format-truncation -Wno-stringop-truncation -O2
-I../../../../src/include -D_GNU_SOURCE -c -o sync.o sync.c
sync.c: In function ‘RememberSyncRequest’:
sync.c:528:10: warning: assignment to ‘PendingFsyncEntry *’ {aka ‘struct
<anonymous> *’} from incompatible pointer type ‘PendingUnlinkEntry *’ {aka
‘struct <anonymous> *’} [-Wincompatible-pointer-types]
528 | entry = (PendingUnlinkEntry *) lfirst(cell);

Although the structures are identical, gcc bothers to assign a pointer from
one to the other.

typedef struct
{
FileTag tag; /* identifies handler and file */
CycleCtr cycle_ctr; /* sync_cycle_ctr of oldest request */
bool canceled; /* canceled is true if we canceled "recently" */
} PendingFsyncEntry;

typedef struct
{
FileTag tag; /* identifies handler and file */
CycleCtr cycle_ctr; /* checkpoint_cycle_ctr when request was made */
bool canceled; /* true if request has been canceled */
} PendingUnlinkEntry;

The patch tries to fix this.

regards,
Ranier Vilela

Attachment Content-Type Size
fix_warning_gcc_sync.patch text/x-patch 588 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Thomas Munro 2022-07-10 01:45:23 Cleaning up historical portability baggage
Previous Message Tom Lane 2022-07-10 00:45:07 Re: Making CallContext and InlineCodeBlock less special-case-y