Re: [PATCH net-next] net/rds: use strscpy() to instead of strncpy()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 9 Jan 2023 19:48:43 +0800 (CST) yang.yang29@xxxxxxxxxx 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. 



[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux