Commit 63fe077c authored by Thorsten Blum's avatar Thorsten Blum Committed by Jakub Kicinski
Browse files

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: default avatarThorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250811093442.5075-2-thorsten.blum@linux.dev


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent e0ab61fa
Loading
Loading
Loading
Loading
+1 −3
Original line number Diff line number Diff line
@@ -257,9 +257,7 @@ int cfctrl_linkup_request(struct cflayer *layer,
		cfpkt_add_body(pkt, &tmp16, 2);
		tmp16 = cpu_to_le16(param->u.utility.fifosize_bufs);
		cfpkt_add_body(pkt, &tmp16, 2);
		memset(utility_name, 0, sizeof(utility_name));
		strscpy(utility_name, param->u.utility.name,
			UTILITY_NAME_LENGTH);
		strscpy_pad(utility_name, param->u.utility.name);
		cfpkt_add_body(pkt, utility_name, UTILITY_NAME_LENGTH);
		tmp8 = param->u.utility.paramlen;
		cfpkt_add_body(pkt, &tmp8, 1);