mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
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>
This commit is contained in:
committed by
Jakub Kicinski
parent
7f4b3960e5
commit
a885a6b2d3
@@ -1828,8 +1828,7 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info)
|
||||
parms.dp = dp;
|
||||
parms.port_no = OVSP_LOCAL;
|
||||
parms.upcall_portids = a[OVS_DP_ATTR_UPCALL_PID];
|
||||
parms.desired_ifindex = a[OVS_DP_ATTR_IFINDEX]
|
||||
? nla_get_s32(a[OVS_DP_ATTR_IFINDEX]) : 0;
|
||||
parms.desired_ifindex = nla_get_s32_default(a[OVS_DP_ATTR_IFINDEX], 0);
|
||||
|
||||
/* So far only local changes have been made, now need the lock. */
|
||||
ovs_lock();
|
||||
@@ -2266,8 +2265,7 @@ static int ovs_vport_cmd_new(struct sk_buff *skb, struct genl_info *info)
|
||||
if (a[OVS_VPORT_ATTR_IFINDEX] && parms.type != OVS_VPORT_TYPE_INTERNAL)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
port_no = a[OVS_VPORT_ATTR_PORT_NO]
|
||||
? nla_get_u32(a[OVS_VPORT_ATTR_PORT_NO]) : 0;
|
||||
port_no = nla_get_u32_default(a[OVS_VPORT_ATTR_PORT_NO], 0);
|
||||
if (port_no >= DP_MAX_PORTS)
|
||||
return -EFBIG;
|
||||
|
||||
@@ -2304,8 +2302,8 @@ restart:
|
||||
parms.dp = dp;
|
||||
parms.port_no = port_no;
|
||||
parms.upcall_portids = a[OVS_VPORT_ATTR_UPCALL_PID];
|
||||
parms.desired_ifindex = a[OVS_VPORT_ATTR_IFINDEX]
|
||||
? nla_get_s32(a[OVS_VPORT_ATTR_IFINDEX]) : 0;
|
||||
parms.desired_ifindex = nla_get_s32_default(a[OVS_VPORT_ATTR_IFINDEX],
|
||||
0);
|
||||
|
||||
vport = new_vport(&parms);
|
||||
err = PTR_ERR(vport);
|
||||
|
||||
Reference in New Issue
Block a user