Re: [PATCH] char: xillybus: use strscpy() in init_chrdev

From: Eli Billauer

Date: Tue Apr 28 2026 - 04:59:34 EST


Hello,

On 27/04/2026 19:37, Thorsten Blum wrote:

if (!enumerate)
- snprintf(unit->name, UNITNAMELEN, "%s", prefix);
+ strscpy(unit->name, prefix);
for (i = 0; enumerate; i++) {
snprintf(unit->name, UNITNAMELEN, "%s_%02d",

snprintf() is used deliberately for code clarity: It makes a simple visual contrast with the use of snprintf() three rows below. As this call takes place only once for each physical hardware device handled by the driver, the advantage in optimizing this function call is negligible.

And even though it's formally OK to use strscpy() with two arguments, and 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.

So overall, I can't say I'm very fond of this patch. Thanks for the effort nevertheless.

Regards,
Eli