Re: [PATCH] media: radio: Replace strlcat() with seq_buf in TEA drivers
From: Alejandro Colomar
Date: Sat Nov 07 2026 - 02:39:43 EST
Hi Mariia,
> Date: 2026-11-06 20:31:53-0800
> From: Mariia Nikitash <nikitash.mariiaw@xxxxxxxxx>
>
[...]
> > > @@ -255,10 +256,15 @@ static int vidioc_querycap(struct file *file, void *priv,
> > > struct v4l2_capability *v)
> > > {
> > > struct radio_tea5777 *tea = video_drvdata(file);
> > > + struct seq_buf s;
> > >
> > > strscpy(v->driver, tea->v4l2_dev->name, sizeof(v->driver));
> > > - strscpy(v->card, tea->card, sizeof(v->card));
> > > - strlcat(v->card, " TEA5777", sizeof(v->card));
> > > +
> > > + seq_buf_init(&s, (char *)v->card, sizeof(v->card));
> > > + seq_buf_puts(&s, (const char *)tea->card);
> > > + seq_buf_puts(&s, " TEA5777");
> > > + seq_buf_terminate(&s);
> > > +
> >
> > Why are the casts needed?
>
> Hi Alex,
>
> I added the casts to make conversions from u8/__u8 to
> character-pointer types expected by the seq_buf helpers explicit.
I was surprised that it wasn't needed before. In theory, strscpy()
should be expecting the same types, so if it wasn't needed before, it
shouldn't be needed now (and conversely, if it is needed now, it would
have been needed before).
>
> I'm also considering simplifying these two-part string constructions
> using scnprintf() instead. Would this approach be preferred?
I certainly prefer scnprintf() over seq_buf. :)
Have a lovely day!
Alex
--
<https://www.alejandro-colomar.es>
Attachment:
signature.asc
Description: PGP signature