svn commit: r358177 - head/sys/compat/linuxkpi/common/include/linux

Emmanuel Vadot manu at FreeBSD.org
Thu Feb 20 17:20:51 UTC 2020


Author: manu
Date: Thu Feb 20 17:20:50 2020
New Revision: 358177
URL: https://svnweb.freebsd.org/changeset/base/358177

Log:
  linuxkpi: Add str_has_prefix
  
  This function test if the string str begins with the string pointed
  at by prefix.
  
  Reviewed by:	hselasky
  MFC after:	1 week
  Differential Revision:	https://reviews.freebsd.org/D23767

Modified:
  head/sys/compat/linuxkpi/common/include/linux/string.h

Modified: head/sys/compat/linuxkpi/common/include/linux/string.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/string.h	Thu Feb 20 17:19:16 2020	(r358176)
+++ head/sys/compat/linuxkpi/common/include/linux/string.h	Thu Feb 20 17:20:50 2020	(r358177)
@@ -154,4 +154,13 @@ memchr_inv(const void *start, int c, size_t length)
 	return (NULL);
 }
 
+static inline size_t
+str_has_prefix(const char *str, const char *prefix)
+{
+	size_t len;
+
+	len = strlen(prefix);
+	return (strncmp(str, prefix, len) == 0 ? len : 0);
+}
+
 #endif					/* _LINUX_STRING_H_ */


More information about the svn-src-head mailing list