Re: [PATCH] printk: cleanup deprecated uses of strncpy/strcpy
From: Christophe JAILLET
Date: Thu May 02 2024 - 01:06:45 EST
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.
CJ
I'll remove the brackets but I will briefly wait to see if any other
concerns come in.
Thanks
CJ