On Fri, 18 Jul 2025 14:49:41 -0700 Linus Torvalds torvalds@linux-foundation.org wrote:
...
Side note: I think some coccinelle (or sed) script that replaces that older form of
typeof(x) Y = (typeof(x))(Z);
...
with just
auto Y = Z;
is also worthwhile at some point.
That one needs to keep the typeof() - but the cast might be spurious. It could be either: typeof(x) Y = Z; or: auto Y = (typeof(x))(Z); but the latter could hide compilation errors.
I'm waiting for the next 'duck shoot' (after strings) to be casts.
While casts of 'buffer' to/from 'void *' are fine (and not needed), casts to/from 'integer_type *' are definitely problematic.
And 'random' casts of integer values could easily hide real bugs and most just aren't needed. Although you might want the compiler to make the result of 'u64_var & 0xffu' 'unsigned int'.
David