3 ms·
> In place of strncpy, Linux kernel code should use strscpy() for NUL terminated destinations, strscpy_pad() for NUl-terminated destinations with zero-padding,
by thiht 3mo ago
> In place of strncpy, Linux kernel code should use strscpy() for NUL terminated destinations, strscpy_pad() for NUl-terminated destinations with zero-padding, strtomem_pad() for non-NUL-terminated fixed-width fields, memcpy_and_pad() for bounded copies with explicit padding, or memcpy() for known-length memory copies
What a nightmare, does it have to be so convoluted?
- MarkMarine 3mo agoPerformance. A safe Swiss Army knife function that did most of this would be slow because of the internal branching you’d need to be safe, and because there is developer intent in the selection of these functions. I’d rather have the choice and clear dev intent when I see the function used when reading code.
- hahn-kev 3mo agoCouldn't they at least give them better names?
- bobmcnamara 3mo ago> does it have to be so convoluted? Getting strncpy right always has been