From: | Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Daniel Gustafsson <daniel(at)yesql(dot)se>, Peter Eisentraut <peter(at)eisentraut(dot)org>, Antonin Houska <ah(at)cybertec(dot)at>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: [PoC] Federated Authn/z with OAUTHBEARER |
Date: | 2025-02-24 17:39:57 |
Message-ID: | CAOYmi+m8CP=eL-FE7bMQfsBPrFDTWFaLzk6mCyfcZEjuzz1OFQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Sun, Feb 23, 2025 at 8:49 AM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> IMO, the set of cases where it's legitimate to mark individual struct
> fields as const is negligibly small, and this doesn't seem to be one
> of them. It's not obvious to me where/how PGoauthBearerRequest
> structs are supposed to be constructed, but I find it hard to believe
> that they will all spring full-grown from the forehead of Zeus.
> Nonetheless, this declaration requires exactly that.
As read-only inputs to the client API, they're not meant to be changed
for the lifetime of the struct (and the lifetime of the client flow).
The only place to initialize such a struct is directly above this
code.
> (I'm kind of surprised that we're not getting similar bleats from
> any buildfarm animals, but so far I don't see any.)
Is there a reason for compilers to complain? memcpy's the way I know
of to put a const-member struct on the heap, but maybe there are other
ways that don't annoy Coverity?
If the cost of this warning is too high, removing the const
declarations isn't the end of the world. But we use unconstify and
other type-punning copies in so many other places that this didn't
seem all that bad for the goal of helping out the client writer.
> BTW, as another nitpicky style matter: why do PGoauthBearerRequest
> etc. spell their struct tag names differently from their typedef names
> (that is, with/without an underscore)? That is not our project style
> anywhere else, and I'm failing to detect a good reason to do it here.
This underscore pattern was copied directly from PQconninfoOption and
PQprintOpt.
Thanks,
--Jacob
From | Date | Subject | |
---|---|---|---|
Next Message | Jacob Champion | 2025-02-24 17:43:41 | Re: [PoC] Federated Authn/z with OAUTHBEARER |
Previous Message | Jacob Champion | 2025-02-24 17:39:52 | Re: [PoC] Federated Authn/z with OAUTHBEARER |