Re: [RFC][PATCH] lib/string: introduce sysfs_strncpy() and sysfs_strlcpy()

From: Sergey Senozhatsky
Date: Tue Aug 21 2018 - 20:32:15 EST


On (08/21/18 15:00), Andy Shevchenko wrote:
> > Returning the length of dst/-EOVERFLOW is a bit inconvenient, because
> > "the length" forces us to have size_t return, which is unsigned.
>
> We have for ages ssize_t to workaround that.

OK.

[..]
> Wouldn't be better to split out something like
>
> strnstrip() out of strim(), with simultaneous changes to strim(),
> strstrip(), and use it here?

Maybe yes, maybe not. strim() modifies the original string right after
it's done moving the end pointer. We can't do that in strcpy_trim() and
need to keep the original source string. So probably these two functions
don't have that much of a common code after all.

-ss