From patchwork Sat Aug 24 07:40:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13776359 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from szxga07-in.huawei.com (szxga07-in.huawei.com [45.249.212.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1ED1E2D7B8; Sat, 24 Aug 2024 07:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.35 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484800; cv=none; b=uMK0xuJV/+oXDF3pd3wtI0cc7Tpi1PEMDblOVzinC6lHFNdMRvxdiZEJQEeltDH6ib8MicxoWmWq0pzk8mMp3hrFJmqEGXDnOAukMuQrKx9NA2CoNy4BVIX2c7bXZOYzva66j6vGV5SXQVku/qHU4BPmRJMRloXgRyRKDoZKW6I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484800; c=relaxed/simple; bh=vhj7JegrniHUVNoTBlLWxbuanhFLd38NBAGgKpKlWR4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MxLhbyAaMiI3L9Wwnq4FWgRWrsRIVjPia50s/BX9xdJmaOtAo3LsDo21XnqQubNA4bndC3CWH5bYr9yDNdkOGqMhtr4krVoewluh8JPZTKPUY03eIXePPxnAZpiKyPfo2N0bFn6na2Vjd4irBODlpMiXaJWvZ5a4Y0MmVcxd26M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.35 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.44]) by szxga07-in.huawei.com (SkyGuard) with ESMTP id 4WrTDz2mT4z1S8mL; Sat, 24 Aug 2024 15:33:07 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id EFF2D1402D0; Sat, 24 Aug 2024 15:33:13 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 24 Aug 2024 15:33:13 +0800 From: Hongbo Li To: , , , , , , , CC: , , , , , , Subject: [PATCH net-next 1/8] net/mac80211: use max to simplify the code Date: Sat, 24 Aug 2024 15:40:26 +0800 Message-ID: <20240824074033.2134514-2-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240824074033.2134514-1-lihongbo22@huawei.com> References: <20240824074033.2134514-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) 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 --- 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(-) diff --git a/net/mac80211/driver-ops.h b/net/mac80211/driver-ops.h index d382d9729e85..6b75c7eeff25 100644 --- a/net/mac80211/driver-ops.h +++ b/net/mac80211/driver-ops.h @@ -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) diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c index 4779a18ab75d..60a7631f0457 100644 --- a/net/mac80211/mlme.c +++ b/net/mac80211/mlme.c @@ -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); } diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index b5f2df61c7f6..e77c9f07b046 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c @@ -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); diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c index f07b40916485..719739def96c 100644 --- a/net/mac80211/tdls.c +++ b/net/mac80211/tdls.c @@ -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)) From patchwork Sat Aug 24 07:40:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13776358 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D20DA746E; Sat, 24 Aug 2024 07:33:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.187 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484800; cv=none; b=HzESADeKFTX63Jz3GPAiEs5fLKFoeewEPbPogVCAZ4nF9uSmRsqxJZL08a20TKo3T1Y4tSnRFcB/oNfteB8m8Y7FHUQUxrQCrPAkO5+7qezzp0GY8KoqNdwe19Tle9OsYAxVmYmzQ2midnqQhtV2u+Onp/f3G4AkNmTlolicuXA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484800; c=relaxed/simple; bh=48Em0RcKvHK8LCBYl3gaXRieC5bB2sJ6QpJq+jnDrAk=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Vn3fBVBpPEKWUT8EOeJqph7n4DgUAQsB3zowmOAc3CFhsKGM6YAKs13LAaVAxZUh9f3ho/4U3y8IMJ5hohccMFJvLkU3PJc0K7ud6A3f89eku2k7F0y3gZj9d+f9lubrxZbnuBYg9IpcHUY621p3I9zHHUgFGx8aFwIifFIDT0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.187 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4WrTDc2YLszyR2M; Sat, 24 Aug 2024 15:32:48 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 25D0B1800A5; Sat, 24 Aug 2024 15:33:14 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 24 Aug 2024 15:33:13 +0800 From: Hongbo Li To: , , , , , , , CC: , , , , , , Subject: [PATCH net-next 2/8] net/rds: Use max() to simplify the code Date: Sat, 24 Aug 2024 15:40:27 +0800 Message-ID: <20240824074033.2134514-3-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240824074033.2134514-1-lihongbo22@huawei.com> References: <20240824074033.2134514-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) The target if-else can be replaced with max(). Signed-off-by: Hongbo Li Reviewed-by: Allison Henderson --- net/rds/info.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/net/rds/info.c b/net/rds/info.c index b6b46a8214a0..8558b0a466b4 100644 --- a/net/rds/info.c +++ b/net/rds/info.c @@ -194,10 +194,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval, } ret = pin_user_pages_fast(start, nr_pages, FOLL_WRITE, pages); if (ret != nr_pages) { - if (ret > 0) - nr_pages = ret; - else - nr_pages = 0; + nr_pages = max(ret, 0); ret = -EAGAIN; /* XXX ? */ goto out; } From patchwork Sat Aug 24 07:40:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13776361 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from szxga05-in.huawei.com (szxga05-in.huawei.com [45.249.212.191]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E10D72D7B8; Sat, 24 Aug 2024 07:33:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.191 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484804; cv=none; b=CaWJqQCKf4lJ5IwAp9uQA4w1hwPj7yAwR4bNQm2Ief5E+PtIGw7KylrxxNzOgVcDbX6K0HkDDwwqhbvWNMyfUlAYRYCjrPkPc1mRbpp+iel8CparizxcUMtIk7uVYM2edjxxYwQx7pS2ojrRe87lMGrRUjbn3Q25WjE/jbcAvfc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484804; c=relaxed/simple; bh=2Lhf//eOuftp5GWtCDU5XsiHeG7f1DhzdYzQ7ZKsezQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uzeCb03ndp21GlWNsUUrDkNr2PVVuIfWnSIA8RGX63d+kPYEuIj91sM8HkM9mlq5BWTM/i7Sn4u2I9iTXFDO9YHRNyMcXr6rZKN+N84IATmfQIhaK+Qx/FTxgD57/rdaI8b8YXmE966sfs7I5rlQLGaPvhOnr3BWJ0qGVgdzvKI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.191 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.214]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4WrT9M0qtHz1HGkR; Sat, 24 Aug 2024 15:29:59 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 540731A016C; Sat, 24 Aug 2024 15:33:14 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 24 Aug 2024 15:33:14 +0800 From: Hongbo Li To: , , , , , , , CC: , , , , , , Subject: [PATCH net-next 3/8] net/ipv4: Use min() to simplify the code Date: Sat, 24 Aug 2024 15:40:28 +0800 Message-ID: <20240824074033.2134514-4-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240824074033.2134514-1-lihongbo22@huawei.com> References: <20240824074033.2134514-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) The following Coccinelle/coccicheck warning reported by minmax.cocci: WARNING opportunity for min() Let's use min() to simplify the code and fix the warning. Signed-off-by: Hongbo Li --- net/ipv4/ip_sockglue.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c index cf377377b52d..f35aba4c3b0e 100644 --- a/net/ipv4/ip_sockglue.c +++ b/net/ipv4/ip_sockglue.c @@ -282,7 +282,7 @@ int ip_cmsg_send(struct sock *sk, struct msghdr *msg, struct ipcm_cookie *ipc, /* Our caller is responsible for freeing ipc->opt */ err = ip_options_get(net, &ipc->opt, KERNEL_SOCKPTR(CMSG_DATA(cmsg)), - err < 40 ? err : 40); + min(40, err)); if (err) return err; break; From patchwork Sat Aug 24 07:40:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13776366 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 634F4155733; Sat, 24 Aug 2024 07:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484805; cv=none; b=qmCjuzik0tMP+tj3Gct/733DAuB1jinbC/P7U8vwDUZU/QjM7E+ERszqdkdih92owNWq9QxQEK/KH3nuoIqnQLds3AtBKv1t7DO+TzQEqsrsTOxBmBBKErJOGUycRzan/R6adFAzmikQC+2UOjnwXXw0RCVr55C/1CyIIV1cS+A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484805; c=relaxed/simple; bh=6GXKtjujGwEH+GhrHTdQj88RQxkCOT45Z7plPSoEHCE=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qcJMvBHK5BZN9MFrFYBL7i7g6XMETKlqhbTyfUf8H1WYleu8AokZUGW//0V6Pkwz6mr/eN28Lu23Zd4fjZEYCGROW9kFAx7lwCMDkAliZaLGNX3jAVjuC0N6aPznSgsxD8JkSWNraZb+lVOKCnvAgeobX3YvLWiY7SnWHLeUEsU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.174]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WrTCG5W2QzpStD; Sat, 24 Aug 2024 15:31:38 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 8024414035E; Sat, 24 Aug 2024 15:33:14 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 24 Aug 2024 15:33:14 +0800 From: Hongbo Li To: , , , , , , , CC: , , , , , , Subject: [PATCH net-next 4/8] net/core: Use min()/max() to simplify the code Date: Sat, 24 Aug 2024 15:40:29 +0800 Message-ID: <20240824074033.2134514-5-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240824074033.2134514-1-lihongbo22@huawei.com> References: <20240824074033.2134514-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) Let's use min()/max() to simplify the code and fix the Coccinelle/coccicheck warning. Signed-off-by: Hongbo Li --- net/core/pktgen.c | 6 ++---- net/core/sock.c | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/net/core/pktgen.c b/net/core/pktgen.c index ea55a758a475..5d4d5ec4a126 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c @@ -2793,8 +2793,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb, } i = 0; - frag_len = (datalen/frags) < PAGE_SIZE ? - (datalen/frags) : PAGE_SIZE; + frag_len = min(datalen/frags, PAGE_SIZE); while (datalen > 0) { if (unlikely(!pkt_dev->page)) { int node = numa_node_id(); @@ -2811,8 +2810,7 @@ static void pktgen_finalize_skb(struct pktgen_dev *pkt_dev, struct sk_buff *skb, if (i == (frags - 1)) skb_frag_fill_page_desc(&skb_shinfo(skb)->frags[i], pkt_dev->page, 0, - (datalen < PAGE_SIZE ? - datalen : PAGE_SIZE)); + min(datalen, PAGE_SIZE)); else skb_frag_fill_page_desc(&skb_shinfo(skb)->frags[i], pkt_dev->page, 0, frag_len); diff --git a/net/core/sock.c b/net/core/sock.c index bbe4c58470c3..c9910f48903f 100644 --- a/net/core/sock.c +++ b/net/core/sock.c @@ -3800,7 +3800,7 @@ int sock_prot_inuse_get(struct net *net, struct proto *prot) for_each_possible_cpu(cpu) res += per_cpu_ptr(net->core.prot_inuse, cpu)->val[idx]; - return res >= 0 ? res : 0; + return max(res, 0); } EXPORT_SYMBOL_GPL(sock_prot_inuse_get); From patchwork Sat Aug 24 07:40:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13776364 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 64659155736; Sat, 24 Aug 2024 07:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484804; cv=none; b=f7LMVWJDsYYCOfbwtHtMSn+K++birDqwOjxrwKNdi64l2vLEGLSVwzWbMNUGWuY7OGCo2oX8N0EFEsUevi8aCaYu0CURZomuSSA60DtmMhp6FDrBnn5oEvafuqsjIRnw041kVMT7eWYTi0j7z2y5Zt7OgbjuQyyLHNjvG/h8sP0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484804; c=relaxed/simple; bh=6JzBL7tRSY3xdYZzPOvXqNovzWc8wJRXhUw0LGRPXLQ=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Li4XOFfbUINiqgPZkKR+3opLt0lK5uzaBqhKNTpxXsFEhVvx0XdYyGd3J+Mygx1ONIiz4VTsxMjm7RZ15WGatlP8JeNcIlJmRWFYV6qoz8xC1JBm64bRFZC2BgAxUhsHf2m8DOHmKGwc8Y5SAPmXsopUQV9oOxO2PfbpS5t7DXw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.162.112]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WrTF04xnwz2CnRb; Sat, 24 Aug 2024 15:33:08 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id AB74B14013B; Sat, 24 Aug 2024 15:33:14 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 24 Aug 2024 15:33:14 +0800 From: Hongbo Li To: , , , , , , , CC: , , , , , , Subject: [PATCH net-next 5/8] net/dccp: Use min()/max() to simplify the code Date: Sat, 24 Aug 2024 15:40:30 +0800 Message-ID: <20240824074033.2134514-6-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240824074033.2134514-1-lihongbo22@huawei.com> References: <20240824074033.2134514-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) Let's use min()/max() to simplify the code and fix the Coccinelle/coccicheck warning reported by minmax.cocci. Signed-off-by: Hongbo Li --- net/dccp/ackvec.c | 2 +- net/dccp/dccp.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net/dccp/ackvec.c b/net/dccp/ackvec.c index 1cba001bb4c8..faadd0190107 100644 --- a/net/dccp/ackvec.c +++ b/net/dccp/ackvec.c @@ -305,7 +305,7 @@ void dccp_ackvec_clear_state(struct dccp_ackvec *av, const u64 ackno) * Deal with overlapping Ack Vectors: don't subtract more than the * number of packets between tail_ackno and ack_ackno. */ - eff_runlen = delta < avr->avr_ack_runlen ? delta : avr->avr_ack_runlen; + eff_runlen = min(delta, avr->avr_ack_runlen); runlen_now = dccp_ackvec_runlen(av->av_buf + avr->avr_ack_ptr); /* diff --git a/net/dccp/dccp.h b/net/dccp/dccp.h index 1f748ed1279d..872d17fb85b5 100644 --- a/net/dccp/dccp.h +++ b/net/dccp/dccp.h @@ -149,7 +149,7 @@ static inline u64 dccp_loss_count(const u64 s1, const u64 s2, const u64 ndp) WARN_ON(delta < 0); delta -= ndp + 1; - return delta > 0 ? delta : 0; + return max(delta, 0); } /** From patchwork Sat Aug 24 07:40:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13776365 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6346D155398; Sat, 24 Aug 2024 07:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484805; cv=none; b=YyBR0GhT5G5KV2bL1zvivMMrvQDVF0FlAgqQb85M88/jSBEvHfhBtehOZ7IuJTZVCLedzA7q6477DwfDF1LReQ+uPxigLErhjrhXimNrAQxovXN/k63ORAzpnrqb2cEbw68WubWzhTf9l9OVUOP0Qg17MyyPlP9SKINQ87+rAfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484805; c=relaxed/simple; bh=zR7+B23CWhFGznAhbvD+/Vaalurqp9BoWmWW0F2bidw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pMk/1t1FismH7kRoIXbiIzPFF5et+8uf0ATxiqzET04lFr+hP6wuat8KEy4ljrUxbqtoSZtUmMR0jvkpWyFGDRJG3KWRHdVDkaxifhkAwYSQDK9+kwYdg9uJMIgk0x0ezjtufuVd9pNbeAXQk6kM469myNgk7U7U2muu4xLfRSY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.194]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WrTCH0nRhzpSw1; Sat, 24 Aug 2024 15:31:39 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id D2A86140202; Sat, 24 Aug 2024 15:33:14 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 24 Aug 2024 15:33:14 +0800 From: Hongbo Li To: , , , , , , , CC: , , , , , , Subject: [PATCH net-next 6/8] net/openvswitch: Use max() to simplify the code Date: Sat, 24 Aug 2024 15:40:31 +0800 Message-ID: <20240824074033.2134514-7-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240824074033.2134514-1-lihongbo22@huawei.com> References: <20240824074033.2134514-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) Let's use max() to simplify the code and fix the Coccinelle/coccicheck warning reported by minmax.cocci. Signed-off-by: Hongbo Li Acked-by: Eelco Chaudron Reviewed-by: Aaron Conole --- net/openvswitch/vport.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index 8732f6e51ae5..859208df65ea 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c @@ -534,7 +534,7 @@ static int packet_length(const struct sk_buff *skb, * account for 802.1ad. e.g. is_skb_forwardable(). */ - return length > 0 ? length : 0; + return max(length, 0); } void ovs_vport_send(struct vport *vport, struct sk_buff *skb, u8 mac_proto) From patchwork Sat Aug 24 07:40:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13776362 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63536155735; Sat, 24 Aug 2024 07:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484804; cv=none; b=Vld7CF4EJcKvCP2fx/xUpxR2KWfC7wOdY/I8qQOU/Jx44Pm5QQl8CQmZoLQ4GjuWdUKalemAhMPL8fDA/IwUkDWHYPuCFtTbbr/LvK5tCDoX+en7GsvULhsSnn36sJIL9kN39eW5Lz3qeOsNUv/hFxR8Zp902droJsgzh7vjmvk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484804; c=relaxed/simple; bh=Zl6JU4raRf1DfkAjrXYsxw8FZaF/pAfSri/sLIxlhdw=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VjHePwygHFfPudRlIvcLxHibQNmYuTOHryXSaPEAPX5h+iRovi/Tug4lpBOadYp0GY8KhMbtBfgsQPYO5ZqJMaM/QmHjm2XeNfYDIVFreVHbq5CfUzQz6Tw/4ckv5+mITdYV7r3RJnjm8HuTVal3IQ57Vlvl1eTnmzfObttuXsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.105]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WrTBn0ntCzhXgK; Sat, 24 Aug 2024 15:31:13 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 0CEFD140137; Sat, 24 Aug 2024 15:33:15 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 24 Aug 2024 15:33:14 +0800 From: Hongbo Li To: , , , , , , , CC: , , , , , , Subject: [PATCH net-next 7/8] net/rxrpc: Use min() to simplify the code Date: Sat, 24 Aug 2024 15:40:32 +0800 Message-ID: <20240824074033.2134514-8-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240824074033.2134514-1-lihongbo22@huawei.com> References: <20240824074033.2134514-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) Let's use min() to simplify the code and fix the Coccinelle/coccicheck warning reported by minmax.cocci. Signed-off-by: Hongbo Li --- net/rxrpc/input.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/net/rxrpc/input.c b/net/rxrpc/input.c index 16d49a861dbb..455aa0189b28 100644 --- a/net/rxrpc/input.c +++ b/net/rxrpc/input.c @@ -868,8 +868,7 @@ static void rxrpc_input_ack(struct rxrpc_call *call, struct sk_buff *skb) prev_pkt = sp->ack.prev_ack; nr_acks = sp->ack.nr_acks; hard_ack = first_soft_ack - 1; - summary.ack_reason = (sp->ack.reason < RXRPC_ACK__INVALID ? - sp->ack.reason : RXRPC_ACK__INVALID); + summary.ack_reason = min(sp->ack.reason, RXRPC_ACK__INVALID); trace_rxrpc_rx_ack(call, ack_serial, acked_serial, first_soft_ack, prev_pkt, From patchwork Sat Aug 24 07:40:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hongbo Li X-Patchwork-Id: 13776363 X-Patchwork-Delegate: johannes@sipsolutions.net Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 634AE155730; Sat, 24 Aug 2024 07:33:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.188 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484804; cv=none; b=qyQR5lzcbuopOFXKFqiorSATGq8bJWGxb8PcUNn+V7of790z3kMH/iKE0I8y0pKm4rJVoLaDxoZPJuoGygdaIXIl1Ak2GsqBDxEJtGpP+/QVKslAjBj4yneIwfdJKQAbnkLss1lIVgNlRjWBTMSvslKwxWMDkRh7M9XS8g0Eeec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724484804; c=relaxed/simple; bh=vLibUpSaG3BzdKHKvIS416D8qK4XEhhguVioin6uHVs=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=M4o6/KHu9g9wK1iyvlMTH8HOZsqouNmb+/QPFrgC5X8Ey+qNcHLws+yFW97OdTNzYpZgWiJL6oEi6yRWnQiUZQRM5srq9veMpB72JnyQfzF7MwSuTVkQiL5FernFm74bjOVGTZAhBSqf8smVmM6CAvv+agYgNObmoLiI6S+Ok0I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.188 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.163.252]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4WrTBn20vCzhY5w; Sat, 24 Aug 2024 15:31:13 +0800 (CST) Received: from dggpeml500022.china.huawei.com (unknown [7.185.36.66]) by mail.maildlp.com (Postfix) with ESMTPS id 37F141800A5; Sat, 24 Aug 2024 15:33:15 +0800 (CST) Received: from huawei.com (10.90.53.73) by dggpeml500022.china.huawei.com (7.185.36.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.39; Sat, 24 Aug 2024 15:33:14 +0800 From: Hongbo Li To: , , , , , , , CC: , , , , , , Subject: [PATCH net-next 8/8] net/ceph: Use min() to simplify the code Date: Sat, 24 Aug 2024 15:40:33 +0800 Message-ID: <20240824074033.2134514-9-lihongbo22@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240824074033.2134514-1-lihongbo22@huawei.com> References: <20240824074033.2134514-1-lihongbo22@huawei.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To dggpeml500022.china.huawei.com (7.185.36.66) Let's use min() to simplify the code and fix the Coccinelle/coccicheck warning reported by minmax.cocci. Signed-off-by: Hongbo Li --- net/ceph/osd_client.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 9d078b37fe0b..450eb3be48b0 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -3058,7 +3058,7 @@ static void linger_reg_commit_complete(struct ceph_osd_linger_request *lreq, int result) { if (!completion_done(&lreq->reg_commit_wait)) { - lreq->reg_commit_error = (result <= 0 ? result : 0); + lreq->reg_commit_error = min(result, 0); complete_all(&lreq->reg_commit_wait); } }