lkml.org 
[lkml]   [2023]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next] net/rds: use strscpy() to instead of strncpy()
On Mon, 9 Jan 2023 19:48:43 +0800 (CST) yang.yang29@zte.com.cn wrote:
> BUG_ON(strlen(names[i]) >= sizeof(ctr.name));
> - strncpy(ctr.name, names[i], sizeof(ctr.name) - 1);
> - ctr.name[sizeof(ctr.name) - 1] = '\0';
> + strscpy(ctr.name, names[i], sizeof(ctr.name));

You can make use of the fact that strscpy returns useful information
and the copy and the preceding BUG_ON() together.

\
 
 \ /
  Last update: 2023-03-26 23:34    [W:0.177 / U:0.304 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site