1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/intel
Johannes Berg e8058a49e6 netlink: introduce type-checking attribute iteration
There are, especially with multi-attr arrays, many cases
of needing to iterate all attributes of a specific type
in a netlink message or a nested attribute. Add specific
macros to support that case.

Also convert many instances using this spatch:

    @@
    iterator nla_for_each_attr;
    iterator name nla_for_each_attr_type;
    identifier nla;
    expression head, len, rem;
    expression ATTR;
    type T;
    identifier x;
    @@
    -nla_for_each_attr(nla, head, len, rem)
    +nla_for_each_attr_type(nla, ATTR, head, len, rem)
     {
    <... T x; ...>
    -if (nla_type(nla) == ATTR) {
     ...
    -}
     }

    @@
    identifier nla;
    iterator nla_for_each_nested;
    iterator name nla_for_each_nested_type;
    expression attr, rem;
    expression ATTR;
    type T;
    identifier x;
    @@
    -nla_for_each_nested(nla, attr, rem)
    +nla_for_each_nested_type(nla, ATTR, attr, rem)
     {
    <... T x; ...>
    -if (nla_type(nla) == ATTR) {
     ...
    -}
     }

    @@
    iterator nla_for_each_attr;
    iterator name nla_for_each_attr_type;
    identifier nla;
    expression head, len, rem;
    expression ATTR;
    type T;
    identifier x;
    @@
    -nla_for_each_attr(nla, head, len, rem)
    +nla_for_each_attr_type(nla, ATTR, head, len, rem)
     {
    <... T x; ...>
    -if (nla_type(nla) != ATTR) continue;
     ...
     }

    @@
    identifier nla;
    iterator nla_for_each_nested;
    iterator name nla_for_each_nested_type;
    expression attr, rem;
    expression ATTR;
    type T;
    identifier x;
    @@
    -nla_for_each_nested(nla, attr, rem)
    +nla_for_each_nested_type(nla, ATTR, attr, rem)
     {
    <... T x; ...>
    -if (nla_type(nla) != ATTR) continue;
     ...
     }

Although I had to undo one bad change this made, and
I also adjusted some other code for whitespace and to
use direct variable initialization now.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Link: https://lore.kernel.org/r/20240328203144.b5a6c895fb80.I1869b44767379f204998ff44dd239803f39c23e0@changeid
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-03-29 15:06:02 -07:00
..
e1000 intel: legacy: field get conversion 2023-12-18 11:20:43 -08:00
e1000e Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-03-07 10:29:36 -08:00
fm10k intel: legacy: field get conversion 2023-12-18 11:20:43 -08:00
i40e netlink: introduce type-checking attribute iteration 2024-03-29 15:06:02 -07:00
iavf net: remove gfp_mask from napi_alloc_skb() 2024-03-28 18:30:40 -07:00
ice netlink: introduce type-checking attribute iteration 2024-03-29 15:06:02 -07:00
idpf idpf: sprinkle __counted_by{,_le}() in the virtchnl2 header 2024-03-28 18:50:47 -07:00
igb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2024-03-11 20:38:36 -07:00
igbvf net: adopt skb_network_offset() and similar helpers 2024-03-04 08:47:06 +00:00
igc net: remove gfp_mask from napi_alloc_skb() 2024-03-28 18:30:40 -07:00
ixgbe netlink: introduce type-checking attribute iteration 2024-03-29 15:06:02 -07:00
ixgbevf net: adopt skb_network_offset() and similar helpers 2024-03-04 08:47:06 +00:00
e100.c intel: make module parameters readable in sys filesystem 2024-03-04 20:49:58 -08:00
Kconfig igc: fix LEDS_CLASS dependency 2024-03-04 20:49:58 -08:00
Makefile idpf: add SRIOV support and other ndo_ops 2023-09-13 14:59:24 -07:00