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

Hans Petter Selasky hselasky at FreeBSD.org
Wed Mar 14 19:51:29 UTC 2018


Author: hselasky
Date: Wed Mar 14 19:51:28 2018
New Revision: 330944
URL: https://svnweb.freebsd.org/changeset/base/330944

Log:
  Fix compliancy of the kstrtoXXX() functions in the LinuxKPI, by skipping
  one newline character at the end, if any.
  
  Found by:	greg at unrelenting.technology
  MFC after:	1 week
  Sponsored by:	Mellanox Technologies

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

Modified: head/sys/compat/linuxkpi/common/include/linux/kernel.h
==============================================================================
--- head/sys/compat/linuxkpi/common/include/linux/kernel.h	Wed Mar 14 19:23:17 2018	(r330943)
+++ head/sys/compat/linuxkpi/common/include/linux/kernel.h	Wed Mar 14 19:51:28 2018	(r330944)
@@ -295,6 +295,9 @@ kstrtoul(const char *cp, unsigned int base, unsigned l
 
 	*res = strtoul(cp, &end, base);
 
+	/* skip newline character, if any */
+	if (*end == '\n')
+		end++;
 	if (*cp == 0 || *end != 0)
 		return (-EINVAL);
 	return (0);
@@ -307,6 +310,9 @@ kstrtol(const char *cp, unsigned int base, long *res)
 
 	*res = strtol(cp, &end, base);
 
+	/* skip newline character, if any */
+	if (*end == '\n')
+		end++;
 	if (*cp == 0 || *end != 0)
 		return (-EINVAL);
 	return (0);
@@ -320,6 +326,9 @@ kstrtoint(const char *cp, unsigned int base, int *res)
 
 	*res = temp = strtol(cp, &end, base);
 
+	/* skip newline character, if any */
+	if (*end == '\n')
+		end++;
 	if (*cp == 0 || *end != 0)
 		return (-EINVAL);
 	if (temp != (int)temp)
@@ -335,6 +344,9 @@ kstrtouint(const char *cp, unsigned int base, unsigned
 
 	*res = temp = strtoul(cp, &end, base);
 
+	/* skip newline character, if any */
+	if (*end == '\n')
+		end++;
 	if (*cp == 0 || *end != 0)
 		return (-EINVAL);
 	if (temp != (unsigned int)temp)
@@ -350,6 +362,9 @@ kstrtou32(const char *cp, unsigned int base, u32 *res)
 
 	*res = temp = strtoul(cp, &end, base);
 
+	/* skip newline character, if any */
+	if (*end == '\n')
+		end++;
 	if (*cp == 0 || *end != 0)
 		return (-EINVAL);
 	if (temp != (u32)temp)


More information about the svn-src-head mailing list