Re: -Wcast-qual home stretch

From: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
To: Peter Eisentraut <peter(at)eisentraut(dot)org>
Cc: pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: -Wcast-qual home stretch
Date: 2026-11-16 01:30:30
Message-ID: 9C722416-EDF7-44F4-9828-E63E0B5B8DCC@gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Nov 13, 2026, at 17:36, Peter Eisentraut <peter(at)eisentraut(dot)org> wrote:
>
> On 05.11.26 06:39, Chao Li wrote:
>>> Ok, what platform and libreadline/libedit version is this? (It's apparently not covered on CI.)
>>>
>> It's MacOS 26.6.2 on arm64, using Apple’s system libedit. otool -L reports current version 3.0.0 and compatibility version 2.0.0:
> Here is an updated patch set. It needed a bit of rebasing over this week's security fixes. And I included a fix for the macOS libedit issue.
> <v2-0001-Fix-accidentally-casting-away-const.patch><v2-0002-Fix-Wcast-qual-warning-in-lnext.patch><v2-0003-Fix-Wcast-qual-warning-in-foreach_delete_current.patch><v2-0004-Fix-Wcast-qual-warning-in-XLogInsertRecord.patch><v2-0005-Fix-Wcast-qual-warnings-in-regex-module.patch><v2-0006-Fix-Wcast-qual-warning-in-guc_funcs.c.patch><v2-0007-Fix-Wcast-qual-warnings-in-psql.patch><v2-0008-Add-unconstify_pointee.patch><v2-0009-Fix-Wcast-qual-warnings-in-read-write-accessor-ma.patch><v2-0010-Adjust-unconstify-unvolatize-to-avoid-Wcast-qual-.patch><v2-0011-Add-warning-option-Wcast-qual.patch>

Thanks for updating the patch. With v2, my local build passed without any warning.

I also went through the patch set again, no more finding. So, v2 overall looks good to me.

A nitpick on 0009:
```
#define ARR_DIMS(a) \
- ((int *) (((char *) (a)) + sizeof(ArrayType)))
+ ((int *) ((unconstify(char *, (const char *) (a))) + sizeof(ArrayType)))
#define ARR_LBOUND(a) \
- ((int *) (((char *) (a)) + sizeof(ArrayType) + \
+ ((int *) ((unconstify(char *, (const char *) (a))) + sizeof(ArrayType) + \
sizeof(int) * ARR_NDIM(a)))

#define ARR_NULLBITMAP(a) \
(ARR_HASNULL(a) ? \
- (uint8 *) (((char *) (a)) + sizeof(ArrayType) + \
+ (uint8 *) ((unconstify(char *, (const char *) (a))) + sizeof(ArrayType) + \
2 * sizeof(int) * ARR_NDIM(a)) \
: (uint8 *) NULL)
```

For these three macros, unconstify() already wraps its result in parentheses, so the additional parentheses around the unconstify() calls are unnecessary. For example, ARR_DIMS() could be simplified to:
```
#define ARR_DIMS(a) \
((int *) (unconstify(char *, (const char *) (a)) + sizeof(ArrayType)))
```

Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Chao Li 2026-11-16 01:44:07 Re: extension_control_path: ignore empty elements and deduplicate directories
Previous Message Hayato Kuroda (Fujitsu) 2026-11-16 01:29:48 RE: Incorrect CONTEXT reported for errors from parallel apply worker in logical replication