Re: Convert varatt.h macros to static inline functions

From: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Michael Paquier <michael(at)paquier(dot)xyz>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Convert varatt.h macros to static inline functions
Date: 2025-08-05 17:33:47
Message-ID: CAD21AoCOZxfqnNgfM5yVKJZYnOq5m2Q96fBGy1fovEqQ9V4OZA@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On Tue, Aug 5, 2025 at 9:42 AM Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> On 03.08.25 22:20, Tom Lane wrote:
> > It looks like the majority vote is still in favor of writing out
> > DatumGetPointer instead of using "_D()" functions, so let's roll
> > with that approach.
> >
> > I looked through our two versions of the varatt.h changes and
> > merged them. The attached is only cosmetically different from
> > yours, I think --- mostly, I kept the comments I'd written.
> >
> > I've tested this atop 0001-0005 from [1], and it all seems good.
> > I'd like to move along with getting these changes committed, and
> > then I'll take another look at the 8-byte-datums-everywhere proposal.
>
> I committed this with the required prerequisite patches. That concludes
> this thread, I think. I'll follow up on the remaining work in the
> "Datum as struct" thread, and the work in the "8 byte Datums" thread can
> also continue.
>

I got the following compiler warning:

% make -C src/backend/storage/large_object
inv_api.c: In function ‘inv_write’:
inv_api.c:565:29: warning: ‘workbuf’ may be used uninitialized
[-Wmaybe-uninitialized]
565 | char *workb = VARDATA(&workbuf.hdr);
| ^~~~~~~~~~~~~~~~~~~~~
In file included from ../../../../src/include/access/htup_details.h:22,
from ../../../../src/include/nodes/tidbitmap.h:25,
from ../../../../src/include/access/genam.h:20,
from inv_api.c:36:
../../../../src/include/varatt.h:305:1: note: by argument 1 of type
‘const void *’ to ‘VARDATA’ declared here
305 | VARDATA(const void *PTR)
| ^~~~~~~
inv_api.c:564:33: note: ‘workbuf’ declared here
564 | } workbuf;
| ^~~~~~~
inv_api.c: In function ‘inv_truncate’:
inv_api.c:756:29: warning: ‘workbuf’ may be used uninitialized
[-Wmaybe-uninitialized]
756 | char *workb = VARDATA(&workbuf.hdr);
| ^~~~~~~~~~~~~~~~~~~~~
../../../../src/include/varatt.h:305:1: note: by argument 1 of type
‘const void *’ to ‘VARDATA’ declared here
305 | VARDATA(const void *PTR)
| ^~~~~~~
inv_api.c:755:33: note: ‘workbuf’ declared here
755 | } workbuf;
| ^~~~~~~

I've not fully investigated the root cause but commit e035863c9a0
presumably is the culprit. FYI I'm using gcc 14.2.1.

The attached patch fixes the warning.

Regards,

--
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com

Attachment Content-Type Size
fix_compiler_warning.patch application/x-patch 874 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dmitry Mityugov 2025-08-05 17:37:01 printtup.c: error: ‘VARSIZE_ANY’ makes pointer from integer when USE_VALGRIND is defined
Previous Message Tom Lane 2025-08-05 17:26:22 Re: cpluspluscheck vs ICU again