From patchwork Thu Aug 22 13:39:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 13773416 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) (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 DB29E1C9449; Thu, 22 Aug 2024 13:31:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.189 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724333500; cv=none; b=rhKgypF7EBCD37G99OqXy1GfXSQx78al5KUkoF5eniqaDqtSiUfK6FOmkazyEwKbfYEq7KbjVeVGgIU2xH20Xv39mzV1de+xAaJy1SY0xbcuXyr5DWaWlws5QwEvXhon9RdLa0hY6glvzDlw0X1PqSCe62n8XteenPlrJiZrUlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724333500; c=relaxed/simple; bh=d1a/3Sd+36deN85pJ5KQ8bi8G8VN5Djen+1eXVXVhXM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jFoGdzyTXB5kXGOYPEo0byTnQmkP/pMygL/kkyzbgzOIpSjhg2+rX66dzwvAVlepkKUkg3Sw2+Rvo5xYuabGVByQH6k4ZvW+PWPIPopcDKfQhaR4vyhT1IwpxRp6XB+oLyB25EvU6j4uhfotkuglR93PeJr6Bm9NfBSLY6uHoyk= 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.189 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 szxga03-in.huawei.com (SkyGuard) with ESMTP id 4WqPB51XmNz69NR; Thu, 22 Aug 2024 21:26:53 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 7E48A140553; Thu, 22 Aug 2024 21:31:36 +0800 (CST) Received: from huawei.com (10.90.53.73) by kwepemd500012.china.huawei.com (7.221.188.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Thu, 22 Aug 2024 21:31:35 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , Subject: [PATCH net-next 5/8] net: remove redundant judgments to simplify the code Date: Thu, 22 Aug 2024 21:39:05 +0800 Message-ID: <20240822133908.1042240-6-lizetao1@huawei.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240822133908.1042240-1-lizetao1@huawei.com> References: <20240822133908.1042240-1-lizetao1@huawei.com> Precedence: bulk X-Mailing-List: linux-bluetooth@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 kwepemd500012.china.huawei.com (7.221.188.25) The res variable has been initialized to 0, and the number of prots being used will not exceed MAX_INT, so there is no need to judge whether it is greater than 0 before returning. Refer to the implementation of sock_inuse_get. Signed-off-by: Li Zetao --- net/core/sock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/core/sock.c b/net/core/sock.c index bbe4c58470c3..52bfc86a2f37 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 res; } EXPORT_SYMBOL_GPL(sock_prot_inuse_get);