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

caif: Replace memset(0) + strscpy() with strscpy_pad()

Replace memset(0) followed by strscpy() with strscpy_pad() to improve
cfctrl_linkup_request(). This avoids zeroing the memory before copying
the string and ensures the destination buffer is only written to once,
simplifying the code and improving efficiency.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250811093442.5075-2-thorsten.blum@linux.dev
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Thorsten Blum and committed by
Jakub Kicinski
63fe077c e0ab61fa

+1 -3
+1 -3
net/caif/cfctrl.c
··· 257 257 cfpkt_add_body(pkt, &tmp16, 2); 258 258 tmp16 = cpu_to_le16(param->u.utility.fifosize_bufs); 259 259 cfpkt_add_body(pkt, &tmp16, 2); 260 - memset(utility_name, 0, sizeof(utility_name)); 261 - strscpy(utility_name, param->u.utility.name, 262 - UTILITY_NAME_LENGTH); 260 + strscpy_pad(utility_name, param->u.utility.name); 263 261 cfpkt_add_body(pkt, utility_name, UTILITY_NAME_LENGTH); 264 262 tmp8 = param->u.utility.paramlen; 265 263 cfpkt_add_body(pkt, &tmp8, 1);