Re: [PATCH] printk: cleanup deprecated uses of strncpy/strcpy

From: Petr Mladek
Date: Thu May 02 2024 - 11:14:23 EST


On Thu 2024-05-02 07:06:21, Christophe JAILLET wrote:
> Le 02/05/2024 à 01:18, Justin Stitt a écrit :
> > On Wed, May 1, 2024 at 2:39 PM Christophe JAILLET
> > <christophe.jaillet@xxxxxxxxxx> wrote:
> > > Hi,
> > >
> > > Nit: The { } around each branch can now also be removed.
> >
> > There was one line before and there's one line now.
>
> In the block after the "else", yes, but now the block after the "if" is only
> 1 line. (it was 2 before).
>
> So, {} should now be omitted on both branches.
>
> - if (str[0] >= '0' && str[0] <= '9') {
> - strcpy(buf, "ttyS");
> - strncpy(buf + 4, str, sizeof(buf) - 5);
> + if (isdigit(str[0])) {
> + scnprintf(buf, sizeof(buf), "ttyS%s", str);
> } else {
> - strncpy(buf, str, sizeof(buf) - 1);
> + strscpy(buf, str);
> }
>
> This is a really minor nitpick. Not sure you need to repost if there is no
> other comment.

I could remove the brackets when pushing the patch. But feel free to
send v2.

I am going to push it the following week if nobody complains.

Best Regards,
Petr