Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Li Zetao <lizetao1@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20240822133908.1042240-4-lizetao1@huawei.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Li Zetao and committed by
Jakub Kicinski
b4985aa8 77f0caec

+2 -4
+2 -4
net/caif/cfpkt_skbuff.c
··· 298 298 if (unlikely(is_erronous(dstpkt) || is_erronous(addpkt))) { 299 299 return dstpkt; 300 300 } 301 - if (expectlen > addlen) 302 - neededtailspace = expectlen; 303 - else 304 - neededtailspace = addlen; 301 + 302 + neededtailspace = max(expectlen, addlen); 305 303 306 304 if (dst->tail + neededtailspace > dst->end) { 307 305 /* Create a dumplicate of 'dst' with more tail space */