Re: Convert varatt.h macros to static inline functions - Mailing list pgsql-hackers

From Masahiko Sawada
Subject Re: Convert varatt.h macros to static inline functions
Date
Msg-id CAD21AoCOZxfqnNgfM5yVKJZYnOq5m2Q96fBGy1fovEqQ9V4OZA@mail.gmail.com
Whole thread Raw
In response to Re: Convert varatt.h macros to static inline functions  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Convert varatt.h macros to static inline functions
List pgsql-hackers
Hi,

On Tue, Aug 5, 2025 at 9:42 AM Peter Eisentraut <peter@eisentraut.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

pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: cpluspluscheck vs ICU again
Next
From: Dmitry Mityugov
Date:
Subject: printtup.c: error: ‘VARSIZE_ANY’ makes pointer from integer when USE_VALGRIND is defined