summaryrefslogtreecommitdiff
path: root/rust/kernel/firmware.rs
diff options
context:
space:
mode:
authorVincent Mailhol <mailhol@kernel.org>2026-07-14 20:18:03 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2026-07-15 07:15:26 +0200
commitf9e7a7564834af3e1239fbb9a4161f448edd04fa (patch)
tree003dd6c4313f5b0184717b255200b946637ab0d2 /rust/kernel/firmware.rs
parent1ead62bc1bd7f48bc7d4d107769fb991f6f3961c (diff)
downloadlinux-next-f9e7a7564834af3e1239fbb9a4161f448edd04fa.tar.gz
linux-next-f9e7a7564834af3e1239fbb9a4161f448edd04fa.zip
container_of: remove local __mptr variable
container_of() can be called in a nested manner to retrieve the grand parent structure as illustrated below: struct foo { int a; }; struct bar { struct foo foo; }; #define to_foo(a_ptr) container_of(a_ptr, struct foo, a) #define to_bar(a_ptr) container_of(to_foo(a_ptr), struct bar, foo) The issue is that the above construct will cause __mptr, the local variable of container_of(), to shadow itself because of the nested call. This then triggers a warning in sparse and W=2 builds. While this warning is benign, it still causes some overhead as proven by below list of commits in which people made local workarounds: - commit 7eab14de73a8 ("mdio, phy: fix -Wshadow warnings triggered by nested container_of()") - commit 8d8c3131248d ("clk: define to_clk_regmap() as inline function") - commit bfb972c5e1cb ("IB/verbs: avoid nested container_of()") - commit 093adbcedf12 ("btrfs: switch helper macros to static inlines in sysfs.h") - commit c1d35dfa0f7d ("rt2x00: Fix sparse warning on nested container_of()") (the list is probably not exhaustive). As a matter of fact, the local variable __mptr is only used once in container_of(). As such, it is not strictly needed. Inline that local __mptr variable to remove once and for all the risk of variable shadowing when nesting container_of() and prevent people from writing further local fixes. Signed-off-by: Vincent Mailhol <mailhol@kernel.org> Link: https://patch.msgid.link/20260714-containerof_refactor-v1-3-b5c31164d2ad@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'rust/kernel/firmware.rs')
0 files changed, 0 insertions, 0 deletions