Search Linux Wireless

Re: [RFC PATCH 2/2] net: convert to nla_get_*_default()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 24 Oct 2024 13:18:07 +0200 Johannes Berg wrote:
> diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c
> index 79ba9dc70254..7a10bb159113 100644
> --- a/net/sched/sch_gred.c
> +++ b/net/sched/sch_gred.c
> @@ -750,11 +750,8 @@ static int gred_init(struct Qdisc *sch, struct nlattr *opt,
>  		return -EINVAL;
>  	}
>  
> -	if (tb[TCA_GRED_LIMIT])
> -		sch->limit = nla_get_u32(tb[TCA_GRED_LIMIT]);
> -	else
> -		sch->limit = qdisc_dev(sch)->tx_queue_len
> -		             * psched_mtu(qdisc_dev(sch));
> +	sch->limit = nla_get_u32_default(tb[TCA_GRED_LIMIT],
> +					 qdisc_dev(sch)->tx_queue_len * psched_mtu(qdisc_dev(sch)));

> @@ -7578,10 +7569,8 @@ static int nl80211_new_station(struct sk_buff *skb, struct genl_info *info)
>  			dev->ieee80211_ptr->iftype == NL80211_IFTYPE_P2P_GO;
>  	}
>  
> -	if (info->attrs[NL80211_ATTR_PEER_AID])
> -		params.aid = nla_get_u16(info->attrs[NL80211_ATTR_PEER_AID]);
> -	else
> -		params.aid = nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]);
> +	params.aid = nla_get_u16_default(info->attrs[NL80211_ATTR_PEER_AID],
> +					 nla_get_u16(info->attrs[NL80211_ATTR_STA_AID]));

I'd limit the conversions only to cases where the default is a constant.
In the two cases quoted here it seems like the conversion results in net
loss of readability.




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux