[PATCH v3 01/10] string: provide strends()

Andy Shevchenko andriy.shevchenko at intel.com
Wed Oct 29 04:41:52 PDT 2025


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?

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-arm-kernel mailing list