| From: | Peter Eisentraut <peter(at)eisentraut(dot)org> |
|---|---|
| To: | Bertrand Drouvot <bertranddrouvot(dot)pg(at)gmail(dot)com> |
| Cc: | pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: Fix accidentally cast away qualifiers |
| Date: | 2026-01-21 11:31:27 |
| Message-ID: | e9088f15-d3f1-464e-a6e6-7c7fd94b909b@eisentraut.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
On 20.01.26 13:10, Bertrand Drouvot wrote:
> On Tue, Jan 20, 2026 at 08:54:18AM +0100, Peter Eisentraut wrote:
>> This patch fixes cases where a qualifier (const, in all cases here) was
>> dropped by a cast, but the cast was otherwise necessary or desirable, so the
>> straightforward fix is to add the qualifier into the cast.
>>
>> This was checked with gcc -Wcast-qual, but it doesn't fix all such warnings,
>> only the trivially fixable ones.
>
> diff --git a/src/include/varatt.h b/src/include/varatt.h
> index eccd3ca04d6..03e9d1869aa 100644
> --- a/src/include/varatt.h
> +++ b/src/include/varatt.h
>
> It looks like those changes produce:
>
> ../../../src/include/varatt.h: In function ‘VARDATA’:
> ../../../src/include/varatt.h:261:33: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
> 261 | #define VARDATA_4B(PTR) (((const varattrib_4b *) (PTR))->va_4byte.va_data)
Strange, I don't see that. What compiler is this, and do you use any
special options?
> Also [1], detected a few more trivially fixable ones (see attached).
Yes, these should be included.
The one in spgquadtreeproc.c was #ifdef'ed out, so my testing didn't see
it. I suppose the other one is only compiled when you run the unicode
tests.
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-01-21 11:34:42 | Re: enable fallthrough warnings on clang |
| Previous Message | shveta malik | 2026-01-21 11:27:29 | Re: Skipping schema changes in publication |