Thread: clang-tidy complaints
I just pushed my annual commit that makes function parameter names consistent between function declarations and their corresponding definitions, to cover the Postgres 18 cycle. The details there were all straightforward. But there are 2 remaining complaints from clang-tidy that seem worth fixing, that don't quite fall under any established policy in this area. The first such complaint concerns a new mcxt.c function parameter that shadows a global variable in the same file -- attached patch fixes that by renaming the function parameter. Technically, this is a distinct type of complaint to the clang-tidy complaints that I ordinarily fix this time of year, though it's of the same general nature. The second such complaint is a standard "function parameter name is inconsistent" complaint, though it's one that affects vendored code in src/include/snowball/libstemmer/header.h. I attach a fix for that, too. In the past we have tended to treat cases with vendored code just like non-vendored Postgres code, but there's always a question about whether it's worth diverging from upstream. That needs to be decided on a case-by-case basis, and I don't know enough to know if I should proceed here. I have not attached a fix for a similar vendored code issue that appears in timingsafe_bcmp.c, since that involved a declaration provided by my system's openSSL being inconsistent with our own vendored definition. A fix for that seemed unnecessary. -- Peter Geoghegan
Attachment
Peter Geoghegan <pg@bowt.ie> writes: > The first such complaint concerns a new mcxt.c function parameter that > shadows a global variable in the same file -- attached patch fixes > that by renaming the function parameter. Technically, this is a > distinct type of complaint to the clang-tidy complaints that I > ordinarily fix this time of year, though it's of the same general > nature. Isn't that obsolete in the wake of 55ef7abf8? I'd be inclined to leave it alone if no longer needed, because (to me anyway) "darea" reads worse than "area". > The second such complaint is a standard "function parameter name is > inconsistent" complaint, though it's one that affects vendored code in > src/include/snowball/libstemmer/header.h. I attach a fix for that, > too. In the past we have tended to treat cases with vendored code just > like non-vendored Postgres code, but there's always a question about > whether it's worth diverging from upstream. That needs to be decided > on a case-by-case basis, and I don't know enough to know if I should > proceed here. I don't want to diverge from upstream snowball here, because we do absorb new snowball versions every so often, so the problem would just come back. Maybe you could write to upstream and see if they'd accept the change? If they do, it'd be fine to apply locally. regards, tom lane
On Sat, Apr 12, 2025 at 12:35 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Peter Geoghegan <pg@bowt.ie> writes: > > The first such complaint concerns a new mcxt.c function parameter that > > shadows a global variable in the same file -- attached patch fixes > > that by renaming the function parameter. Technically, this is a > > distinct type of complaint to the clang-tidy complaints that I > > ordinarily fix this time of year, though it's of the same general > > nature. > > Isn't that obsolete in the wake of 55ef7abf8? I'd be inclined to > leave it alone if no longer needed, because (to me anyway) "darea" > reads worse than "area". I missed that, because I was working against a branch that diverged with HEAD as of a couple of days ago. You're right -- it's now obsolete. > I don't want to diverge from upstream snowball here, because we do > absorb new snowball versions every so often, so the problem would just > come back. Maybe you could write to upstream and see if they'd accept > the change? If they do, it'd be fine to apply locally. Okay. I don't think that it's worth pursuing upstream. In general I don't expect clang-tidy to have zero "inconsistent parameter" names at any time, due to a number of special cases (mostly with machine-generated code that uses flex). Looks like I'm done with this process, at least until this time next year. -- Peter Geoghegan
Peter Geoghegan <pg@bowt.ie> writes: > Looks like I'm done with this process, at least until this time next year. OK. Thanks for taking care of it. regards, tom lane
On Sat, Apr 12, 2025 at 11:25 PM Peter Geoghegan <pg@bowt.ie> wrote: > > I just pushed my annual commit that makes function parameter names > consistent between function declarations and their corresponding > definitions, to cover the Postgres 18 cycle. The new CRC function this touched was right in the header but the parameter in the definition didn't match match surrounding code (my fault in 3c6e8c123), so I went ahead and fixed up the definition. (As an aside, one wrinkle in the clang-tidy result is that it only touched the declaration in the "runtime check" stanza and not the "targeting SSE 4.2" stanza.) -- John Naylor Amazon Web Services
Hi, On Sat, Apr 12, 2025 at 01:16:39PM -0400, Tom Lane wrote: > Peter Geoghegan <pg@bowt.ie> writes: > > Looks like I'm done with this process, at least until this time next year. > > OK. Thanks for taking care of it. +1. Peter, do you think you could add "misc-header-include-cycle" in your annual check (see [1])? I'll also put a note on my side to do it at a regular basis. [1]: https://www.postgresql.org/message-id/2238517.1745644856%40sss.pgh.pa.us Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com
On Sun, Apr 27, 2025 at 4:25 AM Bertrand Drouvot <bertranddrouvot.pg@gmail.com> wrote: > +1. Peter, do you think you could add "misc-header-include-cycle" in your > annual check (see [1])? I'll also put a note on my side to do it at a regular > basis. I've added it to my personal clangd config (I mostly use clang-tidy through clangd). I'll try to remember to use it when I run clang-tidy a year from now, to clean up the master branch at the end of the Postgres 19 cycle. -- Peter Geoghegan