Re: Don't cast away const where possible - Mailing list pgsql-hackers

From Bertrand Drouvot
Subject Re: Don't cast away const where possible
Date
Msg-id aZw4fcj1qBYgN41V@ip-10-97-1-34.eu-west-3.compute.internal
Whole thread Raw
In response to Re: Don't cast away const where possible  (Peter Eisentraut <peter@eisentraut.org>)
Responses Re: Don't cast away const where possible
List pgsql-hackers
Hi,

On Mon, Feb 23, 2026 at 08:24:22AM +0100, Peter Eisentraut wrote:
> I have another patch that removes some -Wcast-qual warnings, by adjusting
> some function APIs.
> 
> This is as far as I get without resorting to advanced tricks like
> unconstify() or _Generic.

Yeah, so the patch removes those:

jsonapi.c:2170:53: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
jsonapi.c:2171:52: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
jsonapi.c:2172:54: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
jsonapi.c:2170:53: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
jsonapi.c:2171:52: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
jsonapi.c:2172:54: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
jsonapi.c:2170:53: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
jsonapi.c:2171:52: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
jsonapi.c:2172:54: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
ginbulk.c:247:62: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
ginbulk.c:247:79: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]
parser.c:265:51: warning: cast discards ‘const’ qualifier from pointer target type [-Wcast-qual]

and looks ok.

I can see a "volatile" one though:

vacuum.c:1885:46: warning: cast discards ‘volatile’ qualifier from pointer target type [-Wcast-qual]

worth to "fix" like in the attached while at it? (It's not really a fix as it
moves the warning from vacuum.c to c.h, but that's consistent with 481018f2804).

Regards,

-- 
Bertrand Drouvot
PostgreSQL Contributors Team
RDS Open Source Databases
Amazon Web Services: https://aws.amazon.com

Attachment

pgsql-hackers by date:

Previous
From: Amit Kapila
Date:
Subject: Re: Skipping schema changes in publication
Next
From: Ashutosh Sharma
Date:
Subject: Re: Skipping schema changes in publication