lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241029085740.55888e95@kernel.org>
Date: Tue, 29 Oct 2024 08:57:40 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Johannes Berg <johannes@...solutions.net>
Cc: linux-wireless@...r.kernel.org, netdev@...r.kernel.org, Johannes Berg
 <johannes.berg@...el.com>
Subject: Re: [RFC PATCH 2/2] net: convert to nla_get_*_default()

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.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ