From patchwork Thu Aug 22 13:39:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Li Zetao X-Patchwork-Id: 822264 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 3071F1C944B; Thu, 22 Aug 2024 13:31:36 +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=1724333500; cv=none; b=WWldeq+s5f65M1wlO+6zKJ7hRQ7U2nv3HyBNqKCr5mo42KQGALLuvTpcvOgNS/NI2VqQAI3KfEf6pbl+UpD1nVVmDtHxBjloDRmvFj6hxIkuBf9XHL7a2ST6ZW3G5imtUxWxsuRBSZhr9o7Nl9YaRUo7axh/x7icP3W4r6mdTjo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724333500; c=relaxed/simple; bh=NFgLzZeCnwGzYZjN2AnH5yOVdhYopM0nyGVaWiOVNe4=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Cf+1NIVwZxZ6Y2iKBYRlnkjreNqUXDTrWS2++6tBC9OFESj94/kwagJCELfmrWR089eQAgJuHrgH/kEhwUDeIW7snHqD+hVednEDXoIoC/YqpmfjgWSgHlXNe+2EZc0n+/+ZxVSUknewBQFTqgKTJCpT2L8nFA/OFPgYfi8KU98= 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.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4WqPHQ4kstz2Cn9w; Thu, 22 Aug 2024 21:31:30 +0800 (CST) Received: from kwepemd500012.china.huawei.com (unknown [7.221.188.25]) by mail.maildlp.com (Postfix) with ESMTPS id 601B41400CA; Thu, 22 Aug 2024 21:31:34 +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:33 +0800 From: Li Zetao To: , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , Subject: [PATCH net-next 3/8] net: caif: use max() to simplify the code Date: Thu, 22 Aug 2024 21:39:03 +0800 Message-ID: <20240822133908.1042240-4-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) When processing the tail append of sk buffer, the final length needs to be determined based on expectlen and addlen. Using max() here can increase the readability of the code. Signed-off-by: Li Zetao Reviewed-by: Simon Horman --- net/caif/cfpkt_skbuff.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/net/caif/cfpkt_skbuff.c b/net/caif/cfpkt_skbuff.c index 2ae8cfa3df88..96236d21b18e 100644 --- a/net/caif/cfpkt_skbuff.c +++ b/net/caif/cfpkt_skbuff.c @@ -298,10 +298,8 @@ struct cfpkt *cfpkt_append(struct cfpkt *dstpkt, if (unlikely(is_erronous(dstpkt) || is_erronous(addpkt))) { return dstpkt; } - if (expectlen > addlen) - neededtailspace = expectlen; - else - neededtailspace = addlen; + + neededtailspace = max(expectlen, addlen); if (dst->tail + neededtailspace > dst->end) { /* Create a dumplicate of 'dst' with more tail space */