@@ -971,7 +971,7 @@ drv_mgd_protect_tdls_discover(struct ieee80211_local *local,
return;
WARN_ON_ONCE(sdata->vif.type != NL80211_IFTYPE_STATION);
- link_id = link_id > 0 ? link_id : 0;
+ link_id = max(link_id, 0);
trace_drv_mgd_protect_tdls_discover(local, sdata);
if (local->ops->mgd_protect_tdls_discover)
@@ -5375,7 +5375,7 @@ ieee80211_determine_our_sta_mode_auth(struct ieee80211_sub_if_data *sdata,
struct ieee80211_conn_settings *conn)
{
ieee80211_determine_our_sta_mode(sdata, sband, NULL, wmm_used,
- req->link_id > 0 ? req->link_id : 0,
+ max(req->link_id, 0),
conn);
}
@@ -1013,10 +1013,8 @@ static void ieee80211_scan_state_set_channel(struct ieee80211_local *local,
*/
if ((chan->flags & (IEEE80211_CHAN_NO_IR | IEEE80211_CHAN_RADAR)) ||
!scan_req->n_ssids) {
- *next_delay = msecs_to_jiffies(scan_req->duration) >
- IEEE80211_PASSIVE_CHANNEL_TIME ?
- msecs_to_jiffies(scan_req->duration) :
- IEEE80211_PASSIVE_CHANNEL_TIME;
+ *next_delay = max(msecs_to_jiffies(scan_req->duration),
+ IEEE80211_PASSIVE_CHANNEL_TIME);
local->next_scan_state = SCAN_DECISION;
if (scan_req->n_ssids)
set_bit(SCAN_BEACON_WAIT, &local->scanning);
@@ -919,7 +919,7 @@ ieee80211_tdls_build_mgmt_packet_data(struct ieee80211_sub_if_data *sdata,
int ret;
struct ieee80211_link_data *link;
- link_id = link_id >= 0 ? link_id : 0;
+ link_id = max(link_id, 0);
rcu_read_lock();
link = rcu_dereference(sdata->link[link_id]);
if (WARN_ON(!link))
The following Coccinelle/coccicheck warning reported by minmax.cocci: WARNING opportunity for max() Let's use max() to simplify the code and fix the warning. Signed-off-by: Hongbo Li <lihongbo22@huawei.com> --- v2: - change the commit title v1: https://patchwork.kernel.org/project/linux-wireless/patch/20240824074033.2134514-2-lihongbo22@huawei.com/ --- net/mac80211/driver-ops.h | 2 +- net/mac80211/mlme.c | 2 +- net/mac80211/scan.c | 6 ++---- net/mac80211/tdls.c | 2 +- 4 files changed, 5 insertions(+), 7 deletions(-)