From: | Magnus Hagander <magnus(at)hagander(dot)net> |
---|---|
To: | Erik Rijkers <er(at)xs4all(dot)nl>, Jacob Champion <pchampion(at)vmware(dot)com>, Michael Paquier <michael(at)paquier(dot)xyz> |
Cc: | "pgsql-hackers(at)lists(dot)postgresql(dot)org" <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
Subject: | Re: hba.c:3160:18: warning: comparison of unsigned enum expression |
Date: | 2021-04-07 11:32:37 |
Message-ID: | CABUevEzxyCD=--VEeXqYwGi44O2aFfN8jwKRgSdh-Tc-1jc2ZA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Wed, Apr 7, 2021 at 1:24 PM Magnus Hagander <magnus(at)hagander(dot)net> wrote:
>
> On Wed, Apr 7, 2021 at 1:01 PM Erik Rijkers <er(at)xs4all(dot)nl> wrote:
> >
> > Recently (last day or so), I get this warning from gcc 10.2:
> >
> > -----
> > hba.c:3160:18: warning: comparison of unsigned enum expression < 0 is always false [-Wtautological-compare]
> > if (auth_method < 0 || USER_AUTH_LAST < auth_method)
> > ~~~~~~~~~~~ ^ ~
> > 1 warning generated.
> > -----
>
> This one is from 9afffcb833d3c5e59a328a2af674fac7e7334fc1 (adding
> Jacob and Michael to cc)
>
> And it makes sense to give warning on that. AuthMethod is an enum. It
> can by definition not have a value that's not in the enum. That check
> simply seems wrong/unnecessary.
>
> The only other use fo USER_AUTH_LAST is in fill_hba_line() which also
> gets the name of the auth. That one uses :
> StaticAssertStmt(lengthof(UserAuthName) == USER_AUTH_LAST + 1,
> "UserAuthName[] must match the UserAuth enum");
>
> Which seems like a more reasonable check.
>
> But that also highlights -- shouldn't that function then also be made
> to use hba_authname(), and the assert moved into the function? That
> seems like the cleanest way?
So to be clear, this is what I'm suggesting.
--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/
Attachment | Content-Type | Size |
---|---|---|
hba_authname.patch | text/x-patch | 2.3 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Masahiko Sawada | 2021-04-07 11:41:23 | Re: Set access strategy for parallel vacuum workers |
Previous Message | Thomas Munro | 2021-04-07 11:24:25 | Re: WIP: WAL prefetch (another approach) |