Commit b4985aa8 authored by Li Zetao's avatar Li Zetao Committed by Jakub Kicinski

net: caif: use max() to simplify the code

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: default avatarLi Zetao <lizetao1@huawei.com>
Reviewed-by: default avatarSimon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240822133908.1042240-4-lizetao1@huawei.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 77f0caec
...@@ -298,10 +298,8 @@ struct cfpkt *cfpkt_append(struct cfpkt *dstpkt, ...@@ -298,10 +298,8 @@ struct cfpkt *cfpkt_append(struct cfpkt *dstpkt,
if (unlikely(is_erronous(dstpkt) || is_erronous(addpkt))) { if (unlikely(is_erronous(dstpkt) || is_erronous(addpkt))) {
return dstpkt; return dstpkt;
} }
if (expectlen > addlen)
neededtailspace = expectlen; neededtailspace = max(expectlen, addlen);
else
neededtailspace = addlen;
if (dst->tail + neededtailspace > dst->end) { if (dst->tail + neededtailspace > dst->end) {
/* Create a dumplicate of 'dst' with more tail space */ /* Create a dumplicate of 'dst' with more tail space */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment