From patchwork Thu Aug 22 13:39:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 821780 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 66E48183CB0; Thu, 22 Aug 2024 13:31:36 +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=1724333499; cv=none; b=RA4i1pqxsrHsn2jdxpsf8LUgM34zj16LZMPc9pnYmb5mAAbCWfvidgcTBhb9mokUjfBs794fAwxwJtb5UBBH3iDfp0uyl4cUbK01rJ7VtE/sxC1n8cbKn25B21scp9l/zSOhBNkJSA/ylsChAbuVZ819aZoru7O9Z7HOPB2MPM8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724333499; c=relaxed/simple; bh=h6QniSsn+iP/ZJ8YjlAlY0rwKvwjfTZgr12f0Msgkc4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=BEnw7uCb+t6xwEB9p6J0xoJ7IN2Olb86157EOhquUo0r2sp1C9IgN8hrDn1jIXZvmZ+GAs81gLoy8ALku/eVRaA6xl1zyL3o8Or5BcsJwgOsUEJBPVauTAZYwRiMlozAc1zOB5NAyk6/pebNzdDLOYl6oHxdmP3StTa113VdG/Q= 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 4WqPFh1wJKzpTj8; Thu, 22 Aug 2024 21:30:00 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 500AD140134; Thu, 22 Aug 2024 21:31:33 +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:32 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , Subject: [PATCH net-next 2/8] Bluetooth: use min() to simplify the code Date: Thu, 22 Aug 2024 21:39:02 +0800 Message-ID: <20240822133908.1042240-3-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: ceph-devel@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) When copying data from skb, it needs to determine the copy length. It is easier to understand using min() here. Signed-off-by: Li Zetao --- net/bluetooth/hidp/core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c index 707f229f896a..7bf24f2993ba 100644 --- a/net/bluetooth/hidp/core.c +++ b/net/bluetooth/hidp/core.c @@ -294,7 +294,7 @@ static int hidp_get_raw_report(struct hid_device *hid, skb = session->report_return; if (skb) { - len = skb->len < count ? skb->len : count; + len = min(skb->len, count); memcpy(data, skb->data, len); kfree_skb(skb);