|
|
Subscribe / Log in / New account

Catching the mismatch

Catching the mismatch

Posted Feb 11, 2025 12:22 UTC (Tue) by TomH (subscriber, #56149)
In reply to: Catching the mismatch by farnz
Parent article: Maintainer opinions on Rust-for-Linux

You can also leave the name out completely in C++ to avoid the warning.

In C that's only technically allowed from C23 on but gcc won't complain unless -pedantic is used, though clang will.


to post comments

Catching the mismatch

Posted Feb 11, 2025 12:43 UTC (Tue) by farnz (subscriber, #17727) [Link] (1 responses)

The comment trick q3cpma points out would work, but I'd normally want to have a name in there because of the partially applied patch series problem, where I want people to be aware that this parameter does have a meaning.

And yes, I can (and have) worked around this with documentation comments, but those have a bad habit of getting stale, such that the doc comment refers to a parameter called "ignored_cpu_mask" that's been removed and replaced by a "active_cpu_mask"…

Catching the mismatch

Posted Feb 11, 2025 17:35 UTC (Tue) by mathstuf (subscriber, #69389) [Link]

There are `clang-tidy` checks that check that the declaration parameter name matches the definition name. Nothing more fun than staring at code with a `int f(int a, int b)` declaration but a `int f(int b, int a)` typo in the definition. Though these tools can "read" comments to know that `/*b*/` at the definition site matches the declaration name as well.

See this Rust issue as well for when `_arg` naming is unwelcome: https://github.com/rust-lang/rust/issues/91074


Copyright © 2025, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds