On Wed, Oct 29, 2025 at 12:42 PM Andy Shevchenko <[email protected]> wrote: > > On Wed, Oct 29, 2025 at 12:20:37PM +0100, Bartosz Golaszewski wrote: > > > > Implement a function for checking if a string ends with a different > > string and add its kunit test cases. > > ... > > > +/** > > + * strends - Check if a string ends with another string. > > + * @str - NULL-terminated string to check against @suffix > > + * @suffix - NULL-terminated string defining the suffix to look for in @str > > + * > > + * Returns: > > + * True if @str ends with @suffix. False in all other cases. > > + */ > > +static inline bool strends(const char *str, const char *suffix) > > +{ > > + unsigned int str_len = strlen(str), suffix_len = strlen(suffix); > > + > > + if (str_len < suffix_len) > > + return false; > > + > > + return !(strcmp(str + str_len - suffix_len, suffix)); > > +} > > Can you rather re-use strcmp_suffix() from drivers/of/property.c? >
I think that strends() and its boolean return value are a bit more intuitive to use than strcmp_suffix() and its integer return value, the meaning of which you typically have to look-up to figure out. If there are no objections, I'd like to keep it and - when it's upstream - convert property.c to using it instead. Also: the name strcmp_suffix() could use some improvement, seeing how I wasn't able to find it, even though I looked hard across the kernel source, while I easily stumbled upon a similar implementation of strends() already existing in dtc sources. Bart
