diff options
author | Johannes Berg <johannes.berg@intel.com> | 2024-11-08 11:41:45 +0100 |
---|---|---|
committer | Jakub Kicinski <kuba@kernel.org> | 2024-11-11 10:32:06 -0800 |
commit | a885a6b2d37eaaae08323583bdb1928c8a2935fc (patch) | |
tree | 89aaf7e888f88b28f4c8acc88171c0d21eb2fb08 /net/hsr | |
parent | 7f4b3960e54faec72132a71da4a84a8e2a0b9037 (diff) |
net: convert to nla_get_*_default()
Most of the original conversion is from the spatch below,
but I edited some and left out other instances that were
either buggy after conversion (where default values don't
fit into the type) or just looked strange.
@@
expression attr, def;
expression val;
identifier fn =~ "^nla_get_.*";
fresh identifier dfn = fn ## "_default";
@@
(
-if (attr)
- val = fn(attr);
-else
- val = def;
+val = dfn(attr, def);
|
-if (!attr)
- val = def;
-else
- val = fn(attr);
+val = dfn(attr, def);
|
-if (!attr)
- return def;
-return fn(attr);
+return dfn(attr, def);
|
-attr ? fn(attr) : def
+dfn(attr, def)
|
-!attr ? def : fn(attr)
+dfn(attr, def)
)
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Reviewed-by: Toke Høiland-Jørgensen <toke@kernel.org>
Link: https://patch.msgid.link/20241108114145.0580b8684e7f.I740beeaa2f70ebfc19bfca1045a24d6151992790@changeid
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'net/hsr')
-rw-r--r-- | net/hsr/hsr_netlink.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/net/hsr/hsr_netlink.c b/net/hsr/hsr_netlink.c index 6f09b9512484..b68f2f71d0e1 100644 --- a/net/hsr/hsr_netlink.c +++ b/net/hsr/hsr_netlink.c @@ -82,10 +82,7 @@ static int hsr_newlink(struct net *src_net, struct net_device *dev, return -EINVAL; } - if (!data[IFLA_HSR_MULTICAST_SPEC]) - multicast_spec = 0; - else - multicast_spec = nla_get_u8(data[IFLA_HSR_MULTICAST_SPEC]); + multicast_spec = nla_get_u8_default(data[IFLA_HSR_MULTICAST_SPEC], 0); if (data[IFLA_HSR_PROTOCOL]) proto = nla_get_u8(data[IFLA_HSR_PROTOCOL]); |