Re: [PATCH] char: xillybus: use strscpy() in init_chrdev
From: Eli Billauer
Date: Tue Apr 28 2026 - 05:15:57 EST
On 28/04/2026 10:55, Thorsten Blum wrote:
And even though it's formally OK to use strscpy() with two arguments, andYou probably mean strcpy()? strscpy() is safe regarding buffer overflow.
let the compilation machinery find out the length of the char array, I have
to admit that it gives me the chills. Buffer overflow and that.
I meant strscpy(). We agree that it's formally safe to use, but I get a really bad feeling with not having the length of the buffer explicitly written out in the function call.
One could argue that it's better to let the machine figure out the length of the buffer instead of using UNITNAMELEN (because I'm a human and I can err), but in this specific case, UNITNAMELEN is relied upon anyhow a few rows later.
This is all about coding style. The main point is that I see this patch as a negligible optimization in CPU cycles coming with a slight obfuscation of the code's readability. A bit of "if it ain't broke, don't fix it".
Regards,
Eli