From: Jakub Kicinski <kuba@kernel.org>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
Johannes Berg <johannes.berg@intel.com>
Subject: Re: [RFC PATCH 2/2] net: convert to nla_get_*_default()
Date: Tue, 29 Oct 2024 08:57:40 -0700 [thread overview]
Message-ID: <20241029085740.55888e95@kernel.org> (raw)
In-Reply-To: <20241024131807.d5b9f6e57ede.I740beeaa2f70ebfc19bfca1045a24d6151992790@changeid>
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.
next prev parent reply other threads:[~2024-10-29 15:57 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-24 11:18 [RFC PATCH 1/2] net: netlink: add nla_get_*_default() accessors Johannes Berg
2024-10-24 11:18 ` [RFC PATCH 2/2] net: convert to nla_get_*_default() Johannes Berg
2024-10-24 12:11 ` Johannes Berg
2024-10-24 14:28 ` Sabrina Dubroca
2024-10-24 14:31 ` Johannes Berg
2024-10-24 14:40 ` Johannes Berg
2024-10-24 13:41 ` Johannes Berg
2024-10-24 14:48 ` Sabrina Dubroca
2024-10-24 14:52 ` Johannes Berg
2024-10-24 15:17 ` Sabrina Dubroca
2024-10-24 15:29 ` Johannes Berg
2024-10-29 15:57 ` Jakub Kicinski [this message]
2024-10-24 11:29 ` [RFC PATCH 1/2] net: netlink: add nla_get_*_default() accessors Johannes Berg
2024-10-24 12:51 ` Toke Høiland-Jørgensen
2024-10-29 15:54 ` Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241029085740.55888e95@kernel.org \
--to=kuba@kernel.org \
--cc=johannes.berg@intel.com \
--cc=johannes@sipsolutions.net \
--cc=linux-wireless@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).