net: bridge: add compile-time assert for cb struct size
Subsystems (3)
PATCH 1/1 net: bridge: add compile-time assert for cb struct size
make build fail if struct doesn't fit into ->cb storage area.
Signed-off-by Florian Westphal <[email protected]>
--- net/bridge/br.c | 3 +++ 1 file changed, 3 insertions(+)
net/bridge/br.c +3 -0
@@ -188,8 +188,11 @@ static const struct stp_proto br_stp_proto = {static int __init br_init (void ) { +struct sk_buff *skb;int err; +BUILD_BUG_ON (sizeof (struct br_input_skb_cb ) >sizeof (skb->cb)); + err =stp_proto_register (&br_stp_proto);if (err <0 ) {pr_err ("bridge: can't register sap for STP\n" );
Signature · 1 line
2.0.5
David Miller
maintainerFrom: Florian Westphal <[email protected]>
Date: Tue, 3 Mar 2015 03:50:22 +0100
net/bridge/br.c static const struct stp_proto br_stp_proto = { · line 198
Quoted 12 lines
net/bridge/br.c +3
-0@@ -188,8 +188,11 @@ static const struct stp_proto br_stp_proto = {static int __init br_init (void ) { +struct sk_buff *skb;int err; +BUILD_BUG_ON (sizeof (struct br_input_skb_cb ) >sizeof (skb->cb)); + err =stp_proto_register (&br_stp_proto);if (err <0 ) {pr_err ("bridge: can't register sap for STP\n" );
The canonical way to do this, unless you needed the 'skb' variable for another reason, is to use FIELD_SIZEOF().