Re: strncpy clarify result may not be null terminated

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

 



On 2023-11-10 03:05, Alejandro Colomar wrote:
Hopefully, it won't be so bad in terms of performance.

It's significantly slower than strncpy for typical use (smallish fixed-size destination buffers). So just use strncpy for that. It may be bad, but it's better than the alternatives you've mentioned. You can package strncpy inside a [[nodiscard]] inline wrapper if you like.

More importantly, the manual should not push strlcpy as being superior or being in any way a "fix" for strncpy's problems. strlcpy is worse than strncpy in important ways and besides - as mentioned in the glibc manual - neither function is a good choice for string processing.




[Index of Archives]     [Kernel Documentation]     [Netdev]     [Linux Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux