Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 559b140a authored by Michal Nazarewicz's avatar Michal Nazarewicz Committed by Linus Torvalds
Browse files

lib: vsprintf: useless strlen() removed



The strict_strtoul() and strict_strtoull() functions used strlen() to
check argument's length in a situation where it wasn't strictly necessary

Signed-off-by: default avatarMichal Nazarewicz <mina86@mina86.com>
Cc: "Yi Yang" <yi.y.yang@intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent e3f76e33
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -146,19 +146,16 @@ int strict_strtoul(const char *cp, unsigned int base, unsigned long *res)
{
	char *tail;
	unsigned long val;
	size_t len;

	*res = 0;
	len = strlen(cp);
	if (len == 0)
	if (!*cp)
		return -EINVAL;

	val = simple_strtoul(cp, &tail, base);
	if (tail == cp)
		return -EINVAL;

	if ((*tail == '\0') ||
		((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
	if ((tail[0] == '\0') || (tail[0] == '\n' && tail[1] == '\0')) {
		*res = val;
		return 0;
	}
@@ -220,18 +217,15 @@ int strict_strtoull(const char *cp, unsigned int base, unsigned long long *res)
{
	char *tail;
	unsigned long long val;
	size_t len;

	*res = 0;
	len = strlen(cp);
	if (len == 0)
	if (!*cp)
		return -EINVAL;

	val = simple_strtoull(cp, &tail, base);
	if (tail == cp)
		return -EINVAL;
	if ((*tail == '\0') ||
		((len == (size_t)(tail - cp) + 1) && (*tail == '\n'))) {
	if ((tail[0] == '\0') || (tail[0] == '\n' && tail[1] == '\0')) {
		*res = val;
		return 0;
	}